OSDN Git Service

Daily bump.
[pf3gnuchains/gcc-fork.git] / gcc / ada / 5aosinte.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 --                                                                          --
10 --           Copyright (C) 1998-2001 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 the DEC Unix 4.0/5.1 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
41 --  It is designed to be a bottom-level (leaf) package.
42
43 with Interfaces.C;
44 package System.OS_Interface is
45    pragma Preelaborate;
46
47    pragma Linker_Options ("-lpthread");
48    pragma Linker_Options ("-lmach");
49    pragma Linker_Options ("-lexc");
50    pragma Linker_Options ("-lrt");
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    subtype char_array     is Interfaces.C.char_array;
62
63    -----------
64    -- Errno --
65    -----------
66
67    function errno return int;
68    pragma Import (C, errno, "_Geterrno");
69
70    EAGAIN    : constant := 35;
71    EINTR     : constant := 4;
72    EINVAL    : constant := 22;
73    ENOMEM    : constant := 12;
74    ETIMEDOUT : constant := 60;
75
76    -------------
77    -- Signals --
78    -------------
79
80    Max_Interrupt : constant := 48;
81    type Signal is new int range 0 .. Max_Interrupt;
82    for Signal'Size use int'Size;
83
84    SIGHUP     : constant := 1; --  hangup
85    SIGINT     : constant := 2; --  interrupt (rubout)
86    SIGQUIT    : constant := 3; --  quit (ASCD FS)
87    SIGILL     : constant := 4; --  illegal instruction (not reset)
88    SIGTRAP    : constant := 5; --  trace trap (not reset)
89    SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the  future
90    SIGIOT     : constant := 6; --  abort (terminate) process
91    SIGLOST    : constant := 6; --  old BSD signal ??
92    SIGEMT     : constant := 7; --  EMT instruction
93    SIGFPE     : constant := 8; --  floating point exception
94    SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
95    SIGBUS     : constant := 10; --  bus error
96    SIGSEGV    : constant := 11; --  segmentation violation
97    SIGSYS     : constant := 12; --  bad argument to system call
98    SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
99    SIGALRM    : constant := 14; --  alarm clock
100    SIGTERM    : constant := 15; --  software termination signal from kill
101    SIGURG     : constant := 16; --  urgent condition on IO channel
102    SIGIOINT   : constant := 16; --  printer to backend error signal
103    SIGSTOP    : constant := 17; --  stop (cannot be caught or ignored)
104    SIGTSTP    : constant := 18; --  user stop requested from tty
105    SIGCONT    : constant := 19; --  stopped process has been continued
106    SIGCHLD    : constant := 20; --  child status change
107    SIGTTIN    : constant := 21; --  background tty read attempted
108    SIGTTOU    : constant := 22; --  background tty write attempted
109    SIGPOLL    : constant := 23; --  I/O possible, or completed
110    SIGIO      : constant := 23; --  STREAMS version of SIGPOLL
111    SIGAIO     : constant := 23; --  base lan i/o
112    SIGPTY     : constant := 23; --  pty i/o
113    SIGXCPU    : constant := 24; --  CPU time limit exceeded
114    SIGXFSZ    : constant := 25; --  filesize limit exceeded
115    SIGVTALRM  : constant := 26; --  virtual timer expired
116    SIGPROF    : constant := 27; --  profiling timer expired
117    SIGWINCH   : constant := 28; --  window size change
118    SIGINFO    : constant := 29; --  information request
119    SIGPWR     : constant := 29; --  Power Fail/Restart -- SVID3/SVR4
120    SIGUSR1    : constant := 30; --  user defined signal 1
121    SIGUSR2    : constant := 31; --  user defined signal 2
122    SIGRESV    : constant := 32; --  reserved by Digital for future use
123
124    SIGADAABORT : constant := SIGABRT;
125
126    type Signal_Set is array (Natural range <>) of Signal;
127
128    Unmasked    : constant Signal_Set := (0 .. 0 => SIGTRAP);
129    Reserved    : constant Signal_Set := (SIGALRM, SIGABRT, SIGKILL, SIGSTOP);
130
131    type sigset_t is private;
132
133    function sigaddset (set : access sigset_t; sig : Signal) return int;
134    pragma Import (C, sigaddset);
135
136    function sigdelset (set : access sigset_t; sig : Signal) return int;
137    pragma Import (C, sigdelset);
138
139    function sigfillset (set : access sigset_t) return int;
140    pragma Import (C, sigfillset);
141
142    function sigismember (set : access sigset_t; sig : Signal) return int;
143    pragma Import (C, sigismember);
144
145    function sigemptyset (set : access sigset_t) return int;
146    pragma Import (C, sigemptyset);
147
148    type union_type_3 is new String (1 .. 116);
149    type siginfo_t is record
150       si_signo     : int;
151       si_errno     : int;
152       si_code      : int;
153       X_data       : union_type_3;
154    end record;
155    for siginfo_t'Size use 8 * 128;
156    pragma Convention (C, siginfo_t);
157
158    type struct_sigaction is record
159       sa_handler : System.Address;
160       sa_mask    : sigset_t;
161       sa_flags   : int;
162       sa_signo   : int;
163    end record;
164    pragma Convention (C, struct_sigaction);
165    type struct_sigaction_ptr is access all struct_sigaction;
166
167    SIG_BLOCK   : constant := 1;
168    SIG_UNBLOCK : constant := 2;
169    SIG_SETMASK : constant := 3;
170
171    SIG_DFL : constant := 0;
172    SIG_IGN : constant := 1;
173
174    SA_NODEFER : constant := 8;
175    SA_SIGINFO : constant := 16#40#;
176
177    function sigaction
178      (sig  : Signal;
179       act  : struct_sigaction_ptr;
180       oact : struct_sigaction_ptr) return int;
181    pragma Import (C, sigaction);
182
183    ----------
184    -- Time --
185    ----------
186
187    type timespec is private;
188
189    function nanosleep (rqtp, rmtp : access timespec)  return int;
190    pragma Import (C, nanosleep);
191
192    type clockid_t is private;
193
194    CLOCK_REALTIME : constant clockid_t;
195
196    function clock_gettime
197      (clock_id : clockid_t;
198       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_timezone is record
208       tz_minuteswest : int;
209       tz_dsttime     : int;
210    end record;
211    pragma Convention (C, struct_timezone);
212    type struct_timeval is private;
213    --  This is needed on systems that do not have clock_gettime()
214    --  but do have gettimeofday().
215
216    function To_Duration (TV : struct_timeval) return Duration;
217    pragma Inline (To_Duration);
218
219    function To_Timeval (D : Duration) return struct_timeval;
220    pragma Inline (To_Timeval);
221
222    -------------------------
223    -- Priority Scheduling --
224    -------------------------
225
226    SCHED_FIFO  : constant := 1;
227    SCHED_RR    : constant := 2;
228    SCHED_OTHER : constant := 3;
229    SCHED_LFI   : constant := 5;
230
231    -------------
232    -- Process --
233    -------------
234
235    type pid_t is private;
236
237    function kill (pid : pid_t; sig : Signal) return int;
238    pragma Import (C, kill);
239
240    function getpid return pid_t;
241    pragma Import (C, getpid);
242
243    BIND_NO_INHERIT  : constant := 1;
244
245    function bind_to_cpu
246      (pid       : pid_t;
247       cpu_mask  : unsigned_long;
248       flag      : unsigned_long := BIND_NO_INHERIT) return int;
249    pragma Import (C, bind_to_cpu);
250
251    -------------
252    -- Threads --
253    -------------
254
255    type Thread_Body is access
256      function (arg : System.Address) return System.Address;
257    type pthread_t           is private;
258    subtype Thread_Id        is pthread_t;
259
260    type pthread_mutex_t     is limited private;
261    type pthread_cond_t      is limited private;
262    type pthread_attr_t      is limited private;
263    type pthread_mutexattr_t is limited private;
264    type pthread_condattr_t  is limited private;
265    type pthread_key_t       is private;
266
267    PTHREAD_CREATE_DETACHED : constant := 1;
268
269    PTHREAD_SCOPE_PROCESS : constant := 0;
270    PTHREAD_SCOPE_SYSTEM  : constant := 1;
271
272    PTHREAD_EXPLICIT_SCHED : constant := 1;
273
274    ---------------------------------------
275    -- Nonstandard Thread Initialization --
276    ---------------------------------------
277
278    procedure pthread_init;
279    pragma Inline (pthread_init);
280    --  This is a dummy procedure to share some GNULLI files
281
282    ---------------------------
283    --  POSIX.1c  Section 3  --
284    ---------------------------
285
286    function sigwait
287      (set : access sigset_t;
288       sig : access Signal) return int;
289    pragma Import (C, sigwait, "__sigwaitd10");
290
291    function pthread_kill
292      (thread : pthread_t;
293       sig    : Signal) return int;
294    pragma Import (C, pthread_kill);
295
296    type sigset_t_ptr is access all sigset_t;
297
298    function pthread_sigmask
299      (how  : int;
300       set  : sigset_t_ptr;
301       oset : sigset_t_ptr) return int;
302    pragma Import (C, pthread_sigmask);
303
304    ----------------------------
305    --  POSIX.1c  Section 11  --
306    ----------------------------
307
308    function pthread_mutexattr_init (attr : access pthread_mutexattr_t)
309      return int;
310    pragma Import (C, pthread_mutexattr_init);
311
312    function pthread_mutexattr_destroy
313      (attr : access pthread_mutexattr_t) return int;
314    pragma Import (C, pthread_mutexattr_destroy);
315
316    function pthread_mutex_init
317      (mutex : access pthread_mutex_t;
318       attr  : access pthread_mutexattr_t) return int;
319    pragma Import (C, pthread_mutex_init, "__pthread_mutex_init");
320
321    function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
322    pragma Import (C, pthread_mutex_destroy, "__pthread_mutex_destroy");
323
324    function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
325    pragma Import (C, pthread_mutex_lock, "__pthread_mutex_lock");
326
327    function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
328    pragma Import (C, pthread_mutex_unlock, "__pthread_mutex_unlock");
329
330    function pthread_condattr_init
331      (attr : access pthread_condattr_t) return int;
332    pragma Import (C, pthread_condattr_init);
333
334    function pthread_condattr_destroy
335      (attr : access pthread_condattr_t) return int;
336    pragma Import (C, pthread_condattr_destroy);
337
338    function pthread_cond_init
339      (cond : access pthread_cond_t;
340       attr : access pthread_condattr_t) return int;
341    pragma Import (C, pthread_cond_init, "__pthread_cond_init");
342
343    function pthread_cond_destroy (cond : access pthread_cond_t) return int;
344    pragma Import (C, pthread_cond_destroy, "__pthread_cond_destroy");
345
346    function pthread_cond_signal (cond : access pthread_cond_t) return int;
347    pragma Import (C, pthread_cond_signal, "__pthread_cond_signal");
348
349    function pthread_cond_wait
350      (cond  : access pthread_cond_t;
351       mutex : access pthread_mutex_t) return  int;
352    pragma Import (C, pthread_cond_wait, "__pthread_cond_wait");
353
354    function pthread_cond_timedwait
355      (cond    : access pthread_cond_t;
356       mutex   : access pthread_mutex_t;
357       abstime : access timespec) return int;
358    pragma Import (C, pthread_cond_timedwait, "__pthread_cond_timedwait");
359
360    ----------------------------
361    --  POSIX.1c  Section 13  --
362    ----------------------------
363
364    function pthread_mutexattr_setprotocol
365      (attr     : access pthread_mutexattr_t;
366       protocol : int) return int;
367    pragma Import (C, pthread_mutexattr_setprotocol);
368
369    function pthread_mutexattr_setprioceiling
370      (attr     : access pthread_mutexattr_t;
371       prioceiling : int) return int;
372    pragma Import (C, pthread_mutexattr_setprioceiling);
373
374    type struct_sched_param is record
375       sched_priority : int;  --  scheduling priority
376    end record;
377
378    function pthread_setschedparam
379      (thread : pthread_t;
380       policy : int;
381       param  : access struct_sched_param) return int;
382    pragma Import (C, pthread_setschedparam);
383
384    function pthread_attr_setscope
385      (attr            : access pthread_attr_t;
386       contentionscope : int) return int;
387    pragma Import (C, pthread_attr_setscope);
388
389    function pthread_attr_setinheritsched
390      (attr            : access pthread_attr_t;
391       inheritsched    : int) return int;
392    pragma Import (C, pthread_attr_setinheritsched,
393      "__pthread_attr_setinheritsched");
394
395    function pthread_attr_setschedpolicy
396      (attr : access pthread_attr_t; policy : int) return int;
397    pragma Import (C, pthread_attr_setschedpolicy);
398
399    function pthread_attr_setschedparam
400      (attr        : access pthread_attr_t;
401       sched_param : access struct_sched_param) return int;
402    pragma Import (C, pthread_attr_setschedparam);
403
404    function sched_yield return int;
405    pragma Import (C, sched_yield);
406
407    ---------------------------
408    -- P1003.1c - Section 16 --
409    ---------------------------
410
411    function pthread_attr_init (attributes : access pthread_attr_t)
412      return int;
413    pragma Import (C, pthread_attr_init);
414
415    function pthread_attr_destroy (attributes : access pthread_attr_t)
416      return int;
417    pragma Import (C, pthread_attr_destroy);
418
419    function pthread_attr_setdetachstate
420      (attr        : access pthread_attr_t;
421       detachstate : int) return int;
422    pragma Import (C, pthread_attr_setdetachstate);
423
424    function pthread_attr_setstacksize
425      (attr      : access pthread_attr_t;
426       stacksize : size_t) return int;
427    pragma Import (C, pthread_attr_setstacksize, "__pthread_attr_setstacksize");
428
429    function pthread_create
430      (thread        : access pthread_t;
431       attributes    : access pthread_attr_t;
432       start_routine : Thread_Body;
433       arg           : System.Address) return int;
434    pragma Import (C, pthread_create, "__pthread_create");
435
436    procedure pthread_exit (status : System.Address);
437    pragma Import (C, pthread_exit, "__pthread_exit");
438
439    function pthread_self return pthread_t;
440    pragma Import (C, pthread_self, "__pthread_self");
441
442    --------------------------
443    -- POSIX.1c  Section 17 --
444    --------------------------
445
446    function pthread_setspecific
447      (key : pthread_key_t; value : System.Address) return int;
448    pragma Import (C, pthread_setspecific, "__pthread_setspecific");
449
450    function pthread_getspecific (key : pthread_key_t) return System.Address;
451    pragma Import (C, pthread_getspecific, "__pthread_getspecific");
452
453    type destructor_pointer is access procedure (arg : System.Address);
454
455    function pthread_key_create
456      (key        : access pthread_key_t;
457       destructor : destructor_pointer) return int;
458    pragma Import (C, pthread_key_create);
459
460 private
461
462    type sigset_t is new unsigned_long;
463
464    type pid_t is new int;
465
466    type time_t is new int;
467
468    type timespec is record
469       tv_sec  : time_t;
470       tv_nsec : long;
471    end record;
472    pragma Convention (C, timespec);
473
474    type clockid_t is new int;
475    CLOCK_REALTIME : constant clockid_t := 1;
476
477    type struct_timeval is record
478       tv_sec  : time_t;
479       tv_usec : time_t;
480    end record;
481    pragma Convention (C, struct_timeval);
482
483    type unsigned_long_array is array (Natural range <>) of unsigned_long;
484
485    type pthread_t is new System.Address;
486
487    type pthread_cond_t is record
488       state     : unsigned;
489       valid     : unsigned;
490       name      : System.Address;
491       arg       : unsigned;
492       reserved1 : unsigned;
493       sequence  : unsigned_long;
494       block     : System.Address;
495    end record;
496    pragma Convention (C, pthread_cond_t);
497
498    type pthread_attr_t is record
499       valid    : long;
500       name     : System.Address;
501       arg      : unsigned_long;
502       reserved : unsigned_long_array (0 .. 18);
503    end record;
504    pragma Convention (C, pthread_attr_t);
505
506    type pthread_mutex_t is record
507       lock     : unsigned;
508       valid    : unsigned;
509       name     : System.Address;
510       arg      : unsigned;
511       depth    : unsigned;
512       sequence : unsigned_long;
513       owner    : unsigned_long;
514       block    : System.Address;
515    end record;
516    for pthread_mutex_t'Size use 8 * 48;
517    pragma Convention (C, pthread_mutex_t);
518
519    type pthread_mutexattr_t is record
520       valid    : long;
521       reserved : unsigned_long_array (0 .. 14);
522    end record;
523    pragma Convention (C, pthread_mutexattr_t);
524
525    type pthread_condattr_t is record
526       valid    : long;
527       reserved : unsigned_long_array (0 .. 12);
528    end record;
529    pragma Convention (C, pthread_condattr_t);
530
531    type pthread_key_t is new unsigned;
532
533 end System.OS_Interface;