OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [s-proinf-irix-athread.adb] - Blame information for rev 729

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                         GNAT COMPILER COMPONENTS                         --
4
--                                                                          --
5
--                 S Y S T E M . P R O G R A M  _  I N F O                  --
6
--                                                                          --
7
--                                 B o d y                                  --
8
--                                                                          --
9
--          Copyright (C) 1997-2009, Free Software Foundation, Inc.         --
10
--                                                                          --
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.                                     --
17
--                                                                          --
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.               --
21
--                                                                          --
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/>.                                          --
26
--                                                                          --
27
-- GNAT was originally developed  by the GNAT team at  New York University. --
28
-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29
--                                                                          --
30
------------------------------------------------------------------------------
31
 
32
--  This is an Irix (old pthread library) version of this package
33
 
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.
37
--
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
40
--  with the command:
41
--
42
--     % gcc -c -O2 -gnatpg s-proinf.adb
43
--
44
--  then relink your application as usual.
45
 
46
pragma Warnings (Off); -- why???
47
with System.OS_Lib;
48
pragma Warnings (On);
49
 
50
package body System.Program_Info is
51
 
52
   Kbytes : constant := 1024;
53
 
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;
63
 
64
   -------------------------
65
   -- Initial_Sproc_Count --
66
   -------------------------
67
 
68
   function Initial_Sproc_Count return Integer is
69
 
70
      function sysmp (P1 : Integer) return Integer;
71
      pragma Import (C, sysmp, "sysmp", "sysmp");
72
 
73
      MP_NPROCS : constant := 1; --   # processor in complex
74
 
75
      Pthread_Sproc_Count : constant System.OS_Lib.String_Access :=
76
        System.OS_Lib.Getenv ("PTHREAD_SPROC_COUNT");
77
 
78
   begin
79
      if Pthread_Sproc_Count.all'Length = 0 then
80
         return Default_Initial_Sproc_Count;
81
 
82
      elsif Pthread_Sproc_Count.all = "AUTO" then
83
         return sysmp (MP_NPROCS);
84
 
85
      else
86
         return Integer'Value (Pthread_Sproc_Count.all);
87
      end if;
88
 
89
   exception
90
      when others =>
91
         return Default_Initial_Sproc_Count;
92
   end Initial_Sproc_Count;
93
 
94
   ---------------------
95
   -- Max_Sproc_Count --
96
   ---------------------
97
 
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");
101
 
102
   begin
103
      if Pthread_Max_Sproc_Count.all'Length = 0 then
104
         return Default_Max_Sproc_Count;
105
      else
106
         return Integer'Value (Pthread_Max_Sproc_Count.all);
107
      end if;
108
   exception
109
      when others =>
110
         return Default_Max_Sproc_Count;
111
   end Max_Sproc_Count;
112
 
113
   ----------------------
114
   -- Sproc_Stack_Size --
115
   ----------------------
116
 
117
   function Sproc_Stack_Size return Integer is
118
   begin
119
      return Default_Sproc_Stack_Size;
120
   end Sproc_Stack_Size;
121
 
122
   ------------------------
123
   -- Default_Time_Slice --
124
   ------------------------
125
 
126
   function Default_Time_Slice return Duration is
127
      Pthread_Time_Slice_Sec : constant System.OS_Lib.String_Access :=
128
                                 System.OS_Lib.Getenv
129
                                   ("PTHREAD_TIME_SLICE_SEC");
130
      Pthread_Time_Slice_Usec : constant System.OS_Lib.String_Access :=
131
                                  System.OS_Lib.Getenv
132
                                    ("PTHREAD_TIME_SLICE_USEC");
133
 
134
      Val_Sec, Val_Usec : Integer := 0;
135
 
136
   begin
137
      if Pthread_Time_Slice_Sec.all'Length /= 0 or
138
        Pthread_Time_Slice_Usec.all'Length /= 0
139
      then
140
         if Pthread_Time_Slice_Sec.all'Length /= 0 then
141
            Val_Sec := Integer'Value (Pthread_Time_Slice_Sec.all);
142
         end if;
143
 
144
         if Pthread_Time_Slice_Usec.all'Length /= 0 then
145
            Val_Usec := Integer'Value (Pthread_Time_Slice_Usec.all);
146
         end if;
147
 
148
         return Duration (Val_Sec) + Duration (Val_Usec) / 1000.0;
149
      else
150
         return Default_Default_Time_Slice;
151
      end if;
152
 
153
   exception
154
      when others =>
155
         return Default_Default_Time_Slice;
156
   end Default_Time_Slice;
157
 
158
   ------------------------
159
   -- Default_Task_Stack --
160
   ------------------------
161
 
162
   function Default_Task_Stack return Integer is
163
   begin
164
      return Default_Default_Task_Stack;
165
   end Default_Task_Stack;
166
 
167
   -----------------------
168
   -- Stack_Guard_Pages --
169
   -----------------------
170
 
171
   function Stack_Guard_Pages return Integer is
172
      Pthread_Stack_Guard_Pages : constant System.OS_Lib.String_Access :=
173
                                    System.OS_Lib.Getenv
174
                                      ("PTHREAD_STACK_GUARD_PAGES");
175
   begin
176
      if Pthread_Stack_Guard_Pages.all'Length /= 0 then
177
         return Integer'Value (Pthread_Stack_Guard_Pages.all);
178
      else
179
         return Default_Stack_Guard_Pages;
180
      end if;
181
   exception
182
      when others =>
183
         return Default_Stack_Guard_Pages;
184
   end Stack_Guard_Pages;
185
 
186
   --------------------------
187
   -- Pthread_Sched_Signal --
188
   --------------------------
189
 
190
   function Pthread_Sched_Signal return Integer is
191
   begin
192
      return Default_Pthread_Sched_Signal;
193
   end Pthread_Sched_Signal;
194
 
195
   ------------------------
196
   -- Pthread_Arena_Size --
197
   ------------------------
198
 
199
   function Pthread_Arena_Size  return Integer is
200
      Pthread_Arena_Size : constant System.OS_Lib.String_Access :=
201
                             System.OS_Lib.Getenv
202
                               ("PTHREAD_ARENA_SIZE");
203
 
204
   begin
205
      if Pthread_Arena_Size.all'Length = 0 then
206
         return Default_Pthread_Arena_Size;
207
      else
208
         return Integer'Value (Pthread_Arena_Size.all);
209
      end if;
210
 
211
   exception
212
      when others =>
213
         return Default_Pthread_Arena_Size;
214
   end Pthread_Arena_Size;
215
 
216
   -------------------------
217
   -- Os_Default_Priority --
218
   -------------------------
219
 
220
   function Os_Default_Priority return Integer is
221
   begin
222
      return Default_Os_Default_Priority;
223
   end Os_Default_Priority;
224
 
225
end System.Program_Info;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.