Daily bump.
[official-gcc.git] / gcc / ada / 5fosinte.ads
blob6e5973d9e21e3a901253215b34ec807258404d67
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.13 $
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 SGI Pthreads 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 -- or remove the pragma Elaborate_Body.
44 -- It is designed to be a bottom-level (leaf) package.
46 with Interfaces.C;
47 package System.OS_Interface is
49 pragma Preelaborate;
51 pragma Linker_Options ("-lpthread");
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;
63 -----------
64 -- Errno --
65 -----------
67 function errno return int;
68 pragma Import (C, errno, "__get_errno");
70 EINTR : constant := 4; -- interrupted system call
71 EAGAIN : constant := 11; -- No more processes
72 ENOMEM : constant := 12; -- Not enough core
73 EINVAL : constant := 22; -- Invalid argument
74 ETIMEDOUT : constant := 145; -- Connection timed out
76 -------------
77 -- Signals --
78 -------------
80 Max_Interrupt : constant := 64;
81 type Signal is new int range 0 .. Max_Interrupt;
82 for Signal'Size use int'Size;
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 SIGIOT : constant := 6; -- IOT instruction
90 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the
91 -- future
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 SIGUSR1 : constant := 16; -- user defined signal 1
102 SIGUSR2 : constant := 17; -- user defined signal 2
103 SIGCLD : constant := 18; -- alias for SIGCHLD
104 SIGCHLD : constant := 18; -- child status change
105 SIGPWR : constant := 19; -- power-fail restart
106 SIGWINCH : constant := 20; -- window size change
107 SIGURG : constant := 21; -- urgent condition on IO channel
108 SIGPOLL : constant := 22; -- pollable event occurred
109 SIGIO : constant := 22; -- I/O possible (Solaris SIGPOLL alias)
110 SIGSTOP : constant := 23; -- stop (cannot be caught or ignored)
111 SIGTSTP : constant := 24; -- user stop requested from tty
112 SIGCONT : constant := 25; -- stopped process has been continued
113 SIGTTIN : constant := 26; -- background tty read attempted
114 SIGTTOU : constant := 27; -- background tty write attempted
115 SIGVTALRM : constant := 28; -- virtual timer expired
116 SIGPROF : constant := 29; -- profiling timer expired
117 SIGXCPU : constant := 30; -- CPU time limit exceeded
118 SIGXFSZ : constant := 31; -- filesize limit exceeded
119 SIGK32 : constant := 32; -- reserved for kernel (IRIX)
120 SIGCKPT : constant := 33; -- Checkpoint warning
121 SIGRESTART : constant := 34; -- Restart warning
122 SIGUME : constant := 35; -- Uncorrectable memory error
123 -- Signals defined for Posix 1003.1c.
124 SIGPTINTR : constant := 47;
125 SIGPTRESCHED : constant := 48;
126 -- Posix 1003.1b signals
127 SIGRTMIN : constant := 49; -- Posix 1003.1b signals
128 SIGRTMAX : constant := 64; -- Posix 1003.1b signals
130 type sigset_t is private;
131 type sigset_t_ptr is access all sigset_t;
133 function sigaddset (set : access sigset_t; sig : Signal) return int;
134 pragma Import (C, sigaddset, "sigaddset");
136 function sigdelset (set : access sigset_t; sig : Signal) return int;
137 pragma Import (C, sigdelset, "sigdelset");
139 function sigfillset (set : access sigset_t) return int;
140 pragma Import (C, sigfillset, "sigfillset");
142 function sigismember (set : access sigset_t; sig : Signal) return int;
143 pragma Import (C, sigismember, "sigismember");
145 function sigemptyset (set : access sigset_t) return int;
146 pragma Import (C, sigemptyset, "sigemptyset");
148 type array_type_2 is array (Integer range 0 .. 1) of int;
149 type struct_sigaction is record
150 sa_flags : int;
151 sa_handler : System.Address;
152 sa_mask : sigset_t;
153 sa_resv : array_type_2;
154 end record;
155 pragma Convention (C, struct_sigaction);
157 type struct_sigaction_ptr is access all struct_sigaction;
159 SIG_BLOCK : constant := 1;
160 SIG_UNBLOCK : constant := 2;
161 SIG_SETMASK : constant := 3;
163 SIG_DFL : constant := 0;
164 SIG_IGN : constant := 1;
166 function sigaction
167 (sig : Signal;
168 act : struct_sigaction_ptr;
169 oact : struct_sigaction_ptr := null) return int;
170 pragma Import (C, sigaction, "sigaction");
172 ----------
173 -- Time --
174 ----------
176 type timespec is private;
177 type timespec_ptr is access all timespec;
179 type clockid_t is private;
181 CLOCK_REALTIME : constant clockid_t;
182 CLOCK_SGI_FAST : constant clockid_t;
183 CLOCK_SGI_CYCLE : constant clockid_t;
185 SGI_CYCLECNTR_SIZE : constant := 165;
187 function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
188 pragma Import (C, syssgi, "syssgi");
190 function clock_gettime
191 (clock_id : clockid_t;
192 tp : access timespec) return int;
193 pragma Import (C, clock_gettime, "clock_gettime");
195 function clock_getres
196 (clock_id : clockid_t;
197 tp : access timespec) return int;
198 pragma Import (C, clock_getres, "clock_getres");
200 function To_Duration (TS : timespec) return Duration;
201 pragma Inline (To_Duration);
203 function To_Timespec (D : Duration) return timespec;
204 pragma Inline (To_Timespec);
206 type struct_timeval is private;
208 function To_Duration (TV : struct_timeval) return Duration;
209 pragma Inline (To_Duration);
211 function To_Timeval (D : Duration) return struct_timeval;
212 pragma Inline (To_Timeval);
214 -------------------------
215 -- Priority Scheduling --
216 -------------------------
218 SCHED_FIFO : constant := 1;
219 SCHED_RR : constant := 2;
220 SCHED_TS : constant := 3;
221 SCHED_OTHER : constant := 3;
222 SCHED_NP : constant := 4;
224 function sched_get_priority_min (Policy : int) return int;
225 pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
227 function sched_get_priority_max (Policy : int) return int;
228 pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
230 -------------
231 -- Process --
232 -------------
234 type pid_t is private;
236 function kill (pid : pid_t; sig : Signal) return int;
237 pragma Import (C, kill, "kill");
239 function getpid return pid_t;
240 pragma Import (C, getpid, "getpid");
242 -------------
243 -- Threads --
244 -------------
246 type Thread_Body is access
247 function (arg : System.Address) return System.Address;
248 type pthread_t is private;
249 subtype Thread_Id is pthread_t;
251 type pthread_mutex_t is limited private;
252 type pthread_cond_t is limited private;
253 type pthread_attr_t is limited private;
254 type pthread_mutexattr_t is limited private;
255 type pthread_condattr_t is limited private;
256 type pthread_key_t is private;
258 PTHREAD_CREATE_DETACHED : constant := 1;
260 ---------------------------------------
261 -- Nonstandard Thread Initialization --
262 ---------------------------------------
264 procedure pthread_init;
265 pragma Inline (pthread_init);
266 -- This is a dummy procedure to share some GNULLI files
268 -------------------------
269 -- POSIX.1c Section 3 --
270 -------------------------
272 function sigwait
273 (set : access sigset_t;
274 sig : access Signal) return int;
275 pragma Import (C, sigwait, "sigwait");
277 function pthread_kill
278 (thread : pthread_t;
279 sig : Signal) return int;
280 pragma Import (C, pthread_kill, "pthread_kill");
282 function pthread_sigmask
283 (how : int;
284 set : sigset_t_ptr;
285 oset : sigset_t_ptr) return int;
286 pragma Import (C, pthread_sigmask, "pthread_sigmask");
288 --------------------------
289 -- POSIX.1c Section 11 --
290 --------------------------
292 function pthread_mutexattr_init
293 (attr : access pthread_mutexattr_t) return int;
294 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
296 function pthread_mutexattr_destroy
297 (attr : access pthread_mutexattr_t) return int;
298 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
300 function pthread_mutex_init
301 (mutex : access pthread_mutex_t;
302 attr : access pthread_mutexattr_t) return int;
303 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
305 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
306 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
308 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
309 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
311 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
312 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
314 function pthread_condattr_init
315 (attr : access pthread_condattr_t) return int;
316 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
318 function pthread_condattr_destroy
319 (attr : access pthread_condattr_t) return int;
320 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
322 function pthread_cond_init
323 (cond : access pthread_cond_t;
324 attr : access pthread_condattr_t) return int;
325 pragma Import (C, pthread_cond_init, "pthread_cond_init");
327 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
328 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
330 function pthread_cond_signal (cond : access pthread_cond_t) return int;
331 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
333 function pthread_cond_wait
334 (cond : access pthread_cond_t;
335 mutex : access pthread_mutex_t) return int;
336 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
338 function pthread_cond_timedwait
339 (cond : access pthread_cond_t;
340 mutex : access pthread_mutex_t;
341 abstime : access timespec) return int;
342 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
344 --------------------------
345 -- POSIX.1c Section 13 --
346 --------------------------
348 PTHREAD_PRIO_NONE : constant := 0;
349 PTHREAD_PRIO_PROTECT : constant := 2;
350 PTHREAD_PRIO_INHERIT : constant := 1;
352 function pthread_mutexattr_setprotocol
353 (attr : access pthread_mutexattr_t;
354 protocol : int) return int;
355 pragma Import (C, pthread_mutexattr_setprotocol);
357 function pthread_mutexattr_setprioceiling
358 (attr : access pthread_mutexattr_t;
359 prioceiling : int) return int;
360 pragma Import (C, pthread_mutexattr_setprioceiling);
362 type struct_sched_param is record
363 sched_priority : int;
364 end record;
365 pragma Convention (C, struct_sched_param);
367 function pthread_setschedparam
368 (thread : pthread_t;
369 policy : int;
370 param : access struct_sched_param)
371 return int;
372 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
374 function pthread_attr_setscope
375 (attr : access pthread_attr_t;
376 contentionscope : int) return int;
377 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
379 function pthread_attr_setinheritsched
380 (attr : access pthread_attr_t;
381 inheritsched : int) return int;
382 pragma Import
383 (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
385 function pthread_attr_setschedpolicy
386 (attr : access pthread_attr_t;
387 policy : int) return int;
388 pragma Import (C, pthread_attr_setschedpolicy);
390 function pthread_attr_setschedparam
391 (attr : access pthread_attr_t;
392 sched_param : access struct_sched_param)
393 return int;
394 pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
396 function sched_yield return int;
397 pragma Import (C, sched_yield, "sched_yield");
399 ---------------------------
400 -- P1003.1c - Section 16 --
401 ---------------------------
403 function pthread_attr_init (attributes : access pthread_attr_t) return int;
404 pragma Import (C, pthread_attr_init, "pthread_attr_init");
406 function pthread_attr_destroy
407 (attributes : access pthread_attr_t) return int;
408 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
410 function pthread_attr_setdetachstate
411 (attr : access pthread_attr_t;
412 detachstate : int) return int;
413 pragma Import (C, pthread_attr_setdetachstate);
415 function pthread_attr_setstacksize
416 (attr : access pthread_attr_t;
417 stacksize : size_t) return int;
418 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
420 function pthread_create
421 (thread : access pthread_t;
422 attributes : access pthread_attr_t;
423 start_routine : Thread_Body;
424 arg : System.Address) return int;
425 pragma Import (C, pthread_create, "pthread_create");
427 procedure pthread_exit (status : System.Address);
428 pragma Import (C, pthread_exit, "pthread_exit");
430 function pthread_self return pthread_t;
431 pragma Import (C, pthread_self, "pthread_self");
433 --------------------------
434 -- POSIX.1c Section 17 --
435 --------------------------
437 function pthread_setspecific
438 (key : pthread_key_t;
439 value : System.Address) return int;
440 pragma Import (C, pthread_setspecific, "pthread_setspecific");
442 function pthread_getspecific (key : pthread_key_t) return System.Address;
443 pragma Import (C, pthread_getspecific, "pthread_getspecific");
445 type destructor_pointer is access procedure (arg : System.Address);
447 function pthread_key_create
448 (key : access pthread_key_t;
449 destructor : destructor_pointer) return int;
450 pragma Import (C, pthread_key_create, "pthread_key_create");
452 ---------------------------------------------------------------
453 -- Non portable SGI 6.5 additions to the pthread interface --
454 -- must be executed from within the context of a system --
455 -- scope task --
456 ---------------------------------------------------------------
458 function pthread_setrunon_np (cpu : int) return int;
459 pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
461 private
463 type array_type_1 is array (Integer range 0 .. 3) of unsigned;
464 type sigset_t is record
465 X_X_sigbits : array_type_1;
466 end record;
467 pragma Convention (C, sigset_t);
469 type pid_t is new long;
471 type time_t is new long;
473 type timespec is record
474 tv_sec : time_t;
475 tv_nsec : long;
476 end record;
477 pragma Convention (C, timespec);
479 type clockid_t is new int;
480 CLOCK_REALTIME : constant clockid_t := 1;
481 CLOCK_SGI_CYCLE : constant clockid_t := 2;
482 CLOCK_SGI_FAST : constant clockid_t := 3;
484 type struct_timeval is record
485 tv_sec : time_t;
486 tv_usec : time_t;
487 end record;
488 pragma Convention (C, struct_timeval);
490 type array_type_9 is array (Integer range 0 .. 4) of long;
491 type pthread_attr_t is record
492 X_X_D : array_type_9;
493 end record;
494 pragma Convention (C, pthread_attr_t);
496 type array_type_8 is array (Integer range 0 .. 1) of long;
497 type pthread_condattr_t is record
498 X_X_D : array_type_8;
499 end record;
500 pragma Convention (C, pthread_condattr_t);
502 type array_type_7 is array (Integer range 0 .. 1) of long;
503 type pthread_mutexattr_t is record
504 X_X_D : array_type_7;
505 end record;
506 pragma Convention (C, pthread_mutexattr_t);
508 type pthread_t is new unsigned;
510 type array_type_10 is array (Integer range 0 .. 7) of long;
511 type pthread_mutex_t is record
512 X_X_D : array_type_10;
513 end record;
514 pragma Convention (C, pthread_mutex_t);
516 type array_type_11 is array (Integer range 0 .. 7) of long;
517 type pthread_cond_t is record
518 X_X_D : array_type_11;
519 end record;
520 pragma Convention (C, pthread_cond_t);
522 type pthread_key_t is new int;
524 end System.OS_Interface;