Daily bump.
[official-gcc.git] / gcc / ada / 5aosinte.ads
blobb155210636d0f47e05aed642a46ff0dbc3d63419
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.1 $
10 -- --
11 -- Copyright (C) 1998-2001 Free Software Foundation, Inc. --
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. --
32 -- Extensive contributions were provided by Ada Core Technologies Inc. --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This is the DEC Unix 4.0/5.1 version of this package.
38 -- This package encapsulates all direct interfaces to OS services
39 -- that are needed by children of System.
41 -- PLEASE DO NOT add any with-clauses to this package
42 -- It is designed to be a bottom-level (leaf) package.
44 with Interfaces.C;
45 package System.OS_Interface is
46 pragma Preelaborate;
48 pragma Linker_Options ("-lpthread");
49 pragma Linker_Options ("-lmach");
50 pragma Linker_Options ("-lexc");
51 pragma Linker_Options ("-lrt");
53 subtype int is Interfaces.C.int;
54 subtype short is Interfaces.C.short;
55 subtype long is Interfaces.C.long;
56 subtype unsigned is Interfaces.C.unsigned;
57 subtype unsigned_short is Interfaces.C.unsigned_short;
58 subtype unsigned_long is Interfaces.C.unsigned_long;
59 subtype unsigned_char is Interfaces.C.unsigned_char;
60 subtype plain_char is Interfaces.C.plain_char;
61 subtype size_t is Interfaces.C.size_t;
62 subtype char_array is Interfaces.C.char_array;
64 -----------
65 -- Errno --
66 -----------
68 function errno return int;
69 pragma Import (C, errno, "_Geterrno");
71 EAGAIN : constant := 35;
72 EINTR : constant := 4;
73 EINVAL : constant := 22;
74 ENOMEM : constant := 12;
75 ETIMEDOUT : constant := 60;
77 -------------
78 -- Signals --
79 -------------
81 Max_Interrupt : constant := 48;
82 type Signal is new int range 0 .. Max_Interrupt;
83 for Signal'Size use int'Size;
85 SIGHUP : constant := 1; -- hangup
86 SIGINT : constant := 2; -- interrupt (rubout)
87 SIGQUIT : constant := 3; -- quit (ASCD FS)
88 SIGILL : constant := 4; -- illegal instruction (not reset)
89 SIGTRAP : constant := 5; -- trace trap (not reset)
90 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
91 SIGIOT : constant := 6; -- abort (terminate) process
92 SIGLOST : constant := 6; -- old BSD signal ??
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 SIGURG : constant := 16; -- urgent condition on IO channel
103 SIGIOINT : constant := 16; -- printer to backend error signal
104 SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
105 SIGTSTP : constant := 18; -- user stop requested from tty
106 SIGCONT : constant := 19; -- stopped process has been continued
107 SIGCHLD : constant := 20; -- child status change
108 SIGTTIN : constant := 21; -- background tty read attempted
109 SIGTTOU : constant := 22; -- background tty write attempted
110 SIGPOLL : constant := 23; -- I/O possible, or completed
111 SIGIO : constant := 23; -- STREAMS version of SIGPOLL
112 SIGAIO : constant := 23; -- base lan i/o
113 SIGPTY : constant := 23; -- pty i/o
114 SIGXCPU : constant := 24; -- CPU time limit exceeded
115 SIGXFSZ : constant := 25; -- filesize limit exceeded
116 SIGVTALRM : constant := 26; -- virtual timer expired
117 SIGPROF : constant := 27; -- profiling timer expired
118 SIGWINCH : constant := 28; -- window size change
119 SIGINFO : constant := 29; -- information request
120 SIGPWR : constant := 29; -- Power Fail/Restart -- SVID3/SVR4
121 SIGUSR1 : constant := 30; -- user defined signal 1
122 SIGUSR2 : constant := 31; -- user defined signal 2
123 SIGRESV : constant := 32; -- reserved by Digital for future use
125 SIGADAABORT : constant := SIGABRT;
127 type Signal_Set is array (Natural range <>) of Signal;
129 Unmasked : constant Signal_Set := (0 .. 0 => SIGTRAP);
130 Reserved : constant Signal_Set := (SIGALRM, SIGABRT, SIGKILL, SIGSTOP);
132 type sigset_t is private;
134 function sigaddset (set : access sigset_t; sig : Signal) return int;
135 pragma Import (C, sigaddset);
137 function sigdelset (set : access sigset_t; sig : Signal) return int;
138 pragma Import (C, sigdelset);
140 function sigfillset (set : access sigset_t) return int;
141 pragma Import (C, sigfillset);
143 function sigismember (set : access sigset_t; sig : Signal) return int;
144 pragma Import (C, sigismember);
146 function sigemptyset (set : access sigset_t) return int;
147 pragma Import (C, sigemptyset);
149 type union_type_3 is new String (1 .. 116);
150 type siginfo_t is record
151 si_signo : int;
152 si_errno : int;
153 si_code : int;
154 X_data : union_type_3;
155 end record;
156 for siginfo_t'Size use 8 * 128;
157 pragma Convention (C, siginfo_t);
159 type struct_sigaction is record
160 sa_handler : System.Address;
161 sa_mask : sigset_t;
162 sa_flags : int;
163 sa_signo : int;
164 end record;
165 pragma Convention (C, struct_sigaction);
166 type struct_sigaction_ptr is access all struct_sigaction;
168 SIG_BLOCK : constant := 1;
169 SIG_UNBLOCK : constant := 2;
170 SIG_SETMASK : constant := 3;
172 SIG_DFL : constant := 0;
173 SIG_IGN : constant := 1;
175 SA_NODEFER : constant := 8;
176 SA_SIGINFO : constant := 16#40#;
178 function sigaction
179 (sig : Signal;
180 act : struct_sigaction_ptr;
181 oact : struct_sigaction_ptr) return int;
182 pragma Import (C, sigaction);
184 ----------
185 -- Time --
186 ----------
188 type timespec is private;
190 function nanosleep (rqtp, rmtp : access timespec) return int;
191 pragma Import (C, nanosleep);
193 type clockid_t is private;
195 CLOCK_REALTIME : constant clockid_t;
197 function clock_gettime
198 (clock_id : clockid_t;
199 tp : access timespec) return int;
200 pragma Import (C, clock_gettime);
202 function To_Duration (TS : timespec) return Duration;
203 pragma Inline (To_Duration);
205 function To_Timespec (D : Duration) return timespec;
206 pragma Inline (To_Timespec);
208 type struct_timezone is record
209 tz_minuteswest : int;
210 tz_dsttime : int;
211 end record;
212 pragma Convention (C, struct_timezone);
213 type struct_timeval is private;
214 -- This is needed on systems that do not have clock_gettime()
215 -- but do have gettimeofday().
217 function To_Duration (TV : struct_timeval) return Duration;
218 pragma Inline (To_Duration);
220 function To_Timeval (D : Duration) return struct_timeval;
221 pragma Inline (To_Timeval);
223 -------------------------
224 -- Priority Scheduling --
225 -------------------------
227 SCHED_FIFO : constant := 1;
228 SCHED_RR : constant := 2;
229 SCHED_OTHER : constant := 3;
230 SCHED_LFI : constant := 5;
232 -------------
233 -- Process --
234 -------------
236 type pid_t is private;
238 function kill (pid : pid_t; sig : Signal) return int;
239 pragma Import (C, kill);
241 function getpid return pid_t;
242 pragma Import (C, getpid);
244 BIND_NO_INHERIT : constant := 1;
246 function bind_to_cpu
247 (pid : pid_t;
248 cpu_mask : unsigned_long;
249 flag : unsigned_long := BIND_NO_INHERIT) return int;
250 pragma Import (C, bind_to_cpu);
252 -------------
253 -- Threads --
254 -------------
256 type Thread_Body is access
257 function (arg : System.Address) return System.Address;
258 type pthread_t is private;
259 subtype Thread_Id is pthread_t;
261 type pthread_mutex_t is limited private;
262 type pthread_cond_t is limited private;
263 type pthread_attr_t is limited private;
264 type pthread_mutexattr_t is limited private;
265 type pthread_condattr_t is limited private;
266 type pthread_key_t is private;
268 PTHREAD_CREATE_DETACHED : constant := 1;
270 PTHREAD_SCOPE_PROCESS : constant := 0;
271 PTHREAD_SCOPE_SYSTEM : constant := 1;
273 PTHREAD_EXPLICIT_SCHED : constant := 1;
275 ---------------------------------------
276 -- Nonstandard Thread Initialization --
277 ---------------------------------------
279 procedure pthread_init;
280 pragma Inline (pthread_init);
281 -- This is a dummy procedure to share some GNULLI files
283 ---------------------------
284 -- POSIX.1c Section 3 --
285 ---------------------------
287 function sigwait
288 (set : access sigset_t;
289 sig : access Signal) return int;
290 pragma Import (C, sigwait, "__sigwaitd10");
292 function pthread_kill
293 (thread : pthread_t;
294 sig : Signal) return int;
295 pragma Import (C, pthread_kill);
297 type sigset_t_ptr is access all sigset_t;
299 function pthread_sigmask
300 (how : int;
301 set : sigset_t_ptr;
302 oset : sigset_t_ptr) return int;
303 pragma Import (C, pthread_sigmask);
305 ----------------------------
306 -- POSIX.1c Section 11 --
307 ----------------------------
309 function pthread_mutexattr_init (attr : access pthread_mutexattr_t)
310 return int;
311 pragma Import (C, pthread_mutexattr_init);
313 function pthread_mutexattr_destroy
314 (attr : access pthread_mutexattr_t) return int;
315 pragma Import (C, pthread_mutexattr_destroy);
317 function pthread_mutex_init
318 (mutex : access pthread_mutex_t;
319 attr : access pthread_mutexattr_t) return int;
320 pragma Import (C, pthread_mutex_init, "__pthread_mutex_init");
322 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
323 pragma Import (C, pthread_mutex_destroy, "__pthread_mutex_destroy");
325 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
326 pragma Import (C, pthread_mutex_lock, "__pthread_mutex_lock");
328 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
329 pragma Import (C, pthread_mutex_unlock, "__pthread_mutex_unlock");
331 function pthread_condattr_init
332 (attr : access pthread_condattr_t) return int;
333 pragma Import (C, pthread_condattr_init);
335 function pthread_condattr_destroy
336 (attr : access pthread_condattr_t) return int;
337 pragma Import (C, pthread_condattr_destroy);
339 function pthread_cond_init
340 (cond : access pthread_cond_t;
341 attr : access pthread_condattr_t) return int;
342 pragma Import (C, pthread_cond_init, "__pthread_cond_init");
344 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
345 pragma Import (C, pthread_cond_destroy, "__pthread_cond_destroy");
347 function pthread_cond_signal (cond : access pthread_cond_t) return int;
348 pragma Import (C, pthread_cond_signal, "__pthread_cond_signal");
350 function pthread_cond_wait
351 (cond : access pthread_cond_t;
352 mutex : access pthread_mutex_t) return int;
353 pragma Import (C, pthread_cond_wait, "__pthread_cond_wait");
355 function pthread_cond_timedwait
356 (cond : access pthread_cond_t;
357 mutex : access pthread_mutex_t;
358 abstime : access timespec) return int;
359 pragma Import (C, pthread_cond_timedwait, "__pthread_cond_timedwait");
361 ----------------------------
362 -- POSIX.1c Section 13 --
363 ----------------------------
365 function pthread_mutexattr_setprotocol
366 (attr : access pthread_mutexattr_t;
367 protocol : int) return int;
368 pragma Import (C, pthread_mutexattr_setprotocol);
370 function pthread_mutexattr_setprioceiling
371 (attr : access pthread_mutexattr_t;
372 prioceiling : int) return int;
373 pragma Import (C, pthread_mutexattr_setprioceiling);
375 type struct_sched_param is record
376 sched_priority : int; -- scheduling priority
377 end record;
379 function pthread_setschedparam
380 (thread : pthread_t;
381 policy : int;
382 param : access struct_sched_param) return int;
383 pragma Import (C, pthread_setschedparam);
385 function pthread_attr_setscope
386 (attr : access pthread_attr_t;
387 contentionscope : int) return int;
388 pragma Import (C, pthread_attr_setscope);
390 function pthread_attr_setinheritsched
391 (attr : access pthread_attr_t;
392 inheritsched : int) return int;
393 pragma Import (C, pthread_attr_setinheritsched,
394 "__pthread_attr_setinheritsched");
396 function pthread_attr_setschedpolicy
397 (attr : access pthread_attr_t; policy : int) return int;
398 pragma Import (C, pthread_attr_setschedpolicy);
400 function pthread_attr_setschedparam
401 (attr : access pthread_attr_t;
402 sched_param : access struct_sched_param) return int;
403 pragma Import (C, pthread_attr_setschedparam);
405 function sched_yield return int;
406 pragma Import (C, sched_yield);
408 ---------------------------
409 -- P1003.1c - Section 16 --
410 ---------------------------
412 function pthread_attr_init (attributes : access pthread_attr_t)
413 return int;
414 pragma Import (C, pthread_attr_init);
416 function pthread_attr_destroy (attributes : access pthread_attr_t)
417 return int;
418 pragma Import (C, pthread_attr_destroy);
420 function pthread_attr_setdetachstate
421 (attr : access pthread_attr_t;
422 detachstate : int) return int;
423 pragma Import (C, pthread_attr_setdetachstate);
425 function pthread_attr_setstacksize
426 (attr : access pthread_attr_t;
427 stacksize : size_t) return int;
428 pragma Import (C, pthread_attr_setstacksize, "__pthread_attr_setstacksize");
430 function pthread_create
431 (thread : access pthread_t;
432 attributes : access pthread_attr_t;
433 start_routine : Thread_Body;
434 arg : System.Address) return int;
435 pragma Import (C, pthread_create, "__pthread_create");
437 procedure pthread_exit (status : System.Address);
438 pragma Import (C, pthread_exit, "__pthread_exit");
440 function pthread_self return pthread_t;
441 pragma Import (C, pthread_self, "__pthread_self");
443 --------------------------
444 -- POSIX.1c Section 17 --
445 --------------------------
447 function pthread_setspecific
448 (key : pthread_key_t; value : System.Address) return int;
449 pragma Import (C, pthread_setspecific, "__pthread_setspecific");
451 function pthread_getspecific (key : pthread_key_t) return System.Address;
452 pragma Import (C, pthread_getspecific, "__pthread_getspecific");
454 type destructor_pointer is access procedure (arg : System.Address);
456 function pthread_key_create
457 (key : access pthread_key_t;
458 destructor : destructor_pointer) return int;
459 pragma Import (C, pthread_key_create);
461 private
463 type sigset_t is new unsigned_long;
465 type pid_t is new int;
467 type time_t is new int;
469 type timespec is record
470 tv_sec : time_t;
471 tv_nsec : long;
472 end record;
473 pragma Convention (C, timespec);
475 type clockid_t is new int;
476 CLOCK_REALTIME : constant clockid_t := 1;
478 type struct_timeval is record
479 tv_sec : time_t;
480 tv_usec : time_t;
481 end record;
482 pragma Convention (C, struct_timeval);
484 type unsigned_long_array is array (Natural range <>) of unsigned_long;
486 type pthread_t is new System.Address;
488 type pthread_cond_t is record
489 state : unsigned;
490 valid : unsigned;
491 name : System.Address;
492 arg : unsigned;
493 reserved1 : unsigned;
494 sequence : unsigned_long;
495 block : System.Address;
496 end record;
497 pragma Convention (C, pthread_cond_t);
499 type pthread_attr_t is record
500 valid : long;
501 name : System.Address;
502 arg : unsigned_long;
503 reserved : unsigned_long_array (0 .. 18);
504 end record;
505 pragma Convention (C, pthread_attr_t);
507 type pthread_mutex_t is record
508 lock : unsigned;
509 valid : unsigned;
510 name : System.Address;
511 arg : unsigned;
512 depth : unsigned;
513 sequence : unsigned_long;
514 owner : unsigned_long;
515 block : System.Address;
516 end record;
517 for pthread_mutex_t'Size use 8 * 48;
518 pragma Convention (C, pthread_mutex_t);
520 type pthread_mutexattr_t is record
521 valid : long;
522 reserved : unsigned_long_array (0 .. 14);
523 end record;
524 pragma Convention (C, pthread_mutexattr_t);
526 type pthread_condattr_t is record
527 valid : long;
528 reserved : unsigned_long_array (0 .. 12);
529 end record;
530 pragma Convention (C, pthread_condattr_t);
532 type pthread_key_t is new unsigned;
534 end System.OS_Interface;