mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-08 03:48:07 +02:00
* Darwin/BSD: fixed StackBottom calculation
git-svn-id: trunk@49139 -
This commit is contained in:
parent
ca399f3c71
commit
4166e8c464
@ -350,13 +350,27 @@ begin
|
||||
GetProcessID := SizeUInt (fpGetPID);
|
||||
end;
|
||||
|
||||
function InternalPageSize: SizeUInt; inline;
|
||||
begin
|
||||
{$ifndef darwin}
|
||||
InternalPageSize := 4096;
|
||||
{$else not darwin}
|
||||
InternalPageSize := darwin_page_size;
|
||||
{$endif not darwin}
|
||||
end;
|
||||
|
||||
function AlignedStackTop: Pointer;
|
||||
begin
|
||||
AlignedStackTop:=Pointer((ptruint(sptr) + InternalPageSize - 1) and not(InternalPageSize - 1));
|
||||
end;
|
||||
|
||||
function CheckInitialStkLen(stklen : SizeUInt) : SizeUInt;
|
||||
var
|
||||
stackpointer: ptruint;
|
||||
begin
|
||||
stackpointer := (ptruint(sptr) + 4095) and not(4095);
|
||||
stackpointer := ptruint(AlignedStackTop);
|
||||
if stklen > stackpointer then
|
||||
stklen := stackpointer-4096;
|
||||
stklen := stackpointer - InternalPageSize;
|
||||
result := stklen;
|
||||
end;
|
||||
|
||||
@ -366,7 +380,7 @@ Begin
|
||||
{$endif darwin}
|
||||
IsConsole := TRUE;
|
||||
StackLength := CheckInitialStkLen(InitialStkLen);
|
||||
StackBottom := Sptr - StackLength;
|
||||
StackBottom := AlignedStackTop - StackLength;
|
||||
{$ifdef FPC_HAS_SETSYSNR_INC}
|
||||
{ This procedure is needed for openbsd system which re-uses
|
||||
the same syscall numbers depending on OS version }
|
||||
|
Loading…
Reference in New Issue
Block a user