mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-11-04 20:59:58 +01:00
* reuse generic align()
git-svn-id: trunk@4382 -
This commit is contained in:
parent
e5dc751f95
commit
16f121a8bc
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -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;
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user