Debian Codegraph @

gcc/ada/libgnarl/s-osinte__linux.ads

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