From 8a7d4501c04bb93dd75669a54b2967f381123b09 Mon Sep 17 00:00:00 2001 From: karoly Date: Wed, 14 Apr 2021 02:35:01 +0000 Subject: rtl: make STACK_MARGIN a variable instead of a const. this allows adjusting margin size on system unit init, based on the actual stack length of the executable. useful for small systems running with little stack. allow overwriting SysBackTraceStr with a platform-specific implementation git-svn-id: https://svn.freepascal.org/svn/fpc/trunk@49200 3ad0048d-3df7-0310-abae-a5850022a9f2 --- rtl/inc/system.inc | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'rtl') diff --git a/rtl/inc/system.inc b/rtl/inc/system.inc index ca28731a2c..b35d50cedf 100644 --- a/rtl/inc/system.inc +++ b/rtl/inc/system.inc @@ -45,12 +45,13 @@ type const {$if defined(CPUAVR)} - STACK_MARGIN = 64; { Stack size margin for stack checking } + STACK_MARGIN_MAX = 64; { Stack size margin for stack checking } {$elseif defined(CPUZ80)} - STACK_MARGIN = 64; { Stack size margin for stack checking } + STACK_MARGIN_MAX = 64; { Stack size margin for stack checking } {$else} - STACK_MARGIN = 16384; { Stack size margin for stack checking } + STACK_MARGIN_MAX = 16384; { Stack size margin for stack checking } {$endif} + StackMargin: ptruint = STACK_MARGIN_MAX; { Random / Randomize constants } OldRandSeed : Cardinal = 0; @@ -1042,7 +1043,7 @@ begin { don't use stack_size, since the stack pointer has already been decreased when this routine is called } - c := Sptr - STACK_MARGIN; + c := Sptr - StackMargin; if (c <= StackBottom) then begin StackError:=true; @@ -1289,10 +1290,12 @@ Begin end; +{$ifndef FPC_SYSTEM_HAS_BACKTRACESTR} function SysBackTraceStr (Addr: CodePointer): ShortString; begin SysBackTraceStr:=' $'+hexstr(addr); end; +{$endif FPC_SYSTEM_HAS_BACKTRACESTR} {$ifndef FPC_SYSTEM_HAS_CAPTUREBACKTRACE} -- cgit v1.2.1