From: Johannes Kliemann Date: Wed, 29 Mar 2023 10:42:20 +0000 (+0000) Subject: ada: Add QNX specific version of System.Parameters X-Git-Tag: basepoints/gcc-15~8820 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f180888c8f38920e6731e5bc1dc5e06f5ac7d340;p=thirdparty%2Fgcc.git ada: Add QNX specific version of System.Parameters The QNX runtimes used the default implementation of System.Parameters that defines a default stack size of 2 MB. The QNX specific version uses the QNX default stack size of 256 KB instead. gcc/ada/ * Makefile.rtl (QNX): Use s-parame__qnx.adb for s-parame.adb. * libgnat/s-parame__qnx.adb: Add QNX specific version of System.Parameters. --- diff --git a/gcc/ada/Makefile.rtl b/gcc/ada/Makefile.rtl index 2cfdd8dc613c..3da32fa66684 100644 --- a/gcc/ada/Makefile.rtl +++ b/gcc/ada/Makefile.rtl @@ -1412,6 +1412,7 @@ ifeq ($(strip $(filter-out arm aarch64 %qnx,$(target_cpu) $(target_os))),) s-taspri.ads. -- +-- -- +-- GNAT was originally developed by the GNAT team at New York University. -- +-- Extensive contributions were provided by Ada Core Technologies Inc. -- +-- -- +------------------------------------------------------------------------------ + +-- This is the version for AArch64 QNX + +package body System.Parameters is + + ------------------------- + -- Adjust_Storage_Size -- + ------------------------- + + function Adjust_Storage_Size (Size : Size_Type) return Size_Type is + begin + if Size = Unspecified_Size then + return Default_Stack_Size; + elsif Size < Minimum_Stack_Size then + return Minimum_Stack_Size; + else + return Size; + end if; + end Adjust_Storage_Size; + + ------------------------ + -- Default_Stack_Size -- + ------------------------ + + function Default_Stack_Size return Size_Type is + Default_Stack_Size : constant Integer; + pragma Import (C, Default_Stack_Size, "__gl_default_stack_size"); + begin + if Default_Stack_Size = -1 then + -- 256K is the default stack size on aarch64 QNX + return 256 * 1024; + elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then + return Minimum_Stack_Size; + else + return Size_Type (Default_Stack_Size); + end if; + end Default_Stack_Size; + + ------------------------ + -- Minimum_Stack_Size -- + ------------------------ + + function Minimum_Stack_Size return Size_Type is + begin + -- 256 is the value of PTHREAD_STACK_MIN on QNX and + -- 12K is required for stack-checking. The value is + -- rounded up to a multiple of a 4K page. + return 16 * 1024; + end Minimum_Stack_Size; + +end System.Parameters;