[Ada] RTEMS: use regular RTEMS API for minimum stack size calculation

Message ID 20211011133945.GA1519045@adacore.com
State New
Headers show
Series
  • [Ada] RTEMS: use regular RTEMS API for minimum stack size calculation
Related show

Commit Message

Richard Biener via Gcc-patches Oct. 11, 2021, 1:39 p.m.
Use _POSIX_Threads_Minimum_stack_size instead of
ada_pthread_minimum_stack_size so the runtime does not require the RTEMS
kernel to be configured to have Ada support.

Tested on x86_64-pc-linux-gnu, committed on trunk

gcc/ada/

	* libgnat/s-parame__rtems.adb: use
	_POSIX_Threads_Minimum_stack_size instead of
	ada_pthread_minimum_stack_size.

Patch

diff --git a/gcc/ada/libgnat/s-parame__rtems.adb b/gcc/ada/libgnat/s-parame__rtems.adb
--- a/gcc/ada/libgnat/s-parame__rtems.adb
+++ b/gcc/ada/libgnat/s-parame__rtems.adb
@@ -35,10 +35,6 @@  with Interfaces.C;
 
 package body System.Parameters is
 
-   function ada_pthread_minimum_stack_size return Interfaces.C.size_t;
-   pragma Import (C, ada_pthread_minimum_stack_size,
-     "_ada_pthread_minimum_stack_size");
-
    -------------------------
    -- Adjust_Storage_Size --
    -------------------------
@@ -61,8 +57,15 @@  package body System.Parameters is
    ------------------------
 
    function Default_Stack_Size return Size_Type is
+      Default_Stack_Size : constant Integer
+        with Import, Convention => C,
+             External_Name => "__gl_default_stack_size";
    begin
-      return Size_Type (ada_pthread_minimum_stack_size);
+      if Default_Stack_Size = -1 then
+         return 32 * 1024;
+      else
+         return Size_Type (Default_Stack_Size);
+      end if;
    end Default_Stack_Size;
 
    ------------------------
@@ -70,9 +73,11 @@  package body System.Parameters is
    ------------------------
 
    function Minimum_Stack_Size return Size_Type is
-
+      POSIX_Threads_Minimum_stack_size : constant Interfaces.C.size_t
+        with Import, Convention => C,
+             External_Name => "_POSIX_Threads_Minimum_stack_size";
    begin
-      return Size_Type (ada_pthread_minimum_stack_size);
+      return Size_Type (POSIX_Threads_Minimum_stack_size);
    end Minimum_Stack_Size;
 
 end System.Parameters;