1
--- /dev/null 2012-01-30 20:41:15.189616186 +0100
2
+++ b/src/gcc/ada/s-osinte-gnu.ads 2012-04-11 19:34:45.000000000 +0200
4
+------------------------------------------------------------------------------
6
+-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
8
+-- S Y S T E M . O S _ I N T E R F A C E --
12
+-- Copyright (C) 1991-1994, Florida State University --
13
+-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
15
+-- GNARL is free software; you can redistribute it and/or modify it under --
16
+-- terms of the GNU General Public License as published by the Free Soft- --
17
+-- ware Foundation; either version 2, or (at your option) any later ver- --
18
+-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
19
+-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
20
+-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
21
+-- for more details. You should have received a copy of the GNU General --
22
+-- Public License distributed with GNARL; see file COPYING. If not, write --
23
+-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
24
+-- Boston, MA 02110-1301, USA. --
26
+-- As a special exception, if other files instantiate generics from this --
27
+-- unit, or you link this unit with other files to produce an executable, --
28
+-- this unit does not by itself cause the resulting executable to be --
29
+-- covered by the GNU General Public License. This exception does not --
30
+-- however invalidate any other reasons why the executable file might be --
31
+-- covered by the GNU Public License. --
33
+-- GNARL was developed by the GNARL team at Florida State University. --
34
+-- Extensive contributions were provided by Ada Core Technologies, Inc. --
36
+------------------------------------------------------------------------------
38
+-- This is the GNU/Hurd version of this package
40
+-- This package encapsulates all direct interfaces to OS services
41
+-- that are needed by children of System.
43
+-- PLEASE DO NOT add any with-clauses to this package or remove the pragma
44
+-- Preelaborate. This package is designed to be a bottom-level (leaf) package
47
+with Unchecked_Conversion;
49
+package System.OS_Interface is
50
+ pragma Preelaborate;
52
+ pragma Linker_Options ("-lpthread");
53
+ pragma Linker_Options ("-lrt");
55
+ subtype int is Interfaces.C.int;
56
+ subtype char is Interfaces.C.char;
57
+ subtype short is Interfaces.C.short;
58
+ subtype long is Interfaces.C.long;
59
+ subtype unsigned is Interfaces.C.unsigned;
60
+ subtype unsigned_short is Interfaces.C.unsigned_short;
61
+ subtype unsigned_long is Interfaces.C.unsigned_long;
62
+ subtype unsigned_char is Interfaces.C.unsigned_char;
63
+ subtype plain_char is Interfaces.C.plain_char;
64
+ subtype size_t is Interfaces.C.size_t;
69
+ -- From /usr/include/i386-gnu/bits/errno.h
71
+ function errno return int;
72
+ pragma Import (C, errno, "__get_errno");
74
+ EAGAIN : constant := 1073741859;
75
+ EINTR : constant := 1073741828;
76
+ EINVAL : constant := 1073741846;
77
+ ENOMEM : constant := 1073741836;
78
+ EPERM : constant := 1073741825;
79
+ ETIMEDOUT : constant := 1073741884;
84
+ -- From /usr/include/i386-gnu/bits/signum.h
86
+ Max_Interrupt : constant := 32;
87
+ type Signal is new int range 0 .. Max_Interrupt;
88
+ for Signal'Size use int'Size;
90
+ SIGHUP : constant := 1; -- hangup
91
+ SIGINT : constant := 2; -- interrupt (rubout)
92
+ SIGQUIT : constant := 3; -- quit (ASCD FS)
93
+ SIGILL : constant := 4; -- illegal instruction (not reset)
94
+ SIGTRAP : constant := 5; -- trace trap (not reset)
95
+ SIGIOT : constant := 6; -- IOT instruction
96
+ SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
97
+ SIGEMT : constant := 7; -- EMT instruction
98
+ SIGFPE : constant := 8; -- floating point exception
99
+ SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
100
+ SIGBUS : constant := 10; -- bus error
101
+ SIGSEGV : constant := 11; -- segmentation violation
102
+ SIGSYS : constant := 12; -- bad argument to system call
103
+ SIGPIPE : constant := 13; -- write on a pipe with no one to read it
104
+ SIGALRM : constant := 14; -- alarm clock
105
+ SIGTERM : constant := 15; -- software termination signal from kill
106
+ SIGURG : constant := 16; -- urgent condition on IO channel
107
+ SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
108
+ SIGTSTP : constant := 18; -- user stop requested from tty
109
+ SIGCONT : constant := 19; -- stopped process has been continued
110
+ SIGCLD : constant := 20; -- alias for SIGCHLD
111
+ SIGCHLD : constant := 20; -- child status change
112
+ SIGTTIN : constant := 21; -- background tty read attempted
113
+ SIGTTOU : constant := 22; -- background tty write attempted
114
+ SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
115
+ SIGPOLL : constant := 23; -- I/O possible (same as SIGIO?)
116
+ SIGXCPU : constant := 24; -- CPU time limit exceeded
117
+ SIGXFSZ : constant := 25; -- filesize limit exceeded
118
+ SIGVTALRM : constant := 26; -- virtual timer expired
119
+ SIGPROF : constant := 27; -- profiling timer expired
120
+ SIGWINCH : constant := 28; -- window size change
121
+ SIGINFO : constant := 29; -- information request (NetBSD/FreeBSD)
122
+ SIGUSR1 : constant := 30; -- user defined signal 1
123
+ SIGUSR2 : constant := 31; -- user defined signal 2
124
+ SIGLOST : constant := 32; -- Resource lost (Sun); server died (GNU)
125
+-- SIGLTHRRES : constant := 32; -- GNU/LinuxThreads restart signal
126
+-- SIGLTHRCAN : constant := 33; -- GNU/LinuxThreads cancel signal
127
+-- SIGLTHRDBG : constant := 34; -- GNU/LinuxThreads debugger signal
129
+ SIGADAABORT : constant := SIGABRT;
130
+ -- Change this if you want to use another signal for task abort.
131
+ -- SIGTERM might be a good one.
133
+ type Signal_Set is array (Natural range <>) of Signal;
135
+ Unmasked : constant Signal_Set := (
137
+ -- To enable debugging on multithreaded applications, mark SIGTRAP to
138
+ -- be kept unmasked.
142
+ SIGTTIN, SIGTTOU, SIGTSTP,
143
+ -- Keep these three signals unmasked so that background processes
144
+ -- and IO behaves as normal "C" applications
147
+ -- To avoid confusing the profiler
150
+ -- These two signals actually cannot be masked;
151
+ -- POSIX simply won't allow it.
153
+ Reserved : constant Signal_Set :=
154
+ -- I am not sure why the following signal is reserved.
155
+ -- I guess they are not supported by this version of GNU/Hurd.
156
+ (0 .. 0 => SIGVTALRM);
158
+ type sigset_t is private;
160
+ -- From /usr/include/signal.h /usr/include/i386-gnu/bits/sigset.h
161
+ function sigaddset (set : access sigset_t; sig : Signal) return int;
162
+ pragma Import (C, sigaddset, "sigaddset");
164
+ function sigdelset (set : access sigset_t; sig : Signal) return int;
165
+ pragma Import (C, sigdelset, "sigdelset");
167
+ function sigfillset (set : access sigset_t) return int;
168
+ pragma Import (C, sigfillset, "sigfillset");
170
+ function sigismember (set : access sigset_t; sig : Signal) return int;
171
+ pragma Import (C, sigismember, "sigismember");
173
+ function sigemptyset (set : access sigset_t) return int;
174
+ pragma Import (C, sigemptyset, "sigemptyset");
176
+ -- sigcontext is architecture dependent, so define it private
177
+ type struct_sigcontext is private;
179
+ -- From /usr/include/i386-gnu/bits/sigaction.h: Note: arg. order differs
180
+ type struct_sigaction is record
181
+ sa_handler : System.Address;
182
+ sa_mask : sigset_t;
185
+ pragma Convention (C, struct_sigaction);
187
+ type struct_sigaction_ptr is access all struct_sigaction;
189
+ -- From /usr/include/i386-gnu/bits/sigaction.h
190
+ SIG_BLOCK : constant := 1;
191
+ SIG_UNBLOCK : constant := 2;
192
+ SIG_SETMASK : constant := 3;
194
+ -- From /usr/include/i386-gnu/bits/signum.h
195
+ SIG_ERR : constant := 1;
196
+ SIG_DFL : constant := 0;
197
+ SIG_IGN : constant := 1;
198
+ SIG_HOLD : constant := 2;
200
+ -- From /usr/include/i386-gnu/bits/sigaction.h
201
+ SA_SIGINFO : constant := 16#0040#;
202
+ SA_ONSTACK : constant := 16#0001#;
206
+ act : struct_sigaction_ptr;
207
+ oact : struct_sigaction_ptr) return int;
208
+ pragma Import (C, sigaction, "sigaction");
214
+ Time_Slice_Supported : constant Boolean := True;
215
+ -- Indicates whether time slicing is supported (i.e SCHED_RR is supported)
217
+ type timespec is private;
219
+ function nanosleep (rqtp, rmtp : access timespec) return int;
220
+ pragma Import (C, nanosleep, "nanosleep");
222
+ type clockid_t is private;
224
+ CLOCK_REALTIME : constant clockid_t;
226
+ -- From: /usr/include/time.h
227
+ function clock_gettime
228
+ (clock_id : clockid_t;
229
+ tp : access timespec)
231
+ pragma Import (C, clock_gettime, "clock_gettime");
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
+ 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 Unchecked_Conversion
302
+ (unsigned_long, pthread_t);
304
+ type pthread_mutex_t is limited private;
305
+ type pthread_cond_t is limited private;
306
+ type pthread_attr_t is limited private;
307
+ type pthread_mutexattr_t is limited private;
308
+ type pthread_condattr_t is limited private;
309
+ type pthread_key_t is private;
311
+ -- From /usr/include/pthread/pthreadtypes.h
312
+ PTHREAD_CREATE_DETACHED : constant := 1;
313
+ PTHREAD_CREATE_JOINABLE : constant := 0;
315
+ PTHREAD_SCOPE_PROCESS : constant := 1;
316
+ PTHREAD_SCOPE_SYSTEM : constant := 0;
322
+ -- From: /usr/include/i386-gnu/bits/sigstack.h
323
+ type stack_t is record
324
+ ss_sp : System.Address;
328
+ pragma Convention (C, stack_t);
330
+ function sigaltstack
331
+ (ss : not null access stack_t;
332
+ oss : access stack_t) return int;
333
+ pragma Import (C, sigaltstack, "sigaltstack");
335
+ Alternate_Stack : aliased System.Address;
336
+ -- This is a dummy definition, never used (Alternate_Stack_Size is null)
338
+ Alternate_Stack_Size : constant := 0;
339
+ -- No alternate signal stack is used on this platform
341
+ Stack_Base_Available : constant Boolean := False;
342
+ -- Indicates whether the stack base is available on this target
344
+ function Get_Stack_Base (thread : pthread_t) return Address;
345
+ pragma Inline (Get_Stack_Base);
346
+ -- returns the stack base of the specified thread. Only call this function
347
+ -- when Stack_Base_Available is True.
349
+ -- From: /usr/include/i386-gnu/bits/shm.h __getpagesize or getpagesize??
350
+ function Get_Page_Size return size_t;
351
+ function Get_Page_Size return Address;
352
+ pragma Import (C, Get_Page_Size, "__getpagesize");
353
+ -- Returns the size of a page
355
+ -- From /usr/include/i386-gnu/bits/mman.h
356
+ PROT_NONE : constant := 0;
357
+ PROT_READ : constant := 4;
358
+ PROT_WRITE : constant := 2;
359
+ PROT_EXEC : constant := 1;
360
+ PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
361
+ PROT_ON : constant := PROT_NONE;
362
+ PROT_OFF : constant := PROT_ALL;
364
+ -- From /usr/include/i386-gnu/bits/mman.h
365
+ function mprotect (addr : Address; len : size_t; prot : int) return int;
366
+ pragma Import (C, mprotect);
368
+ ---------------------------------------
369
+ -- Nonstandard Thread Initialization --
370
+ ---------------------------------------
372
+ procedure pthread_init;
373
+ pragma Inline (pthread_init);
374
+ -- This is a dummy procedure to share some GNULLI files
376
+ -------------------------
377
+ -- POSIX.1c Section 3 --
378
+ -------------------------
380
+ -- From: /usr/include/signal.h:
381
+ -- sigwait (__const sigset_t *__restrict __set, int *__restrict __sig)
382
+ function sigwait (set : access sigset_t; sig : access Signal) return int;
383
+ pragma Import (C, sigwait, "sigwait");
385
+ -- From: /usr/include/pthread/pthread.h:
386
+ -- extern int pthread_kill (pthread_t thread, int signo);
387
+ function pthread_kill (thread : pthread_t; sig : Signal) return int;
388
+ pragma Import (C, pthread_kill, "pthread_kill");
390
+ -- From: /usr/include/i386-gnu/bits/sigthread.h
391
+ -- extern int pthread_sigmask (int __how, __const __sigset_t *__newmask,
392
+ -- __sigset_t *__oldmask) __THROW;
393
+ function pthread_sigmask
395
+ set : access sigset_t;
396
+ oset : access sigset_t) return int;
397
+ pragma Import (C, pthread_sigmask, "pthread_sigmask");
399
+ --------------------------
400
+ -- POSIX.1c Section 11 --
401
+ --------------------------
403
+ -- From: /usr/include/pthread/pthread.h and
404
+ -- /usr/include/pthread/pthreadtypes.h
405
+ function pthread_mutexattr_init
406
+ (attr : access pthread_mutexattr_t) return int;
407
+ pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
409
+ function pthread_mutexattr_destroy
410
+ (attr : access pthread_mutexattr_t) return int;
411
+ pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
413
+ function pthread_mutex_init
414
+ (mutex : access pthread_mutex_t;
415
+ attr : access pthread_mutexattr_t) return int;
416
+ pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
418
+ function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
419
+ pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
421
+ function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
422
+ pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
424
+ function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
425
+ pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
427
+ function pthread_condattr_init
428
+ (attr : access pthread_condattr_t) return int;
429
+ pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
431
+ function pthread_condattr_destroy
432
+ (attr : access pthread_condattr_t) return int;
433
+ pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
435
+ function pthread_cond_init
436
+ (cond : access pthread_cond_t;
437
+ attr : access pthread_condattr_t) return int;
438
+ pragma Import (C, pthread_cond_init, "pthread_cond_init");
440
+ function pthread_cond_destroy (cond : access pthread_cond_t) return int;
441
+ pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
443
+ function pthread_cond_signal (cond : access pthread_cond_t) return int;
444
+ pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
446
+ function pthread_cond_wait
447
+ (cond : access pthread_cond_t;
448
+ mutex : access pthread_mutex_t) return int;
449
+ pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
451
+ function pthread_cond_timedwait
452
+ (cond : access pthread_cond_t;
453
+ mutex : access pthread_mutex_t;
454
+ abstime : access timespec) return int;
455
+ pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
457
+ Relative_Timed_Wait : constant Boolean := False;
458
+ -- pthread_cond_timedwait requires an absolute delay time
460
+ --------------------------
461
+ -- POSIX.1c Section 13 --
462
+ --------------------------
463
+ -- From /usr/include/pthread/pthreadtypes.h
465
+ PTHREAD_PRIO_NONE : constant := 0;
466
+ PTHREAD_PRIO_PROTECT : constant := 2;
467
+ PTHREAD_PRIO_INHERIT : constant := 1;
469
+ -- From: /usr/include/pthread/pthread.h
470
+ function pthread_mutexattr_setprotocol
471
+ (attr : access pthread_mutexattr_t;
472
+ protocol : int) return int;
473
+ pragma Import (C, pthread_mutexattr_setprotocol,
474
+ "pthread_mutexattr_setprotocol");
476
+ function pthread_mutexattr_getprotocol
477
+ (attr : access pthread_mutexattr_t;
478
+ protocol : access int) return int;
479
+ pragma Import (C, pthread_mutexattr_getprotocol,
480
+ "pthread_mutexattr_getprotocol");
482
+ function pthread_mutexattr_setprioceiling
483
+ (attr : access pthread_mutexattr_t;
484
+ prioceiling : int) return int;
485
+ pragma Import (C, pthread_mutexattr_setprioceiling,
486
+ "pthread_mutexattr_setprioceiling");
488
+ function pthread_mutexattr_getprioceiling
489
+ (attr : access pthread_mutexattr_t;
490
+ prioceiling : access int) return int;
491
+ pragma Import (C, pthread_mutexattr_getprioceiling,
492
+ "pthread_mutexattr_getprioceiling");
494
+ type struct_sched_param is record
495
+ sched_priority : int; -- scheduling priority
497
+ pragma Convention (C, struct_sched_param);
499
+ function pthread_setschedparam
500
+ (thread : pthread_t;
502
+ param : access struct_sched_param) return int;
503
+ pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
505
+ function pthread_attr_setscope
506
+ (attr : access pthread_attr_t;
507
+ contentionscope : int) return int;
508
+ pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
510
+ function pthread_attr_getscope
511
+ (attr : access pthread_attr_t;
512
+ contentionscope : access int) return int;
513
+ pragma Import (C, pthread_attr_getscope, "pthread_attr_getscope");
515
+ function pthread_attr_setinheritsched
516
+ (attr : access pthread_attr_t;
517
+ inheritsched : int) return int;
518
+ pragma Import (C, pthread_attr_setinheritsched,
519
+ "pthread_attr_setinheritsched");
521
+ function pthread_attr_getinheritsched
522
+ (attr : access pthread_attr_t;
523
+ inheritsched : access int) return int;
524
+ pragma Import (C, pthread_attr_getinheritsched,
525
+ "pthread_attr_getinheritsched");
527
+ function pthread_attr_setschedpolicy
528
+ (attr : access pthread_attr_t;
529
+ policy : int) return int;
530
+ pragma Import (C, pthread_attr_setschedpolicy, "pthread_setschedpolicy");
532
+ function sched_yield return int;
533
+ pragma Import (C, sched_yield, "sched_yield");
535
+ ---------------------------
536
+ -- P1003.1c - Section 16 --
537
+ ---------------------------
539
+ function pthread_attr_init
540
+ (attributes : access pthread_attr_t) return int;
541
+ pragma Import (C, pthread_attr_init, "pthread_attr_init");
543
+ function pthread_attr_destroy
544
+ (attributes : access pthread_attr_t) return int;
545
+ pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
547
+ function pthread_attr_setdetachstate
548
+ (attr : access pthread_attr_t;
549
+ detachstate : int) return int;
551
+ (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
553
+ function pthread_attr_setstacksize
554
+ (attr : access pthread_attr_t;
555
+ stacksize : size_t) return int;
556
+ pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
558
+ -- From: /usr/include/pthread/pthread.h
559
+ function pthread_create
560
+ (thread : access pthread_t;
561
+ attributes : access pthread_attr_t;
562
+ start_routine : Thread_Body;
563
+ arg : System.Address) return int;
564
+ pragma Import (C, pthread_create, "pthread_create");
566
+ procedure pthread_exit (status : System.Address);
567
+ pragma Import (C, pthread_exit, "pthread_exit");
569
+ function pthread_self return pthread_t;
570
+ pragma Import (C, pthread_self, "pthread_self");
572
+ --------------------------
573
+ -- POSIX.1c Section 17 --
574
+ --------------------------
576
+ function pthread_setspecific
577
+ (key : pthread_key_t;
578
+ value : System.Address) return int;
579
+ pragma Import (C, pthread_setspecific, "pthread_setspecific");
581
+ function pthread_getspecific (key : pthread_key_t) return System.Address;
582
+ pragma Import (C, pthread_getspecific, "pthread_getspecific");
584
+ type destructor_pointer is access procedure (arg : System.Address);
585
+ pragma Convention (C, destructor_pointer);
587
+ function pthread_key_create
588
+ (key : access pthread_key_t;
589
+ destructor : destructor_pointer) return int;
590
+ pragma Import (C, pthread_key_create, "pthread_key_create");
592
+ -- From /usr/include/i386-gnu/bits/sched.h
594
+ CPU_SETSIZE : constant := 1_024;
596
+ type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
597
+ for bit_field'Size use CPU_SETSIZE;
598
+ pragma Pack (bit_field);
599
+ pragma Convention (C, bit_field);
601
+ type cpu_set_t is record
604
+ pragma Convention (C, cpu_set_t);
606
+ -- function pthread_setaffinity_np
607
+ -- (thread : pthread_t;
608
+ -- cpusetsize : size_t;
609
+ -- cpuset : access cpu_set_t) return int;
610
+ -- pragma Import (C, pthread_setaffinity_np,
611
+ -- "__gnat_pthread_setaffinity_np");
615
+ type sigset_t is array (1 .. 4) of unsigned;
618
+ -- In GNU/Hurd the component sa_handler turns out to
619
+ -- be one a union type, and the selector is a macro:
620
+ -- #define sa_handler __sigaction_handler.sa_handler
621
+ -- #define sa_sigaction __sigaction_handler.sa_sigaction
623
+ -- In FreeBSD the component sa_handler turns out to
624
+ -- be one a union type, and the selector is a macro:
625
+ -- #define sa_handler __sigaction_u._handler
626
+ -- #define sa_sigaction __sigaction_u._sigaction
628
+ -- Should we add a signal_context type here ?
629
+ -- How could it be done independent of the CPU architecture ?
630
+ -- sigcontext type is opaque, so it is architecturally neutral.
631
+ -- It is always passed as an access type, so define it as an empty record
632
+ -- since the contents are not used anywhere.
633
+ type struct_sigcontext is null record;
634
+ pragma Convention (C, struct_sigcontext);
636
+ type pid_t is new int;
638
+ type time_t is new long;
640
+ type timespec is record
644
+ pragma Convention (C, timespec);
646
+ type clockid_t is new int;
647
+ CLOCK_REALTIME : constant clockid_t := 0;
649
+ -- From: /usr/include/pthread/pthreadtypes.h:
650
+ -- typedef struct __pthread_attr pthread_attr_t;
651
+ -- /usr/include/bits/thread-attr.h: struct __pthread_attr...
652
+ -- /usr/include/pthread/pthreadtypes.h: enum __pthread_contentionscope
653
+ -- enum __pthread_detachstate detachstate;
654
+ -- enum __pthread_inheritsched inheritsched;
655
+ -- enum __pthread_contentionscope contentionscope;
656
+ -- Not used: schedpolicy : int;
657
+ type pthread_attr_t is record
658
+ schedparam : struct_sched_param;
659
+ stackaddr : System.Address;
660
+ stacksize : size_t;
661
+ guardsize : size_t;
663
+ inheritsched : int;
664
+ contentionscope : int;
667
+ pragma Convention (C, pthread_attr_t);
669
+ -- From: /usr/include/pthread/pthreadtypes.h:
670
+ -- typedef struct __pthread_condattr pthread_condattr_t;
671
+ -- From: /usr/include/bits/condition-attr.h:
672
+ -- struct __pthread_condattr {
673
+ -- enum __pthread_process_shared pshared;
674
+ -- __Clockid_T Clock;}
675
+ -- From: /usr/include/pthread/pthreadtypes.h:
676
+ -- enum __pthread_process_shared
677
+ type pthread_condattr_t is record
681
+ pragma Convention (C, pthread_condattr_t);
683
+ -- From: /usr/include/pthread/pthreadtypes.h:
684
+ -- typedef struct __pthread_mutexattr pthread_mutexattr_t; and
685
+ -- /usr/include/bits/mutex-attr.h
686
+ -- struct __pthread_mutexattr {
687
+ -- Int Prioceiling;
688
+ -- Enum __Pthread_Mutex_Protocol Protocol;
689
+ -- Enum __Pthread_Process_Shared Pshared;
690
+ -- Enum __Pthread_Mutex_Type Mutex_Type;};
691
+ type pthread_mutexattr_t is record
697
+ pragma Convention (C, pthread_mutexattr_t);
699
+ -- From: /usr/include/pthread/pthreadtypes.h
700
+ -- typedef struct __pthread_mutex pthread_mutex_t; and
701
+ -- /usr/include/bits/mutex.h:
702
+ -- struct __pthread_mutex {
703
+ -- __pthread_spinlock_t __held;
704
+ -- __pthread_spinlock_t __lock;
705
+ -- /* in cthreads, mutex_init does not initialized the third
706
+ -- pointer, as such, we cannot rely on its value for anything. */
707
+ -- char *cthreadscompat1;
708
+ -- struct __pthread *__queue;
709
+ -- struct __pthread_mutexattr *attr;
711
+ -- /* up to this point, we are completely compatible with cthreads
712
+ -- and what libc expects. */
715
+ -- /* if null then the default attributes apply. */
717
+ type pthread_mutex_t is record
720
+ cthreadcompat : System.Address;
721
+ queue : System.Address;
722
+ attr : System.Address;
723
+ data : System.Address;
724
+ owner : System.Address;
727
+ pragma Convention (C, pthread_mutex_t);
729
+ -- type pthread_mutex_t_ptr is access pthread_mutex_t;
731
+ -- From: /usr/include/pthread/pthreadtypes.h:
732
+ -- typedef struct __pthread_cond pthread_cond_t;
733
+ -- typedef struct __pthread_condattr pthread_condattr_t;
734
+ -- /usr/include/bits/condition.h:struct __pthread_cond{}
735
+ -- pthread_condattr_t: see above!
736
+ -- /usr/include/bits/condition.h: struct __pthread_condimpl *__impl;
738
+ type pthread_cond_t is record
740
+ queue : System.Address;
741
+ condattr : System.Address;
742
+ impl : System.Address;
743
+ data : System.Address;
745
+ pragma Convention (C, pthread_cond_t);
747
+ -- From: /usr/include/pthread/pthreadtypes.h:
748
+ -- typedef __pthread_key pthread_key_t; and
749
+ -- /usr/include/bits/thread-specific.h:
750
+ -- typedef int __pthread_key;
751
+ type pthread_key_t is new int;
753
+end System.OS_Interface;