~angelsl/ubuntu/wily/gcc-5/mips-cross

« back to all changes in this revision

Viewing changes to debian/patches/ada-s-osinte-gnu.ads.diff

  • Committer: angelsl
  • Date: 2015-10-30 03:30:35 UTC
  • Revision ID: angelsl-20151030033035-rmug41zm8hyjgisg
Original import

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
3
@@ -0,0 +1,750 @@
 
4
+------------------------------------------------------------------------------
 
5
+--                                                                          --
 
6
+--                GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS               --
 
7
+--                                                                          --
 
8
+--                   S Y S T E M . O S _ I N T E R F A C E                  --
 
9
+--                                                                          --
 
10
+--                                  S p e c                                 --
 
11
+--                                                                          --
 
12
+--             Copyright (C) 1991-1994, Florida State University            --
 
13
+--          Copyright (C) 1995-2011, Free Software Foundation, Inc.         --
 
14
+--                                                                          --
 
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.                                              --
 
25
+--                                                                          --
 
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.                                      --
 
32
+--                                                                          --
 
33
+-- GNARL was developed by the GNARL team at Florida State University.       --
 
34
+-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
 
35
+--                                                                          --
 
36
+------------------------------------------------------------------------------
 
37
+
 
38
+--  This is the GNU/Hurd version of this package
 
39
+
 
40
+--  This package encapsulates all direct interfaces to OS services
 
41
+--  that are needed by children of System.
 
42
+
 
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
 
45
+
 
46
+with Interfaces.C;
 
47
+with Unchecked_Conversion;
 
48
+
 
49
+package System.OS_Interface is
 
50
+   pragma Preelaborate;
 
51
+
 
52
+   pragma Linker_Options ("-lpthread");
 
53
+   pragma Linker_Options ("-lrt");
 
54
+
 
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;
 
65
+
 
66
+   -----------
 
67
+   -- Errno --
 
68
+   -----------
 
69
+   --  From /usr/include/i386-gnu/bits/errno.h
 
70
+
 
71
+   function errno return int;
 
72
+   pragma Import (C, errno, "__get_errno");
 
73
+
 
74
+   EAGAIN   : constant := 1073741859;
 
75
+   EINTR    : constant := 1073741828;
 
76
+   EINVAL   : constant := 1073741846;
 
77
+   ENOMEM   : constant := 1073741836;
 
78
+   EPERM    : constant := 1073741825;
 
79
+   ETIMEDOUT    : constant := 1073741884;
 
80
+
 
81
+   -------------
 
82
+   -- Signals --
 
83
+   -------------
 
84
+   --  From /usr/include/i386-gnu/bits/signum.h
 
85
+
 
86
+   Max_Interrupt : constant := 32;
 
87
+   type Signal is new int range 0 .. Max_Interrupt;
 
88
+   for Signal'Size use int'Size;
 
89
+
 
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
 
128
+
 
129
+   SIGADAABORT : constant := SIGABRT;
 
130
+   --  Change this if you want to use another signal for task abort.
 
131
+   --  SIGTERM might be a good one.
 
132
+
 
133
+   type Signal_Set is array (Natural range <>) of Signal;
 
134
+
 
135
+   Unmasked    : constant Signal_Set := (
 
136
+      SIGTRAP,
 
137
+      --  To enable debugging on multithreaded applications, mark SIGTRAP to
 
138
+      --  be kept unmasked.
 
139
+
 
140
+      SIGBUS,
 
141
+
 
142
+      SIGTTIN, SIGTTOU, SIGTSTP,
 
143
+      --  Keep these three signals unmasked so that background processes
 
144
+      --  and IO behaves as normal "C" applications
 
145
+
 
146
+      SIGPROF,
 
147
+      --  To avoid confusing the profiler
 
148
+
 
149
+      SIGKILL, SIGSTOP);
 
150
+      --  These two signals actually cannot be masked;
 
151
+      --  POSIX simply won't allow it.
 
152
+
 
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);
 
157
+
 
158
+   type sigset_t is private;
 
159
+
 
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");
 
163
+
 
164
+   function sigdelset (set : access sigset_t; sig : Signal) return int;
 
165
+   pragma Import (C, sigdelset, "sigdelset");
 
166
+
 
167
+   function sigfillset (set : access sigset_t) return int;
 
168
+   pragma Import (C, sigfillset, "sigfillset");
 
169
+
 
170
+   function sigismember (set : access sigset_t; sig : Signal) return int;
 
171
+   pragma Import (C, sigismember, "sigismember");
 
172
+
 
173
+   function sigemptyset (set : access sigset_t) return int;
 
174
+   pragma Import (C, sigemptyset, "sigemptyset");
 
175
+
 
176
+   --  sigcontext is architecture dependent, so define it private
 
