* reuse generic align()

git-svn-id: trunk@4382 -
This commit is contained in:
peter 2006-08-07 07:03:25 +00:00
parent e5dc751f95
commit 16f121a8bc
2 changed files with 8 additions and 7 deletions

View File

@ -28,10 +28,10 @@ type
function aligntoptr(p : pointer) : pointer;inline; function aligntoptr(p : pointer) : pointer;inline;
begin begin
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT} {$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
if (ptrint(p) mod sizeof(ptrint))<>0 then result:=align(p,sizeof(p));
inc(ptrint(p),sizeof(ptrint)-ptrint(p) mod sizeof(ptrint)); {$else FPC_REQUIRES_PROPER_ALIGNMENT}
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
result:=p; result:=p;
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
end; end;

View File

@ -21,6 +21,7 @@ unit typinfo;
interface interface
{$MODE objfpc} {$MODE objfpc}
{$inline on}
{$h+} {$h+}
uses SysUtils; uses SysUtils;
@ -310,13 +311,13 @@ type
Auxiliary methods Auxiliary methods
---------------------------------------------------------------------} ---------------------------------------------------------------------}
function aligntoptr(p : pointer) : pointer; function aligntoptr(p : pointer) : pointer;inline;
begin begin
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT} {$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
if (ptruint(p) and (sizeof(ptruint)-1))<>0 then result:=align(p,sizeof(p));
ptruint(p) := (ptruint(p) + sizeof(ptruint) - 1) and not (sizeof(ptruint) - 1); {$else FPC_REQUIRES_PROPER_ALIGNMENT}
result:=p;
{$endif FPC_REQUIRES_PROPER_ALIGNMENT} {$endif FPC_REQUIRES_PROPER_ALIGNMENT}
aligntoptr:=p;
end; end;