1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . P R O G R A M _ I N F O --
-- --
-- B o d y --
-- --
-- $Revision: 1.2 $ --
-- --
-- Copyright (C) 1996 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This package contains the parameters used by the run-time system at
-- program startup. These parameters are isolated in this package body to
-- facilitate replacement by the end user.
--
-- To repalce the default values, copy this source file into your build
-- directory, edit the file to reflect your desired behavior, and recompile
-- with the command:
--
-- % gcc -c -O2 -gnatg s-proinf.adb
--
-- then relink your application as usual.
--
with Interfaces.C.Strings;
package body System.Program_Info is
Kbytes : constant := 1024;
Default_Initial_Sproc_Count : constant := 0;
Default_Max_Sproc_Count : constant := 128;
Default_Sproc_Stack_Size : constant := 16#4000#;
Default_Stack_Guard_Pages : constant := 1;
Default_Default_Time_Slice : constant := 0.0;
Default_Default_Task_Stack : constant := 12 * Kbytes;
Default_Pthread_Sched_Signal : constant := 33;
Default_Pthread_Arena_Size : constant := 16#40000#;
Default_Os_Default_Priority : constant := 0;
use Interfaces.C.Strings;
function Getenv (Name : String) return String;
function Getenv (Name : String) return String is
function C_Getenv (P1 : chars_ptr) return chars_ptr;
pragma Import (C, C_Getenv, "getenv", "getenv");
Result : chars_ptr;
C_P1 : chars_ptr := New_String (Name);
begin
Result := C_Getenv (C_P1);
Free (C_P1);
if Result = Null_Ptr then
return "";
else
return Value (Result);
end if;
end Getenv;
function Initial_Sproc_Count return Integer is
function sysmp (P1 : Integer) return Integer;
pragma Import (C, sysmp, "sysmp", "sysmp");
MP_NPROCS : constant := 1; -- # processor in complex
PTHREAD_SPROC_COUNT_STR : constant String
:= Getenv ("PTHREAD_SPROC_COUNT");
begin
if PTHREAD_SPROC_COUNT_STR = "" then
return Default_Initial_Sproc_Count;
elsif PTHREAD_SPROC_COUNT_STR'Length >= 4 and then
PTHREAD_SPROC_COUNT_STR (1 .. 4) = "AUTO" then
return sysmp (MP_NPROCS);
else
return Integer'Value (PTHREAD_SPROC_COUNT_STR);
end if;
exception
when others => return 0;
end Initial_Sproc_Count;
function Max_Sproc_Count return Integer is
PTHREAD_MAX_SPROC_COUNT_STR : constant String
:= Getenv ("PTHREAD_MAX_SPROC_COUNT");
begin
if PTHREAD_MAX_SPROC_COUNT_STR = "" then
return Default_Max_Sproc_Count;
else
return Integer'Value (PTHREAD_MAX_SPROC_COUNT_STR);
end if;
exception
when others =>
return Integer'Value (PTHREAD_MAX_SPROC_COUNT_STR);
end Max_Sproc_Count;
function Sproc_Stack_Size return Integer is
begin
return Default_Sproc_Stack_Size;
end Sproc_Stack_Size;
function Default_Time_Slice return Duration is
PTHREAD_TIME_SLICE_USEC_STR : constant String
:= Getenv ("PTHREAD_TIME_SLICE_USEC");
PTHREAD_TIME_SLICE_SEC_STR : constant String
:= Getenv ("PTHREAD_TIME_SLICE_SEC");
Time_Slice : Duration := 0.0;
begin
if PTHREAD_TIME_SLICE_USEC_STR /= "" or
PTHREAD_TIME_SLICE_SEC_STR /= "" then
if PTHREAD_TIME_SLICE_SEC_STR /= "" then
Time_Slice := Time_Slice +
Duration (Integer'Value (PTHREAD_TIME_SLICE_SEC_STR));
end if;
if PTHREAD_TIME_SLICE_USEC_STR /= "" then
Time_Slice := Time_Slice +
Duration (Integer'Value (PTHREAD_TIME_SLICE_SEC_STR)) / 1000.0;
end if;
return Time_Slice;
else
return Default_Default_Time_Slice;
end if;
exception
when others =>
return Default_Default_Time_Slice;
end Default_Time_Slice;
function Default_Task_Stack return Integer is
begin
return Default_Default_Task_Stack;
end Default_Task_Stack;
function Stack_Guard_Pages return Integer is
PTHREAD_STACK_GUARD_PAGES_STR : constant String
:= Getenv ("PTHREAD_STACK_GUARD_PAGES");
begin
if PTHREAD_STACK_GUARD_PAGES_STR /= "" then
return Integer'Value (PTHREAD_STACK_GUARD_PAGES_STR);
else
return Default_Stack_Guard_Pages;
end if;
exception
when others =>
return Default_Stack_Guard_Pages;
end Stack_Guard_Pages;
function Pthread_Sched_Signal return Integer is
begin
return Default_Pthread_Sched_Signal;
end Pthread_Sched_Signal;
function Pthread_Arena_Size return Integer is
PTHREAD_ARENA_SIZE_STR : constant String
:= Getenv ("PTHREAD_ARENA_SIZE");
begin
if PTHREAD_ARENA_SIZE_STR = "" then
return Default_Pthread_Arena_Size;
else
return Integer'Value (PTHREAD_ARENA_SIZE_STR);
end if;
exception
when others =>
return Default_Pthread_Arena_Size;
end Pthread_Arena_Size;
function Os_Default_Priority return Integer is
begin
return Default_Os_Default_Priority;
end Os_Default_Priority;
end System.Program_Info;
|