177
+   type struct_sigcontext is private;
 
178
+
 
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;
 
183
+      sa_flags   : int;
 
184
+   end record;
 
185
+   pragma Convention (C, struct_sigaction);
 
186
+
 
187
+   type struct_sigaction_ptr is access all struct_sigaction;
 
188
+
 
189
+   --  From /usr/include/i386-gnu/bits/sigaction.h
 
190
+   SIG_BLOCK   : constant := 1;
 
191
+   SIG_UNBLOCK : constant := 2;
 
192
+   SIG_SETMASK : constant := 3;
 
193
+
 
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;
 
199
+
 
200
+   --  From /usr/include/i386-gnu/bits/sigaction.h
 
201
+   SA_SIGINFO : constant := 16#0040#;
 
202
+   SA_ONSTACK : constant := 16#0001#;
 
203
+
 
204
+   function sigaction
 
205
+     (sig  : Signal;
 
206
+      act  : struct_sigaction_ptr;
 
207
+      oact : struct_sigaction_ptr) return int;
 
208
+   pragma Import (C, sigaction, "sigaction");
 
209
+
 
210
+   ----------
 
211
+   -- Time --
 
212
+   ----------
 
213
+
 
214
+   Time_Slice_Supported : constant Boolean := True;
 
215
+   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
 
216
+
 
217
+   type timespec is private;
 
218
+
 
219
+   function nanosleep (rqtp, rmtp : access timespec) return int;
 
220
+   pragma Import (C, nanosleep, "nanosleep");
 
221
+
 
222
+   type clockid_t is private;
 
223
+
 
224
+   CLOCK_REALTIME : constant clockid_t;
 
225
+
 
226
+   --  From: /usr/include/time.h
 
227
+   function clock_gettime
 
228
+     (clock_id : clockid_t;
 
229
+      tp       : access timespec)
 
230
+      return int;
 
231
+   pragma Import (C, clock_gettime, "clock_gettime");
 
232
+
 
233
+   function To_Duration (TS : timespec) return Duration;
 
234
+   pragma Inline (To_Duration);
 
235
+
 
236
+   function To_Timespec (D : Duration) return timespec;
 
237
+   pragma Inline (To_Timespec);
 
238
+
 
239
+   --  From: /usr/include/unistd.h
 
240
+   function sysconf (name : int) return long;
 
241
+   pragma Import (C, sysconf);
 
242
+
 
243
+   --  From /usr/include/i386-gnu/bits/confname.h
 
244
+   SC_CLK_TCK          : constant := 2;
 
245
+   SC_NPROCESSORS_ONLN : constant := 84;
 
246
+
 
247
+   -------------------------
 
248
+   -- Priority Scheduling --
 
249
+   -------------------------
 
250
+   --  From /usr/include/i386-gnu/bits/sched.h
 
251
+
 
252
+   SCHED_OTHER : constant := 0;
 
253
+   SCHED_FIFO  : constant := 1;
 
254
+   SCHED_RR    : constant := 2;
 
255
+
 
256
+   function To_Target_Priority
 
257
+     (Prio : System.Any_Priority) return Interfaces.C.int;
 
258
+   --  Maps System.Any_Priority to a POSIX priority.
 
259
+
 
260
+   -------------
 
261
+   -- Process --
 
262
+   -------------
 
263
+
 
264
+   type pid_t is private;
 
265
+
 
266
+   --  From: /usr/include/signal.h
 
267
+   function kill (pid : pid_t; sig : Signal) return int;
 
268
+   pragma Import (C, kill, "kill");
 
269
+
 
270
+   --  From: /usr/include/unistd.h
 
271
+   function getpid return pid_t;
 
272
+   pragma Import (C, getpid, "getpid");
 
273
+
 
274
+   ---------
 
275
+   -- LWP --
 
276
+   ---------
 
277
+
 
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");
 
284
+
 
285
+   -------------
 
286
+   -- Threads --
 
287
+   -------------
 
288
+
 
289
+   type Thread_Body is access
 
290
+     function (arg : System.Address) return System.Address;
 
291
+   pragma Convention (C, Thread_Body);
 
292
+
 
293
+   function Thread_Body_Access is new
 
294
+     Unchecked_Conversion (System.Address, Thread_Body);
 
295
+
 
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;
 
300
+
 
301
+   function To_pthread_t is new Unchecked_Conversion
 
302
+     (unsigned_long, pthread_t);
 
303
+
 
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;
 
310
+
 
311
+   --  From /usr/include/pthread/pthreadtypes.h
 
312
+   PTHREAD_CREATE_DETACHED : constant := 1;
 
313
+   PTHREAD_CREATE_JOINABLE : constant := 0;
 
314
+
 
