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-1999 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, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, 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.
51 package body System
.Program_Info
is
53 Kbytes
: constant := 1024;
55 Default_Initial_Sproc_Count
: constant := 0;
56 Default_Max_Sproc_Count
: constant := 128;
57 Default_Sproc_Stack_Size
: constant := 16#
4000#
;
58 Default_Stack_Guard_Pages
: constant := 1;
59 Default_Default_Time_Slice
: constant := 0.0;
60 Default_Default_Task_Stack
: constant := 12 * Kbytes
;
61 Default_Pthread_Sched_Signal
: constant := 35;
62 Default_Pthread_Arena_Size
: constant := 16#
40000#
;
63 Default_Os_Default_Priority
: constant := 0;
65 -------------------------
66 -- Initial_Sproc_Count --
67 -------------------------
69 function Initial_Sproc_Count
return Integer is
71 function sysmp
(P1
: Integer) return Integer;
72 pragma Import
(C
, sysmp
, "sysmp", "sysmp");
74 MP_NPROCS
: constant := 1; -- # processor in complex
76 Pthread_Sproc_Count
: constant GNAT
.OS_Lib
.String_Access
:=
77 GNAT
.OS_Lib
.Getenv
("PTHREAD_SPROC_COUNT");
80 if Pthread_Sproc_Count
.all'Length = 0 then
81 return Default_Initial_Sproc_Count
;
83 elsif Pthread_Sproc_Count
.all = "AUTO" then
84 return sysmp
(MP_NPROCS
);
87 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 GNAT
.OS_Lib
.String_Access
:=
100 GNAT
.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 GNAT
.OS_Lib
.String_Access
:=
128 GNAT
.OS_Lib
.Getenv
("PTHREAD_TIME_SLICE_SEC");
129 Pthread_Time_Slice_Usec
: constant GNAT
.OS_Lib
.String_Access
:=
130 GNAT
.OS_Lib
.Getenv
("PTHREAD_TIME_SLICE_USEC");
132 Val_Sec
, Val_Usec
: Integer := 0;
135 if Pthread_Time_Slice_Sec
.all'Length /= 0 or
136 Pthread_Time_Slice_Usec
.all'Length /= 0
138 if Pthread_Time_Slice_Sec
.all'Length /= 0 then
139 Val_Sec
:= Integer'Value (Pthread_Time_Slice_Sec
.all);
142 if Pthread_Time_Slice_Usec
.all'Length /= 0 then
143 Val_Usec
:= Integer'Value (Pthread_Time_Slice_Usec
.all);
146 return Duration (Val_Sec
) + Duration (Val_Usec
) / 1000.0;
148 return Default_Default_Time_Slice
;
153 return Default_Default_Time_Slice
;
154 end Default_Time_Slice
;
156 ------------------------
157 -- Default_Task_Stack --
158 ------------------------
160 function Default_Task_Stack
return Integer is
162 return Default_Default_Task_Stack
;
163 end Default_Task_Stack
;
165 -----------------------
166 -- Stack_Guard_Pages --
167 -----------------------
169 function Stack_Guard_Pages
return Integer is
170 Pthread_Stack_Guard_Pages
: constant GNAT
.OS_Lib
.String_Access
:=
171 GNAT
.OS_Lib
.Getenv
("PTHREAD_STACK_GUARD_PAGES");
174 if Pthread_Stack_Guard_Pages
.all'Length /= 0 then
175 return Integer'Value (Pthread_Stack_Guard_Pages
.all);
177 return Default_Stack_Guard_Pages
;
181 return Default_Stack_Guard_Pages
;
182 end Stack_Guard_Pages
;
184 --------------------------
185 -- Pthread_Sched_Signal --
186 --------------------------
188 function Pthread_Sched_Signal
return Integer is
190 return Default_Pthread_Sched_Signal
;
191 end Pthread_Sched_Signal
;
193 ------------------------
194 -- Pthread_Arena_Size --
195 ------------------------
197 function Pthread_Arena_Size
return Integer is
198 Pthread_Arena_Size
: constant GNAT
.OS_Lib
.String_Access
:=
199 GNAT
.OS_Lib
.Getenv
("PTHREAD_ARENA_SIZE");
202 if Pthread_Arena_Size
.all'Length = 0 then
203 return Default_Pthread_Arena_Size
;
205 return Integer'Value (Pthread_Arena_Size
.all);
209 return Default_Pthread_Arena_Size
;
210 end Pthread_Arena_Size
;
212 -------------------------
213 -- Os_Default_Priority --
214 -------------------------
216 function Os_Default_Priority
return Integer is
218 return Default_Os_Default_Priority
;
219 end Os_Default_Priority
;
221 end System
.Program_Info
;