* 5oosinte.adb: Add 2001 to copyright notice.
[platform/upstream/gcc.git] / gcc / ada / 5hosinte.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 --                             $Revision: 1.28 $
10 --                                                                          --
11 --             Copyright (C) 1997-2001, Florida State University            --
12 --                                                                          --
13 -- GNARL is free software; you can  redistribute it  and/or modify it under --
14 -- terms of the  GNU General Public License as published  by the Free Soft- --
15 -- ware  Foundation;  either version 2,  or (at your option) any later ver- --
16 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
17 -- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
18 -- or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License --
19 -- for  more details.  You should have  received  a copy of the GNU General --
20 -- Public License  distributed with GNARL; see file COPYING.  If not, write --
21 -- to  the Free Software Foundation,  59 Temple Place - Suite 330,  Boston, --
22 -- MA 02111-1307, USA.                                                      --
23 --                                                                          --
24 -- As a special exception,  if other files  instantiate  generics from this --
25 -- unit, or you link  this unit with other files  to produce an executable, --
26 -- this  unit  does not  by itself cause  the resulting  executable  to  be --
27 -- covered  by the  GNU  General  Public  License.  This exception does not --
28 -- however invalidate  any other reasons why  the executable file  might be --
29 -- covered by the  GNU Public License.                                      --
30 --                                                                          --
31 -- GNARL was developed by the GNARL team at Florida State University. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com).                                  --
34 --                                                                          --
35 ------------------------------------------------------------------------------
36
37 --  This is the HP-UX version of this package.
38
39 --  This package encapsulates all direct interfaces to OS services
40 --  that are needed by children of System.
41
42 --  PLEASE DO NOT add any with-clauses to this package
43 --  or remove the pragma Elaborate_Body.
44 --  It is designed to be a bottom-level (leaf) package.
45
46 with Interfaces.C;
47 package System.OS_Interface is
48    pragma Preelaborate;
49
50    pragma Linker_Options ("-lcma");
51
52    subtype int            is Interfaces.C.int;
53    subtype short          is Interfaces.C.short;
54    subtype long           is Interfaces.C.long;
55    subtype unsigned       is Interfaces.C.unsigned;
56    subtype unsigned_short is Interfaces.C.unsigned_short;
57    subtype unsigned_long  is Interfaces.C.unsigned_long;
58    subtype unsigned_char  is Interfaces.C.unsigned_char;
59    subtype plain_char     is Interfaces.C.plain_char;
60    subtype size_t         is Interfaces.C.size_t;
61
62    -----------
63    -- Errno --
64    -----------
65
66    function errno return int;
67    pragma Import (C, errno, "__get_errno");
68
69    EAGAIN    : constant := 11;
70    EINTR     : constant := 4;
71    EINVAL    : constant := 22;
72    ENOMEM    : constant := 12;
73    ETIME     : constant := 52;
74    ETIMEDOUT : constant := 238;
75
76    FUNC_ERR : constant := -1;
77
78    -------------
79    -- Signals --
80    -------------
81
82    Max_Interrupt : constant := 44;
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  future
93    SIGEMT     : constant := 7; --  EMT instruction
94    SIGFPE     : constant := 8; --  floating point exception
95    SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
96    SIGBUS     : constant := 10; --  bus error
97    SIGSEGV    : constant := 11; --  segmentation violation
98    SIGSYS     : constant := 12; --  bad argument to system call
99    SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
100    SIGALRM    : constant := 14; --  alarm clock
101    SIGTERM    : constant := 15; --  software termination signal from kill
102    SIGUSR1    : constant := 16; --  user defined signal 1
103    SIGUSR2    : constant := 17; --  user defined signal 2
104    SIGCLD     : constant := 18; --  alias for SIGCHLD
105    SIGCHLD    : constant := 18; --  child status change
106    SIGPWR     : constant := 19; --  power-fail restart
107    SIGVTALRM  : constant := 20; --  virtual timer alarm
108    SIGPROF    : constant := 21; --  profiling timer alarm
109    SIGIO      : constant := 22; --  asynchronous I/O
110    SIGPOLL    : constant := 22; --  pollable event occurred
111    SIGWINCH   : constant := 23; --  window size change
112    SIGSTOP    : constant := 24; --  stop (cannot be caught or ignored)
113    SIGTSTP    : constant := 25; --  user stop requested from tty
114    SIGCONT    : constant := 26; --  stopped process has been continued
115    SIGTTIN    : constant := 27; --  background tty read attempted
116    SIGTTOU    : constant := 28; --  background tty write attempted
117    SIGURG     : constant := 29; --  urgent condition on IO channel
118    SIGLOST    : constant := 30; --  remote lock lost  (NFS)
119    SIGDIL     : constant := 32; --  DIL signal
120    SIGXCPU    : constant := 33; --  CPU time limit exceeded (setrlimit)
121    SIGXFSZ    : constant := 34; --  file size limit exceeded (setrlimit)
122
123    SIGADAABORT : constant := SIGABRT;
124    --  Note: on other targets, we usually use SIGABRT, but on HP/UX, it
125    --  appears that SIGABRT can't be used in sigwait(), so we use SIGTERM.
126
127    type Signal_Set is array (Natural range <>) of Signal;
128
129    Unmasked    : constant Signal_Set :=
130      (SIGBUS, SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP);
131
132    Reserved    : constant Signal_Set := (SIGKILL, SIGSTOP);
133
134    type sigset_t is private;
135
136    type isr_address is access procedure (sig : int);
137
138    function intr_attach (sig : int; handler : isr_address) return long;
139
140    Intr_Attach_Reset : constant Boolean := True;
141    --  True if intr_attach is reset after an interrupt handler is called
142
143    function sigaddset (set : access sigset_t; sig : Signal) return int;
144    pragma Import (C, sigaddset, "sigaddset");
145
146    function sigdelset (set : access sigset_t; sig : Signal) return int;
147    pragma Import (C, sigdelset, "sigdelset");
148
149    function sigfillset (set : access sigset_t) return int;
150    pragma Import (C, sigfillset, "sigfillset");
151
152    function sigismember (set : access sigset_t; sig : Signal) return int;
153    pragma Import (C, sigismember, "sigismember");
154
155    function sigemptyset (set : access sigset_t) return int;
156    pragma Import (C, sigemptyset, "sigemptyset");
157
158    type Signal_Handler is access procedure (signo : Signal);
159
160    type struct_sigaction is record
161       sa_handler : System.Address;
162       sa_mask    : sigset_t;
163       sa_flags   : int;
164    end record;
165    pragma Convention (C, struct_sigaction);
166    type struct_sigaction_ptr is access all struct_sigaction;
167
168    SA_RESTART  : constant  := 16#40#;
169
170    SIG_BLOCK   : constant  := 0;
171    SIG_UNBLOCK : constant  := 1;
172    SIG_SETMASK : constant  := 2;
173
174    SIG_DFL : constant := 0;
175    SIG_IGN : constant := 1;
176    SIG_ERR : constant := -1;
177
178    function sigaction
179      (sig  : Signal;
180       act  : struct_sigaction_ptr;
181       oact : struct_sigaction_ptr) return int;
182    pragma Import (C, sigaction, "sigaction");
183
184    ----------
185    -- Time --
186    ----------
187
188    type timespec is private;
189
190    function nanosleep (rqtp, rmtp : access timespec) return int;
191    pragma Import (C, nanosleep);
192
193    type clockid_t is private;
194
195    CLOCK_REALTIME : constant clockid_t;
196
197    function Clock_Gettime
198      (Clock_Id : clockid_t; Tp : access timespec) return int;
199    pragma Import (C, Clock_Gettime);
200
201    function To_Duration (TS : timespec) return Duration;
202    pragma Inline (To_Duration);
203
204    function To_Timespec (D : Duration) return timespec;
205    pragma Inline (To_Timespec);
206
207    type struct_timeval is private;
208
209    function To_Duration (TV : struct_timeval) return Duration;
210    pragma Inline (To_Duration);
211
212    function To_Timeval (D : Duration) return struct_timeval;
213    pragma Inline (To_Timeval);
214
215    -------------------------
216    -- Priority Scheduling --
217    -------------------------
218
219    SCHED_FIFO  : constant := 0;
220    SCHED_RR    : constant := 1;
221    SCHED_OTHER : constant := 2;
222
223    -------------
224    -- Process --
225    -------------
226
227    type pid_t is private;
228
229    function kill (pid : pid_t; sig : Signal) return int;
230    pragma Import (C, kill, "kill");
231
232    function getpid return pid_t;
233    pragma Import (C, getpid, "getpid");
234
235    -------------
236    -- Threads --
237    -------------
238
239    type Thread_Body is access
240      function (arg : System.Address) return System.Address;
241    type pthread_t           is private;
242    subtype Thread_Id        is pthread_t;
243
244    type pthread_mutex_t     is limited private;
245    type pthread_cond_t      is limited private;
246    type pthread_attr_t      is limited private;
247    type pthread_mutexattr_t is limited private;
248    type pthread_condattr_t  is limited private;
249    type pthread_key_t       is private;
250
251    -----------
252    -- Stack --
253    -----------
254
255    function Get_Stack_Base (thread : pthread_t) return Address;
256    pragma Inline (Get_Stack_Base);
257    --  This is a dummy procedure to share some GNULLI files
258
259    ---------------------------------------
260    -- Nonstandard Thread Initialization --
261    ---------------------------------------
262
263    procedure pthread_init;
264    pragma Inline (pthread_init);
265    --  This is a dummy procedure to share some GNULLI files
266
267    -------------------------
268    -- POSIX.1c  Section 3 --
269    -------------------------
270
271    function sigwait (set : access sigset_t) return int;
272    pragma Import (C, sigwait, "cma_sigwait");
273
274    function sigwait
275      (set : access sigset_t;
276       sig : access Signal) return int;
277    pragma Inline (sigwait);
278    --  DCE_THREADS has a nonstandard sigwait
279
280    function pthread_kill
281      (thread : pthread_t;
282       sig    : Signal) return int;
283    pragma Inline (pthread_kill);
284    --  DCE_THREADS doesn't have pthread_kill
285
286    type sigset_t_ptr is access all sigset_t;
287
288    function pthread_sigmask
289      (how  : int;
290       set  : sigset_t_ptr;
291       oset : sigset_t_ptr) return int;
292    --  DCE THREADS does not have pthread_sigmask. Instead, it uses
293    --  sigprocmask to do the signal handling when the thread library is
294    --  sucked in.
295    pragma Import (C, pthread_sigmask, "sigprocmask");
296
297    --------------------------
298    -- POSIX.1c  Section 11 --
299    --------------------------
300
301    function pthread_mutexattr_init
302      (attr : access pthread_mutexattr_t) return int;
303    --  DCE_THREADS has a nonstandard pthread_mutexattr_init.
304
305    function pthread_mutexattr_destroy
306      (attr : access pthread_mutexattr_t) return int;
307    --  DCE_THREADS has a nonstandard pthread_mutexattr_destroy
308
309    function pthread_mutex_init
310      (mutex : access pthread_mutex_t;
311       attr  : access pthread_mutexattr_t) return int;
312    --  DCE_THREADS has a nonstandard pthread_mutex_init
313
314    function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
315    --  DCE_THREADS has a nonstandard pthread_mutex_destroy
316
317    function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
318    pragma Inline (pthread_mutex_lock);
319    --  DCE_THREADS has nonstandard pthread_mutex_lock
320
321    function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
322    pragma Inline (pthread_mutex_unlock);
323    --  DCE_THREADS has nonstandard pthread_mutex_lock
324
325    function pthread_condattr_init
326      (attr : access pthread_condattr_t) return int;
327    --  DCE_THREADS has nonstandard pthread_condattr_init
328
329    function pthread_condattr_destroy
330      (attr : access pthread_condattr_t) return int;
331    --  DCE_THREADS has nonstandard pthread_condattr_destroy
332
333    function pthread_cond_init
334      (cond : access pthread_cond_t;
335       attr : access pthread_condattr_t) return int;
336    --  DCE_THREADS has nonstandard pthread_cond_init
337
338    function pthread_cond_destroy (cond : access pthread_cond_t) return int;
339    --  DCE_THREADS has nonstandard pthread_cond_destroy
340
341    function pthread_cond_signal (cond : access pthread_cond_t) return int;
342    pragma Inline (pthread_cond_signal);
343    --  DCE_THREADS has nonstandard pthread_cond_signal
344
345    function pthread_cond_wait
346      (cond  : access pthread_cond_t;
347       mutex : access pthread_mutex_t) return int;
348    pragma Inline (pthread_cond_wait);
349    --  DCE_THREADS has a nonstandard pthread_cond_wait
350
351    function pthread_cond_timedwait
352      (cond    : access pthread_cond_t;
353       mutex   : access pthread_mutex_t;
354       abstime : access timespec) return int;
355    pragma Inline (pthread_cond_timedwait);
356    --  DCE_THREADS has a nonstandard pthread_cond_timedwait
357
358    --------------------------
359    -- POSIX.1c  Section 13 --
360    --------------------------
361
362    type struct_sched_param is record
363       sched_priority : int;  --  scheduling priority
364    end record;
365
366    function pthread_setschedparam
367      (thread : pthread_t;
368       policy : int;
369       param  : access struct_sched_param) return int;
370    pragma Inline (pthread_setschedparam);
371    --  DCE_THREADS has a nonstandard pthread_setschedparam
372
373    function sched_yield return int;
374    pragma Inline (sched_yield);
375    --  DCE_THREADS has a nonstandard sched_yield
376
377    ---------------------------
378    -- P1003.1c - Section 16 --
379    ---------------------------
380
381    function pthread_attr_init (attributes : access pthread_attr_t) return int;
382    pragma Inline (pthread_attr_init);
383    --  DCE_THREADS has a nonstandard pthread_attr_init
384
385    function pthread_attr_destroy
386      (attributes : access pthread_attr_t) return int;
387    pragma Inline (pthread_attr_destroy);
388    --  DCE_THREADS has a nonstandard pthread_attr_destroy
389
390    function pthread_attr_setstacksize
391      (attr      : access pthread_attr_t;
392       stacksize : size_t) return int;
393    pragma Inline (pthread_attr_setstacksize);
394    --  DCE_THREADS has a nonstandard pthread_attr_setstacksize
395
396    function pthread_create
397      (thread        : access pthread_t;
398       attributes    : access pthread_attr_t;
399       start_routine : Thread_Body;
400       arg           : System.Address) return int;
401    pragma Inline (pthread_create);
402    --  DCE_THREADS has a nonstandard pthread_create
403
404    procedure pthread_detach (thread : access pthread_t);
405    pragma Import (C, pthread_detach);
406
407    procedure pthread_exit (status : System.Address);
408    pragma Import (C, pthread_exit, "pthread_exit");
409
410    function pthread_self return pthread_t;
411    pragma Import (C, pthread_self, "pthread_self");
412
413    --------------------------
414    -- POSIX.1c  Section 17 --
415    --------------------------
416
417    function pthread_setspecific
418      (key   : pthread_key_t;
419       value : System.Address) return int;
420    pragma Inline (pthread_setspecific);
421    --  DCE_THREADS has a nonstandard pthread_setspecific
422
423    function pthread_getspecific (key : pthread_key_t) return System.Address;
424    pragma Inline (pthread_getspecific);
425    --  DCE_THREADS has a nonstandard pthread_getspecific
426
427    type destructor_pointer is access procedure (arg : System.Address);
428
429    function pthread_key_create
430      (key        : access pthread_key_t;
431       destructor : destructor_pointer) return int;
432    pragma Inline (pthread_key_create);
433    --  DCE_THREADS has a nonstandard pthread_key_create
434
435 private
436
437    type array_type_1 is array (Integer range 0 .. 7) of unsigned_long;
438    type sigset_t is record
439       X_X_sigbits : array_type_1;
440    end record;
441    pragma Convention (C, sigset_t);
442
443    type pid_t is new int;
444
445    type time_t is new long;
446
447    type timespec is record
448       tv_sec  : time_t;
449       tv_nsec : long;
450    end record;
451    pragma Convention (C, timespec);
452
453    type clockid_t is new int;
454    CLOCK_REALTIME : constant clockid_t := 1;
455
456    type struct_timeval is record
457       tv_sec  : time_t;
458       tv_usec : time_t;
459    end record;
460    pragma Convention (C, struct_timeval);
461
462    type cma_t_address is new System.Address;
463
464    type cma_t_handle is record
465       field1 : cma_t_address;
466       field2 : Short_Integer;
467       field3 : Short_Integer;
468    end record;
469    for cma_t_handle'Size use 64;
470
471    type pthread_attr_t is new cma_t_handle;
472    pragma Convention (C_Pass_By_Copy, pthread_attr_t);
473
474    type pthread_condattr_t is new cma_t_handle;
475    pragma Convention (C_Pass_By_Copy, pthread_condattr_t);
476
477    type pthread_mutexattr_t is new cma_t_handle;
478    pragma Convention (C_Pass_By_Copy, pthread_mutexattr_t);
479
480    type pthread_t is new cma_t_handle;
481    pragma Convention (C_Pass_By_Copy, pthread_t);
482
483    type pthread_mutex_t is new cma_t_handle;
484    pragma Convention (C_Pass_By_Copy, pthread_mutex_t);
485
486    type pthread_cond_t is new cma_t_handle;
487    pragma Convention (C_Pass_By_Copy, pthread_cond_t);
488
489    type pthread_key_t is new int;
490
491 end System.OS_Interface;