1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- S Y S T E M . O S _ I N T E R F A C E --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 1991-1994, Florida State University --
|
10 |
|
|
-- Copyright (C) 1995-2008, Free Software Foundation, Inc. --
|
11 |
|
|
-- --
|
12 |
|
|
-- GNARL 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. GNARL 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 GNARL; see file COPYING. If not, write --
|
20 |
|
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
21 |
|
|
-- Boston, MA 02110-1301, USA. --
|
22 |
|
|
-- --
|
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. --
|
29 |
|
|
-- --
|
30 |
|
|
-- GNARL was developed by the GNARL team at Florida State University. --
|
31 |
|
|
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
|
32 |
|
|
-- --
|
33 |
|
|
------------------------------------------------------------------------------
|
34 |
|
|
|
35 |
|
|
-- This is a LynxOS (Native) version of this package
|
36 |
|
|
|
37 |
|
|
-- This package encapsulates all direct interfaces to OS services
|
38 |
|
|
-- that are needed by the tasking run-time (libgnarl).
|
39 |
|
|
|
40 |
|
|
-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
|
41 |
|
|
-- Preelaborate. This package is designed to be a bottom-level (leaf) package.
|
42 |
|
|
|
43 |
|
|
with Ada.Unchecked_Conversion;
|
44 |
|
|
|
45 |
|
|
with Interfaces.C;
|
46 |
|
|
|
47 |
|
|
package System.OS_Interface is
|
48 |
|
|
pragma Preelaborate;
|
49 |
|
|
|
50 |
|
|
pragma Linker_Options ("-mthreads");
|
51 |
|
|
|
52 |
|
|
subtype int is Interfaces.C.int;
|
53 |
|
|
subtype char is Interfaces.C.char;
|
54 |
|
|
subtype short is Interfaces.C.short;
|
55 |
|
|
subtype long is Interfaces.C.long;
|
56 |
|
|
subtype unsigned is Interfaces.C.unsigned;
|
57 |
|
|
subtype unsigned_short is Interfaces.C.unsigned_short;
|
58 |
|
|
subtype unsigned_long is Interfaces.C.unsigned_long;
|
59 |
|
|
subtype unsigned_char is Interfaces.C.unsigned_char;
|
60 |
|
|
subtype plain_char is Interfaces.C.plain_char;
|
61 |
|
|
subtype size_t is Interfaces.C.size_t;
|
62 |
|
|
|
63 |
|
|
-----------
|
64 |
|
|
-- Errno --
|
65 |
|
|
-----------
|
66 |
|
|
|
67 |
|
|
function errno return int;
|
68 |
|
|
pragma Import (C, errno, "__get_errno");
|
69 |
|
|
|
70 |
|
|
EAGAIN : constant := 11;
|
71 |
|
|
EINTR : constant := 4;
|
72 |
|
|
EINVAL : constant := 22;
|
73 |
|
|
ENOMEM : constant := 12;
|
74 |
|
|
ETIMEDOUT : constant := 60;
|
75 |
|
|
|
76 |
|
|
-------------
|
77 |
|
|
-- Signals --
|
78 |
|
|
-------------
|
79 |
|
|
|
80 |
|
|
Max_Interrupt : constant := 63;
|
81 |
|
|
type Signal is new int range 0 .. Max_Interrupt;
|
82 |
|
|
for Signal'Size use int'Size;
|
83 |
|
|
|
84 |
|
|
SIGHUP : constant := 1; -- hangup
|
85 |
|
|
SIGINT : constant := 2; -- interrupt (rubout)
|
86 |
|
|
SIGQUIT : constant := 3; -- quit (ASCD FS)
|
87 |
|
|
SIGILL : constant := 4; -- illegal instruction (not reset)
|
88 |
|
|
SIGTRAP : constant := 5; -- trace trap (not reset)
|
89 |
|
|
SIGBRK : constant := 6; -- break
|
90 |
|
|
SIGIOT : constant := 6; -- IOT instruction
|
91 |
|
|
SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
|
92 |
|
|
SIGCORE : constant := 7; -- kill with core dump
|
93 |
|
|
SIGEMT : constant := 7; -- EMT instruction
|
94 |
|
|
SIGFPE : constant := 8; -- floating point exception
|
95 |
|
|
SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
|
96 |
|
|
SIGBUS : constant := 10; -- bus error
|
97 |
|
|
SIGSEGV : constant := 11; -- segmentation violation
|
98 |
|
|
SIGSYS : constant := 12; -- bad argument to system call
|
99 |
|
|
SIGPIPE : constant := 13; -- write on a pipe with no one to read it
|
100 |
|
|
SIGALRM : constant := 14; -- alarm clock
|
101 |
|
|
SIGTERM : constant := 15; -- software termination signal from kill
|
102 |
|
|
SIGURG : constant := 16; -- urgent condition on IO channel
|
103 |
|
|
SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
|
104 |
|
|
SIGTSTP : constant := 18; -- user stop requested from tty
|
105 |
|
|
SIGCONT : constant := 19; -- stopped process has been continued
|
106 |
|
|
SIGCLD : constant := 20; -- alias for SIGCHLD
|
107 |
|
|
SIGCHLD : constant := 20; -- child status change
|
108 |
|
|
SIGTTIN : constant := 21; -- background tty read attempted
|
109 |
|
|
SIGTTOU : constant := 22; -- background tty write attempted
|
110 |
|
|
SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
|
111 |
|
|
SIGPOLL : constant := 23; -- pollable event occurred
|
112 |
|
|
SIGXCPU : constant := 24; -- CPU time limit exceeded
|
113 |
|
|
SIGXFSZ : constant := 25; -- filesize limit exceeded
|
114 |
|
|
SIGVTALRM : constant := 26; -- virtual timer expired
|
115 |
|
|
SIGPROF : constant := 27; -- profiling timer expired
|
116 |
|
|
SIGWINCH : constant := 28; -- window size change
|
117 |
|
|
SIGLOST : constant := 29; -- SUN 4.1 compatibility
|
118 |
|
|
SIGUSR1 : constant := 30; -- user defined signal 1
|
119 |
|
|
SIGUSR2 : constant := 31; -- user defined signal 2
|
120 |
|
|
SIGPRIO : constant := 32; -- sent to a process with its priority or
|
121 |
|
|
-- group is changed
|
122 |
|
|
|
123 |
|
|
SIGADAABORT : constant := SIGABRT;
|
124 |
|
|
-- Change this if you want to use another signal for task abort.
|
125 |
|
|
-- SIGTERM might be a good one.
|
126 |
|
|
|
127 |
|
|
type Signal_Set is array (Natural range <>) of Signal;
|
128 |
|
|
|
129 |
|
|
Unmasked : constant Signal_Set :=
|
130 |
|
|
(SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF);
|
131 |
|
|
Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP, SIGPRIO);
|
132 |
|
|
|
133 |
|
|
type sigset_t is private;
|
134 |
|
|
|
135 |
|
|
function sigaddset (set : access sigset_t; sig : Signal) return int;
|
136 |
|
|
pragma Import (C, sigaddset, "sigaddset");
|
137 |
|
|
|
138 |
|
|
function sigdelset (set : access sigset_t; sig : Signal) return int;
|
139 |
|
|
pragma Import (C, sigdelset, "sigdelset");
|
140 |
|
|
|
141 |
|
|
function sigfillset (set : access sigset_t) return int;
|
142 |
|
|
pragma Import (C, sigfillset, "sigfillset");
|
143 |
|
|
|
144 |
|
|
function sigismember (set : access sigset_t; sig : Signal) return int;
|
145 |
|
|
pragma Import (C, sigismember, "sigismember");
|
146 |
|
|
|
147 |
|
|
function sigemptyset (set : access sigset_t) return int;
|
148 |
|
|
pragma Import (C, sigemptyset, "sigemptyset");
|
149 |
|
|
|
150 |
|
|
type struct_sigaction is record
|
151 |
|
|
sa_handler : System.Address;
|
152 |
|
|
sa_mask : sigset_t;
|
153 |
|
|
sa_flags : int;
|
154 |
|
|
end record;
|
155 |
|
|
pragma Convention (C, struct_sigaction);
|
156 |
|
|
type struct_sigaction_ptr is access all struct_sigaction;
|
157 |
|
|
|
158 |
|
|
SA_SIGINFO : constant := 16#80#;
|
159 |
|
|
|
160 |
|
|
SIG_BLOCK : constant := 0;
|
161 |
|
|
SIG_UNBLOCK : constant := 1;
|
162 |
|
|
SIG_SETMASK : constant := 2;
|
163 |
|
|
|
164 |
|
|
SIG_DFL : constant := 0;
|
165 |
|
|
SIG_IGN : constant := 1;
|
166 |
|
|
|
167 |
|
|
function sigaction
|
168 |
|
|
(sig : Signal;
|
169 |
|
|
act : struct_sigaction_ptr;
|
170 |
|
|
oact : struct_sigaction_ptr) return int;
|
171 |
|
|
pragma Import (C, sigaction, "sigaction");
|
172 |
|
|
|
173 |
|
|
----------
|
174 |
|
|
-- Time --
|
175 |
|
|
----------
|
176 |
|
|
|
177 |
|
|
Time_Slice_Supported : constant Boolean := True;
|
178 |
|
|
-- Indicates whether time slicing is supported
|
179 |
|
|
|
180 |
|
|
type timespec is private;
|
181 |
|
|
|
182 |
|
|
type clockid_t is private;
|
183 |
|
|
|
184 |
|
|
CLOCK_REALTIME : constant clockid_t;
|
185 |
|
|
|
186 |
|
|
function clock_gettime
|
187 |
|
|
(clock_id : clockid_t;
|
188 |
|
|
tp : access timespec) return int;
|
189 |
|
|
pragma Inline (clock_gettime);
|
190 |
|
|
-- LynxOS has non standard clock_gettime
|
191 |
|
|
|
192 |
|
|
function To_Duration (TS : timespec) return Duration;
|
193 |
|
|
pragma Inline (To_Duration);
|
194 |
|
|
|
195 |
|
|
function To_Timespec (D : Duration) return timespec;
|
196 |
|
|
pragma Inline (To_Timespec);
|
197 |
|
|
|
198 |
|
|
type struct_timezone is record
|
199 |
|
|
tz_minuteswest : int;
|
200 |
|
|
tz_dsttime : int;
|
201 |
|
|
end record;
|
202 |
|
|
pragma Convention (C, struct_timezone);
|
203 |
|
|
type struct_timezone_ptr is access all struct_timezone;
|
204 |
|
|
|
205 |
|
|
-------------------------
|
206 |
|
|
-- Priority Scheduling --
|
207 |
|
|
-------------------------
|
208 |
|
|
|
209 |
|
|
SCHED_FIFO : constant := 16#00200000#;
|
210 |
|
|
SCHED_RR : constant := 16#00100000#;
|
211 |
|
|
SCHED_OTHER : constant := 16#00400000#;
|
212 |
|
|
|
213 |
|
|
function To_Target_Priority
|
214 |
|
|
(Prio : System.Any_Priority) return Interfaces.C.int;
|
215 |
|
|
-- Maps System.Any_Priority to a POSIX priority
|
216 |
|
|
|
217 |
|
|
-------------
|
218 |
|
|
-- Process --
|
219 |
|
|
-------------
|
220 |
|
|
|
221 |
|
|
type pid_t is private;
|
222 |
|
|
|
223 |
|
|
function kill (pid : pid_t; sig : Signal) return int;
|
224 |
|
|
pragma Import (C, kill, "kill");
|
225 |
|
|
|
226 |
|
|
function getpid return pid_t;
|
227 |
|
|
pragma Import (C, getpid, "getpid");
|
228 |
|
|
|
229 |
|
|
---------
|
230 |
|
|
-- LWP --
|
231 |
|
|
---------
|
232 |
|
|
|
233 |
|
|
function lwp_self return System.Address;
|
234 |
|
|
-- lwp_self does not exist on this thread library, revert to pthread_self
|
235 |
|
|
-- which is the closest approximation (with getpid). This function is
|
236 |
|
|
-- needed to share 7staprop.adb across POSIX-like targets.
|
237 |
|
|
pragma Import (C, lwp_self, "pthread_self");
|
238 |
|
|
|
239 |
|
|
-------------
|
240 |
|
|
-- Threads --
|
241 |
|
|
-------------
|
242 |
|
|
|
243 |
|
|
type Thread_Body is access
|
244 |
|
|
function (arg : System.Address) return System.Address;
|
245 |
|
|
pragma Convention (C, Thread_Body);
|
246 |
|
|
|
247 |
|
|
function Thread_Body_Access is new
|
248 |
|
|
Ada.Unchecked_Conversion (System.Address, Thread_Body);
|
249 |
|
|
|
250 |
|
|
type pthread_t is private;
|
251 |
|
|
subtype Thread_Id is pthread_t;
|
252 |
|
|
|
253 |
|
|
type pthread_mutex_t is limited private;
|
254 |
|
|
type pthread_cond_t is limited private;
|
255 |
|
|
type st_t is limited private;
|
256 |
|
|
type pthread_attr_t is limited private;
|
257 |
|
|
type pthread_mutexattr_t is limited private;
|
258 |
|
|
type pthread_condattr_t is limited private;
|
259 |
|
|
type pthread_key_t is private;
|
260 |
|
|
|
261 |
|
|
PTHREAD_CREATE_DETACHED : constant := 0;
|
262 |
|
|
|
263 |
|
|
PTHREAD_SCOPE_PROCESS : constant := 0;
|
264 |
|
|
PTHREAD_SCOPE_SYSTEM : constant := 1;
|
265 |
|
|
|
266 |
|
|
-----------
|
267 |
|
|
-- Stack --
|
268 |
|
|
-----------
|
269 |
|
|
|
270 |
|
|
Alternate_Stack_Size : constant := 0;
|
271 |
|
|
-- No alternate signal stack is used on this platform
|
272 |
|
|
|
273 |
|
|
Stack_Base_Available : constant Boolean := False;
|
274 |
|
|
-- Indicates whether the stack base is available on this target
|
275 |
|
|
|
276 |
|
|
function Get_Stack_Base (thread : pthread_t) return Address;
|
277 |
|
|
pragma Inline (Get_Stack_Base);
|
278 |
|
|
-- returns the stack base of the specified thread.
|
279 |
|
|
-- Only call this function when Stack_Base_Available is True.
|
280 |
|
|
|
281 |
|
|
function Get_Page_Size return size_t;
|
282 |
|
|
function Get_Page_Size return Address;
|
283 |
|
|
pragma Import (C, Get_Page_Size, "getpagesize");
|
284 |
|
|
-- returns the size of a page, or 0 if this is not relevant on this
|
285 |
|
|
-- target
|
286 |
|
|
|
287 |
|
|
PROT_NONE : constant := 0;
|
288 |
|
|
PROT_READ : constant := 1;
|
289 |
|
|
PROT_WRITE : constant := 2;
|
290 |
|
|
PROT_EXEC : constant := 4;
|
291 |
|
|
PROT_USER : constant := 8;
|
292 |
|
|
PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC + PROT_USER;
|
293 |
|
|
|
294 |
|
|
PROT_ON : constant := PROT_READ;
|
295 |
|
|
PROT_OFF : constant := PROT_ALL;
|
296 |
|
|
|
297 |
|
|
function mprotect (addr : Address; len : size_t; prot : int) return int;
|
298 |
|
|
pragma Import (C, mprotect);
|
299 |
|
|
|
300 |
|
|
-------------------------
|
301 |
|
|
-- POSIX.1c Section 3 --
|
302 |
|
|
-------------------------
|
303 |
|
|
|
304 |
|
|
function sigwait
|
305 |
|
|
(set : access sigset_t;
|
306 |
|
|
sig : access Signal) return int;
|
307 |
|
|
pragma Inline (sigwait);
|
308 |
|
|
-- LynxOS has non standard sigwait
|
309 |
|
|
|
310 |
|
|
function pthread_kill (thread : pthread_t; sig : Signal) return int;
|
311 |
|
|
pragma Import (C, pthread_kill, "pthread_kill");
|
312 |
|
|
|
313 |
|
|
function pthread_sigmask
|
314 |
|
|
(how : int;
|
315 |
|
|
set : access sigset_t;
|
316 |
|
|
oset : access sigset_t) return int;
|
317 |
|
|
pragma Import (C, pthread_sigmask, "sigprocmask");
|
318 |
|
|
|
319 |
|
|
--------------------------
|
320 |
|
|
-- POSIX.1c Section 11 --
|
321 |
|
|
--------------------------
|
322 |
|
|
|
323 |
|
|
function pthread_mutexattr_init
|
324 |
|
|
(attr : access pthread_mutexattr_t) return int;
|
325 |
|
|
pragma Inline (pthread_mutexattr_init);
|
326 |
|
|
-- LynxOS has a nonstandard pthread_mutexattr_init
|
327 |
|
|
|
328 |
|
|
function pthread_mutexattr_destroy
|
329 |
|
|
(attr : access pthread_mutexattr_t) return int;
|
330 |
|
|
pragma Inline (pthread_mutexattr_destroy);
|
331 |
|
|
-- Lynxos has a nonstandard pthread_mutexattr_destroy
|
332 |
|
|
|
333 |
|
|
function pthread_mutex_init
|
334 |
|
|
(mutex : access pthread_mutex_t;
|
335 |
|
|
attr : access pthread_mutexattr_t) return int;
|
336 |
|
|
pragma Inline (pthread_mutex_init);
|
337 |
|
|
-- LynxOS has a nonstandard pthread_mutex_init
|
338 |
|
|
|
339 |
|
|
function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
|
340 |
|
|
pragma Inline (pthread_mutex_destroy);
|
341 |
|
|
-- LynxOS has a nonstandard pthread_mutex_destroy
|
342 |
|
|
|
343 |
|
|
function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
|
344 |
|
|
pragma Inline (pthread_mutex_lock);
|
345 |
|
|
-- LynxOS has a nonstandard pthread_mutex_lock
|
346 |
|
|
|
347 |
|
|
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
|
348 |
|
|
pragma Inline (pthread_mutex_unlock);
|
349 |
|
|
-- LynxOS has a nonstandard pthread_mutex_unlock
|
350 |
|
|
|
351 |
|
|
function pthread_condattr_init
|
352 |
|
|
(attr : access pthread_condattr_t) return int;
|
353 |
|
|
pragma Inline (pthread_condattr_init);
|
354 |
|
|
-- LynxOS has a nonstandard pthread_condattr_init
|
355 |
|
|
|
356 |
|
|
function pthread_condattr_destroy
|
357 |
|
|
(attr : access pthread_condattr_t) return int;
|
358 |
|
|
pragma Inline (pthread_condattr_destroy);
|
359 |
|
|
-- LynxOS has a nonstandard pthread_condattr_destroy
|
360 |
|
|
|
361 |
|
|
function pthread_cond_init
|
362 |
|
|
(cond : access pthread_cond_t;
|
363 |
|
|
attr : access pthread_condattr_t) return int;
|
364 |
|
|
pragma Inline (pthread_cond_init);
|
365 |
|
|
-- LynxOS has a non standard pthread_cond_init
|
366 |
|
|
|
367 |
|
|
function pthread_cond_destroy (cond : access pthread_cond_t) return int;
|
368 |
|
|
pragma Inline (pthread_cond_destroy);
|
369 |
|
|
-- LynxOS has a nonstandard pthread_cond_destroy
|
370 |
|
|
|
371 |
|
|
function pthread_cond_signal (cond : access pthread_cond_t) return int;
|
372 |
|
|
pragma Inline (pthread_cond_signal);
|
373 |
|
|
-- LynxOS has a nonstandard pthread_cond_signal
|
374 |
|
|
|
375 |
|
|
function pthread_cond_wait
|
376 |
|
|
(cond : access pthread_cond_t;
|
377 |
|
|
mutex : access pthread_mutex_t) return int;
|
378 |
|
|
pragma Inline (pthread_cond_wait);
|
379 |
|
|
-- LynxOS has a nonstandard pthread_cond_wait
|
380 |
|
|
|
381 |
|
|
function pthread_cond_timedwait
|
382 |
|
|
(cond : access pthread_cond_t;
|
383 |
|
|
mutex : access pthread_mutex_t;
|
384 |
|
|
reltime : access timespec) return int;
|
385 |
|
|
pragma Inline (pthread_cond_timedwait);
|
386 |
|
|
-- LynxOS has a nonstandard pthread_cond_timedwait
|
387 |
|
|
|
388 |
|
|
Relative_Timed_Wait : constant Boolean := True;
|
389 |
|
|
-- pthread_cond_timedwait requires a relative delay time
|
390 |
|
|
|
391 |
|
|
--------------------------
|
392 |
|
|
-- POSIX.1c Section 13 --
|
393 |
|
|
--------------------------
|
394 |
|
|
|
395 |
|
|
PTHREAD_PRIO_NONE : constant := 0;
|
396 |
|
|
PTHREAD_PRIO_INHERIT : constant := 0;
|
397 |
|
|
PTHREAD_PRIO_PROTECT : constant := 0;
|
398 |
|
|
|
399 |
|
|
type struct_sched_param is record
|
400 |
|
|
sched_priority : int; -- scheduling priority
|
401 |
|
|
end record;
|
402 |
|
|
|
403 |
|
|
function pthread_setschedparam
|
404 |
|
|
(thread : pthread_t;
|
405 |
|
|
policy : int;
|
406 |
|
|
param : access struct_sched_param) return int;
|
407 |
|
|
pragma Inline (pthread_setschedparam);
|
408 |
|
|
-- LynxOS doesn't have pthread_setschedparam.
|
409 |
|
|
-- Instead, use pthread_setscheduler
|
410 |
|
|
|
411 |
|
|
function pthread_mutexattr_setprotocol
|
412 |
|
|
(attr : access pthread_mutexattr_t;
|
413 |
|
|
protocol : int) return int;
|
414 |
|
|
pragma Inline (pthread_mutexattr_setprotocol);
|
415 |
|
|
-- LynxOS doesn't have pthread_mutexattr_setprotocol
|
416 |
|
|
|
417 |
|
|
function pthread_mutexattr_setprioceiling
|
418 |
|
|
(attr : access pthread_mutexattr_t;
|
419 |
|
|
prioceiling : int) return int;
|
420 |
|
|
pragma Inline (pthread_mutexattr_setprioceiling);
|
421 |
|
|
-- LynxOS doesn't have pthread_mutexattr_setprioceiling
|
422 |
|
|
|
423 |
|
|
function pthread_attr_setscope
|
424 |
|
|
(attr : access pthread_attr_t;
|
425 |
|
|
contentionscope : int) return int;
|
426 |
|
|
-- LynxOS doesn't have pthread_attr_setscope: all threads have system scope
|
427 |
|
|
pragma Inline (pthread_attr_setscope);
|
428 |
|
|
|
429 |
|
|
function pthread_attr_setschedpolicy
|
430 |
|
|
(attr : access pthread_attr_t;
|
431 |
|
|
policy : int) return int;
|
432 |
|
|
pragma Import (C, pthread_attr_setschedpolicy, "pthread_attr_setsched");
|
433 |
|
|
|
434 |
|
|
function sched_yield return int;
|
435 |
|
|
-- pragma Import (C, sched_yield, "sched_yield");
|
436 |
|
|
pragma Inline (sched_yield);
|
437 |
|
|
|
438 |
|
|
---------------------------
|
439 |
|
|
-- P1003.1c - Section 16 --
|
440 |
|
|
---------------------------
|
441 |
|
|
|
442 |
|
|
function pthread_attr_init (attributes : access pthread_attr_t) return int;
|
443 |
|
|
pragma Import (C, pthread_attr_init, "pthread_attr_create");
|
444 |
|
|
|
445 |
|
|
function pthread_attr_destroy
|
446 |
|
|
(attributes : access pthread_attr_t) return int;
|
447 |
|
|
pragma Import (C, pthread_attr_destroy, "pthread_attr_delete");
|
448 |
|
|
|
449 |
|
|
function pthread_attr_setdetachstate
|
450 |
|
|
(attr : access pthread_attr_t;
|
451 |
|
|
detachstate : int) return int;
|
452 |
|
|
pragma Inline (pthread_attr_setdetachstate);
|
453 |
|
|
-- LynxOS doesn't have pthread_attr_setdetachstate
|
454 |
|
|
|
455 |
|
|
function pthread_attr_setstacksize
|
456 |
|
|
(attr : access pthread_attr_t;
|
457 |
|
|
stacksize : size_t) return int;
|
458 |
|
|
pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
|
459 |
|
|
|
460 |
|
|
function pthread_create
|
461 |
|
|
(thread : access pthread_t;
|
462 |
|
|
attributes : access pthread_attr_t;
|
463 |
|
|
start_routine : Thread_Body;
|
464 |
|
|
arg : System.Address) return int;
|
465 |
|
|
pragma Inline (pthread_create);
|
466 |
|
|
-- LynxOS has a non standard pthread_create
|
467 |
|
|
|
468 |
|
|
function pthread_detach (thread : pthread_t) return int;
|
469 |
|
|
pragma Inline (pthread_detach);
|
470 |
|
|
|
471 |
|
|
procedure pthread_exit (status : System.Address);
|
472 |
|
|
pragma Import (C, pthread_exit, "pthread_exit");
|
473 |
|
|
|
474 |
|
|
function pthread_self return pthread_t;
|
475 |
|
|
pragma Import (C, pthread_self, "pthread_self");
|
476 |
|
|
|
477 |
|
|
--------------------------
|
478 |
|
|
-- POSIX.1c Section 17 --
|
479 |
|
|
--------------------------
|
480 |
|
|
|
481 |
|
|
function pthread_setspecific
|
482 |
|
|
(key : pthread_key_t;
|
483 |
|
|
value : System.Address) return int;
|
484 |
|
|
pragma Inline (pthread_setspecific);
|
485 |
|
|
-- LynxOS has a non standard pthread_setspecific
|
486 |
|
|
|
487 |
|
|
function pthread_getspecific (key : pthread_key_t) return System.Address;
|
488 |
|
|
pragma Inline (pthread_getspecific);
|
489 |
|
|
-- LynxOS has a non standard pthread_getspecific
|
490 |
|
|
|
491 |
|
|
type destructor_pointer is access procedure (arg : System.Address);
|
492 |
|
|
pragma Convention (C, destructor_pointer);
|
493 |
|
|
|
494 |
|
|
function pthread_key_create
|
495 |
|
|
(key : access pthread_key_t;
|
496 |
|
|
destructor : destructor_pointer) return int;
|
497 |
|
|
pragma Inline (pthread_key_create);
|
498 |
|
|
-- LynxOS has a non standard pthread_keycreate
|
499 |
|
|
|
500 |
|
|
procedure pthread_init;
|
501 |
|
|
-- This is a dummy procedure to share some GNULLI files
|
502 |
|
|
|
503 |
|
|
private
|
504 |
|
|
|
505 |
|
|
type sigbit_array is array (1 .. 2) of long;
|
506 |
|
|
type sigset_t is record
|
507 |
|
|
sa_sigbits : sigbit_array;
|
508 |
|
|
end record;
|
509 |
|
|
pragma Convention (C_Pass_By_Copy, sigset_t);
|
510 |
|
|
|
511 |
|
|
type pid_t is new long;
|
512 |
|
|
|
513 |
|
|
type time_t is new long;
|
514 |
|
|
|
515 |
|
|
type timespec is record
|
516 |
|
|
tv_sec : time_t;
|
517 |
|
|
tv_nsec : long;
|
518 |
|
|
end record;
|
519 |
|
|
pragma Convention (C, timespec);
|
520 |
|
|
|
521 |
|
|
type clockid_t is new unsigned_char;
|
522 |
|
|
CLOCK_REALTIME : constant clockid_t := 0;
|
523 |
|
|
|
524 |
|
|
type st_t is record
|
525 |
|
|
stksize : int;
|
526 |
|
|
prio : int;
|
527 |
|
|
inheritsched : int;
|
528 |
|
|
state : int;
|
529 |
|
|
sched : int;
|
530 |
|
|
end record;
|
531 |
|
|
pragma Convention (C, st_t);
|
532 |
|
|
|
533 |
|
|
type pthread_attr_t is record
|
534 |
|
|
st : st_t;
|
535 |
|
|
pthread_attr_scope : int; -- ignored
|
536 |
|
|
end record;
|
537 |
|
|
pragma Convention (C, pthread_attr_t);
|
538 |
|
|
|
539 |
|
|
type pthread_condattr_t is new int;
|
540 |
|
|
|
541 |
|
|
type pthread_mutexattr_t is new int;
|
542 |
|
|
|
543 |
|
|
type tid_t is new short;
|
544 |
|
|
type pthread_t is new tid_t;
|
545 |
|
|
|
546 |
|
|
type synch_ptr is access all pthread_mutex_t;
|
547 |
|
|
type pthread_mutex_t is record
|
548 |
|
|
w_count : int;
|
549 |
|
|
mut_owner : int;
|
550 |
|
|
id : unsigned;
|
551 |
|
|
next : synch_ptr;
|
552 |
|
|
end record;
|
553 |
|
|
pragma Convention (C, pthread_mutex_t);
|
554 |
|
|
|
555 |
|
|
type pthread_cond_t is new pthread_mutex_t;
|
556 |
|
|
|
557 |
|
|
type pthread_key_t is new int;
|
558 |
|
|
|
559 |
|
|
end System.OS_Interface;
|