111
|
1 ------------------------------------------------------------------------------
|
|
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 --
|
145
|
10 -- Copyright (C) 1995-2019, Free Software Foundation, Inc. --
|
111
|
11 -- --
|
|
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 3, 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. --
|
|
18 -- --
|
|
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
|
|
20 -- additional permissions described in the GCC Runtime Library Exception, --
|
|
21 -- version 3.1, as published by the Free Software Foundation. --
|
|
22 -- --
|
|
23 -- You should have received a copy of the GNU General Public License and --
|
|
24 -- a copy of the GCC Runtime Library Exception along with this program; --
|
|
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
|
|
26 -- <http://www.gnu.org/licenses/>. --
|
|
27 -- --
|
|
28 -- GNARL was developed by the GNARL team at Florida State University. --
|
|
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
|
|
30 -- --
|
|
31 ------------------------------------------------------------------------------
|
|
32
|
|
33 -- This is a LynxOS-178 Elf (POSIX-8 Threads) version of this package
|
|
34
|
|
35 -- This package encapsulates all direct interfaces to OS services that are
|
|
36 -- needed by the tasking run-time (libgnarl).
|
|
37
|
|
38 -- PLEASE DO NOT add any with-clauses to this package or remove the pragma
|
|
39 -- Preelaborate. This package is designed to be a bottom-level (leaf) package.
|
|
40
|
|
41 with Ada.Unchecked_Conversion;
|
|
42
|
|
43 with Interfaces.C;
|
|
44
|
|
45 with System.Multiprocessors;
|
|
46
|
|
47 package System.OS_Interface is
|
|
48 pragma Preelaborate;
|
|
49
|
|
50 pragma Linker_Options ("-mthreads");
|
|
51 -- Selects the POSIX 1.c runtime, rather than the non-threading runtime or
|
|
52 -- the deprecated legacy threads library.
|
|
53
|
|
54 subtype int is Interfaces.C.int;
|
|
55 subtype short is Interfaces.C.short;
|
|
56 subtype long is Interfaces.C.long;
|
|
57 subtype unsigned is Interfaces.C.unsigned;
|
|
58 subtype unsigned_short is Interfaces.C.unsigned_short;
|
|
59 subtype unsigned_long is Interfaces.C.unsigned_long;
|
|
60 subtype unsigned_char is Interfaces.C.unsigned_char;
|
|
61 subtype plain_char is Interfaces.C.plain_char;
|
|
62 subtype size_t is Interfaces.C.size_t;
|
|
63 subtype int64 is Interfaces.Integer_64;
|
|
64
|
|
65 -----------
|
|
66 -- Errno --
|
|
67 -----------
|
|
68
|
|
69 function errno return int;
|
|
70 pragma Import (C, errno, "__get_errno");
|
|
71
|
|
72 EAGAIN : constant := 11;
|
|
73 EINTR : constant := 4;
|
|
74 EINVAL : constant := 22;
|
|
75 ENOMEM : constant := 12;
|
|
76 ETIMEDOUT : constant := 60;
|
|
77 -- Error codes
|
|
78
|
|
79 -------------
|
|
80 -- Signals --
|
|
81 -------------
|
|
82
|
|
83 Max_Interrupt : constant := 63;
|
|
84 -- Max_Interrupt is the number of OS signals, as defined in:
|
|
85 --
|
|
86 -- /usr/include/sys/signal.h
|
|
87 --
|
|
88 -- The lowest numbered signal is 1, but 0 is a valid argument to some
|
|
89 -- library functions, e.g. kill(2). However, 0 is not just another signal:
|
|
90 -- For instance 'I in Signal' and similar should be used with caution.
|
|
91
|
|
92 type Signal is new int range 0 .. Max_Interrupt;
|
|
93 for Signal'Size use int'Size;
|
|
94
|
|
95 SIGHUP : constant := 1; -- hangup
|
|
96 SIGINT : constant := 2; -- interrupt (rubout)
|
|
97 SIGQUIT : constant := 3; -- quit (ASCD FS)
|
|
98 SIGILL : constant := 4; -- illegal instruction (not reset)
|
|
99 SIGTRAP : constant := 5; -- trace trap (not reset)
|
|
100 SIGBRK : constant := 6; -- break
|
|
101 SIGIOT : constant := 6; -- IOT instruction
|
|
102 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in future
|
|
103 SIGCORE : constant := 7; -- kill with core dump
|
|
104 SIGEMT : constant := 7; -- EMT instruction
|
|
105 SIGFPE : constant := 8; -- floating point exception
|
|
106 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
|
|
107 SIGBUS : constant := 10; -- bus error
|
|
108 SIGSEGV : constant := 11; -- segmentation violation
|
|
109 SIGSYS : constant := 12; -- bad argument to system call
|
|
110 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
|
|
111 SIGALRM : constant := 14; -- alarm clock
|
|
112 SIGTERM : constant := 15; -- software termination signal from kill
|
|
113 SIGURG : constant := 16; -- urgent condition on IO channel
|
|
114 SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
|
|
115 SIGTSTP : constant := 18; -- user stop requested from tty
|
|
116 SIGCONT : constant := 19; -- stopped process has been continued
|
|
117 SIGCLD : constant := 20; -- alias for SIGCHLD
|
|
118 SIGCHLD : constant := 20; -- child status change
|
|
119 SIGTTIN : constant := 21; -- background tty read attempted
|
|
120 SIGTTOU : constant := 22; -- background tty write attempted
|
|
121 SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
|
|
122 SIGPOLL : constant := 23; -- pollable event occurred
|
|
123 SIGTHREADKILL : constant := 24; -- Reserved by LynxOS runtime
|
|
124 SIGXCPU : constant := 24; -- CPU time limit exceeded
|
|
125 SIGXFSZ : constant := 25; -- filesize limit exceeded
|
|
126 SIGVTALRM : constant := 26; -- virtual timer expired
|
|
127 SIGPROF : constant := 27; -- profiling timer expired
|
|
128 SIGWINCH : constant := 28; -- window size change
|
|
129 SIGLOST : constant := 29; -- SUN 4.1 compatibility
|
|
130 SIGUSR1 : constant := 30; -- user defined signal 1
|
|
131 SIGUSR2 : constant := 31; -- user defined signal 2
|
|
132
|
|
133 SIGPRIO : constant := 32;
|
|
134 -- Sent to a process with its priority or group is changed
|
|
135
|
|
136 SIGADAABORT : constant := SIGABRT;
|
|
137 -- Change this if you want to use another signal for task abort. SIGTERM
|
|
138 -- might be a good one.
|
|
139
|
|
140 type Signal_Set is array (Natural range <>) of Signal;
|
|
141
|
|
142 Unmasked : constant Signal_Set :=
|
|
143 (SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF, SIGTHREADKILL);
|
|
144 Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP, SIGPRIO);
|
|
145
|
|
146 type sigset_t is private;
|
|
147
|
|
148 function sigaddset (set : access sigset_t; sig : Signal) return int;
|
|
149 pragma Import (C, sigaddset, "sigaddset");
|
|
150
|
|
151 function sigdelset (set : access sigset_t; sig : Signal) return int;
|
|
152 pragma Import (C, sigdelset, "sigdelset");
|
|
153
|
|
154 function sigfillset (set : access sigset_t) return int;
|
|
155 pragma Import (C, sigfillset, "sigfillset");
|
|
156
|
|
157 function sigismember (set : access sigset_t; sig : Signal) return int;
|
|
158 pragma Import (C, sigismember, "sigismember");
|
|
159
|
|
160 function sigemptyset (set : access sigset_t) return int;
|
|
161 pragma Import (C, sigemptyset, "sigemptyset");
|
|
162
|
|
163 type struct_sigaction is record
|
|
164 sa_handler : System.Address;
|
|
165 sa_mask : sigset_t;
|
|
166 sa_flags : int;
|
|
167 end record;
|
|
168 pragma Convention (C, struct_sigaction);
|
|
169 type struct_sigaction_ptr is access all struct_sigaction;
|
|
170
|
|
171 SA_SIGINFO : constant := 16#80#;
|
|
172
|
|
173 SA_ONSTACK : constant := 16#00#;
|
|
174 -- SA_ONSTACK is not defined on LynxOS, but it is referred to in the POSIX
|
|
175 -- implementation of System.Interrupt_Management. Therefore we define a
|
|
176 -- dummy value of zero here so that setting this flag is a nop.
|
|
177
|
|
178 SIG_BLOCK : constant := 0;
|
|
179 SIG_UNBLOCK : constant := 1;
|
|
180 SIG_SETMASK : constant := 2;
|
|
181
|
|
182 SIG_DFL : constant := 0;
|
|
183 SIG_IGN : constant := 1;
|
|
184
|
|
185 function sigaction
|
|
186 (sig : Signal;
|
|
187 act : struct_sigaction_ptr;
|
|
188 oact : struct_sigaction_ptr) return int;
|
|
189 pragma Import (C, sigaction, "sigaction");
|
|
190
|
|
191 ----------
|
|
192 -- Time --
|
|
193 ----------
|
|
194
|
|
195 Time_Slice_Supported : constant Boolean := True;
|
|
196 -- Indicates whether time slicing is supported
|
|
197
|
|
198 type timespec is private;
|
|
199
|
|
200 type clockid_t is new int;
|
|
201
|
|
202 function clock_gettime
|
|
203 (clock_id : clockid_t;
|
|
204 tp : access timespec) return int;
|
|
205 pragma Import (C, clock_gettime, "clock_gettime");
|
|
206
|
|
207 function clock_getres
|
|
208 (clock_id : clockid_t;
|
|
209 res : access timespec) return int;
|
|
210 pragma Import (C, clock_getres, "clock_getres");
|
|
211
|
|
212 function To_Duration (TS : timespec) return Duration;
|
|
213 pragma Inline (To_Duration);
|
|
214
|
|
215 function To_Timespec (D : Duration) return timespec;
|
|
216 pragma Inline (To_Timespec);
|
|
217
|
|
218 type struct_timezone is record
|
|
219 tz_minuteswest : int;
|
|
220 tz_dsttime : int;
|
|
221 end record;
|
|
222 pragma Convention (C, struct_timezone);
|
|
223 type struct_timezone_ptr is access all struct_timezone;
|
|
224
|
|
225 type struct_timeval is private;
|
|
226
|
|
227 -------------------------
|
|
228 -- Priority Scheduling --
|
|
229 -------------------------
|
|
230
|
|
231 SCHED_RR : constant := 16#100_000#;
|
|
232 SCHED_FIFO : constant := 16#200_000#;
|
|
233 SCHED_OTHER : constant := 16#400_000#;
|
|
234
|
|
235 function To_Target_Priority
|
|
236 (Prio : System.Any_Priority) return Interfaces.C.int;
|
|
237 -- Maps System.Any_Priority to a POSIX priority
|
|
238
|
|
239 -------------
|
|
240 -- Process --
|
|
241 -------------
|
|
242
|
|
243 type pid_t is private;
|
|
244
|
|
245 function kill (pid : pid_t; sig : Signal) return int;
|
|
246 pragma Import (C, kill, "kill");
|
|
247
|
|
248 function getpid return pid_t;
|
|
249 pragma Import (C, getpid, "getpid");
|
|
250
|
|
251 ---------
|
|
252 -- LWP --
|
|
253 ---------
|
|
254
|
|
255 type pthread_t is private;
|
|
256
|
|
257 function lwp_self return pthread_t;
|
|
258 pragma Import (C, lwp_self, "pthread_self");
|
|
259
|
|
260 -------------
|
|
261 -- Threads --
|
|
262 -------------
|
|
263
|
|
264 type Thread_Body is access
|
|
265 function (arg : System.Address) return System.Address;
|
|
266 pragma Convention (C, Thread_Body);
|
|
267
|
|
268 function Thread_Body_Access is new
|
|
269 Ada.Unchecked_Conversion (System.Address, Thread_Body);
|
|
270
|
|
271 subtype Thread_Id is pthread_t;
|
|
272
|
|
273 type pthread_mutex_t is limited private;
|
|
274 type pthread_cond_t is limited private;
|
|
275 type pthread_attr_t is limited private;
|
|
276 type pthread_mutexattr_t is limited private;
|
|
277 type pthread_condattr_t is limited private;
|
|
278 type pthread_key_t is private;
|
|
279
|
|
280 PTHREAD_CREATE_DETACHED : constant := 1;
|
|
281 PTHREAD_CREATE_JOINABLE : constant := 0;
|
|
282
|
|
283 PTHREAD_SCOPE_PROCESS : constant := 0; -- not supported by LynxOS178
|
|
284 PTHREAD_SCOPE_SYSTEM : constant := 1;
|
|
285
|
|
286 -- Read/Write lock not supported on LynxOS. To add support both types
|
|
287 -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
|
|
288 -- with the associated routines pthread_rwlock_[init/destroy] and
|
|
289 -- pthread_rwlock_[rdlock/wrlock/unlock].
|
|
290
|
|
291 subtype pthread_rwlock_t is pthread_mutex_t;
|
|
292 subtype pthread_rwlockattr_t is pthread_mutexattr_t;
|
|
293
|
|
294 -----------
|
|
295 -- Stack --
|
|
296 -----------
|
|
297
|
|
298 type stack_t is record
|
|
299 ss_sp : System.Address;
|
|
300 ss_flags : int;
|
|
301 ss_size : size_t;
|
|
302 end record;
|
|
303 pragma Convention (C, stack_t);
|
|
304
|
|
305 function sigaltstack
|
|
306 (ss : not null access stack_t;
|
|
307 oss : access stack_t) return int;
|
|
308 pragma Import (C, sigaltstack, "sigaltstack");
|
|
309 -- Neither stack_t nor sigaltstack are available on LynxOS-178
|
|
310
|
|
311 Alternate_Stack : aliased System.Address;
|
|
312 -- This is a dummy definition, never used (Alternate_Stack_Size is 0)
|
|
313
|
|
314 Alternate_Stack_Size : constant := 0;
|
|
315 -- No alternate signal stack is used on this platform
|
|
316
|
|
317 Stack_Base_Available : constant Boolean := False;
|
|
318 -- Indicates whether the stack base is available on this target
|
|
319
|
|
320 function Get_Stack_Base (thread : pthread_t) return Address;
|
|
321 pragma Inline (Get_Stack_Base);
|
|
322 -- Returns the stack base of the specified thread. Only call this function
|
|
323 -- when Stack_Base_Available is True.
|
|
324
|
|
325 function Get_Page_Size return int;
|
|
326 -- Returns the size of a page in bytes
|
|
327
|
|
328 PROT_NONE : constant := 1;
|
|
329 PROT_READ : constant := 2;
|
|
330 PROT_WRITE : constant := 4;
|
|
331 PROT_EXEC : constant := 8;
|
|
332 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
|
|
333
|
|
334 PROT_ON : constant := PROT_READ;
|
|
335 PROT_OFF : constant := PROT_ALL;
|
|
336
|
|
337 function mprotect (addr : Address; len : size_t; prot : int) return int;
|
|
338 pragma Import (C, mprotect);
|
|
339
|
|
340 ---------------------------------------
|
|
341 -- Nonstandard Thread Initialization --
|
|
342 ---------------------------------------
|
|
343
|
|
344 procedure pthread_init;
|
|
345 -- This is a dummy procedure to share some GNULLI files
|
|
346
|
|
347 -------------------------
|
|
348 -- POSIX.1c Section 3 --
|
|
349 -------------------------
|
|
350 function sigwait
|
|
351 (set : access sigset_t;
|
|
352 sig : access Signal) return int;
|
|
353 pragma Inline (sigwait);
|
|
354 -- LynxOS has non standard sigwait
|
|
355
|
|
356 function pthread_kill
|
|
357 (thread : pthread_t;
|
|
358 sig : Signal) return int;
|
|
359 pragma Import (C, pthread_kill, "pthread_kill");
|
|
360
|
|
361 function pthread_sigmask
|
|
362 (how : int;
|
|
363 set : access sigset_t;
|
|
364 oset : access sigset_t) return int;
|
|
365 pragma Import (C, pthread_sigmask, "pthread_sigmask");
|
|
366
|
|
367 ----------------------------
|
|
368 -- POSIX.1c Section 11 --
|
|
369 ----------------------------
|
|
370
|
|
371 function pthread_mutexattr_init
|
|
372 (attr : access pthread_mutexattr_t) return int;
|
|
373 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
|
|
374
|
|
375 function pthread_mutexattr_destroy
|
|
376 (attr : access pthread_mutexattr_t) return int;
|
|
377 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
|
|
378
|
|
379 function pthread_mutex_init
|
|
380 (mutex : access pthread_mutex_t;
|
|
381 attr : access pthread_mutexattr_t) return int;
|
|
382 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
|
|
383
|
|
384 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
|
|
385 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
|
|
386
|
|
387 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
|
|
388 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
|
|
389
|
|
390 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
|
|
391 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
|
|
392
|
|
393 function pthread_condattr_init
|
|
394 (attr : access pthread_condattr_t) return int;
|
|
395 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
|
|
396
|
|
397 function pthread_condattr_destroy
|
|
398 (attr : access pthread_condattr_t) return int;
|
|
399 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
|
|
400
|
|
401 function pthread_cond_init
|
|
402 (cond : access pthread_cond_t;
|
|
403 attr : access pthread_condattr_t) return int;
|
|
404 pragma Import (C, pthread_cond_init, "pthread_cond_init");
|
|
405
|
|
406 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
|
|
407 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
|
|
408
|
|
409 function pthread_cond_signal (cond : access pthread_cond_t) return int;
|
|
410 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
|
|
411
|
|
412 function pthread_cond_wait
|
|
413 (cond : access pthread_cond_t;
|
|
414 mutex : access pthread_mutex_t) return int;
|
|
415 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
|
|
416
|
|
417 function pthread_cond_timedwait
|
|
418 (cond : access pthread_cond_t;
|
|
419 mutex : access pthread_mutex_t;
|
|
420 abstime : access timespec) return int;
|
|
421 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
|
|
422
|
|
423 --------------------------
|
|
424 -- POSIX.1c Section 13 --
|
|
425 --------------------------
|
|
426
|
|
427 PTHREAD_PRIO_NONE : constant := 0;
|
|
428 PTHREAD_PRIO_INHERIT : constant := 1;
|
|
429 PTHREAD_PRIO_PROTECT : constant := 2;
|
|
430
|
|
431 function pthread_mutexattr_setprotocol
|
|
432 (attr : access pthread_mutexattr_t;
|
|
433 protocol : int) return int;
|
|
434 pragma Import (C, pthread_mutexattr_setprotocol);
|
|
435
|
|
436 function pthread_mutexattr_setprioceiling
|
|
437 (attr : access pthread_mutexattr_t;
|
|
438 prioceiling : int) return int;
|
|
439 pragma Import (C, pthread_mutexattr_setprioceiling);
|
|
440
|
|
441 type struct_sched_param is record
|
|
442 sched_priority : int;
|
|
443 end record;
|
|
444 pragma Convention (C, struct_sched_param);
|
|
445
|
|
446 function pthread_setschedparam
|
|
447 (thread : pthread_t;
|
|
448 policy : int;
|
|
449 param : access struct_sched_param) return int;
|
|
450 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
|
|
451
|
|
452 function pthread_attr_setscope
|
131
|
453 (Unused_attr : access pthread_attr_t;
|
|
454 Unused_contentionscope : int) return int is (0);
|
111
|
455 -- pthread_attr_setscope is not implemented in production mode
|
|
456
|
|
457 function pthread_attr_setinheritsched
|
|
458 (attr : access pthread_attr_t;
|
|
459 inheritsched : int) return int;
|
|
460 pragma Import (C, pthread_attr_setinheritsched);
|
|
461
|
|
462 function pthread_attr_setschedpolicy
|
|
463 (attr : access pthread_attr_t;
|
|
464 policy : int) return int;
|
|
465 pragma Import (C, pthread_attr_setschedpolicy);
|
|
466
|
|
467 function sched_yield return int;
|
|
468 pragma Import (C, sched_yield, "sched_yield");
|
|
469
|
|
470 --------------------------
|
|
471 -- P1003.1c Section 16 --
|
|
472 --------------------------
|
|
473
|
|
474 function pthread_attr_init (attributes : access pthread_attr_t) return int;
|
|
475 pragma Import (C, pthread_attr_init, "pthread_attr_init");
|
|
476
|
|
477 function pthread_attr_destroy
|
|
478 (attributes : access pthread_attr_t) return int;
|
|
479 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
|
|
480
|
|
481 function pthread_attr_setdetachstate
|
|
482 (attr : access pthread_attr_t;
|
|
483 detachstate : int) return int;
|
|
484 pragma Import (C, pthread_attr_setdetachstate);
|
|
485
|
|
486 function pthread_attr_setstacksize
|
|
487 (attr : access pthread_attr_t;
|
|
488 stacksize : size_t) return int;
|
|
489 pragma Import (C, pthread_attr_setstacksize);
|
|
490
|
|
491 function pthread_create
|
|
492 (thread : access pthread_t;
|
|
493 attributes : access pthread_attr_t;
|
|
494 start_routine : Thread_Body;
|
|
495 arg : System.Address) return int;
|
|
496 pragma Import (C, pthread_create, "pthread_create");
|
|
497
|
|
498 procedure pthread_exit (status : System.Address);
|
|
499 pragma Import (C, pthread_exit, "pthread_exit");
|
|
500
|
|
501 function pthread_self return pthread_t;
|
|
502 pragma Import (C, pthread_self, "pthread_self");
|
|
503
|
|
504 --------------------------
|
|
505 -- POSIX.1c Section 17 --
|
|
506 --------------------------
|
|
507
|
|
508 function pthread_setspecific
|
|
509 (key : pthread_key_t;
|
|
510 value : System.Address) return int;
|
|
511 pragma Import (C, pthread_setspecific, "pthread_setspecific");
|
|
512
|
|
513 function pthread_getspecific
|
|
514 (key : pthread_key_t) return System.Address;
|
|
515 pragma Import (C, pthread_getspecific, "pthread_getspecific");
|
|
516
|
|
517 type destructor_pointer is access procedure (arg : System.Address);
|
|
518 pragma Convention (C, destructor_pointer);
|
|
519
|
|
520 function pthread_key_create
|
|
521 (key : access pthread_key_t;
|
|
522 destructor : destructor_pointer
|
|
523 ) return int;
|
|
524 pragma Import (C, pthread_key_create, "pthread_key_create");
|
|
525
|
|
526 ---------------------
|
|
527 -- Multiprocessors --
|
|
528 ---------------------
|
|
529
|
|
530 function Current_CPU return Multiprocessors.CPU;
|
|
531 -- Return the id of the current CPU
|
|
532
|
|
533 function Get_Affinity (Id : Thread_Id) return Multiprocessors.CPU_Range;
|
|
534 -- Return CPU affinity of the given thread (maybe Not_A_Specific_CPU)
|
|
535
|
|
536 function Get_CPU (Id : Thread_Id) return Multiprocessors.CPU;
|
|
537 -- Return the CPU in charge of the given thread (always a valid CPU)
|
|
538
|
|
539 private
|
|
540
|
|
541 type sigset_t is array (1 .. 2) of long;
|
|
542 pragma Convention (C, sigset_t);
|
|
543
|
|
544 type pid_t is new long;
|
|
545
|
|
546 type time_t is new int64;
|
|
547
|
|
548 type suseconds_t is new int;
|
|
549
|
|
550 type timespec is record
|
|
551 tv_sec : time_t;
|
|
552 tv_nsec : long;
|
|
553 end record;
|
|
554 pragma Convention (C, timespec);
|
|
555
|
|
556 type struct_timeval is record
|
|
557 tv_sec : time_t;
|
|
558 tv_usec : suseconds_t;
|
|
559 end record;
|
|
560 pragma Convention (C, struct_timeval);
|
|
561
|
|
562 type st_attr is record
|
|
563 stksize : int;
|
|
564 prio : int;
|
|
565 inheritsched : int;
|
|
566 state : int;
|
|
567 sched : int;
|
|
568 detachstate : int;
|
|
569 guardsize : int;
|
|
570 end record;
|
|
571 pragma Convention (C, st_attr);
|
|
572 subtype st_attr_t is st_attr;
|
|
573
|
|
574 type pthread_attr_t is record
|
|
575 pthread_attr_magic : unsigned;
|
|
576 st : st_attr_t;
|
|
577 pthread_attr_scope : int;
|
|
578 end record;
|
|
579 pragma Convention (C, pthread_attr_t);
|
|
580
|
|
581 type pthread_condattr_t is record
|
|
582 cv_magic : unsigned;
|
|
583 cv_pshared : unsigned;
|
|
584 end record;
|
|
585 pragma Convention (C, pthread_condattr_t);
|
|
586
|
|
587 type pthread_mutexattr_t is record
|
|
588 m_flags : unsigned;
|
|
589 m_prio_c : int;
|
|
590 m_pshared : int;
|
|
591 end record;
|
|
592 pragma Convention (C, pthread_mutexattr_t);
|
|
593
|
|
594 type tid_t is new short;
|
|
595 type pthread_t is new tid_t;
|
|
596
|
|
597 type block_obj_t is record
|
|
598 b_head : int;
|
|
599 end record;
|
|
600 pragma Convention (C, block_obj_t);
|
|
601
|
|
602 type pthread_mutex_t is record
|
|
603 m_flags : unsigned;
|
|
604 m_owner : tid_t;
|
|
605 m_wait : block_obj_t;
|
|
606 m_prio_c : int;
|
|
607 m_oldprio : int;
|
|
608 m_count : int;
|
|
609 m_referenced : int;
|
|
610 end record;
|
|
611 pragma Convention (C, pthread_mutex_t);
|
|
612 type pthread_mutex_t_ptr is access all pthread_mutex_t;
|
|
613
|
|
614 type pthread_cond_t is record
|
|
615 cv_magic : unsigned;
|
|
616 cv_wait : block_obj_t;
|
|
617 cv_mutex : pthread_mutex_t_ptr;
|
|
618 cv_refcnt : int;
|
|
619 end record;
|
|
620 pragma Convention (C, pthread_cond_t);
|
|
621
|
|
622 type pthread_key_t is new int;
|
|
623
|
|
624 end System.OS_Interface;
|