[COMMITTED] ada: Add QNX specific version of System.Parameters
Commit Message
From: Johannes Kliemann <kliemann@adacore.com>
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.
Tested on x86_64-pc-linux-gnu, committed on master.
---
gcc/ada/Makefile.rtl | 1 +
gcc/ada/libgnat/s-parame__qnx.adb | 81 +++++++++++++++++++++++++++++++
2 files changed, 82 insertions(+)
create mode 100644 gcc/ada/libgnat/s-parame__qnx.adb
@@ -1412,6 +1412,7 @@ ifeq ($(strip $(filter-out arm aarch64 %qnx,$(target_cpu) $(target_os))),)
s-taspri.ads<libgnarl/s-taspri__posix.ads \
s-tpopsp.adb<libgnarl/s-tpopsp__posix-foreign.adb \
g-soliop.ads<libgnat/g-soliop__qnx.ads \
+ s-parame.adb<libgnat/s-parame__qnx.adb \
$(ATOMICS_TARGET_PAIRS) \
$(ATOMICS_BUILTINS_TARGET_PAIRS) \
system.ads<libgnat/system-qnx-arm.ads
new file mode 100644
@@ -0,0 +1,81 @@
+------------------------------------------------------------------------------
+-- --
+-- GNAT COMPILER COMPONENTS --
+-- --
+-- S Y S T E M . P A R A M E T E R S --
+-- --
+-- B o d y --
+-- --
+-- Copyright (C) 1995-2023, Free Software Foundation, Inc. --
+-- --
+-- GNAT is free software; you can redistribute it and/or modify it under --
+-- terms of the GNU General Public License as published by the Free Soft- --
+-- ware Foundation; either version 3, or (at your option) any later ver- --
+-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
+-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
+-- or FITNESS FOR A PARTICULAR PURPOSE. --
+-- --
+-- As a special exception under Section 7 of GPL version 3, you are granted --
+-- additional permissions described in the GCC Runtime Library Exception, --
+-- version 3.1, as published by the Free Software Foundation. --
+-- --
+-- You should have received a copy of the GNU General Public License and --
+-- a copy of the GCC Runtime Library Exception along with this program; --
+-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
+-- <http://www.gnu.org/licenses/>. --
+-- --
+-- 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;