OSDN Git Service

optimize
[pf3gnuchains/gcc-fork.git] / gcc / ada / s-osinte-irix-athread.ads
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                 GNU ADA 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-2004, Free Software Foundation, Inc.      --
11 --                                                                          --
12 -- GNARL 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 2,  or (at your option) any later ver- --
15 -- sion. GNARL 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.  See the GNU General Public License --
18 -- for  more details.  You should have  received  a copy of the GNU General --
19 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
20 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
21 -- MA 02111-1307, USA.                                                      --
22 --                                                                          --
23 -- As a special exception,  if other files  instantiate  generics from this --
24 -- unit, or you link  this unit with other files  to produce an executable, --
25 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
26 -- covered  by the  GNU  General  Public  License.  This exception does not --
27 -- however invalidate  any other reasons why  the executable file  might be --
28 -- covered by the  GNU Public License.                                      --
29 --                                                                          --
30 -- GNARL was developed by the GNARL team at Florida State University.       --
31 -- Extensive contributions were provided by Ada Core Technologies, Inc.     --
32 --                                                                          --
33 ------------------------------------------------------------------------------
34
35 --  This is an Irix (old pthread library) version of this package
36
37 --  This package encapsulates all direct interfaces to OS services
38 --  that are needed by children of System.
39
40 --  PLEASE DO NOT add any with-clauses to this package or remove the pragma
41 --  Preelaborate. This package is designed to be a bottom-level (leaf) package.
42
43 with Interfaces;
44 with Interfaces.C;
45 with Interfaces.C.Strings;
46 with Unchecked_Conversion;
47
48 package System.OS_Interface is
49
50    pragma Preelaborate;
51
52    pragma Linker_Options ("-lathread");
53
54    subtype int            is Interfaces.C.int;
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;
63    subtype chars_ptr      is Interfaces.C.Strings.chars_ptr;
64
65    -----------
66    -- Errno --
67    -----------
68
69    function errno return int;
70    pragma Import (C, errno, "__get_errno");
71
72    EINTR     : constant := 4;   --  interrupted system call
73    EAGAIN    : constant := 11;  --  No more processes
74    ENOMEM    : constant := 12;  --  Not enough core
75    EINVAL    : constant := 22;  --  Invalid argument
76    ETIMEDOUT : constant := 145; --  Connection timed out
77
78    -------------
79    -- Signals --
80    -------------
81
82    Max_Interrupt : constant := 64;
83    type Signal is new int range 0 .. Max_Interrupt;
84    for Signal'Size use int'Size;
85
86    SIGHUP     : constant := 1; --  hangup
87    SIGINT     : constant := 2; --  interrupt (rubout)
88    SIGQUIT    : constant := 3; --  quit (ASCD FS)
89    SIGILL     : constant := 4; --  illegal instruction (not reset)
90    SIGTRAP    : constant := 5; --  trace trap (not reset)
91    SIGIOT     : constant := 6; --  IOT instruction
92    SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the
93    --                              future
94    SIGEMT     : constant := 7; --  EMT instruction
95    SIGFPE     : constant := 8; --  floating point exception
96    SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
97    SIGBUS     : constant := 10; --  bus error
98    SIGSEGV    : constant := 11; --  segmentation violation
99    SIGSYS     : constant := 12; --  bad argument to system call
100    SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
101    SIGALRM    : constant := 14; --  alarm clock
102    SIGTERM    : constant := 15; --  software termination signal from kill
103    SIGUSR1    : constant := 16; --  user defined signal 1
104    SIGUSR2    : constant := 17; --  user defined signal 2
105    SIGCLD     : constant := 18; --  alias for SIGCHLD
106    SIGCHLD    : constant := 18; --  child status change
107    SIGPWR     : constant := 19; --  power-fail restart
108    SIGWINCH   : constant := 20; --  window size change
109    SIGURG     : constant := 21; --  urgent condition on IO channel
110    SIGPOLL    : constant := 22; --  pollable event occurred
111    SIGIO      : constant := 22; --  I/O possible (Solaris SIGPOLL alias)
112    SIGSTOP    : constant := 23; --  stop (cannot be caught or ignored)
113    SIGTSTP    : constant := 24; --  user stop requested from tty
114    SIGCONT    : constant := 25; --  stopped process has been continued
115    SIGTTIN    : constant := 26; --  background tty read attempted
116    SIGTTOU    : constant := 27; --  background tty write attempted
117    SIGVTALRM  : constant := 28; --  virtual timer expired
118    SIGPROF    : constant := 29; --  profiling timer expired
119    SIGXCPU    : constant := 30; --  CPU time limit exceeded
120    SIGXFSZ    : constant := 31; --  filesize limit exceeded
121    SIGK32     : constant := 32; --  reserved for kernel (IRIX)
122    SIGCKPT    : constant := 33; --  Checkpoint warning
123    SIGRESTART : constant := 34; --  Restart warning
124    SIGUME     : constant := 35; --  Uncorrectable memory error
125    --  Signals defined for Posix 1003.1c.
126    SIGPTINTR    : constant := 47;
127    SIGPTRESCHED : constant := 48;
128    --  Posix 1003.1b signals
129    SIGRTMIN   : constant := 49; --  Posix 1003.1b signals
130    SIGRTMAX   : constant := 64; --  Posix 1003.1b signals
131
132    type sigset_t is private;
133    type sigset_t_ptr is access all sigset_t;
134
135    function sigaddset (set : access sigset_t; sig : Signal) return int;
136    pragma Import (C, sigaddset, "sigaddset");
137
138    function sigdelset (set : access sigset_t; sig : Signal) return int;
139    pragma Import (C, sigdelset, "sigdelset");
140
141    function sigfillset (set : access sigset_t) return int;
142    pragma Import (C, sigfillset, "sigfillset");
143
144    function sigismember (set : access sigset_t; sig : Signal) return int;
145    pragma Import (C, sigismember, "sigismember");
146
147    function sigemptyset (set : access sigset_t) return int;
148    pragma Import (C, sigemptyset, "sigemptyset");
149
150    type siginfo_t is record
151       si_signo     : int;
152       si_code      : int;
153       si_errno     : int;
154       bit_field_substitute_1 : String (1 .. 116);
155    end record;
156    pragma Convention (C, siginfo_t);
157
158    type array_type_2 is array (Integer range 0 .. 1) of int;
159    type struct_sigaction is record
160       sa_flags     : int;
161       sa_handler   : System.Address;
162       sa_mask      : sigset_t;
163       sa_resv      : array_type_2;
164    end record;
165    pragma Convention (C, struct_sigaction);
166    type struct_sigaction_ptr is access all struct_sigaction;
167
168    SIG_BLOCK   : constant := 1;
169    SIG_UNBLOCK : constant := 2;
170    SIG_SETMASK : constant := 3;
171
172    SIG_DFL : constant := 0;
173    SIG_IGN : constant := 1;
174
175    function sigaction
176      (sig  : Signal;
177       act  : struct_sigaction_ptr;
178       oact : struct_sigaction_ptr := null) return int;
179    pragma Import (C, sigaction, "sigaction");
180
181    ----------
182    -- Time --
183    ----------
184
185    type time_t is new int;
186
187    type timespec is record
188       tv_sec  : time_t;
189       tv_nsec : long;
190    end record;
191    pragma Convention (C, timespec);
192    type timespec_ptr is access all timespec;
193
194    function To_Duration (TS : timespec) return Duration;
195    pragma Inline (To_Duration);
196
197    function To_Timespec (D : Duration) return timespec;
198    pragma Inline (To_Timespec);
199
200    type timer_t is new Integer;
201    type clockid_t is private;
202
203    CLOCK_REALTIME  : constant clockid_t;
204    CLOCK_SGI_FAST  : constant clockid_t;
205    CLOCK_SGI_CYCLE : constant clockid_t;
206
207    SGI_CYCLECNTR_SIZE : constant := 165;
208    function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
209
210    pragma Import (C, syssgi, "syssgi");
211
212    function clock_gettime
213      (clock_id : clockid_t;
214       tp       : access timespec) return int;
215    pragma Import (C, clock_gettime, "clock_gettime");
216
217    function clock_getres
218      (clock_id : clockid_t; tp : access timespec) return int;
219    pragma Import (C, clock_getres, "clock_getres");
220
221    type struct_timeval is record
222       tv_sec  : time_t;
223       tv_usec : time_t;
224    end record;
225    pragma Convention (C, struct_timeval);
226
227    function To_Duration (TV : struct_timeval) return Duration;
228    pragma Inline (To_Duration);
229
230    function To_Timeval (D : Duration) return struct_timeval;
231    pragma Inline (To_Timeval);
232
233    function gettimeofday
234      (tv : access struct_timeval;
235       tz : System.Address := System.Null_Address) return int;
236    pragma Import (C, gettimeofday, "gettimeofday");
237
238    -------------------------
239    -- Priority Scheduling --
240    -------------------------
241
242    SCHED_FIFO  : constant := 0;
243    SCHED_RR    : constant := 0;
244    SCHED_OTHER : constant := 0;
245
246    -------------
247    -- Process --
248    -------------
249
250    type pid_t is private;
251
252    function kill (pid : pid_t; sig : Signal) return int;
253    pragma Import (C, kill, "kill");
254
255    function getpid return pid_t;
256    pragma Import (C, getpid, "getpid");
257
258    ---------------------------------------
259    -- Nonstandard Thread Initialization --
260    ---------------------------------------
261
262    procedure pthread_init;
263    pragma Inline (pthread_init);
264    --  This is a dummy procedure to share some GNULLI files
265
266    -------------
267    -- Threads --
268    -------------
269
270    type Thread_Body is access
271      function (arg : System.Address) return System.Address;
272
273    function Thread_Body_Access is new
274      Unchecked_Conversion (System.Address, Thread_Body);
275
276    type pthread_t           is private; --   thread identifier
277    subtype Thread_Id        is pthread_t;
278
279    type pthread_mutex_t     is private; --   mutex identifier
280    type pthread_cond_t      is private; --   cond identifier
281    type pthread_attr_t      is private; --   pthread attributes
282    type pthread_mutexattr_t is private; --   mutex attributes
283    type pthread_condattr_t  is private; --   mutex attributes
284    type sem_t               is private; --   semaphore identifier
285    type pthread_key_t       is private; --   per thread key
286
287    subtype pthread_once_t   is int;     --   dynamic package initialization
288    subtype resource_t       is long;    --   sproc. resource info.
289    type start_addr is access function (arg : Address) return Address;
290    type sproc_start_addr is access function (arg : Address) return int;
291    type callout_addr is
292      access function (arg : Address; arg1 : Address) return Address;
293
294    --  SGI specific types
295
296    subtype sproc_t      is Address; --   sproc identifier
297    subtype sproc_attr_t is Address; --   sproc attributes
298
299    subtype spcb_p is Address;
300    subtype ptcb_p is Address;
301
302    --  Pthread Error Types
303
304    FUNC_OK  : constant := 0;
305    FUNC_ERR : constant := -1;
306
307    --  pthread run-time initialization data structure
308
309    type pthread_init_struct is record
310       conf_initsize       : int; --  shared area size
311       max_sproc_count     : int; --  maximum number of sprocs
312       sproc_stack_size    : size_t;  --  sproc stack size
313       os_default_priority : int; --  default IRIX pri for main process
314       os_sched_signal     : int; --  default OS scheduling signal
315       guard_pages         : int; --  number of guard pages per stack
316       init_sproc_count    : int; --  initial number of sprocs
317    end record;
318
319    --
320    --  Pthread Attribute Initialize / Destroy
321    --
322
323    function pthread_attr_init (attr : access pthread_attr_t) return int;
324    pragma Import (C, pthread_attr_init, "pthread_attr_init");
325
326    function pthread_attr_destroy (attr : access pthread_attr_t) return int;
327    pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
328
329    --
330    --  Thread Attributes
331    --
332
333    function pthread_attr_setstacksize
334      (attr : access pthread_attr_t; stacksize : size_t) return int;
335    pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
336
337    function pthread_attr_setdetachstate
338      (attr : access pthread_attr_t; detachstate : int) return int;
339    pragma Import (C, pthread_attr_setdetachstate);
340
341    function pthread_attr_setname
342      (attr : access pthread_attr_t; name : chars_ptr) return int;
343    pragma Import (C, pthread_attr_setname, "pthread_attr_setname");
344
345    --
346    --  Thread Scheduling Attributes
347    --
348
349    function pthread_attr_setscope
350      (attr : access pthread_attr_t; contentionscope : int) return int;
351    pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
352
353    function pthread_attr_setinheritsched
354      (attr : access pthread_attr_t; inherit : int) return int;
355    pragma Import
356      (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
357
358    function pthread_attr_setsched
359      (attr : access pthread_attr_t; scheduler : int) return int;
360    pragma Import (C, pthread_attr_setsched, "pthread_attr_setsched");
361
362    function  pthread_attr_setprio
363      (attr : access pthread_attr_t; priority : int) return int;
364    pragma Import (C, pthread_attr_setprio, "pthread_attr_setprio");
365
366    --
367    --  SGI Extensions to Thread Attributes
368    --
369
370    --  Bound to sproc attribute values
371
372    PTHREAD_BOUND     : constant := 1;
373    PTHREAD_NOT_BOUND : constant := 0;
374
375    function pthread_attr_setresources
376      (attr : access pthread_attr_t; resources : resource_t) return int;
377    pragma Import (C, pthread_attr_setresources, "pthread_attr_setresources");
378
379    function pthread_attr_set_boundtosproc
380      (attr : access pthread_attr_t; bound_to_sproc : int) return int;
381    pragma Import
382      (C, pthread_attr_set_boundtosproc, "pthread_attr_set_boundtosproc");
383
384    function pthread_attr_set_bsproc
385      (attr : access pthread_attr_t; bsproc : spcb_p) return int;
386    pragma Import (C, pthread_attr_set_bsproc, "pthread_attr_set_bsproc");
387
388    function pthread_attr_set_tslice
389      (attr        : access pthread_attr_t;
390       ts_interval : access struct_timeval) return int;
391    pragma Import (C, pthread_attr_set_tslice, "pthread_attr_set_tslice");
392
393    --
394    --  Thread Creation & Management
395    --
396
397    function pthread_create
398      (thread        : access pthread_t;
399       attr          : access pthread_attr_t;
400       start_routine : start_addr;
401       arg           : Address) return int;
402    pragma Import (C, pthread_create, "pthread_create");
403
404    procedure pthread_exit (status : Address);
405    pragma Import (C, pthread_exit, "pthread_exit");
406
407    procedure pthread_yield (arg : Address := System.Null_Address);
408    pragma Import (C, pthread_yield, "pthread_yield");
409
410    function pthread_self return pthread_t;
411    pragma Import (C, pthread_self, "pthread_self");
412
413    function pthread_kill (thread : pthread_t; sig : int) return int;
414    pragma Import (C, pthread_kill, "pthread_kill");
415
416    --
417    --  SGI Extensions to POSIX thread operations
418    --
419
420    function pthread_setprio (thread : pthread_t; priority : int) return int;
421    pragma Import (C, pthread_setprio, "pthread_setprio");
422
423    function pthread_suspend (thread : pthread_t) return int;
424    pragma Import (C, pthread_suspend, "pthread_suspend");
425
426    function pthread_resume (thread : pthread_t) return int;
427    pragma Import (C, pthread_resume, "pthread_resume");
428
429    function pthread_get_current_ada_tcb return Address;
430    pragma Import (C, pthread_get_current_ada_tcb);
431
432    function pthread_set_ada_tcb
433      (thread : pthread_t; data : Address) return int;
434    pragma Import (C, pthread_set_ada_tcb, "pthread_set_ada_tcb");
435
436    --  Mutex Initialization / Destruction
437
438    function pthread_mutexattr_init
439      (attr : access pthread_mutexattr_t) return int;
440    pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
441
442    function pthread_mutexattr_destroy
443      (attr : access pthread_mutexattr_t) return int;
444    pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
445
446    function pthread_mutexattr_setqueueorder
447      (attr : access pthread_mutexattr_t; order : int) return int;
448    pragma Import (C, pthread_mutexattr_setqueueorder);
449
450    function pthread_mutexattr_setceilingprio
451      (attr : access pthread_mutexattr_t; priority : int) return int;
452    pragma Import (C, pthread_mutexattr_setceilingprio);
453
454    --  Mutex Attributes
455
456    --  Threads queueing order
457
458    MUTEX_PRIORITY         : constant := 0; --   wait in priority order
459    MUTEX_FIFO             : constant := 1; --   first-in-first-out
460    MUTEX_PRIORITY_INHERIT : constant := 2; --   priority inhertance mutex
461    MUTEX_PRIORITY_CEILING : constant := 3; --   priority ceiling mutex
462
463    --  Mutex debugging options
464
465    MUTEX_NO_DEBUG  : constant := 0; --   no debugging on mutex
466    MUTEX_DEBUG     : constant := 1; --   debugging is on
467
468    --  Mutex spin on lock operations
469
470    MUTEX_NO_SPIN   : constant := 0;  --   no spin, try once only
471    MUTEX_SPIN_ONLY : constant := -1; --   spin forever
472    --  cnt > 0, limited spin
473    --  Mutex sharing attributes
474
475    MUTEX_SHARED    : constant := 0; --   shared between processes
476    MUTEX_NOTSHARED : constant := 1; --   not shared between processes
477
478    --  Mutex Operations
479
480    function pthread_mutex_init
481      (mutex : access pthread_mutex_t;
482       attr  : access pthread_mutexattr_t) return int;
483    pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
484
485    function pthread_mutex_destroy
486      (mutex : access pthread_mutex_t) return int;
487    pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
488
489    function pthread_mutex_lock
490      (mutex : access pthread_mutex_t) return int;
491    pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
492
493    function pthread_mutex_unlock
494      (mutex : access pthread_mutex_t) return int;
495    pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
496
497    --  Condition Initialization / Destruction
498
499    function pthread_condattr_init
500      (attr : access pthread_condattr_t) return int;
501    pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
502
503    function pthread_condattr_destroy
504      (attr : access pthread_condattr_t) return int;
505    pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
506
507    --  Condition Attributes
508
509    COND_PRIORITY  : constant := 0; --   wait in priority order
510    COND_FIFO      : constant := 1; --   first-in-first-out
511
512    --  Condition debugging options
513
514    COND_NO_DEBUG  : constant := 0; --   no debugging on mutex
515    COND_DEBUG     : constant := 1; --   debugging is on
516
517    --  Condition sharing attributes
518
519    COND_SHARED    : constant := 0; --   shared between processes
520    COND_NOTSHARED : constant := 1; --   not shared between processes
521
522    --  Condition Operations
523
524    function pthread_cond_init
525      (cond : access pthread_cond_t;
526       attr : access pthread_condattr_t) return int;
527    pragma Import (C, pthread_cond_init, "pthread_cond_init");
528
529    function pthread_cond_destroy
530      (cond : access pthread_cond_t) return int;
531    pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
532
533    function pthread_cond_signal (cond : access pthread_cond_t) return int;
534    pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
535
536    function pthread_cond_wait
537      (cond  : access pthread_cond_t;
538       mutex : access pthread_mutex_t) return int;
539    pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
540
541    function pthread_cond_timedwait
542      (cond    : access pthread_cond_t;
543       mutex   : access pthread_mutex_t;
544       abstime : access struct_timeval) return int;
545    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
546
547    --  Thread-Specific Data
548
549    type foo_h_proc_1 is access procedure (value : Address);
550
551    function pthread_key_create
552      (key : access pthread_key_t; destructor : foo_h_proc_1) return int;
553    pragma Import (C, pthread_key_create, "pthread_key_create");
554
555    function pthread_setspecific
556      (key : pthread_key_t; value : Address) return int;
557    pragma Import (C, pthread_setspecific, "pthread_setspecific");
558
559    function pthread_getspecific
560      (key : pthread_key_t; value : access Address) return int;
561    pragma Import (C, pthread_getspecific, "pthread_getspecific");
562
563    type foo_h_proc_2 is access procedure;
564
565    function pthread_exec_begin (init : access pthread_init_struct) return int;
566    pragma Import (C, pthread_exec_begin, "pthread_exec_begin");
567
568    function sproc_create
569      (sproc_id      : access sproc_t;
570       attr          : access sproc_attr_t;
571       start_routine : sproc_start_addr;
572       arg           : Address) return int;
573    pragma Import (C, sproc_create, "sproc_create");
574
575    function sproc_self return sproc_t;
576    pragma Import (C, sproc_self, "sproc_self");
577
578    --  if equal fast TRUE is returned - common case
579    --  if not equal thread resource must NOT be null in order to compare bits
580
581    --
582    --  Sproc attribute initialize / destroy
583    --
584
585    function sproc_attr_init (attr : access sproc_attr_t) return int;
586    pragma Import (C, sproc_attr_init, "sproc_attr_init");
587
588    function sproc_attr_destroy (attr : access sproc_attr_t) return int;
589    pragma Import (C, sproc_attr_destroy, "sproc_attr_destroy");
590
591    function sproc_attr_setresources
592      (attr : access sproc_attr_t; resources : resource_t) return int;
593    pragma Import (C, sproc_attr_setresources, "sproc_attr_setresources");
594
595    function sproc_attr_getresources
596      (attr      : access sproc_attr_t;
597       resources : access resource_t) return int;
598    pragma Import (C, sproc_attr_getresources, "sproc_attr_getresources");
599
600    function sproc_attr_setcpu
601      (attr : access sproc_attr_t; cpu_num : int) return int;
602    pragma Import (C, sproc_attr_setcpu, "sproc_attr_setcpu");
603
604    function sproc_attr_getcpu
605      (attr : access sproc_attr_t; cpu_num : access int) return int;
606    pragma Import (C, sproc_attr_getcpu, "sproc_attr_getcpu");
607
608    function sproc_attr_setresident
609      (attr : access sproc_attr_t; resident : int) return int;
610    pragma Import (C, sproc_attr_setresident, "sproc_attr_setresident");
611
612    function sproc_attr_getresident
613      (attr : access sproc_attr_t; resident : access int) return int;
614    pragma Import (C, sproc_attr_getresident, "sproc_attr_getresident");
615
616    function sproc_attr_setname
617      (attr : access sproc_attr_t; name : chars_ptr) return int;
618    pragma Import (C, sproc_attr_setname, "sproc_attr_setname");
619
620    function sproc_attr_getname
621      (attr : access sproc_attr_t; name : chars_ptr) return int;
622    pragma Import (C, sproc_attr_getname, "sproc_attr_getname");
623
624    function sproc_attr_setstacksize
625      (attr : access sproc_attr_t; stacksize : size_t) return int;
626    pragma Import (C, sproc_attr_setstacksize, "sproc_attr_setstacksize");
627
628    function sproc_attr_getstacksize
629      (attr : access sproc_attr_t; stacksize : access size_t) return int;
630    pragma Import (C, sproc_attr_getstacksize, "sproc_attr_getstacksize");
631
632    function sproc_attr_setprio
633      (attr : access sproc_attr_t; priority : int) return int;
634    pragma Import (C, sproc_attr_setprio, "sproc_attr_setprio");
635
636    function sproc_attr_getprio
637      (attr : access sproc_attr_t; priority : access int) return int;
638    pragma Import (C, sproc_attr_getprio, "sproc_attr_getprio");
639
640    function sproc_attr_setbthread
641      (attr : access sproc_attr_t; bthread : ptcb_p) return int;
642    pragma Import (C, sproc_attr_setbthread, "sproc_attr_setbthread");
643
644    function sproc_attr_getbthread
645      (attr : access sproc_attr_t; bthread : access ptcb_p) return int;
646    pragma Import (C, sproc_attr_getbthread, "sproc_attr_getbthread");
647
648    SPROC_NO_RESOURCES : constant := 0;
649    SPROC_ANY_CPU      : constant := -1;
650    SPROC_MY_PRIORITY  : constant := -1;
651    SPROC_SWAPPED      : constant := 0;
652    SPROC_RESIDENT     : constant := 1;
653
654    type isr_address is access procedure;
655
656    function intr_attach (sig : int; isr : isr_address) return int;
657    pragma Import (C, intr_attach, "intr_attach");
658
659    Intr_Attach_Reset : constant Boolean := False;
660    --  True if intr_attach is reset after an interrupt handler is called
661
662    function intr_exchange
663      (sig  : int;
664       isr  : isr_address;
665       oisr : access isr_address) return int;
666    pragma Import (C, intr_exchange, "intr_exchange");
667
668    function intr_current_isr
669      (sig  : int;
670       oisr : access isr_address)
671      return int;
672    pragma Import (C, intr_current_isr, "intr_current_isr");
673
674 private
675
676    type clockid_t is new int;
677
678    CLOCK_REALTIME  : constant clockid_t := 1;
679    CLOCK_SGI_CYCLE : constant clockid_t := 2;
680    CLOCK_SGI_FAST  : constant clockid_t := 3;
681
682    type pthread_t           is new Address; --   thread identifier
683    type pthread_mutex_t     is new Address; --   mutex identifier
684    type pthread_cond_t      is new Address; --   cond identifier
685    type pthread_attr_t      is new Address; --   pthread attributes
686    type pthread_mutexattr_t is new Address; --   mutex attributes
687    type pthread_condattr_t  is new Address; --   mutex attributes
688    type sem_t               is new Address; --   semaphore identifier
689    type pthread_key_t       is new Address; --   per thread key
690
691    type sigbits_t is array (Integer range 0 .. 3) of unsigned;
692    type sigset_t is record
693       sigbits : sigbits_t;
694    end record;
695    pragma Convention (C, sigset_t);
696
697    type pid_t is new long;
698
699 end System.OS_Interface;