1 ------------------------------------------------------------------------------
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
5 -- S Y S T E M . O S _ I N T E R F A C E --
9 -- Copyright (C) 1991-1994, Florida State University --
10 -- Copyright (C) 1995-2024, Free Software Foundation, Inc. --
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. --
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. --
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/>. --
28 -- GNARL was developed by the GNARL team at Florida State University. --
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
31 ------------------------------------------------------------------------------
33 -- This is the GNU/Hurd (POSIX Threads) version of this package
35 -- This package encapsulates all direct interfaces to OS services
36 -- that are needed by children of System.
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
41 with Ada
.Unchecked_Conversion
;
46 with System
.Parameters
;
48 package System
.OS_Interface
is
51 pragma Linker_Options
("-lpthread");
52 pragma Linker_Options
("-lrt");
54 subtype int
is Interfaces
.C
.int
;
55 subtype char
is Interfaces
.C
.char
;
56 subtype short
is Interfaces
.C
.short
;
57 subtype long
is Interfaces
.C
.long
;
58 subtype unsigned
is Interfaces
.C
.unsigned
;
59 subtype unsigned_short
is Interfaces
.C
.unsigned_short
;
60 subtype unsigned_long
is Interfaces
.C
.unsigned_long
;
61 subtype unsigned_char
is Interfaces
.C
.unsigned_char
;
62 subtype plain_char
is Interfaces
.C
.plain_char
;
63 subtype size_t
is Interfaces
.C
.size_t
;
68 -- From /usr/include/i386-gnu/bits/errno.h
70 function errno
return int
;
71 pragma Import
(C
, errno
, "__get_errno");
73 EAGAIN
: constant := 1073741859;
74 EINTR
: constant := 1073741828;
75 EINVAL
: constant := 1073741846;
76 ENOMEM
: constant := 1073741836;
77 EPERM
: constant := 1073741825;
78 ETIMEDOUT
: constant := 1073741884;
83 -- From /usr/include/i386-gnu/bits/signum.h
85 Max_Interrupt
: constant := 32;
86 type Signal
is new int
range 0 .. Max_Interrupt
;
87 for Signal
'Size use int
'Size;
89 SIGHUP
: constant := 1; -- hangup
90 SIGINT
: constant := 2; -- interrupt (rubout)
91 SIGQUIT
: constant := 3; -- quit (ASCD FS)
92 SIGILL
: constant := 4; -- illegal instruction (not reset)
93 SIGTRAP
: constant := 5; -- trace trap (not reset)
94 SIGIOT
: constant := 6; -- IOT instruction
95 SIGABRT
: constant := 6; -- used by abort, replace SIGIOT in the future
96 SIGEMT
: constant := 7; -- EMT instruction
97 SIGFPE
: constant := 8; -- floating point exception
98 SIGKILL
: constant := 9; -- kill (cannot be caught or ignored)
99 SIGBUS
: constant := 10; -- bus error
100 SIGSEGV
: constant := 11; -- segmentation violation
101 SIGSYS
: constant := 12; -- bad argument to system call
102 SIGPIPE
: constant := 13; -- write on a pipe with no one to read it
103 SIGALRM
: constant := 14; -- alarm clock
104 SIGTERM
: constant := 15; -- software termination signal from kill
105 SIGURG
: constant := 16; -- urgent condition on IO channel
106 SIGSTOP
: constant := 17; -- stop (cannot be caught or ignored)
107 SIGTSTP
: constant := 18; -- user stop requested from tty
108 SIGCONT
: constant := 19; -- stopped process has been continued
109 SIGCLD
: constant := 20; -- alias for SIGCHLD
110 SIGCHLD
: constant := 20; -- child status change
111 SIGTTIN
: constant := 21; -- background tty read attempted
112 SIGTTOU
: constant := 22; -- background tty write attempted
113 SIGIO
: constant := 23; -- I/O possible (Solaris SIGPOLL alias)
114 SIGPOLL
: constant := 23; -- I/O possible (same as SIGIO?)
115 SIGXCPU
: constant := 24; -- CPU time limit exceeded
116 SIGXFSZ
: constant := 25; -- filesize limit exceeded
117 SIGVTALRM
: constant := 26; -- virtual timer expired
118 SIGPROF
: constant := 27; -- profiling timer expired
119 SIGWINCH
: constant := 28; -- window size change
120 SIGINFO
: constant := 29; -- information request (NetBSD/FreeBSD)
121 SIGUSR1
: constant := 30; -- user defined signal 1
122 SIGUSR2
: constant := 31; -- user defined signal 2
123 SIGLOST
: constant := 32; -- Resource lost (Sun); server died (GNU)
125 SIGADAABORT
: constant := SIGABRT
;
126 -- Change this if you want to use another signal for task abort.
127 -- SIGTERM might be a good one.
129 type Signal_Set
is array (Natural range <>) of Signal
;
131 Unmasked
: constant Signal_Set
:= (
133 -- To enable debugging on multithreaded applications, mark SIGTRAP to
138 SIGTTIN
, SIGTTOU
, SIGTSTP
,
139 -- Keep these three signals unmasked so that background processes
140 -- and IO behaves as normal "C" applications
143 -- To avoid confusing the profiler
146 -- These two signals actually cannot be masked;
147 -- POSIX simply won't allow it.
149 Reserved
: constant Signal_Set
:=
150 -- I am not sure why the following signal is reserved.
151 -- I guess they are not supported by this version of GNU/Hurd.
152 (0 .. 0 => SIGVTALRM
);
154 type sigset_t
is private;
156 -- From /usr/include/signal.h /usr/include/i386-gnu/bits/sigset.h
157 function sigaddset
(set
: access sigset_t
; sig
: Signal
) return int
;
158 pragma Import
(C
, sigaddset
, "sigaddset");
160 function sigdelset
(set
: access sigset_t
; sig
: Signal
) return int
;
161 pragma Import
(C
, sigdelset
, "sigdelset");
163 function sigfillset
(set
: access sigset_t
) return int
;
164 pragma Import
(C
, sigfillset
, "sigfillset");
166 function sigismember
(set
: access sigset_t
; sig
: Signal
) return int
;
167 pragma Import
(C
, sigismember
, "sigismember");
169 function sigemptyset
(set
: access sigset_t
) return int
;
170 pragma Import
(C
, sigemptyset
, "sigemptyset");
172 -- sigcontext is architecture dependent, so define it private
173 type struct_sigcontext
is private;
175 -- From /usr/include/i386-gnu/bits/sigaction.h: Note: arg. order differs
176 type struct_sigaction
is record
177 sa_handler
: System
.Address
;
181 pragma Convention
(C
, struct_sigaction
);
183 type struct_sigaction_ptr
is access all struct_sigaction
;
185 -- From /usr/include/i386-gnu/bits/sigaction.h
186 SIG_BLOCK
: constant := 1;
187 SIG_UNBLOCK
: constant := 2;
188 SIG_SETMASK
: constant := 3;
190 -- From /usr/include/i386-gnu/bits/signum.h
191 SIG_ERR
: constant := 1;
192 SIG_DFL
: constant := 0;
193 SIG_IGN
: constant := 1;
194 SIG_HOLD
: constant := 2;
196 -- From /usr/include/i386-gnu/bits/sigaction.h
197 SA_SIGINFO
: constant := 16#
0040#
;
198 SA_ONSTACK
: constant := 16#
0001#
;
202 act
: struct_sigaction_ptr
;
203 oact
: struct_sigaction_ptr
) return int
;
204 pragma Import
(C
, sigaction
, "sigaction");
210 Time_Slice_Supported
: constant Boolean := True;
211 -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
213 type timespec
is private;
215 function nanosleep
(rqtp
, rmtp
: access timespec
) return int
;
216 pragma Import
(C
, nanosleep
, "nanosleep");
218 type clockid_t
is new int
;
219 CLOCK_REALTIME
: constant clockid_t
:= 0;
221 -- From: /usr/include/time.h
222 function clock_gettime
223 (clock_id
: clockid_t
;
224 tp
: access timespec
)
226 pragma Import
(C
, clock_gettime
, "clock_gettime");
228 function clock_getres
229 (clock_id
: clockid_t
;
230 res
: access timespec
) return int
;
231 pragma Import
(C
, clock_getres
, "clock_getres");
233 function To_Duration
(TS
: timespec
) return Duration;
234 pragma Inline
(To_Duration
);
236 function To_Timespec
(D
: Duration) return timespec
;
237 pragma Inline
(To_Timespec
);
239 -- From: /usr/include/unistd.h
240 function sysconf
(name
: int
) return long
;
241 pragma Import
(C
, sysconf
);
243 -- From /usr/include/i386-gnu/bits/confname.h
244 SC_CLK_TCK
: constant := 2;
245 SC_NPROCESSORS_ONLN
: constant := 84;
247 -------------------------
248 -- Priority Scheduling --
249 -------------------------
250 -- From /usr/include/i386-gnu/bits/sched.h
252 SCHED_OTHER
: constant := 0;
253 SCHED_FIFO
: constant := 1;
254 SCHED_RR
: constant := 2;
256 function To_Target_Priority
257 (Prio
: System
.Any_Priority
) return Interfaces
.C
.int
;
258 -- Maps System.Any_Priority to a POSIX priority.
264 type pid_t
is private;
266 -- From: /usr/include/signal.h
267 function kill
(pid
: pid_t
; sig
: Signal
) return int
;
268 pragma Import
(C
, kill
, "kill");
270 -- From: /usr/include/unistd.h
271 function getpid
return pid_t
;
272 pragma Import
(C
, getpid
, "getpid");
278 -- From: /usr/include/pthread/pthread.h
279 function lwp_self
return System
.Address
;
280 -- lwp_self does not exist on this thread library, revert to pthread_self
281 -- which is the closest approximation (with getpid). This function is
282 -- needed to share 7staprop.adb across POSIX-like targets.
283 pragma Import
(C
, lwp_self
, "pthread_self");
289 type Thread_Body
is access
290 function (arg
: System
.Address
) return System
.Address
;
291 pragma Convention
(C
, Thread_Body
);
293 function Thread_Body_Access
is new
294 Ada
.Unchecked_Conversion
(System
.Address
, Thread_Body
);
296 -- From: /usr/include/bits/pthread.h:typedef int __pthread_t;
297 -- /usr/include/pthread/pthreadtypes.h:typedef __pthread_t pthread_t;
298 type pthread_t
is new unsigned_long
;
299 subtype Thread_Id
is pthread_t
;
301 function To_pthread_t
is new Ada
.Unchecked_Conversion
302 (unsigned_long
, pthread_t
);
304 subtype pthread_mutex_t
is System
.OS_Locks
.pthread_mutex_t
;
305 type pthread_rwlock_t
is limited private;
306 type pthread_cond_t
is limited private;
307 type pthread_attr_t
is limited private;
308 type pthread_mutexattr_t
is limited private;
309 type pthread_rwlockattr_t
is limited private;
310 type pthread_condattr_t
is limited private;
311 type pthread_key_t
is private;
313 -- From /usr/include/pthread/pthreadtypes.h
314 PTHREAD_CREATE_DETACHED
: constant := 1;
315 PTHREAD_CREATE_JOINABLE
: constant := 0;
317 PTHREAD_SCOPE_PROCESS
: constant := 1;
318 PTHREAD_SCOPE_SYSTEM
: constant := 0;
324 -- From: /usr/include/i386-gnu/bits/sigstack.h
325 type stack_t
is record
326 ss_sp
: System
.Address
;
330 pragma Convention
(C
, stack_t
);
333 (ss
: not null access stack_t
;
334 oss
: access stack_t
) return int
;
335 pragma Import
(C
, sigaltstack
, "sigaltstack");
337 Alternate_Stack
: aliased System
.Address
;
338 -- This is a dummy definition, never used (Alternate_Stack_Size is null)
340 Alternate_Stack_Size
: constant := 0;
341 -- No alternate signal stack is used on this platform
343 Stack_Base_Available
: constant Boolean := False;
344 -- Indicates whether the stack base is available on this target
346 function Get_Stack_Base
(thread
: pthread_t
) return Address
;
347 pragma Inline
(Get_Stack_Base
);
348 -- returns the stack base of the specified thread. Only call this function
349 -- when Stack_Base_Available is True.
351 -- From: /usr/include/i386-gnu/bits/shm.h
352 function Get_Page_Size
return int
;
353 pragma Import
(C
, Get_Page_Size
, "getpagesize");
354 -- Returns the size of a page
356 -- From /usr/include/i386-gnu/bits/mman.h
357 PROT_NONE
: constant := 0;
358 PROT_READ
: constant := 4;
359 PROT_WRITE
: constant := 2;
360 PROT_EXEC
: constant := 1;
361 PROT_ALL
: constant := PROT_READ
+ PROT_WRITE
+ PROT_EXEC
;
362 PROT_ON
: constant := PROT_NONE
;
363 PROT_OFF
: constant := PROT_ALL
;
365 -- From /usr/include/i386-gnu/bits/mman.h
366 function mprotect
(addr
: Address
; len
: size_t
; prot
: int
) return int
;
367 pragma Import
(C
, mprotect
);
369 ---------------------------------------
370 -- Nonstandard Thread Initialization --
371 ---------------------------------------
373 procedure pthread_init
;
374 pragma Inline
(pthread_init
);
375 -- This is a dummy procedure to share some GNULLI files
377 -------------------------
378 -- POSIX.1c Section 3 --
379 -------------------------
381 -- From: /usr/include/signal.h:
382 -- sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
383 function sigwait
(set
: access sigset_t
; sig
: access Signal
) return int
;
384 pragma Import
(C
, sigwait
, "sigwait");
386 -- From: /usr/include/pthread/pthread.h:
387 -- extern int pthread_kill (pthread_t thread, int signo);
388 function pthread_kill
(thread
: pthread_t
; sig
: Signal
) return int
;
389 pragma Import
(C
, pthread_kill
, "pthread_kill");
391 -- From: /usr/include/i386-gnu/bits/sigthread.h
392 -- extern int pthread_sigmask (int __how, __const __sigset_t *__newmask,
393 -- __sigset_t *__oldmask) __THROW;
394 function pthread_sigmask
396 set
: access sigset_t
;
397 oset
: access sigset_t
) return int
;
398 pragma Import
(C
, pthread_sigmask
, "pthread_sigmask");
400 --------------------------
401 -- POSIX.1c Section 11 --
402 --------------------------
404 -- From: /usr/include/pthread/pthread.h and
405 -- /usr/include/pthread/pthreadtypes.h
406 function pthread_mutexattr_init
407 (attr
: access pthread_mutexattr_t
) return int
;
408 pragma Import
(C
, pthread_mutexattr_init
, "pthread_mutexattr_init");
410 function pthread_mutexattr_destroy
411 (attr
: access pthread_mutexattr_t
) return int
;
412 pragma Import
(C
, pthread_mutexattr_destroy
, "pthread_mutexattr_destroy");
414 function pthread_mutex_init
415 (mutex
: access pthread_mutex_t
;
416 attr
: access pthread_mutexattr_t
) return int
;
417 pragma Import
(C
, pthread_mutex_init
, "pthread_mutex_init");
419 function pthread_mutex_destroy
(mutex
: access pthread_mutex_t
) return int
;
420 pragma Import
(C
, pthread_mutex_destroy
, "pthread_mutex_destroy");
422 function pthread_mutex_lock
(mutex
: access pthread_mutex_t
) return int
;
423 pragma Import
(C
, pthread_mutex_lock
, "pthread_mutex_lock");
425 function pthread_mutex_unlock
(mutex
: access pthread_mutex_t
) return int
;
426 pragma Import
(C
, pthread_mutex_unlock
, "pthread_mutex_unlock");
428 function pthread_rwlockattr_init
429 (attr
: access pthread_rwlockattr_t
) return int
;
430 pragma Import
(C
, pthread_rwlockattr_init
, "pthread_rwlockattr_init");
432 function pthread_rwlockattr_destroy
433 (attr
: access pthread_rwlockattr_t
) return int
;
434 pragma Import
(C
, pthread_rwlockattr_destroy
, "pthread_rwlockattr_destroy");
435 PTHREAD_RWLOCK_PREFER_READER_NP
: constant := 0;
436 PTHREAD_RWLOCK_PREFER_WRITER_NP
: constant := 1;
437 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP
: constant := 2;
439 function pthread_rwlockattr_setkind_np
440 (attr
: access pthread_rwlockattr_t
;
441 pref
: int
) return int
;
443 (C
, pthread_rwlockattr_setkind_np
, "pthread_rwlockattr_setkind_np");
445 function pthread_rwlock_init
446 (mutex
: access pthread_rwlock_t
;
447 attr
: access pthread_rwlockattr_t
) return int
;
448 pragma Import
(C
, pthread_rwlock_init
, "pthread_rwlock_init");
450 function pthread_rwlock_destroy
451 (mutex
: access pthread_rwlock_t
) return int
;
452 pragma Import
(C
, pthread_rwlock_destroy
, "pthread_rwlock_destroy");
454 function pthread_rwlock_rdlock
(mutex
: access pthread_rwlock_t
) return int
;
455 pragma Import
(C
, pthread_rwlock_rdlock
, "pthread_rwlock_rdlock");
457 function pthread_rwlock_wrlock
(mutex
: access pthread_rwlock_t
) return int
;
458 pragma Import
(C
, pthread_rwlock_wrlock
, "pthread_rwlock_wrlock");
460 function pthread_rwlock_unlock
(mutex
: access pthread_rwlock_t
) return int
;
461 pragma Import
(C
, pthread_rwlock_unlock
, "pthread_rwlock_unlock");
463 function pthread_condattr_init
464 (attr
: access pthread_condattr_t
) return int
;
465 pragma Import
(C
, pthread_condattr_init
, "pthread_condattr_init");
467 function pthread_condattr_destroy
468 (attr
: access pthread_condattr_t
) return int
;
469 pragma Import
(C
, pthread_condattr_destroy
, "pthread_condattr_destroy");
471 function pthread_cond_init
472 (cond
: access pthread_cond_t
;
473 attr
: access pthread_condattr_t
) return int
;
474 pragma Import
(C
, pthread_cond_init
, "pthread_cond_init");
476 function pthread_cond_destroy
(cond
: access pthread_cond_t
) return int
;
477 pragma Import
(C
, pthread_cond_destroy
, "pthread_cond_destroy");
479 function pthread_cond_signal
(cond
: access pthread_cond_t
) return int
;
480 pragma Import
(C
, pthread_cond_signal
, "pthread_cond_signal");
482 function pthread_cond_wait
483 (cond
: access pthread_cond_t
;
484 mutex
: access pthread_mutex_t
) return int
;
485 pragma Import
(C
, pthread_cond_wait
, "pthread_cond_wait");
487 function pthread_cond_timedwait
488 (cond
: access pthread_cond_t
;
489 mutex
: access pthread_mutex_t
;
490 abstime
: access timespec
) return int
;
491 pragma Import
(C
, pthread_cond_timedwait
, "pthread_cond_timedwait");
493 Relative_Timed_Wait
: constant Boolean := False;
494 -- pthread_cond_timedwait requires an absolute delay time
496 --------------------------
497 -- POSIX.1c Section 13 --
498 --------------------------
499 -- From /usr/include/pthread/pthreadtypes.h
501 PTHREAD_PRIO_NONE
: constant := 0;
502 PTHREAD_PRIO_PROTECT
: constant := 2;
503 PTHREAD_PRIO_INHERIT
: constant := 1;
505 -- GNU/Hurd does not support Thread Priority Protection or Thread
506 -- Priority Inheritance and lacks some pthread_mutexattr_* functions.
507 -- Replace them with dummy versions.
508 -- From: /usr/include/pthread/pthread.h
510 function pthread_mutexattr_setprotocol
511 (attr
: access pthread_mutexattr_t
;
512 protocol
: int
) return int
;
513 pragma Import
(C
, pthread_mutexattr_setprotocol
,
514 "pthread_mutexattr_setprotocol");
516 function pthread_mutexattr_getprotocol
517 (attr
: access pthread_mutexattr_t
;
518 protocol
: access int
) return int
;
519 pragma Import
(C
, pthread_mutexattr_getprotocol
,
520 "pthread_mutexattr_getprotocol");
522 function pthread_mutexattr_setprioceiling
523 (attr
: access pthread_mutexattr_t
;
524 prioceiling
: int
) return int
;
526 function pthread_mutexattr_getprioceiling
527 (attr
: access pthread_mutexattr_t
;
528 prioceiling
: access int
) return int
;
530 type struct_sched_param
is record
531 sched_priority
: int
; -- scheduling priority
533 pragma Convention
(C
, struct_sched_param
);
535 function pthread_setschedparam
538 param
: access struct_sched_param
) return int
;
540 function pthread_attr_setscope
541 (attr
: access pthread_attr_t
;
542 contentionscope
: int
) return int
;
543 pragma Import
(C
, pthread_attr_setscope
, "pthread_attr_setscope");
545 function pthread_attr_getscope
546 (attr
: access pthread_attr_t
;
547 contentionscope
: access int
) return int
;
548 pragma Import
(C
, pthread_attr_getscope
, "pthread_attr_getscope");
550 function pthread_attr_setinheritsched
551 (attr
: access pthread_attr_t
;
552 inheritsched
: int
) return int
;
553 pragma Import
(C
, pthread_attr_setinheritsched
,
554 "pthread_attr_setinheritsched");
556 function pthread_attr_getinheritsched
557 (attr
: access pthread_attr_t
;
558 inheritsched
: access int
) return int
;
559 pragma Import
(C
, pthread_attr_getinheritsched
,
560 "pthread_attr_getinheritsched");
562 function pthread_attr_setschedpolicy
563 (attr
: access pthread_attr_t
;
564 policy
: int
) return int
;
565 pragma Import
(C
, pthread_attr_setschedpolicy
, "pthread_setschedpolicy");
567 function sched_yield
return int
;
568 pragma Import
(C
, sched_yield
, "sched_yield");
570 ---------------------------
571 -- P1003.1c - Section 16 --
572 ---------------------------
574 function pthread_attr_init
575 (attributes
: access pthread_attr_t
) return int
;
576 pragma Import
(C
, pthread_attr_init
, "pthread_attr_init");
578 function pthread_attr_destroy
579 (attributes
: access pthread_attr_t
) return int
;
580 pragma Import
(C
, pthread_attr_destroy
, "pthread_attr_destroy");
582 function pthread_attr_setdetachstate
583 (attr
: access pthread_attr_t
;
584 detachstate
: int
) return int
;
586 (C
, pthread_attr_setdetachstate
, "pthread_attr_setdetachstate");
588 function pthread_attr_setstacksize
589 (attr
: access pthread_attr_t
;
590 stacksize
: size_t
) return int
;
591 pragma Import
(C
, pthread_attr_setstacksize
, "pthread_attr_setstacksize");
593 -- From: /usr/include/pthread/pthread.h
594 function pthread_create
595 (thread
: access pthread_t
;
596 attributes
: access pthread_attr_t
;
597 start_routine
: Thread_Body
;
598 arg
: System
.Address
) return int
;
599 pragma Import
(C
, pthread_create
, "pthread_create");
601 procedure pthread_exit
(status
: System
.Address
);
602 pragma Import
(C
, pthread_exit
, "pthread_exit");
604 function pthread_self
return pthread_t
;
605 pragma Import
(C
, pthread_self
, "pthread_self");
607 --------------------------
608 -- POSIX.1c Section 17 --
609 --------------------------
611 function pthread_setspecific
612 (key
: pthread_key_t
;
613 value
: System
.Address
) return int
;
614 pragma Import
(C
, pthread_setspecific
, "pthread_setspecific");
616 function pthread_getspecific
(key
: pthread_key_t
) return System
.Address
;
617 pragma Import
(C
, pthread_getspecific
, "pthread_getspecific");
619 type destructor_pointer
is access procedure (arg
: System
.Address
);
620 pragma Convention
(C
, destructor_pointer
);
622 function pthread_key_create
623 (key
: access pthread_key_t
;
624 destructor
: destructor_pointer
) return int
;
625 pragma Import
(C
, pthread_key_create
, "pthread_key_create");
627 -- From /usr/include/i386-gnu/bits/sched.h
628 CPU_SETSIZE
: constant := 1_024
;
630 type bit_field
is array (1 .. CPU_SETSIZE
) of Boolean;
631 for bit_field
'Size use CPU_SETSIZE
;
632 pragma Pack
(bit_field
);
633 pragma Convention
(C
, bit_field
);
635 type cpu_set_t
is record
638 pragma Convention
(C
, cpu_set_t
);
642 type sigset_t
is array (1 .. 4) of unsigned
;
644 -- In GNU/Hurd the component sa_handler turns out to
645 -- be one a union type, and the selector is a macro:
646 -- #define sa_handler __sigaction_handler.sa_handler
647 -- #define sa_sigaction __sigaction_handler.sa_sigaction
649 -- Should we add a signal_context type here ?
650 -- How could it be done independent of the CPU architecture ?
651 -- sigcontext type is opaque, so it is architecturally neutral.
652 -- It is always passed as an access type, so define it as an empty record
653 -- since the contents are not used anywhere.
654 type struct_sigcontext
is null record;
655 pragma Convention
(C
, struct_sigcontext
);
657 type pid_t
is new int
;
659 type time_t
is range -2 ** (System
.Parameters
.time_t_bits
- 1)
660 .. 2 ** (System
.Parameters
.time_t_bits
- 1) - 1;
662 type timespec
is record
666 pragma Convention
(C
, timespec
);
668 -- From: /usr/include/pthread/pthreadtypes.h:
669 -- typedef struct __pthread_attr pthread_attr_t;
670 -- /usr/include/i386-gnu/bits/thread-attr.h: struct __pthread_attr...
671 -- /usr/include/pthread/pthreadtypes.h: enum __pthread_contentionscope
672 -- enum __pthread_detachstate detachstate;
673 -- enum __pthread_inheritsched inheritsched;
674 -- enum __pthread_contentionscope contentionscope;
675 -- Not used: schedpolicy : int;
676 type pthread_attr_t
is record
677 schedparam
: struct_sched_param
;
678 stackaddr
: System
.Address
;
683 contentionscope
: int
;
686 pragma Convention
(C
, pthread_attr_t
);
688 -- From: /usr/include/pthread/pthreadtypes.h:
689 -- typedef struct __pthread_condattr pthread_condattr_t;
690 -- From: /usr/include/i386-gnu/bits/condition-attr.h:
691 -- struct __pthread_condattr {
692 -- enum __pthread_process_shared pshared;
693 -- __Clockid_T Clock;}
694 -- From: /usr/include/pthread/pthreadtypes.h:
695 -- enum __pthread_process_shared
696 type pthread_condattr_t
is record
700 pragma Convention
(C
, pthread_condattr_t
);
702 -- From: /usr/include/pthread/pthreadtypes.h:
703 -- typedef struct __pthread_mutexattr pthread_mutexattr_t; and
704 -- /usr/include/i386-gnu/bits/mutex-attr.h
705 -- struct __pthread_mutexattr {
707 -- enum __pthread_mutex_protocol protocol;
708 -- enum __pthread_process_shared pshared;
709 -- enum __pthread_mutex_type mutex_type;};
710 type pthread_mutexattr_t
is record
716 pragma Convention
(C
, pthread_mutexattr_t
);
718 -- From: /usr/include/pthread/pthreadtypes.h:
719 -- typedef struct __pthread_cond pthread_cond_t;
720 -- typedef struct __pthread_condattr pthread_condattr_t;
721 -- /usr/include/i386-gnu/bits/condition.h:struct __pthread_cond{}
722 -- pthread_condattr_t: see above!
723 -- /usr/include/i386-gnu/bits/condition.h:
724 -- struct __pthread_condimpl *__impl;
726 type pthread_cond_t
is record
728 queue
: System
.Address
;
729 condattr
: System
.Address
;
730 impl
: System
.Address
;
731 data
: System
.Address
;
733 pragma Convention
(C
, pthread_cond_t
);
735 -- From: /usr/include/pthread/pthreadtypes.h:
736 -- typedef __pthread_key pthread_key_t; and
737 -- /usr/include/i386-gnu/bits/thread-specific.h:
738 -- typedef int __pthread_key;
740 type pthread_key_t
is new int
;
742 -- From: /usr/include/i386-gnu/bits/rwlock-attr.h:
743 -- struct __pthread_rwlockattr {
744 -- enum __pthread_process_shared pshared; };
746 type pthread_rwlockattr_t
is record
749 pragma Convention
(C
, pthread_rwlockattr_t
);
751 -- From: /usr/include/i386-gnu/bits/rwlock.h:
752 -- struct __pthread_rwlock {
753 -- __pthread_spinlock_t __held;
754 -- __pthread_spinlock_t __lock;
756 -- struct __pthread *readerqueue;
757 -- struct __pthread *writerqueue;
758 -- struct __pthread_rwlockattr *__attr;
761 type pthread_rwlock_t
is record
765 readerqueue
: System
.Address
;
766 writerqueue
: System
.Address
;
767 attr
: pthread_rwlockattr_t
;
770 pragma Convention
(C
, pthread_rwlock_t
);
772 end System
.OS_Interface
;