OSDN Git Service

* configure.frag: Delete file.
[pf3gnuchains/gcc-fork.git] / gcc / ada / 5fosinte.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) 1998-2001, Free Software Foundation, Inc.         --
10 --                                                                          --
11 -- GNARL is free software; you can  redistribute it  and/or modify it under --
12 -- terms of the  GNU General Public License as published  by the Free Soft- --
13 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
17 -- for  more details.  You should have  received  a copy of the GNU General --
18 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
19 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
20 -- MA 02111-1307, USA.                                                      --
21 --                                                                          --
22 -- As a special exception,  if other files  instantiate  generics from this --
23 -- unit, or you link  this unit with other files  to produce an executable, --
24 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
25 -- covered  by the  GNU  General  Public  License.  This exception does not --
26 -- however invalidate  any other reasons why  the executable file  might be --
27 -- covered by the  GNU Public License.                                      --
28 --                                                                          --
29 -- GNARL was developed by the GNARL team at Florida State University.       --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34 --  This is the SGI Pthreads version of this package.
35
36 --  This package encapsulates all direct interfaces to OS services
37 --  that are needed by children of System.
38
39 --  PLEASE DO NOT add any with-clauses to this package
40 --  or remove the pragma Elaborate_Body.
41 --  It is designed to be a bottom-level (leaf) package.
42
43 with Interfaces.C;
44 package System.OS_Interface is
45
46    pragma Preelaborate;
47
48    pragma Linker_Options ("-lpthread");
49
50    subtype int            is Interfaces.C.int;
51    subtype short          is Interfaces.C.short;
52    subtype long           is Interfaces.C.long;
53    subtype unsigned       is Interfaces.C.unsigned;
54    subtype unsigned_short is Interfaces.C.unsigned_short;
55    subtype unsigned_long  is Interfaces.C.unsigned_long;
56    subtype unsigned_char  is Interfaces.C.unsigned_char;
57    subtype plain_char     is Interfaces.C.plain_char;
58    subtype size_t         is Interfaces.C.size_t;
59
60    -----------
61    -- Errno --
62    -----------
63
64    function errno return int;
65    pragma Import (C, errno, "__get_errno");
66
67    EINTR     : constant := 4;   --  interrupted system call
68    EAGAIN    : constant := 11;  --  No more processes
69    ENOMEM    : constant := 12;  --  Not enough core
70    EINVAL    : constant := 22;  --  Invalid argument
71    ETIMEDOUT : constant := 145; --  Connection timed out
72
73    -------------
74    -- Signals --
75    -------------
76
77    Max_Interrupt : constant := 64;
78    type Signal is new int range 0 .. Max_Interrupt;
79    for Signal'Size use int'Size;
80
81    SIGHUP     : constant := 1; --  hangup
82    SIGINT     : constant := 2; --  interrupt (rubout)
83    SIGQUIT    : constant := 3; --  quit (ASCD FS)
84    SIGILL     : constant := 4; --  illegal instruction (not reset)
85    SIGTRAP    : constant := 5; --  trace trap (not reset)
86    SIGIOT     : constant := 6; --  IOT instruction
87    SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the
88    --                              future
89    SIGEMT     : constant := 7; --  EMT instruction
90    SIGFPE     : constant := 8; --  floating point exception
91    SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
92    SIGBUS     : constant := 10; --  bus error
93    SIGSEGV    : constant := 11; --  segmentation violation
94    SIGSYS     : constant := 12; --  bad argument to system call
95    SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
96    SIGALRM    : constant := 14; --  alarm clock
97    SIGTERM    : constant := 15; --  software termination signal from kill
98    SIGUSR1    : constant := 16; --  user defined signal 1
99    SIGUSR2    : constant := 17; --  user defined signal 2
100    SIGCLD     : constant := 18; --  alias for SIGCHLD
101    SIGCHLD    : constant := 18; --  child status change
102    SIGPWR     : constant := 19; --  power-fail restart
103    SIGWINCH   : constant := 20; --  window size change
104    SIGURG     : constant := 21; --  urgent condition on IO channel
105    SIGPOLL    : constant := 22; --  pollable event occurred
106    SIGIO      : constant := 22; --  I/O possible (Solaris SIGPOLL alias)
107    SIGSTOP    : constant := 23; --  stop (cannot be caught or ignored)
108    SIGTSTP    : constant := 24; --  user stop requested from tty
109    SIGCONT    : constant := 25; --  stopped process has been continued
110    SIGTTIN    : constant := 26; --  background tty read attempted
111    SIGTTOU    : constant := 27; --  background tty write attempted
112    SIGVTALRM  : constant := 28; --  virtual timer expired
113    SIGPROF    : constant := 29; --  profiling timer expired
114    SIGXCPU    : constant := 30; --  CPU time limit exceeded
115    SIGXFSZ    : constant := 31; --  filesize limit exceeded
116    SIGK32     : constant := 32; --  reserved for kernel (IRIX)
117    SIGCKPT    : constant := 33; --  Checkpoint warning
118    SIGRESTART : constant := 34; --  Restart warning
119    SIGUME     : constant := 35; --  Uncorrectable memory error
120    --  Signals defined for Posix 1003.1c.
121    SIGPTINTR    : constant := 47;
122    SIGPTRESCHED : constant := 48;
123    --  Posix 1003.1b signals
124    SIGRTMIN   : constant := 49; --  Posix 1003.1b signals
125    SIGRTMAX   : constant := 64; --  Posix 1003.1b signals
126
127    type sigset_t is private;
128    type sigset_t_ptr is access all sigset_t;
129
130    function sigaddset (set : access sigset_t; sig : Signal) return int;
131    pragma Import (C, sigaddset, "sigaddset");
132
133    function sigdelset (set : access sigset_t; sig : Signal) return int;
134    pragma Import (C, sigdelset, "sigdelset");
135
136    function sigfillset (set : access sigset_t) return int;
137    pragma Import (C, sigfillset, "sigfillset");
138
139    function sigismember (set : access sigset_t; sig : Signal) return int;
140    pragma Import (C, sigismember, "sigismember");
141
142    function sigemptyset (set : access sigset_t) return int;
143    pragma Import (C, sigemptyset, "sigemptyset");
144
145    type array_type_2 is array (Integer range 0 .. 1) of int;
146    type struct_sigaction is record
147       sa_flags     : int;
148       sa_handler   : System.Address;
149       sa_mask      : sigset_t;
150       sa_resv      : array_type_2;
151    end record;
152    pragma Convention (C, struct_sigaction);
153
154    type struct_sigaction_ptr is access all struct_sigaction;
155
156    SIG_BLOCK   : constant := 1;
157    SIG_UNBLOCK : constant := 2;
158    SIG_SETMASK : constant := 3;
159
160    SIG_DFL : constant := 0;
161    SIG_IGN : constant := 1;
162
163    function sigaction
164      (sig  : Signal;
165       act  : struct_sigaction_ptr;
166       oact : struct_sigaction_ptr := null) return int;
167    pragma Import (C, sigaction, "sigaction");
168
169    ----------
170    -- Time --
171    ----------
172
173    type timespec is private;
174    type timespec_ptr is access all timespec;
175
176    type clockid_t is private;
177
178    CLOCK_REALTIME  : constant clockid_t;
179    CLOCK_SGI_FAST  : constant clockid_t;
180    CLOCK_SGI_CYCLE : constant clockid_t;
181
182    SGI_CYCLECNTR_SIZE : constant := 165;
183
184    function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
185    pragma Import (C, syssgi, "syssgi");
186
187    function clock_gettime
188      (clock_id : clockid_t;
189       tp       : access timespec) return int;
190    pragma Import (C, clock_gettime, "clock_gettime");
191
192    function clock_getres
193      (clock_id : clockid_t;
194       tp       : access timespec) return int;
195    pragma Import (C, clock_getres, "clock_getres");
196
197    function To_Duration (TS : timespec) return Duration;
198    pragma Inline (To_Duration);
199
200    function To_Timespec (D : Duration) return timespec;
201    pragma Inline (To_Timespec);
202
203    type struct_timeval is private;
204
205    function To_Duration (TV : struct_timeval) return Duration;
206    pragma Inline (To_Duration);
207
208    function To_Timeval (D : Duration) return struct_timeval;
209    pragma Inline (To_Timeval);
210
211    -------------------------
212    -- Priority Scheduling --
213    -------------------------
214
215    SCHED_FIFO  : constant := 1;
216    SCHED_RR    : constant := 2;
217    SCHED_TS    : constant := 3;
218    SCHED_OTHER : constant := 3;
219    SCHED_NP    : constant := 4;
220
221    function sched_get_priority_min (Policy : int) return int;
222    pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
223
224    function sched_get_priority_max (Policy : int) return int;
225    pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
226
227    -------------
228    -- Process --
229    -------------
230
231    type pid_t is private;
232
233    function kill (pid : pid_t; sig : Signal) return int;
234    pragma Import (C, kill, "kill");
235
236    function getpid return pid_t;
237    pragma Import (C, getpid, "getpid");
238
239    -------------
240    -- Threads --
241    -------------
242
243    type Thread_Body is access
244      function (arg : System.Address) return System.Address;
245    type pthread_t           is private;
246    subtype Thread_Id        is pthread_t;
247
248    type pthread_mutex_t     is limited private;
249    type pthread_cond_t      is limited private;
250    type pthread_attr_t      is limited private;
251    type pthread_mutexattr_t is limited private;
252    type pthread_condattr_t  is limited private;
253    type pthread_key_t       is private;
254
255    PTHREAD_CREATE_DETACHED : constant := 1;
256
257    ---------------------------------------
258    -- Nonstandard Thread Initialization --
259    ---------------------------------------
260
261    procedure pthread_init;
262    pragma Inline (pthread_init);
263    --  This is a dummy procedure to share some GNULLI files
264
265    -------------------------
266    -- POSIX.1c  Section 3 --
267    -------------------------
268
269    function sigwait
270      (set : access sigset_t;
271       sig : access Signal) return int;
272    pragma Import (C, sigwait, "sigwait");
273
274    function pthread_kill
275      (thread : pthread_t;
276       sig    : Signal) return int;
277    pragma Import (C, pthread_kill, "pthread_kill");
278
279    function pthread_sigmask
280      (how  : int;
281       set  : sigset_t_ptr;
282       oset : sigset_t_ptr) return int;
283    pragma Import (C, pthread_sigmask, "pthread_sigmask");
284
285    --------------------------
286    -- POSIX.1c  Section 11 --
287    --------------------------
288
289    function pthread_mutexattr_init
290      (attr : access pthread_mutexattr_t) return int;
291    pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
292
293    function pthread_mutexattr_destroy
294      (attr : access pthread_mutexattr_t) return int;
295    pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
296
297    function pthread_mutex_init
298      (mutex : access pthread_mutex_t;
299       attr  : access pthread_mutexattr_t) return int;
300    pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
301
302    function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
303    pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
304
305    function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
306    pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
307
308    function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
309    pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
310
311    function pthread_condattr_init
312      (attr : access pthread_condattr_t) return int;
313    pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
314
315    function pthread_condattr_destroy
316      (attr : access pthread_condattr_t) return int;
317    pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
318
319    function pthread_cond_init
320      (cond : access pthread_cond_t;
321       attr : access pthread_condattr_t) return int;
322    pragma Import (C, pthread_cond_init, "pthread_cond_init");
323
324    function pthread_cond_destroy (cond : access pthread_cond_t) return int;
325    pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
326
327    function pthread_cond_signal (cond : access pthread_cond_t) return int;
328    pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
329
330    function pthread_cond_wait
331      (cond  : access pthread_cond_t;
332       mutex : access pthread_mutex_t) return int;
333    pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
334
335    function pthread_cond_timedwait
336      (cond    : access pthread_cond_t;
337       mutex   : access pthread_mutex_t;
338       abstime : access timespec) return int;
339    pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
340
341    --------------------------
342    -- POSIX.1c  Section 13 --
343    --------------------------
344
345    PTHREAD_PRIO_NONE    : constant := 0;
346    PTHREAD_PRIO_PROTECT : constant := 2;
347    PTHREAD_PRIO_INHERIT : constant := 1;
348
349    function pthread_mutexattr_setprotocol
350      (attr     : access pthread_mutexattr_t;
351       protocol : int) return int;
352    pragma Import (C, pthread_mutexattr_setprotocol);
353
354    function pthread_mutexattr_setprioceiling
355      (attr     : access pthread_mutexattr_t;
356       prioceiling : int) return int;
357    pragma Import (C, pthread_mutexattr_setprioceiling);
358
359    type struct_sched_param is record
360       sched_priority : int;
361    end record;
362    pragma Convention (C, struct_sched_param);
363
364    function pthread_setschedparam
365      (thread : pthread_t;
366       policy : int;
367       param  : access struct_sched_param)
368      return int;
369    pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
370
371    function pthread_attr_setscope
372      (attr            : access pthread_attr_t;
373       contentionscope : int) return int;
374    pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
375
376    function pthread_attr_setinheritsched
377      (attr         : access pthread_attr_t;
378       inheritsched : int) return int;
379    pragma Import
380      (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
381
382    function pthread_attr_setschedpolicy
383      (attr   : access pthread_attr_t;
384       policy : int) return int;
385    pragma Import (C, pthread_attr_setschedpolicy);
386
387    function pthread_attr_setschedparam
388      (attr        : access pthread_attr_t;
389       sched_param : access struct_sched_param)
390      return int;
391    pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
392
393    function sched_yield return int;
394    pragma Import (C, sched_yield, "sched_yield");
395
396    ---------------------------
397    -- P1003.1c - Section 16 --
398    ---------------------------
399
400    function pthread_attr_init (attributes : access pthread_attr_t) return int;
401    pragma Import (C, pthread_attr_init, "pthread_attr_init");
402
403    function pthread_attr_destroy
404      (attributes : access pthread_attr_t) return int;
405    pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
406
407    function pthread_attr_setdetachstate
408      (attr        : access pthread_attr_t;
409       detachstate : int) return int;
410    pragma Import (C, pthread_attr_setdetachstate);
411
412    function pthread_attr_setstacksize
413      (attr      : access pthread_attr_t;
414       stacksize : size_t) return int;
415    pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
416
417    function pthread_create
418      (thread        : access pthread_t;
419       attributes    : access pthread_attr_t;
420       start_routine : Thread_Body;
421       arg           : System.Address) return int;
422    pragma Import (C, pthread_create, "pthread_create");
423
424    procedure pthread_exit (status : System.Address);
425    pragma Import (C, pthread_exit, "pthread_exit");
426
427    function pthread_self return pthread_t;
428    pragma Import (C, pthread_self, "pthread_self");
429
430    --------------------------
431    -- POSIX.1c  Section 17 --
432    --------------------------
433
434    function pthread_setspecific
435      (key   : pthread_key_t;
436       value : System.Address) return int;
437    pragma Import (C, pthread_setspecific, "pthread_setspecific");
438
439    function pthread_getspecific (key : pthread_key_t) return System.Address;
440    pragma Import (C, pthread_getspecific, "pthread_getspecific");
441
442    type destructor_pointer is access procedure (arg : System.Address);
443
444    function pthread_key_create
445      (key        : access pthread_key_t;
446       destructor : destructor_pointer) return int;
447    pragma Import (C, pthread_key_create, "pthread_key_create");
448
449    ---------------------------------------------------------------
450    --  Non portable SGI 6.5 additions to the pthread interface  --
451    --  must be executed from within the context of a system     --
452    --  scope task                                               --
453    ---------------------------------------------------------------
454
455    function pthread_setrunon_np (cpu : int) return int;
456    pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
457
458 private
459
460    type array_type_1 is array (Integer range 0 .. 3) of unsigned;
461    type sigset_t is record
462       X_X_sigbits : array_type_1;
463    end record;
464    pragma Convention (C, sigset_t);
465
466    type pid_t is new long;
467
468    type time_t is new long;
469
470    type timespec is record
471       tv_sec  : time_t;
472       tv_nsec : long;
473    end record;
474    pragma Convention (C, timespec);
475
476    type clockid_t is new int;
477    CLOCK_REALTIME  : constant clockid_t := 1;
478    CLOCK_SGI_CYCLE : constant clockid_t := 2;
479    CLOCK_SGI_FAST  : constant clockid_t := 3;
480
481    type struct_timeval is record
482       tv_sec  : time_t;
483       tv_usec : time_t;
484    end record;
485    pragma Convention (C, struct_timeval);
486
487    type array_type_9 is array (Integer range 0 .. 4) of long;
488    type pthread_attr_t is record
489       X_X_D : array_type_9;
490    end record;
491    pragma Convention (C, pthread_attr_t);
492
493    type array_type_8 is array (Integer range 0 .. 1) of long;
494    type pthread_condattr_t is record
495       X_X_D : array_type_8;
496    end record;
497    pragma Convention (C, pthread_condattr_t);
498
499    type array_type_7 is array (Integer range 0 .. 1) of long;
500    type pthread_mutexattr_t is record
501       X_X_D : array_type_7;
502    end record;
503    pragma Convention (C, pthread_mutexattr_t);
504
505    type pthread_t is new unsigned;
506
507    type array_type_10 is array (Integer range 0 .. 7) of long;
508    type pthread_mutex_t is record
509       X_X_D : array_type_10;
510    end record;
511    pragma Convention (C, pthread_mutex_t);
512
513    type array_type_11 is array (Integer range 0 .. 7) of long;
514    type pthread_cond_t is record
515       X_X_D : array_type_11;
516    end record;
517    pragma Convention (C, pthread_cond_t);
518
519    type pthread_key_t is new int;
520
521 end System.OS_Interface;