315
+   PTHREAD_SCOPE_PROCESS : constant := 1;
 
316
+   PTHREAD_SCOPE_SYSTEM  : constant := 0;
 
317
+
 
318
+   -----------
 
319
+   -- Stack --
 
320
+   -----------
 
321
+
 
322
+   --  From: /usr/include/i386-gnu/bits/sigstack.h
 
323
+   type stack_t is record
 
324
+      ss_sp    : System.Address;
 
325
+      ss_size  : size_t;
 
326
+      ss_flags : int;
 
327
+   end record;
 
328
+   pragma Convention (C, stack_t);
 
329
+
 
330
+   function sigaltstack
 
331
+     (ss  : not null access stack_t;
 
332
+      oss : access stack_t) return int;
 
333
+   pragma Import (C, sigaltstack, "sigaltstack");
 
334
+
 
335
+   Alternate_Stack : aliased System.Address;
 
336
+   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
 
337
+
 
338
+   Alternate_Stack_Size : constant := 0;
 
339
+   --  No alternate signal stack is used on this platform
 
340
+
 
341
+   Stack_Base_Available : constant Boolean := False;
 
342
+   --  Indicates whether the stack base is available on this target
 
343
+
 
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.
 
348
+
 
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
 
354
+
 
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;
 
363
+
 
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);
 
367
+
 
368
+   ---------------------------------------
 
369
+   -- Nonstandard Thread Initialization --
 
370
+   ---------------------------------------
 
371
+
 
372
+   procedure pthread_init;
 
373
+   pragma Inline (pthread_init);
 
374
+   --  This is a dummy procedure to share some GNULLI files
 
375
+
 
376
+   -------------------------
 
377
+   -- POSIX.1c  Section 3 --
 
378
+   -------------------------
 
379
+
 
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");
 
384
+
 
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");
 
389
+
 
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
 
394
+     (how  : int;
 
395
+      set  : access sigset_t;
 
396
+      oset : access sigset_t) return int;
 
397
+   pragma Import (C, pthread_sigmask, "pthread_sigmask");
 
398
+
 
399
+   --------------------------
 
400
+   -- POSIX.1c  Section 11 --
 
401
+   --------------------------
 
402
+
 
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");
 
408
+
 
409
+   function pthread_mutexattr_destroy
 
410
+     (attr : access pthread_mutexattr_t) return int;
 
411
+   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
 
412
+
 
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");
 
417
+
 
418
+   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
 
419
+   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
 
420
+
 
421
+   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
 
422
+   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
 
423
+
 
424
+   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
 
425
+   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
 
426
+
 
427
+   function pthread_condattr_init
 
428
+     (attr : access pthread_condattr_t) return int;
 
429
+   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
 
430
+
 
431
+   function pthread_condattr_destroy
 
432
+     (attr : access pthread_condattr_t) return int;
 
433
+   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
 
434
+
 
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");
 
439
+
 
440
+   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
 
441
+   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
 
442
+
 
443
+   function pthread_cond_signal (cond : access pthread_cond_t) return int;
 
444
+   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
 
445
+
 
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");
 
450
+
 
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");
 
456
+
 
457
+   Relative_Timed_Wait : constant Boolean := False;
 
458
+   --  pthread_cond_timedwait requires an absolute delay time
 
459
+
 
460
+   --------------------------
 
461
+   -- POSIX.1c  Section 13 --
 
462
+   --------------------------
 
463
+   --  From /usr/include/pthread/pthreadtypes.h
 
464
+
 
465
+   PTHREAD_PRIO_NONE    : constant := 0;
 
466
+   PTHREAD_PRIO_PROTECT : constant := 2;
 
467
+   PTHREAD_PRIO_INHERIT : constant := 1;
 
468
+
 
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");
 
475
+
 
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");
 
481
+
 
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");
 
487
+
 
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");
 
493
+
 
494
+   type struct_sched_param is record
 
495
+      sched_priority : int;  --  scheduling priority
 
496
+   end record;
 
497
+   pragma Convention (C, struct_sched_param);
 
498
+
 
499
+   function pthread_setschedparam
 
500
+     (thread : pthread_t;
 
501
+      policy : int;
 
502
+      param  : access struct_sched_param) return int;
 
503
+   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
 
504
+
 
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");
 
509
+
 
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");
 
514
+
 
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");
 
520
+
 
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");
 
526
+
 
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");
 
531
+
 
532
+   function sched_yield return int;
 
533
+   pragma Import (C, sched_yield, "sched_yield");
 
534
+
 
535
+   ---------------------------
 
536
+   -- P1003.1c - Section 16 --
 
537
+   ---------------------------
 
538
+
 
539
+   function pthread_attr_init
 
540
+     (attributes : access pthread_attr_t) return int;
 
