* 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;
begin
{$ifdef FPC_REQUIRES_PROPER_ALIGNMENT}
if (ptrint(p) mod sizeof(ptrint))<>0 then
inc(ptrint(p),sizeof(ptrint)-ptrint(p) mod sizeof(ptrint));
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
result:=align(p,sizeof(p));
{$else FPC_REQUIRES_PROPER_ALIGNMENT}
result:=p;
{$endif FPC_REQUIRES_PROPER_ALIGNMENT}
end;

View File

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