2002-02-06 Aldy Hernandez <aldyh@redhat.com>
[official-gcc.git] / gcc / ada / 5aosinte.ads
blob8a1ee3b4a392ca461c051d37492b8be695991396
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.23 $
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. It is --
32 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
33 -- State University (http://www.gnat.com). --
34 -- --
35 ------------------------------------------------------------------------------
37 -- This is the DEC Unix 4.0/5.1 version of this package.
39 -- This package encapsulates all direct interfaces to OS services
40 -- that are needed by children of System.
42 -- PLEASE DO NOT add any with-clauses to this package
43 -- It is designed to be a bottom-level (leaf) package.
45 with Interfaces.C;
46 package System.OS_Interface is
47 pragma Preelaborate;
49 pragma Linker_Options ("-lpthread");
50 pragma Linker_Options ("-lmach");
51 pragma Linker_Options ("-lexc");
52 pragma Linker_Options ("-lrt");
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 char_array is Interfaces.C.char_array;
65 -----------
66 -- Errno --
67 -----------
69 function errno return int;
70 pragma Import (C, errno, "_Geterrno");
72 EAGAIN : constant := 35;
73 EINTR : constant := 4;
74 EINVAL : constant := 22;
75 ENOMEM : constant := 12;
76 ETIMEDOUT : constant := 60;
78 -------------
79 -- Signals --
80 -------------
82 Max_Interrupt : constant := 48;
83 type Signal is new int range 0 .. Max_Interrupt;
84 for Signal'Size use int'Size;
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 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
92 SIGIOT : constant := 6; -- abort (terminate) process
93 SIGLOST : constant := 6; -- old BSD signal ??
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 SIGURG : constant := 16; -- urgent condition on IO channel
104 SIGIOINT : constant := 16; -- printer to backend error signal
105 SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
106 SIGTSTP : constant := 18; -- user stop requested from tty
107 SIGCONT : constant := 19; -- stopped process has been continued
108 SIGCHLD : constant := 20; -- child status change
109 SIGTTIN : constant := 21; -- background tty read attempted
110 SIGTTOU : constant := 22; -- background tty write attempted
111 SIGPOLL : constant := 23; -- I/O possible, or completed
112 SIGIO : constant := 23; -- STREAMS version of SIGPOLL
113 SIGAIO : constant := 23; -- base lan i/o
114 SIGPTY : constant := 23; -- pty i/o
115 SIGXCPU : constant := 24; -- CPU time limit exceeded
116 SIGXFSZ : constant := 25; -- filesize limit exceeded
117 SIGVTALRM : constant := 26; -- virtual timer expired
118 SIGPROF : constant := 27; -- profiling timer expired
119 SIGWINCH : constant := 28; -- window size change
120 SIGINFO : constant := 29; -- information request
121 SIGPWR : constant := 29; -- Power Fail/Restart -- SVID3/SVR4
122 SIGUSR1 : constant := 30; -- user defined signal 1
123 SIGUSR2 : constant := 31; -- user defined signal 2
124 SIGRESV : constant := 32; -- reserved by Digital for future use
126 SIGADAABORT : constant := SIGABRT;
128 type Signal_Set is array (Natural range <>) of Signal;
130 Unmasked : constant Signal_Set := (0 .. 0 => SIGTRAP);
131 Reserved : constant Signal_Set := (SIGALRM, SIGABRT, SIGKILL, SIGSTOP);
133 type sigset_t is private;
135 function sigaddset (set : access sigset_t; sig : Signal) return int;
136 pragma Import (C, sigaddset);
138 function sigdelset (set : access sigset_t; sig : Signal) return int;
139 pragma Import (C, sigdelset);
141 function sigfillset (set : access sigset_t) return int;
142 pragma Import (C, sigfillset);
144 function sigismember (set : access sigset_t; sig : Signal) return int;
145 pragma Import (C, sigismember);
147 function sigemptyset (set : access sigset_t) return int;
148 pragma Import (C, sigemptyset);
150 type union_type_3 is new String (1 .. 116);
151 type siginfo_t is record
152 si_signo : int;
153 si_errno : int;
154 si_code : int;
155 X_data : union_type_3;
156 end record;
157 for siginfo_t'Size use 8 * 128;
158 pragma Convention (C, siginfo_t);
160 type struct_sigaction is record
161 sa_handler : System.Address;
162 sa_mask : sigset_t;
163 sa_flags : int;
164 sa_signo : int;
165 end record;
166 pragma Convention (C, struct_sigaction);
167 type struct_sigaction_ptr is access all struct_sigaction;
169 SIG_BLOCK : constant := 1;
170 SIG_UNBLOCK : constant := 2;
171 SIG_SETMASK : constant := 3;
173 SIG_DFL : constant := 0;
174 SIG_IGN : constant := 1;
176 SA_NODEFER : constant := 8;
177 SA_SIGINFO : constant := 16#40#;
179 function sigaction
180 (sig : Signal;
181 act : struct_sigaction_ptr;
182 oact : struct_sigaction_ptr) return int;
183 pragma Import (C, sigaction);
185 ----------
186 -- Time --
187 ----------
189 type timespec is private;
191 function nanosleep (rqtp, rmtp : access timespec) return int;
192 pragma Import (C, nanosleep);
194 type clockid_t is private;
196 CLOCK_REALTIME : constant clockid_t;
198 function clock_gettime
199 (clock_id : clockid_t;
200 tp : access timespec) return int;
201 pragma Import (C, clock_gettime);
203 function To_Duration (TS : timespec) return Duration;
204 pragma Inline (To_Duration);
206 function To_Timespec (D : Duration) return timespec;
207 pragma Inline (To_Timespec);
209 type struct_timezone is record
210 tz_minuteswest : int;
211 tz_dsttime : int;
212 end record;
213 pragma Convention (C, struct_timezone);
214 type struct_timeval is private;
215 -- This is needed on systems that do not have clock_gettime()
216 -- but do have gettimeofday().
218 function To_Duration (TV : struct_timeval) return Duration;
219 pragma Inline (To_Duration);
221 function To_Timeval (D : Duration) return struct_timeval;
222 pragma Inline (To_Timeval);
224 -------------------------
225 -- Priority Scheduling --
226 -------------------------
228 SCHED_FIFO : constant := 1;
229 SCHED_RR : constant := 2;
230 SCHED_OTHER : constant := 3;
231 SCHED_LFI : constant := 5;
233 -------------
234 -- Process --
235 -------------
237 type pid_t is private;
239 function kill (pid : pid_t; sig : Signal) return int;
240 pragma Import (C, kill);
242 function getpid return pid_t;
243 pragma Import (C, getpid);
245 BIND_NO_INHERIT : constant := 1;
247 function bind_to_cpu
248 (pid : pid_t;
249 cpu_mask : unsigned_long;
250 flag : unsigned_long := BIND_NO_INHERIT) return int;
251 pragma Import (C, bind_to_cpu);
253 -------------
254 -- Threads --
255 -------------
257 type Thread_Body is access
258 function (arg : System.Address) return System.Address;
259 type pthread_t is private;
260 subtype Thread_Id is pthread_t;
262 type pthread_mutex_t is limited private;
263 type pthread_cond_t is limited private;
264 type pthread_attr_t is limited private;
265 type pthread_mutexattr_t is limited private;
266 type pthread_condattr_t is limited private;
267 type pthread_key_t is private;
269 PTHREAD_CREATE_DETACHED : constant := 1;
271 PTHREAD_SCOPE_PROCESS : constant := 0;
272 PTHREAD_SCOPE_SYSTEM : constant := 1;
274 PTHREAD_EXPLICIT_SCHED : constant := 1;
276 ---------------------------------------
277 -- Nonstandard Thread Initialization --
278 ---------------------------------------
280 procedure pthread_init;
281 pragma Inline (pthread_init);
282 -- This is a dummy procedure to share some GNULLI files
284 ---------------------------
285 -- POSIX.1c Section 3 --
286 ---------------------------
288 function sigwait
289 (set : access sigset_t;
290 sig : access Signal) return int;
291 pragma Import (C, sigwait, "__sigwaitd10");
293 function pthread_kill
294 (thread : pthread_t;
295 sig : Signal) return int;
296 pragma Import (C, pthread_kill);
298 type sigset_t_ptr is access all sigset_t;
300 function pthread_sigmask
301 (how : int;
302 set : sigset_t_ptr;
303 oset : sigset_t_ptr) return int;
304 pragma Import (C, pthread_sigmask);
306 ----------------------------
307 -- POSIX.1c Section 11 --
308 ----------------------------
310 function pthread_mutexattr_init (attr : access pthread_mutexattr_t)
311 return int;
312 pragma Import (C, pthread_mutexattr_init);
314 function pthread_mutexattr_destroy
315 (attr : access pthread_mutexattr_t) return int;
316 pragma Import (C, pthread_mutexattr_destroy);
318 function pthread_mutex_init
319 (mutex : access pthread_mutex_t;
320 attr : access pthread_mutexattr_t) return int;
321 pragma Import (C, pthread_mutex_init, "__pthread_mutex_init");
323 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
324 pragma Import (C, pthread_mutex_destroy, "__pthread_mutex_destroy");
326 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
327 pragma Import (C, pthread_mutex_lock, "__pthread_mutex_lock");
329 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
330 pragma Import (C, pthread_mutex_unlock, "__pthread_mutex_unlock");
332 function pthread_condattr_init
333 (attr : access pthread_condattr_t) return int;
334 pragma Import (C, pthread_condattr_init);
336 function pthread_condattr_destroy
337 (attr : access pthread_condattr_t) return int;
338 pragma Import (C, pthread_condattr_destroy);
340 function pthread_cond_init
341 (cond : access pthread_cond_t;
342 attr : access pthread_condattr_t) return int;
343 pragma Import (C, pthread_cond_init, "__pthread_cond_init");
345 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
346 pragma Import (C, pthread_cond_destroy, "__pthread_cond_destroy");
348 function pthread_cond_signal (cond : access pthread_cond_t) return int;
349 pragma Import (C, pthread_cond_signal, "__pthread_cond_signal");
351 function pthread_cond_wait
352 (cond : access pthread_cond_t;
353 mutex : access pthread_mutex_t) return int;
354 pragma Import (C, pthread_cond_wait, "__pthread_cond_wait");
356 function pthread_cond_timedwait
357 (cond : access pthread_cond_t;
358 mutex : access pthread_mutex_t;
359 abstime : access timespec) return int;
360 pragma Import (C, pthread_cond_timedwait, "__pthread_cond_timedwait");
362 ----------------------------
363 -- POSIX.1c Section 13 --
364 ----------------------------
366 function pthread_mutexattr_setprotocol
367 (attr : access pthread_mutexattr_t;
368 protocol : int) return int;
369 pragma Import (C, pthread_mutexattr_setprotocol);
371 function pthread_mutexattr_setprioceiling
372 (attr : access pthread_mutexattr_t;
373 prioceiling : int) return int;
374 pragma Import (C, pthread_mutexattr_setprioceiling);
376 type struct_sched_param is record
377 sched_priority : int; -- scheduling priority
378 end record;
380 function pthread_setschedparam
381 (thread : pthread_t;
382 policy : int;
383 param : access struct_sched_param) return int;
384 pragma Import (C, pthread_setschedparam);
386 function pthread_attr_setscope
387 (attr : access pthread_attr_t;
388 contentionscope : int) return int;
389 pragma Import (C, pthread_attr_setscope);
391 function pthread_attr_setinheritsched
392 (attr : access pthread_attr_t;
393 inheritsched : int) return int;
394 pragma Import (C, pthread_attr_setinheritsched,
395 "__pthread_attr_setinheritsched");
397 function pthread_attr_setschedpolicy
398 (attr : access pthread_attr_t; policy : int) return int;
399 pragma Import (C, pthread_attr_setschedpolicy);
401 function pthread_attr_setschedparam
402 (attr : access pthread_attr_t;
403 sched_param : access struct_sched_param) return int;
404 pragma Import (C, pthread_attr_setschedparam);
406 function sched_yield return int;
407 pragma Import (C, sched_yield);
409 ---------------------------
410 -- P1003.1c - Section 16 --
411 ---------------------------
413 function pthread_attr_init (attributes : access pthread_attr_t)
414 return int;
415 pragma Import (C, pthread_attr_init);
417 function pthread_attr_destroy (attributes : access pthread_attr_t)
418 return int;
419 pragma Import (C, pthread_attr_destroy);
421 function pthread_attr_setdetachstate
422 (attr : access pthread_attr_t;
423 detachstate : int) return int;
424 pragma Import (C, pthread_attr_setdetachstate);
426 function pthread_attr_setstacksize
427 (attr : access pthread_attr_t;
428 stacksize : size_t) return int;
429 pragma Import (C, pthread_attr_setstacksize, "__pthread_attr_setstacksize");
431 function pthread_create
432 (thread : access pthread_t;
433 attributes : access pthread_attr_t;
434 start_routine : Thread_Body;
435 arg : System.Address) return int;
436 pragma Import (C, pthread_create, "__pthread_create");
438 procedure pthread_exit (status : System.Address);
439 pragma Import (C, pthread_exit, "__pthread_exit");
441 function pthread_self return pthread_t;
442 pragma Import (C, pthread_self, "__pthread_self");
444 --------------------------
445 -- POSIX.1c Section 17 --
446 --------------------------
448 function pthread_setspecific
449 (key : pthread_key_t; value : System.Address) return int;
450 pragma Import (C, pthread_setspecific, "__pthread_setspecific");
452 function pthread_getspecific (key : pthread_key_t) return System.Address;
453 pragma Import (C, pthread_getspecific, "__pthread_getspecific");
455 type destructor_pointer is access procedure (arg : System.Address);
457 function pthread_key_create
458 (key : access pthread_key_t;
459 destructor : destructor_pointer) return int;
460 pragma Import (C, pthread_key_create);
462 private
464 type sigset_t is new unsigned_long;
466 type pid_t is new int;
468 type time_t is new int;
470 type timespec is record
471 tv_sec : time_t;
472 tv_nsec : long;
473 end record;
474 pragma Convention (C, timespec);
476 type clockid_t is new int;
477 CLOCK_REALTIME : constant clockid_t := 1;
479 type struct_timeval is record
480 tv_sec : time_t;
481 tv_usec : time_t;
482 end record;
483 pragma Convention (C, struct_timeval);
485 type unsigned_long_array is array (Natural range <>) of unsigned_long;
487 type pthread_t is new System.Address;
489 type pthread_cond_t is record
490 state : unsigned;
491 valid : unsigned;
492 name : System.Address;
493 arg : unsigned;
494 reserved1 : unsigned;
495 sequence : unsigned_long;
496 block : System.Address;
497 end record;
498 pragma Convention (C, pthread_cond_t);
500 type pthread_attr_t is record
501 valid : long;
502 name : System.Address;
503 arg : unsigned_long;
504 reserved : unsigned_long_array (0 .. 18);
505 end record;
506 pragma Convention (C, pthread_attr_t);
508 type pthread_mutex_t is record
509 lock : unsigned;
510 valid : unsigned;
511 name : System.Address;
512 arg : unsigned;
513 depth : unsigned;
514 sequence : unsigned_long;
515 owner : unsigned_long;
516 block : System.Address;
517 end record;
518 for pthread_mutex_t'Size use 8 * 48;
519 pragma Convention (C, pthread_mutex_t);
521 type pthread_mutexattr_t is record
522 valid : long;
523 reserved : unsigned_long_array (0 .. 14);
524 end record;
525 pragma Convention (C, pthread_mutexattr_t);
527 type pthread_condattr_t is record
528 valid : long;
529 reserved : unsigned_long_array (0 .. 12);
530 end record;
531 pragma Convention (C, pthread_condattr_t);
533 type pthread_key_t is new unsigned;
535 end System.OS_Interface;