541
+   pragma Import (C, pthread_attr_init, "pthread_attr_init");
 
542
+
 
543
+   function pthread_attr_destroy
 
544
+     (attributes : access pthread_attr_t) return int;
 
545
+   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
 
546
+
 
547
+   function pthread_attr_setdetachstate
 
548
+     (attr        : access pthread_attr_t;
 
549
+      detachstate : int) return int;
 
550
+   pragma Import
 
551
+     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
 
552
+
 
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");
 
557
+
 
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");
 
565
+
 
566
+   procedure pthread_exit (status : System.Address);
 
567
+   pragma Import (C, pthread_exit, "pthread_exit");
 
568
+
 
569
+   function pthread_self return pthread_t;
 
570
+   pragma Import (C, pthread_self, "pthread_self");
 
571
+
 
572
+   --------------------------
 
573
+   -- POSIX.1c  Section 17 --
 
574
+   --------------------------
 
575
+
 
576
+   function pthread_setspecific
 
577
+     (key   : pthread_key_t;
 
578
+      value : System.Address) return int;
 
579
+   pragma Import (C, pthread_setspecific, "pthread_setspecific");
 
580
+
 
581
+   function pthread_getspecific (key : pthread_key_t) return System.Address;
 
582
+   pragma Import (C, pthread_getspecific, "pthread_getspecific");
 
583
+
 
584
+   type destructor_pointer is access procedure (arg : System.Address);
 
585
+   pragma Convention (C, destructor_pointer);
 
586
+
 
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");
 
591
+
 
592
+   --  From /usr/include/i386-gnu/bits/sched.h
 
593
+   --  1_024 == 1024??
 
594
+   CPU_SETSIZE : constant := 1_024;
 
595
+
 
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);
 
600
+
 
601
+   type cpu_set_t is record
 
602
+      bits : bit_field;
 
603
+   end record;
 
604
+   pragma Convention (C, cpu_set_t);
 
605
+
 
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");
 
612
+
 
613
+private
 
614
+
 
615
+   type sigset_t is array (1 .. 4) of unsigned;
 
616
+
 
617
+   --  FIXME:
 
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
 
622
+
 
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
 
627
+
 
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);
 
635
+
 
636
+   type pid_t is new int;
 
637
+
 
638
+   type time_t is new long;
 
639
+
 
640
+   type timespec is record
 
641
+      tv_sec  : time_t;
 
642
+      tv_nsec : long;
 
643
+   end record;
 
644
+   pragma Convention (C, timespec);
 
645
+
 
646
+   type clockid_t is new int;
 
647
+   CLOCK_REALTIME : constant clockid_t := 0;
 
648
+
 
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;
 
662
+      detachstate   : int;
 
663
+      inheritsched  : int;
 
664
+      contentionscope : int;
 
665
+      schedpolicy   : int;
 
666
+   end record;
 
667
+   pragma Convention (C, pthread_attr_t);
 
668
+
 
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
 
678
+      pshared : int;
 
679
+      clock   : clockid_t;
 
680
+   end record;
 
681
+   pragma Convention (C, pthread_condattr_t);
 
682
+
 
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
 
692
+      prioceiling : int;
 
693
+      protocol    : int;
 
694
+      pshared     : int;
 
695
+      mutex_type  : int;
 
696
+   end record;
 
697
+   pragma Convention (C, pthread_mutexattr_t);
 
698
+
 
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;
 
710
+   --  void *data;
 
711
+   --  /*  up to this point, we are completely compatible with cthreads
 
712
+   --    and what libc expects.  */
 
713
+   --    void *owner;
 
714
+   --  unsigned locks;
 
715
+   --  /* if null then the default attributes apply.  */
 
716
+   --    };
 
717
+   type pthread_mutex_t is record
 
718
+      held          : int;
 
719
+      lock          : int;
 
720
+      cthreadcompat : System.Address;
 
721
+      queue         : System.Address;
 
722
+      attr          : System.Address;
 
723
+      data          : System.Address;
 
724
+      owner         : System.Address;
 
725
+      locks         : unsigned;
 
726
+   end record;
 
727
+   pragma Convention (C, pthread_mutex_t);
 
728
+   --  pointer needed?
 
729
+   --  type pthread_mutex_t_ptr is access pthread_mutex_t;
 
730
+
 
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;
 
737
+
 
738
+   type pthread_cond_t is record
 
739
+      lock       : int;
 
740
+      queue      : System.Address;
 
741
+      condattr   : System.Address;
 
742
+      impl       : System.Address;
 
743
+      data       : System.Address;
 
744
+   end record;
 
745
+   pragma Convention (C, pthread_cond_t);
 
746
+
 
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;
 
752
+
 
753
+end System.OS_Interface;