+ added system.align

+ threadvars are now aligned
This commit is contained in:
florian 2004-10-14 17:39:33 +00:00
parent 169f43ca6a
commit 8c85454cf9
3 changed files with 66 additions and 5 deletions

View File

@ -1084,8 +1084,28 @@ procedure inclocked(var l:int64);
{_$error Sptr must be defined for each processor }
{$endif ndef FPC_SYSTEM_HAS_SPTR}
procedure prefetch(const mem);[internproc:in_prefetch_var];
function align(addr : PtrInt;alignment : PtrInt) : PtrInt;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
if addr mod alignment<>0 then
result:=addr+(alignment-(addr mod alignment))
else
result:=addr;
end;
function align(addr : Pointer;alignment : PtrInt) : Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
begin
if PtrInt(addr) mod alignment<>0 then
result:=pointer(addr+(alignment-(PtrInt(addr) mod alignment)))
else
result:=addr;
end;
{****************************************************************************
Str()
****************************************************************************}
@ -1225,7 +1245,11 @@ end;
{
$Log$
Revision 1.81 2004-10-09 21:00:46 jonas
Revision 1.82 2004-10-14 17:39:33 florian
+ added system.align
+ threadvars are now aligned
Revision 1.81 2004/10/09 21:00:46 jonas
+ cgenmath with libc math functions. Faster than the routines in genmath
and also have full double support (exp() only has support for values in
the single range in genmath, for example). Used in FPC_USE_LIBC is
@ -1435,4 +1459,4 @@ end;
instead of direct comparisons of low/high values of orddefs because
qword is a special case
}
}

View File

@ -423,6 +423,9 @@ Function Swap (X:LongInt):LongInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Swap (X:QWord):QWord;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Swap (X:Int64):Int64;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Align (Addr : PtrInt; Alignment : PtrInt) : PtrInt;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Align (Addr : Pointer; Alignment : PtrInt) : Pointer;{$ifdef SYSTEMINLINE}inline;{$endif}
Function Random(l:longint):longint;
Function Random(l:int64):int64;
Function Random: extended;
@ -761,7 +764,11 @@ const
{
$Log$
Revision 1.103 2004-10-09 21:00:46 jonas
Revision 1.104 2004-10-14 17:39:33 florian
+ added system.align
+ threadvars are now aligned
Revision 1.103 2004/10/09 21:00:46 jonas
+ cgenmath with libc math functions. Faster than the routines in genmath
and also have full double support (exp() only has support for values in
the single range in genmath, for example). Used in FPC_USE_LIBC is
@ -985,4 +992,4 @@ const
instead of direct comparisons of low/high values of orddefs because
qword is a special case
}
}

View File

@ -60,12 +60,38 @@ Uses
const
threadvarblocksize : dword = 0;
var
TLSKey : pthread_key_t;
procedure CInitThreadvar(var offset : dword;size : dword);
begin
{$ifdef cpusparc}
threadvarblocksize:=align(threadvarblocksize,16);
{$endif cpusparc}
{$ifdef cpupowerpc}
threadvarblocksize:=align(threadvarblocksize,8);
{$endif cpupowerc}
{$ifdef cpui386}
threadvarblocksize:=align(threadvarblocksize,8);
{$endif cpui386}
{$ifdef cpuarm}
threadvarblocksize:=align(threadvarblocksize,4);
{$endif cpuarm}
{$ifdef cpum68k}
threadvarblocksize:=align(threadvarblocksize,2);
{$endif cpum68k}
{$ifdef cpux86_64}
threadvarblocksize:=align(threadvarblocksize,16);
{$endif cpux86_64}
offset:=threadvarblocksize;
inc(threadvarblocksize,size);
end;
@ -535,7 +561,11 @@ initialization
end.
{
$Log$
Revision 1.12 2004-09-09 20:29:06 jonas
Revision 1.13 2004-10-14 17:39:33 florian
+ added system.align
+ threadvars are now aligned
Revision 1.12 2004/09/09 20:29:06 jonas
* fixed definition of pthread_mutex_t for non-linux targets (and for
linux as well, actually).
* base libpthread definitions are now in ptypes.inc, included in unixtype