[19/77] Add a smallest_int_mode_for_size helper function
[official-gcc.git] / gcc / ada / s-osinte-linux.ads
blobfa1e060405afd06feb2443dbe6cac35ac3e391e8
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 --
10 -- Copyright (C) 1995-2016, Free Software Foundation, Inc. --
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 ------------------------------------------------------------------------------
33 -- This is a GNU/Linux (GNU/LinuxThreads) version of this package
35 -- This package encapsulates all direct interfaces to OS services
36 -- that are needed by the tasking run-time (libgnarl).
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;
42 with Interfaces.C;
43 with System.Linux;
44 with System.OS_Constants;
46 package System.OS_Interface is
47 pragma Preelaborate;
49 pragma Linker_Options ("-lpthread");
50 pragma Linker_Options ("-lrt");
51 -- Needed for clock_getres with glibc versions prior to 2.17
53 subtype int is Interfaces.C.int;
54 subtype char is Interfaces.C.char;
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;
64 -----------
65 -- Errno --
66 -----------
68 function errno return int;
69 pragma Import (C, errno, "__get_errno");
71 EAGAIN : constant := System.Linux.EAGAIN;
72 EINTR : constant := System.Linux.EINTR;
73 EINVAL : constant := System.Linux.EINVAL;
74 ENOMEM : constant := System.Linux.ENOMEM;
75 EPERM : constant := System.Linux.EPERM;
76 ETIMEDOUT : constant := System.Linux.ETIMEDOUT;
78 -------------
79 -- Signals --
80 -------------
82 Max_Interrupt : constant := 63;
83 type Signal is new int range 0 .. Max_Interrupt;
84 for Signal'Size use int'Size;
86 SIGHUP : constant := System.Linux.SIGHUP;
87 SIGINT : constant := System.Linux.SIGINT;
88 SIGQUIT : constant := System.Linux.SIGQUIT;
89 SIGILL : constant := System.Linux.SIGILL;
90 SIGTRAP : constant := System.Linux.SIGTRAP;
91 SIGIOT : constant := System.Linux.SIGIOT;
92 SIGABRT : constant := System.Linux.SIGABRT;
93 SIGFPE : constant := System.Linux.SIGFPE;
94 SIGKILL : constant := System.Linux.SIGKILL;
95 SIGBUS : constant := System.Linux.SIGBUS;
96 SIGSEGV : constant := System.Linux.SIGSEGV;
97 SIGPIPE : constant := System.Linux.SIGPIPE;
98 SIGALRM : constant := System.Linux.SIGALRM;
99 SIGTERM : constant := System.Linux.SIGTERM;
100 SIGUSR1 : constant := System.Linux.SIGUSR1;
101 SIGUSR2 : constant := System.Linux.SIGUSR2;
102 SIGCLD : constant := System.Linux.SIGCLD;
103 SIGCHLD : constant := System.Linux.SIGCHLD;
104 SIGPWR : constant := System.Linux.SIGPWR;
105 SIGWINCH : constant := System.Linux.SIGWINCH;
106 SIGURG : constant := System.Linux.SIGURG;
107 SIGPOLL : constant := System.Linux.SIGPOLL;
108 SIGIO : constant := System.Linux.SIGIO;
109 SIGLOST : constant := System.Linux.SIGLOST;
110 SIGSTOP : constant := System.Linux.SIGSTOP;
111 SIGTSTP : constant := System.Linux.SIGTSTP;
112 SIGCONT : constant := System.Linux.SIGCONT;
113 SIGTTIN : constant := System.Linux.SIGTTIN;
114 SIGTTOU : constant := System.Linux.SIGTTOU;
115 SIGVTALRM : constant := System.Linux.SIGVTALRM;
116 SIGPROF : constant := System.Linux.SIGPROF;
117 SIGXCPU : constant := System.Linux.SIGXCPU;
118 SIGXFSZ : constant := System.Linux.SIGXFSZ;
119 SIGUNUSED : constant := System.Linux.SIGUNUSED;
120 SIGSTKFLT : constant := System.Linux.SIGSTKFLT;
121 SIGLTHRRES : constant := System.Linux.SIGLTHRRES;
122 SIGLTHRCAN : constant := System.Linux.SIGLTHRCAN;
123 SIGLTHRDBG : constant := System.Linux.SIGLTHRDBG;
125 SIGADAABORT : constant := SIGABRT;
126 -- Change this to use another signal for task abort. SIGTERM might be a
127 -- good one.
129 type Signal_Set is array (Natural range <>) of Signal;
131 Unmasked : constant Signal_Set := (
132 SIGTRAP,
133 -- To enable debugging on multithreaded applications, mark SIGTRAP to
134 -- be kept unmasked.
136 SIGBUS,
138 SIGTTIN, SIGTTOU, SIGTSTP,
139 -- Keep these three signals unmasked so that background processes and IO
140 -- behaves as normal "C" applications
142 SIGPROF,
143 -- To avoid confusing the profiler
145 SIGKILL, SIGSTOP,
146 -- These two signals actually can't be masked (POSIX won't allow it)
148 SIGLTHRRES, SIGLTHRCAN, SIGLTHRDBG);
149 -- These three signals are used by GNU/LinuxThreads starting from glibc
150 -- 2.1 (future 2.2).
152 Reserved : constant Signal_Set := (SIGVTALRM, SIGUNUSED);
153 -- Not clear why these two signals are reserved. Perhaps they are not
154 -- supported by this version of GNU/Linux ???
156 type sigset_t is private;
158 function sigaddset (set : access sigset_t; sig : Signal) return int;
159 pragma Import (C, sigaddset, "sigaddset");
161 function sigdelset (set : access sigset_t; sig : Signal) return int;
162 pragma Import (C, sigdelset, "sigdelset");
164 function sigfillset (set : access sigset_t) return int;
165 pragma Import (C, sigfillset, "sigfillset");
167 function sigismember (set : access sigset_t; sig : Signal) return int;
168 pragma Import (C, sigismember, "sigismember");
170 function sigemptyset (set : access sigset_t) return int;
171 pragma Import (C, sigemptyset, "sigemptyset");
173 type union_type_3 is new String (1 .. 116);
174 type siginfo_t is record
175 si_signo : int;
176 si_code : int;
177 si_errno : int;
178 X_data : union_type_3;
179 end record;
180 pragma Convention (C, siginfo_t);
182 type struct_sigaction is record
183 sa_handler : System.Address;
184 sa_mask : sigset_t;
185 sa_flags : int;
186 sa_restorer : System.Address;
187 end record;
188 pragma Convention (C, struct_sigaction);
190 type struct_sigaction_ptr is access all struct_sigaction;
192 type Machine_State is record
193 eip : unsigned_long;
194 ebx : unsigned_long;
195 esp : unsigned_long;
196 ebp : unsigned_long;
197 esi : unsigned_long;
198 edi : unsigned_long;
199 end record;
200 type Machine_State_Ptr is access all Machine_State;
202 SA_SIGINFO : constant := System.Linux.SA_SIGINFO;
203 SA_ONSTACK : constant := System.Linux.SA_ONSTACK;
205 SIG_BLOCK : constant := 0;
206 SIG_UNBLOCK : constant := 1;
207 SIG_SETMASK : constant := 2;
209 SIG_DFL : constant := 0;
210 SIG_IGN : constant := 1;
212 function sigaction
213 (sig : Signal;
214 act : struct_sigaction_ptr;
215 oact : struct_sigaction_ptr) return int;
216 pragma Import (C, sigaction, "sigaction");
218 ----------
219 -- Time --
220 ----------
222 subtype time_t is System.Linux.time_t;
223 subtype timespec is System.Linux.timespec;
224 subtype timeval is System.Linux.timeval;
225 subtype clockid_t is System.Linux.clockid_t;
227 function clock_gettime
228 (clock_id : clockid_t; tp : access timespec) return int;
229 pragma Import (C, clock_gettime, "clock_gettime");
231 function clock_getres
232 (clock_id : clockid_t;
233 res : access timespec) return int;
234 pragma Import (C, clock_getres, "clock_getres");
236 function To_Duration (TS : timespec) return Duration;
237 pragma Inline (To_Duration);
239 function To_Timespec (D : Duration) return timespec;
240 pragma Inline (To_Timespec);
242 function sysconf (name : int) return long;
243 pragma Import (C, sysconf);
245 SC_CLK_TCK : constant := 2;
246 SC_NPROCESSORS_ONLN : constant := 84;
248 -------------------------
249 -- Priority Scheduling --
250 -------------------------
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
260 -------------
261 -- Process --
262 -------------
264 type pid_t is private;
266 function kill (pid : pid_t; sig : Signal) return int;
267 pragma Import (C, kill, "kill");
269 function getpid return pid_t;
270 pragma Import (C, getpid, "getpid");
272 PR_SET_NAME : constant := 15;
273 PR_GET_NAME : constant := 16;
275 function prctl
276 (option : int;
277 arg2, arg3, arg4, arg5 : unsigned_long := 0) return int;
278 pragma Import (C, prctl);
280 -------------
281 -- Threads --
282 -------------
284 type Thread_Body is access
285 function (arg : System.Address) return System.Address;
286 pragma Convention (C, Thread_Body);
288 function Thread_Body_Access is new
289 Ada.Unchecked_Conversion (System.Address, Thread_Body);
291 type pthread_t is new unsigned_long;
292 subtype Thread_Id is pthread_t;
294 function To_pthread_t is
295 new Ada.Unchecked_Conversion (unsigned_long, pthread_t);
297 type pthread_mutex_t is limited private;
298 type pthread_rwlock_t is limited private;
299 type pthread_cond_t is limited private;
300 type pthread_attr_t is limited private;
301 type pthread_mutexattr_t is limited private;
302 type pthread_rwlockattr_t is limited private;
303 type pthread_condattr_t is limited private;
304 type pthread_key_t is private;
306 PTHREAD_CREATE_DETACHED : constant := 1;
308 -----------
309 -- Stack --
310 -----------
312 type stack_t is record
313 ss_sp : System.Address;
314 ss_flags : int;
315 ss_size : size_t;
316 end record;
317 pragma Convention (C, stack_t);
319 function sigaltstack
320 (ss : not null access stack_t;
321 oss : access stack_t) return int;
322 pragma Import (C, sigaltstack, "sigaltstack");
324 Alternate_Stack : aliased System.Address;
325 pragma Import (C, Alternate_Stack, "__gnat_alternate_stack");
326 -- The alternate signal stack for stack overflows
328 Alternate_Stack_Size : constant := 16 * 1024;
329 -- This must be in keeping with init.c:__gnat_alternate_stack
331 function Get_Stack_Base (thread : pthread_t) return Address;
332 pragma Inline (Get_Stack_Base);
333 -- This is a dummy procedure to share some GNULLI files
335 ---------------------------------------
336 -- Nonstandard Thread Initialization --
337 ---------------------------------------
339 procedure pthread_init;
340 pragma Inline (pthread_init);
341 -- This is a dummy procedure to share some GNULLI files
343 -------------------------
344 -- POSIX.1c Section 3 --
345 -------------------------
347 function sigwait (set : access sigset_t; sig : access Signal) return int;
348 pragma Import (C, sigwait, "sigwait");
350 function pthread_kill (thread : pthread_t; sig : Signal) return int;
351 pragma Import (C, pthread_kill, "pthread_kill");
353 function pthread_sigmask
354 (how : int;
355 set : access sigset_t;
356 oset : access sigset_t) return int;
357 pragma Import (C, pthread_sigmask, "pthread_sigmask");
359 --------------------------
360 -- POSIX.1c Section 11 --
361 --------------------------
363 function pthread_mutexattr_init
364 (attr : access pthread_mutexattr_t) return int;
365 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
367 function pthread_mutexattr_destroy
368 (attr : access pthread_mutexattr_t) return int;
369 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
371 function pthread_mutex_init
372 (mutex : access pthread_mutex_t;
373 attr : access pthread_mutexattr_t) return int;
374 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
376 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
377 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
379 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
380 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
382 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
383 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
385 function pthread_rwlockattr_init
386 (attr : access pthread_rwlockattr_t) return int;
387 pragma Import (C, pthread_rwlockattr_init, "pthread_rwlockattr_init");
389 function pthread_rwlockattr_destroy
390 (attr : access pthread_rwlockattr_t) return int;
391 pragma Import (C, pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy");
393 PTHREAD_RWLOCK_PREFER_READER_NP : constant := 0;
394 PTHREAD_RWLOCK_PREFER_WRITER_NP : constant := 1;
395 PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
397 function pthread_rwlockattr_setkind_np
398 (attr : access pthread_rwlockattr_t;
399 pref : int) return int;
400 pragma Import
401 (C, pthread_rwlockattr_setkind_np, "pthread_rwlockattr_setkind_np");
403 function pthread_rwlock_init
404 (mutex : access pthread_rwlock_t;
405 attr : access pthread_rwlockattr_t) return int;
406 pragma Import (C, pthread_rwlock_init, "pthread_rwlock_init");
408 function pthread_rwlock_destroy
409 (mutex : access pthread_rwlock_t) return int;
410 pragma Import (C, pthread_rwlock_destroy, "pthread_rwlock_destroy");
412 function pthread_rwlock_rdlock (mutex : access pthread_rwlock_t) return int;
413 pragma Import (C, pthread_rwlock_rdlock, "pthread_rwlock_rdlock");
415 function pthread_rwlock_wrlock (mutex : access pthread_rwlock_t) return int;
416 pragma Import (C, pthread_rwlock_wrlock, "pthread_rwlock_wrlock");
418 function pthread_rwlock_unlock (mutex : access pthread_rwlock_t) return int;
419 pragma Import (C, pthread_rwlock_unlock, "pthread_rwlock_unlock");
421 function pthread_condattr_init
422 (attr : access pthread_condattr_t) return int;
423 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
425 function pthread_condattr_destroy
426 (attr : access pthread_condattr_t) return int;
427 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
429 function pthread_cond_init
430 (cond : access pthread_cond_t;
431 attr : access pthread_condattr_t) return int;
432 pragma Import (C, pthread_cond_init, "pthread_cond_init");
434 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
435 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
437 function pthread_cond_signal (cond : access pthread_cond_t) return int;
438 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
440 function pthread_cond_wait
441 (cond : access pthread_cond_t;
442 mutex : access pthread_mutex_t) return int;
443 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
445 function pthread_cond_timedwait
446 (cond : access pthread_cond_t;
447 mutex : access pthread_mutex_t;
448 abstime : access timespec) return int;
449 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
451 --------------------------
452 -- POSIX.1c Section 13 --
453 --------------------------
455 PTHREAD_PRIO_NONE : constant := 0;
456 PTHREAD_PRIO_INHERIT : constant := 1;
457 PTHREAD_PRIO_PROTECT : constant := 2;
459 function pthread_mutexattr_setprotocol
460 (attr : access pthread_mutexattr_t;
461 protocol : int) return int;
462 pragma Import (C, pthread_mutexattr_setprotocol);
464 function pthread_mutexattr_setprioceiling
465 (attr : access pthread_mutexattr_t;
466 prioceiling : int) return int;
467 pragma Import (C, pthread_mutexattr_setprioceiling);
469 type struct_sched_param is record
470 sched_priority : int; -- scheduling priority
471 end record;
472 pragma Convention (C, struct_sched_param);
474 function pthread_setschedparam
475 (thread : pthread_t;
476 policy : int;
477 param : access struct_sched_param) return int;
478 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
480 function pthread_attr_setschedpolicy
481 (attr : access pthread_attr_t;
482 policy : int) return int;
483 pragma Import
484 (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy");
486 function sched_yield return int;
487 pragma Import (C, sched_yield, "sched_yield");
489 ---------------------------
490 -- P1003.1c - Section 16 --
491 ---------------------------
493 function pthread_attr_init
494 (attributes : access pthread_attr_t) return int;
495 pragma Import (C, pthread_attr_init, "pthread_attr_init");
497 function pthread_attr_destroy
498 (attributes : access pthread_attr_t) return int;
499 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
501 function pthread_attr_setdetachstate
502 (attr : access pthread_attr_t;
503 detachstate : int) return int;
504 pragma Import
505 (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
507 function pthread_attr_setstacksize
508 (attr : access pthread_attr_t;
509 stacksize : size_t) return int;
510 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
512 function pthread_create
513 (thread : access pthread_t;
514 attributes : access pthread_attr_t;
515 start_routine : Thread_Body;
516 arg : System.Address) return int;
517 pragma Import (C, pthread_create, "pthread_create");
519 procedure pthread_exit (status : System.Address);
520 pragma Import (C, pthread_exit, "pthread_exit");
522 function pthread_self return pthread_t;
523 pragma Import (C, pthread_self, "pthread_self");
525 function lwp_self return System.Address;
526 pragma Import (C, lwp_self, "__gnat_lwp_self");
528 --------------------------
529 -- POSIX.1c Section 17 --
530 --------------------------
532 function pthread_setspecific
533 (key : pthread_key_t;
534 value : System.Address) return int;
535 pragma Import (C, pthread_setspecific, "pthread_setspecific");
537 function pthread_getspecific (key : pthread_key_t) return System.Address;
538 pragma Import (C, pthread_getspecific, "pthread_getspecific");
540 type destructor_pointer is access procedure (arg : System.Address);
541 pragma Convention (C, destructor_pointer);
543 function pthread_key_create
544 (key : access pthread_key_t;
545 destructor : destructor_pointer) return int;
546 pragma Import (C, pthread_key_create, "pthread_key_create");
548 ----------------
549 -- Extensions --
550 ----------------
552 CPU_SETSIZE : constant := 1_024;
553 -- Size of the cpu_set_t mask on most linux systems (SUSE 11 uses 4_096).
554 -- This is kept for backward compatibility (System.Task_Info uses it), but
555 -- the run-time library does no longer rely on static masks, using
556 -- dynamically allocated masks instead.
558 type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
559 for bit_field'Size use CPU_SETSIZE;
560 pragma Pack (bit_field);
561 pragma Convention (C, bit_field);
563 type cpu_set_t is record
564 bits : bit_field;
565 end record;
566 pragma Convention (C, cpu_set_t);
568 type cpu_set_t_ptr is access all cpu_set_t;
569 -- In the run-time library we use this pointer because the size of type
570 -- cpu_set_t varies depending on the glibc version. Hence, objects of type
571 -- cpu_set_t are allocated dynamically using the number of processors
572 -- available in the target machine (value obtained at execution time).
574 function CPU_ALLOC (count : size_t) return cpu_set_t_ptr;
575 pragma Import (C, CPU_ALLOC, "__gnat_cpu_alloc");
576 -- Wrapper around the CPU_ALLOC C macro
578 function CPU_ALLOC_SIZE (count : size_t) return size_t;
579 pragma Import (C, CPU_ALLOC_SIZE, "__gnat_cpu_alloc_size");
580 -- Wrapper around the CPU_ALLOC_SIZE C macro
582 procedure CPU_FREE (cpuset : cpu_set_t_ptr);
583 pragma Import (C, CPU_FREE, "__gnat_cpu_free");
584 -- Wrapper around the CPU_FREE C macro
586 procedure CPU_ZERO (count : size_t; cpuset : cpu_set_t_ptr);
587 pragma Import (C, CPU_ZERO, "__gnat_cpu_zero");
588 -- Wrapper around the CPU_ZERO_S C macro
590 procedure CPU_SET (cpu : int; count : size_t; cpuset : cpu_set_t_ptr);
591 pragma Import (C, CPU_SET, "__gnat_cpu_set");
592 -- Wrapper around the CPU_SET_S C macro
594 function pthread_setaffinity_np
595 (thread : pthread_t;
596 cpusetsize : size_t;
597 cpuset : cpu_set_t_ptr) return int;
598 pragma Import (C, pthread_setaffinity_np, "pthread_setaffinity_np");
599 pragma Weak_External (pthread_setaffinity_np);
600 -- Use a weak symbol because this function may be available or not,
601 -- depending on the version of the system.
603 function pthread_attr_setaffinity_np
604 (attr : access pthread_attr_t;
605 cpusetsize : size_t;
606 cpuset : cpu_set_t_ptr) return int;
607 pragma Import (C, pthread_attr_setaffinity_np,
608 "pthread_attr_setaffinity_np");
609 pragma Weak_External (pthread_attr_setaffinity_np);
610 -- Use a weak symbol because this function may be available or not,
611 -- depending on the version of the system.
613 private
615 type sigset_t is
616 array (0 .. OS_Constants.SIZEOF_sigset - 1) of unsigned_char;
617 pragma Convention (C, sigset_t);
618 for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment;
620 pragma Warnings (Off);
621 for struct_sigaction use record
622 sa_handler at Linux.sa_handler_pos range 0 .. Standard'Address_Size - 1;
623 sa_mask at Linux.sa_mask_pos range 0 .. 1023;
624 sa_flags at Linux.sa_flags_pos range 0 .. int'Size - 1;
625 end record;
626 -- We intentionally leave sa_restorer unspecified and let the compiler
627 -- append it after the last field, so disable corresponding warning.
628 pragma Warnings (On);
630 type pid_t is new int;
632 subtype char_array is Interfaces.C.char_array;
634 type pthread_attr_t is record
635 Data : char_array (1 .. OS_Constants.PTHREAD_ATTR_SIZE);
636 end record;
637 pragma Convention (C, pthread_attr_t);
638 for pthread_attr_t'Alignment use Interfaces.C.unsigned_long'Alignment;
640 type pthread_condattr_t is record
641 Data : char_array (1 .. OS_Constants.PTHREAD_CONDATTR_SIZE);
642 end record;
643 pragma Convention (C, pthread_condattr_t);
644 for pthread_condattr_t'Alignment use Interfaces.C.int'Alignment;
646 type pthread_mutexattr_t is record
647 Data : char_array (1 .. OS_Constants.PTHREAD_MUTEXATTR_SIZE);
648 end record;
649 pragma Convention (C, pthread_mutexattr_t);
650 for pthread_mutexattr_t'Alignment use Interfaces.C.int'Alignment;
652 type pthread_mutex_t is record
653 Data : char_array (1 .. OS_Constants.PTHREAD_MUTEX_SIZE);
654 end record;
655 pragma Convention (C, pthread_mutex_t);
656 for pthread_mutex_t'Alignment use Interfaces.C.unsigned_long'Alignment;
658 type pthread_rwlockattr_t is record
659 Data : char_array (1 .. OS_Constants.PTHREAD_RWLOCKATTR_SIZE);
660 end record;
661 pragma Convention (C, pthread_rwlockattr_t);
662 for pthread_rwlockattr_t'Alignment use Interfaces.C.unsigned_long'Alignment;
664 type pthread_rwlock_t is record
665 Data : char_array (1 .. OS_Constants.PTHREAD_RWLOCK_SIZE);
666 end record;
667 pragma Convention (C, pthread_rwlock_t);
668 for pthread_rwlock_t'Alignment use Interfaces.C.unsigned_long'Alignment;
670 type pthread_cond_t is record
671 Data : char_array (1 .. OS_Constants.PTHREAD_COND_SIZE);
672 end record;
673 pragma Convention (C, pthread_cond_t);
674 for pthread_cond_t'Alignment use Interfaces.Unsigned_64'Alignment;
676 type pthread_key_t is new unsigned;
678 end System.OS_Interface;