Debian Codegraph @

gcc/ada/libgnat/s-parame__rtems.adb

raw
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT COMPILER COMPONENTS --
4 -- --
5 -- S Y S T E M . P A R A M E T E R S --
6 -- --
7 -- B o d y --
8 -- --
9 -- Copyright (C) 1997-2025, Free Software Foundation, Inc. --
10 -- --
11 -- GNAT is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
17 -- --
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
19 -- additional permissions described in the GCC Runtime Library Exception, --
20 -- version 3.1, as published by the Free Software Foundation. --
21 -- --
22 -- You should have received a copy of the GNU General Public License and --
23 -- a copy of the GCC Runtime Library Exception along with this program; --
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
25 -- <http://www.gnu.org/licenses/>. --
26 -- --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
29 -- --
30 ------------------------------------------------------------------------------
31
32 -- This is the RTEMS specific version
33
34 with Interfaces.C;
35
36 package body System.Parameters is
37
38 -------------------------
39 -- Adjust_Storage_Size --
40 -------------------------
41
42 function Adjust_Storage_Size (Size : Size_Type) return Size_Type is
43 begin
44 if Size = Unspecified_Size then
45 return Default_Stack_Size;
46
47 elsif Size < Minimum_Stack_Size then
48 return Minimum_Stack_Size;
49
50 else
51 return Size;
52 end if;
53 end Adjust_Storage_Size;
54
55 ------------------------
56 -- Default_Stack_Size --
57 ------------------------
58
59 function Default_Stack_Size return Size_Type is
60 Default_Stack_Size : constant Integer
61 with Import, Convention => C,
62 External_Name => "__gl_default_stack_size";
63 begin
64 if Default_Stack_Size = -1 then
65 return 32 * 1024;
66 elsif Size_Type (Default_Stack_Size) < Minimum_Stack_Size then
67 return Minimum_Stack_Size;
68 else
69 return Size_Type (Default_Stack_Size);
70 end if;
71 end Default_Stack_Size;
72
73 ------------------------
74 -- Minimum_Stack_Size --
75 ------------------------
76
77 function Minimum_Stack_Size return Size_Type is
78 POSIX_Threads_Minimum_stack_size : constant Interfaces.C.size_t
79 with Import, Convention => C,
80 External_Name => "_POSIX_Threads_Minimum_stack_size";
81 begin
82 return Size_Type (POSIX_Threads_Minimum_stack_size);
83 end Minimum_Stack_Size;
84
85 end System.Parameters;