1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . P R O G R A M _ I N F O --
9 -- Copyright (C) 1997-2009, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
27 -- GNAT was originally developed by the GNAT team at New York University. --
28 -- Extensive contributions were provided by Ada Core Technologies Inc. --
30 ------------------------------------------------------------------------------
32 -- This is an Irix (old pthread library) version of this package
34 -- This package contains the parameters used by the run-time system at
35 -- program startup. These parameters are isolated in this package body to
36 -- facilitate replacement by the end user.
38 -- To replace the default values, copy this source file into your build
39 -- directory, edit the file to reflect your desired behavior, and recompile
42 -- % gcc -c -O2 -gnatpg s-proinf.adb
44 -- then relink your application as usual.
46 pragma Warnings (Off); -- why???
50 package body System.Program_Info is
52 Kbytes : constant := 1024;
54 Default_Initial_Sproc_Count : constant := 0;
55 Default_Max_Sproc_Count : constant := 128;
56 Default_Sproc_Stack_Size : constant := 16#4000#;
57 Default_Stack_Guard_Pages : constant := 1;
58 Default_Default_Time_Slice : constant := 0.0;
59 Default_Default_Task_Stack : constant := 12 * Kbytes;
60 Default_Pthread_Sched_Signal : constant := 35;
61 Default_Pthread_Arena_Size : constant := 16#40000#;
62 Default_Os_Default_Priority : constant := 0;
64 -------------------------
65 -- Initial_Sproc_Count --
66 -------------------------
68 function Initial_Sproc_Count return Integer is
70 function sysmp (P1 : Integer) return Integer;
71 pragma Import (C, sysmp, "sysmp", "sysmp");
73 MP_NPROCS : constant := 1; -- # processor in complex
75 Pthread_Sproc_Count : constant System.OS_Lib.String_Access :=
76 System.OS_Lib.Getenv ("PTHREAD_SPROC_COUNT");
79 if Pthread_Sproc_Count.all'Length = 0 then
80 return Default_Initial_Sproc_Count;
82 elsif Pthread_Sproc_Count.all = "AUTO" then
83 return sysmp (MP_NPROCS);
86 return Integer'Value (Pthread_Sproc_Count.all);
91 return Default_Initial_Sproc_Count;
92 end Initial_Sproc_Count;
98 function Max_Sproc_Count return Integer is
99 Pthread_Max_Sproc_Count : constant System.OS_Lib.String_Access :=
100 System.OS_Lib.Getenv ("PTHREAD_MAX_SPROC_COUNT");
103 if Pthread_Max_Sproc_Count.all'Length = 0 then
104 return Default_Max_Sproc_Count;
106 return Integer'Value (Pthread_Max_Sproc_Count.all);
110 return Default_Max_Sproc_Count;
113 ----------------------
114 -- Sproc_Stack_Size --
115 ----------------------
117 function Sproc_Stack_Size return Integer is
119 return Default_Sproc_Stack_Size;
120 end Sproc_Stack_Size;
122 ------------------------
123 -- Default_Time_Slice --
124 ------------------------
126 function Default_Time_Slice return Duration is
127 Pthread_Time_Slice_Sec : constant System.OS_Lib.String_Access :=
129 ("PTHREAD_TIME_SLICE_SEC");
130 Pthread_Time_Slice_Usec : constant System.OS_Lib.String_Access :=
132 ("PTHREAD_TIME_SLICE_USEC");
134 Val_Sec, Val_Usec : Integer := 0;
137 if Pthread_Time_Slice_Sec.all'Length /= 0 or
138 Pthread_Time_Slice_Usec.all'Length /= 0
140 if Pthread_Time_Slice_Sec.all'Length /= 0 then
141 Val_Sec := Integer'Value (Pthread_Time_Slice_Sec.all);
144 if Pthread_Time_Slice_Usec.all'Length /= 0 then
145 Val_Usec := Integer'Value (Pthread_Time_Slice_Usec.all);
148 return Duration (Val_Sec) + Duration (Val_Usec) / 1000.0;
150 return Default_Default_Time_Slice;
155 return Default_Default_Time_Slice;
156 end Default_Time_Slice;
158 ------------------------
159 -- Default_Task_Stack --
160 ------------------------
162 function Default_Task_Stack return Integer is
164 return Default_Default_Task_Stack;
165 end Default_Task_Stack;
167 -----------------------
168 -- Stack_Guard_Pages --
169 -----------------------
171 function Stack_Guard_Pages return Integer is
172 Pthread_Stack_Guard_Pages : constant System.OS_Lib.String_Access :=
174 ("PTHREAD_STACK_GUARD_PAGES");
176 if Pthread_Stack_Guard_Pages.all'Length /= 0 then
177 return Integer'Value (Pthread_Stack_Guard_Pages.all);
179 return Default_Stack_Guard_Pages;
183 return Default_Stack_Guard_Pages;
184 end Stack_Guard_Pages;
186 --------------------------
187 -- Pthread_Sched_Signal --
188 --------------------------
190 function Pthread_Sched_Signal return Integer is
192 return Default_Pthread_Sched_Signal;
193 end Pthread_Sched_Signal;
195 ------------------------
196 -- Pthread_Arena_Size --
197 ------------------------
199 function Pthread_Arena_Size return Integer is
200 Pthread_Arena_Size : constant System.OS_Lib.String_Access :=
202 ("PTHREAD_ARENA_SIZE");
205 if Pthread_Arena_Size.all'Length = 0 then
206 return Default_Pthread_Arena_Size;
208 return Integer'Value (Pthread_Arena_Size.all);
213 return Default_Pthread_Arena_Size;
214 end Pthread_Arena_Size;
216 -------------------------
217 -- Os_Default_Priority --
218 -------------------------
220 function Os_Default_Priority return Integer is
222 return Default_Os_Default_Priority;
223 end Os_Default_Priority;
225 end System.Program_Info;