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-2007, 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 2, 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. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNAT; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
20 -- Boston, MA 02110-1301, USA. --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
29 -- GNAT was originally developed by the GNAT team at New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
32 ------------------------------------------------------------------------------
34 -- This is an Irix (old pthread library) version of this package
36 -- This package contains the parameters used by the run-time system at
37 -- program startup. These parameters are isolated in this package body to
38 -- facilitate replacement by the end user.
40 -- To replace the default values, copy this source file into your build
41 -- directory, edit the file to reflect your desired behavior, and recompile
44 -- % gcc -c -O2 -gnatpg s-proinf.adb
46 -- then relink your application as usual.
48 pragma Warnings
(Off
); -- why???
52 package body System
.Program_Info
is
54 Kbytes
: constant := 1024;
56 Default_Initial_Sproc_Count
: constant := 0;
57 Default_Max_Sproc_Count
: constant := 128;
58 Default_Sproc_Stack_Size
: constant := 16#
4000#
;
59 Default_Stack_Guard_Pages
: constant := 1;
60 Default_Default_Time_Slice
: constant := 0.0;
61 Default_Default_Task_Stack
: constant := 12 * Kbytes
;
62 Default_Pthread_Sched_Signal
: constant := 35;
63 Default_Pthread_Arena_Size
: constant := 16#
40000#
;
64 Default_Os_Default_Priority
: constant := 0;
66 -------------------------
67 -- Initial_Sproc_Count --
68 -------------------------
70 function Initial_Sproc_Count
return Integer is
72 function sysmp
(P1
: Integer) return Integer;
73 pragma Import
(C
, sysmp
, "sysmp", "sysmp");
75 MP_NPROCS
: constant := 1; -- # processor in complex
77 Pthread_Sproc_Count
: constant System
.OS_Lib
.String_Access
:=
78 System
.OS_Lib
.Getenv
("PTHREAD_SPROC_COUNT");
81 if Pthread_Sproc_Count
.all'Length = 0 then
82 return Default_Initial_Sproc_Count
;
84 elsif Pthread_Sproc_Count
.all = "AUTO" then
85 return sysmp
(MP_NPROCS
);
88 return Integer'Value (Pthread_Sproc_Count
.all);
93 return Default_Initial_Sproc_Count
;
94 end Initial_Sproc_Count
;
100 function Max_Sproc_Count
return Integer is
101 Pthread_Max_Sproc_Count
: constant System
.OS_Lib
.String_Access
:=
102 System
.OS_Lib
.Getenv
("PTHREAD_MAX_SPROC_COUNT");
105 if Pthread_Max_Sproc_Count
.all'Length = 0 then
106 return Default_Max_Sproc_Count
;
108 return Integer'Value (Pthread_Max_Sproc_Count
.all);
112 return Default_Max_Sproc_Count
;
115 ----------------------
116 -- Sproc_Stack_Size --
117 ----------------------
119 function Sproc_Stack_Size
return Integer is
121 return Default_Sproc_Stack_Size
;
122 end Sproc_Stack_Size
;
124 ------------------------
125 -- Default_Time_Slice --
126 ------------------------
128 function Default_Time_Slice
return Duration is
129 Pthread_Time_Slice_Sec
: constant System
.OS_Lib
.String_Access
:=
131 ("PTHREAD_TIME_SLICE_SEC");
132 Pthread_Time_Slice_Usec
: constant System
.OS_Lib
.String_Access
:=
134 ("PTHREAD_TIME_SLICE_USEC");
136 Val_Sec
, Val_Usec
: Integer := 0;
139 if Pthread_Time_Slice_Sec
.all'Length /= 0 or
140 Pthread_Time_Slice_Usec
.all'Length /= 0
142 if Pthread_Time_Slice_Sec
.all'Length /= 0 then
143 Val_Sec
:= Integer'Value (Pthread_Time_Slice_Sec
.all);
146 if Pthread_Time_Slice_Usec
.all'Length /= 0 then
147 Val_Usec
:= Integer'Value (Pthread_Time_Slice_Usec
.all);
150 return Duration (Val_Sec
) + Duration (Val_Usec
) / 1000.0;
152 return Default_Default_Time_Slice
;
157 return Default_Default_Time_Slice
;
158 end Default_Time_Slice
;
160 ------------------------
161 -- Default_Task_Stack --
162 ------------------------
164 function Default_Task_Stack
return Integer is
166 return Default_Default_Task_Stack
;
167 end Default_Task_Stack
;
169 -----------------------
170 -- Stack_Guard_Pages --
171 -----------------------
173 function Stack_Guard_Pages
return Integer is
174 Pthread_Stack_Guard_Pages
: constant System
.OS_Lib
.String_Access
:=
176 ("PTHREAD_STACK_GUARD_PAGES");
178 if Pthread_Stack_Guard_Pages
.all'Length /= 0 then
179 return Integer'Value (Pthread_Stack_Guard_Pages
.all);
181 return Default_Stack_Guard_Pages
;
185 return Default_Stack_Guard_Pages
;
186 end Stack_Guard_Pages
;
188 --------------------------
189 -- Pthread_Sched_Signal --
190 --------------------------
192 function Pthread_Sched_Signal
return Integer is
194 return Default_Pthread_Sched_Signal
;
195 end Pthread_Sched_Signal
;
197 ------------------------
198 -- Pthread_Arena_Size --
199 ------------------------
201 function Pthread_Arena_Size
return Integer is
202 Pthread_Arena_Size
: constant System
.OS_Lib
.String_Access
:=
204 ("PTHREAD_ARENA_SIZE");
207 if Pthread_Arena_Size
.all'Length = 0 then
208 return Default_Pthread_Arena_Size
;
210 return Integer'Value (Pthread_Arena_Size
.all);
215 return Default_Pthread_Arena_Size
;
216 end Pthread_Arena_Size
;
218 -------------------------
219 -- Os_Default_Priority --
220 -------------------------
222 function Os_Default_Priority
return Integer is
224 return Default_Os_Default_Priority
;
225 end Os_Default_Priority
;
227 end System
.Program_Info
;