1 ------------------------------------------------------------------------------
3 -- GNAT COMPILER COMPONENTS --
5 -- S Y S T E M . P R O G R A M _ I N F O --
10 -- Copyright (C) 1997-1999 Free Software Foundation, Inc. --
12 -- GNAT is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNAT; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
30 -- GNAT was originally developed by the GNAT team at New York University. --
31 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
33 ------------------------------------------------------------------------------
35 -- This is an Irix (old pthread library) version of this package.
37 -- This package contains the parameters used by the run-time system at
38 -- program startup. These parameters are isolated in this package body to
39 -- facilitate replacement by the end user.
41 -- To replace the default values, copy this source file into your build
42 -- directory, edit the file to reflect your desired behavior, and recompile
45 -- % gcc -c -O2 -gnatpg s-proinf.adb
47 -- then relink your application as usual.
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 GNAT
.OS_Lib
.String_Access
:=
78 GNAT
.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);
92 return Default_Initial_Sproc_Count
;
93 end Initial_Sproc_Count
;
99 function Max_Sproc_Count
return Integer is
100 Pthread_Max_Sproc_Count
: constant GNAT
.OS_Lib
.String_Access
:=
101 GNAT
.OS_Lib
.Getenv
("PTHREAD_MAX_SPROC_COUNT");
104 if Pthread_Max_Sproc_Count
.all'Length = 0 then
105 return Default_Max_Sproc_Count
;
107 return Integer'Value (Pthread_Max_Sproc_Count
.all);
111 return Default_Max_Sproc_Count
;
114 ----------------------
115 -- Sproc_Stack_Size --
116 ----------------------
118 function Sproc_Stack_Size
return Integer is
120 return Default_Sproc_Stack_Size
;
121 end Sproc_Stack_Size
;
123 ------------------------
124 -- Default_Time_Slice --
125 ------------------------
127 function Default_Time_Slice
return Duration is
128 Pthread_Time_Slice_Sec
: constant GNAT
.OS_Lib
.String_Access
:=
129 GNAT
.OS_Lib
.Getenv
("PTHREAD_TIME_SLICE_SEC");
130 Pthread_Time_Slice_Usec
: constant GNAT
.OS_Lib
.String_Access
:=
131 GNAT
.OS_Lib
.Getenv
("PTHREAD_TIME_SLICE_USEC");
133 Val_Sec
, Val_Usec
: Integer := 0;
136 if Pthread_Time_Slice_Sec
.all'Length /= 0 or
137 Pthread_Time_Slice_Usec
.all'Length /= 0
139 if Pthread_Time_Slice_Sec
.all'Length /= 0 then
140 Val_Sec
:= Integer'Value (Pthread_Time_Slice_Sec
.all);
143 if Pthread_Time_Slice_Usec
.all'Length /= 0 then
144 Val_Usec
:= Integer'Value (Pthread_Time_Slice_Usec
.all);
147 return Duration (Val_Sec
) + Duration (Val_Usec
) / 1000.0;
149 return Default_Default_Time_Slice
;
154 return Default_Default_Time_Slice
;
155 end Default_Time_Slice
;
157 ------------------------
158 -- Default_Task_Stack --
159 ------------------------
161 function Default_Task_Stack
return Integer is
163 return Default_Default_Task_Stack
;
164 end Default_Task_Stack
;
166 -----------------------
167 -- Stack_Guard_Pages --
168 -----------------------
170 function Stack_Guard_Pages
return Integer is
171 Pthread_Stack_Guard_Pages
: constant GNAT
.OS_Lib
.String_Access
:=
172 GNAT
.OS_Lib
.Getenv
("PTHREAD_STACK_GUARD_PAGES");
175 if Pthread_Stack_Guard_Pages
.all'Length /= 0 then
176 return Integer'Value (Pthread_Stack_Guard_Pages
.all);
178 return Default_Stack_Guard_Pages
;
182 return Default_Stack_Guard_Pages
;
183 end Stack_Guard_Pages
;
185 --------------------------
186 -- Pthread_Sched_Signal --
187 --------------------------
189 function Pthread_Sched_Signal
return Integer is
191 return Default_Pthread_Sched_Signal
;
192 end Pthread_Sched_Signal
;
194 ------------------------
195 -- Pthread_Arena_Size --
196 ------------------------
198 function Pthread_Arena_Size
return Integer is
199 Pthread_Arena_Size
: constant GNAT
.OS_Lib
.String_Access
:=
200 GNAT
.OS_Lib
.Getenv
("PTHREAD_ARENA_SIZE");
203 if Pthread_Arena_Size
.all'Length = 0 then
204 return Default_Pthread_Arena_Size
;
206 return Integer'Value (Pthread_Arena_Size
.all);
210 return Default_Pthread_Arena_Size
;
211 end Pthread_Arena_Size
;
213 -------------------------
214 -- Os_Default_Priority --
215 -------------------------
217 function Os_Default_Priority
return Integer is
219 return Default_Os_Default_Priority
;
220 end Os_Default_Priority
;
222 end System
.Program_Info
;