objc/
[official-gcc.git] / gcc / ada / s-osinte-irix.ads
blob88bb5007c4659cf953d8445a57d75f1103298a21
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNAT 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 -- Copyright (C) 1991-1994, Florida State University --
10 -- Copyright (C) 1995-2005, 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, 51 Franklin Street, Fifth Floor, --
21 -- Boston, MA 02110-1301, 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 ------------------------------------------------------------------------------
35 -- This is the SGI Pthreads version of this package
37 -- This package encapsulates all direct interfaces to OS services
38 -- that are needed by children of System.
40 -- PLEASE DO NOT add any with-clauses to this package or remove the pragma
41 -- Preelaborate. This package is designed to be a bottom-level (leaf) package.
43 with Interfaces.C;
44 with Unchecked_Conversion;
46 package System.OS_Interface is
48 pragma Preelaborate;
50 pragma Linker_Options ("-lpthread");
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;
62 -----------
63 -- Errno --
64 -----------
66 function errno return int;
67 pragma Import (C, errno, "__get_errno");
69 EINTR : constant := 4; -- interrupted system call
70 EAGAIN : constant := 11; -- No more processes
71 ENOMEM : constant := 12; -- Not enough core
72 EINVAL : constant := 22; -- Invalid argument
73 ETIMEDOUT : constant := 145; -- Connection timed out
75 -------------
76 -- Signals --
77 -------------
79 Max_Interrupt : constant := 64;
80 type Signal is new int range 0 .. Max_Interrupt;
81 for Signal'Size use int'Size;
83 SIGHUP : constant := 1; -- hangup
84 SIGINT : constant := 2; -- interrupt (rubout)
85 SIGQUIT : constant := 3; -- quit (ASCD FS)
86 SIGILL : constant := 4; -- illegal instruction (not reset)
87 SIGTRAP : constant := 5; -- trace trap (not reset)
88 SIGIOT : constant := 6; -- IOT instruction
89 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the
90 -- future
91 SIGEMT : constant := 7; -- EMT instruction
92 SIGFPE : constant := 8; -- floating point exception
93 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
94 SIGBUS : constant := 10; -- bus error
95 SIGSEGV : constant := 11; -- segmentation violation
96 SIGSYS : constant := 12; -- bad argument to system call
97 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
98 SIGALRM : constant := 14; -- alarm clock
99 SIGTERM : constant := 15; -- software termination signal from kill
100 SIGUSR1 : constant := 16; -- user defined signal 1
101 SIGUSR2 : constant := 17; -- user defined signal 2
102 SIGCLD : constant := 18; -- alias for SIGCHLD
103 SIGCHLD : constant := 18; -- child status change
104 SIGPWR : constant := 19; -- power-fail restart
105 SIGWINCH : constant := 20; -- window size change
106 SIGURG : constant := 21; -- urgent condition on IO channel
107 SIGPOLL : constant := 22; -- pollable event occurred
108 SIGIO : constant := 22; -- I/O possible (Solaris SIGPOLL alias)
109 SIGSTOP : constant := 23; -- stop (cannot be caught or ignored)
110 SIGTSTP : constant := 24; -- user stop requested from tty
111 SIGCONT : constant := 25; -- stopped process has been continued
112 SIGTTIN : constant := 26; -- background tty read attempted
113 SIGTTOU : constant := 27; -- background tty write attempted
114 SIGVTALRM : constant := 28; -- virtual timer expired
115 SIGPROF : constant := 29; -- profiling timer expired
116 SIGXCPU : constant := 30; -- CPU time limit exceeded
117 SIGXFSZ : constant := 31; -- filesize limit exceeded
118 SIGK32 : constant := 32; -- reserved for kernel (IRIX)
119 SIGCKPT : constant := 33; -- Checkpoint warning
120 SIGRESTART : constant := 34; -- Restart warning
121 SIGUME : constant := 35; -- Uncorrectable memory error
122 -- Signals defined for Posix 1003.1c.
123 SIGPTINTR : constant := 47;
124 SIGPTRESCHED : constant := 48;
125 -- Posix 1003.1b signals
126 SIGRTMIN : constant := 49; -- Posix 1003.1b signals
127 SIGRTMAX : constant := 64; -- Posix 1003.1b signals
129 type sigset_t is private;
130 type sigset_t_ptr is access all sigset_t;
132 function sigaddset (set : access sigset_t; sig : Signal) return int;
133 pragma Import (C, sigaddset, "sigaddset");
135 function sigdelset (set : access sigset_t; sig : Signal) return int;
136 pragma Import (C, sigdelset, "sigdelset");
138 function sigfillset (set : access sigset_t) return int;
139 pragma Import (C, sigfillset, "sigfillset");
141 function sigismember (set : access sigset_t; sig : Signal) return int;
142 pragma Import (C, sigismember, "sigismember");
144 function sigemptyset (set : access sigset_t) return int;
145 pragma Import (C, sigemptyset, "sigemptyset");
147 type array_type_2 is array (Integer range 0 .. 1) of int;
148 type struct_sigaction is record
149 sa_flags : int;
150 sa_handler : System.Address;
151 sa_mask : sigset_t;
152 sa_resv : array_type_2;
153 end record;
154 pragma Convention (C, struct_sigaction);
156 type struct_sigaction_ptr is access all struct_sigaction;
158 SIG_BLOCK : constant := 1;
159 SIG_UNBLOCK : constant := 2;
160 SIG_SETMASK : constant := 3;
162 SIG_DFL : constant := 0;
163 SIG_IGN : constant := 1;
165 function sigaction
166 (sig : Signal;
167 act : struct_sigaction_ptr;
168 oact : struct_sigaction_ptr := null) return int;
169 pragma Import (C, sigaction, "sigaction");
171 ----------
172 -- Time --
173 ----------
175 type timespec is private;
176 type timespec_ptr is access all timespec;
178 type clockid_t is private;
180 CLOCK_REALTIME : constant clockid_t;
181 CLOCK_SGI_FAST : constant clockid_t;
182 CLOCK_SGI_CYCLE : constant clockid_t;
184 SGI_CYCLECNTR_SIZE : constant := 165;
186 function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
187 pragma Import (C, syssgi, "syssgi");
189 function clock_gettime
190 (clock_id : clockid_t;
191 tp : access timespec) return int;
192 pragma Import (C, clock_gettime, "clock_gettime");
194 function clock_getres
195 (clock_id : clockid_t;
196 tp : access timespec) return int;
197 pragma Import (C, clock_getres, "clock_getres");
199 function To_Duration (TS : timespec) return Duration;
200 pragma Inline (To_Duration);
202 function To_Timespec (D : Duration) return timespec;
203 pragma Inline (To_Timespec);
205 type struct_timeval is private;
207 function To_Duration (TV : struct_timeval) return Duration;
208 pragma Inline (To_Duration);
210 function To_Timeval (D : Duration) return struct_timeval;
211 pragma Inline (To_Timeval);
213 -------------------------
214 -- Priority Scheduling --
215 -------------------------
217 SCHED_FIFO : constant := 1;
218 SCHED_RR : constant := 2;
219 SCHED_TS : constant := 3;
220 SCHED_OTHER : constant := 3;
221 SCHED_NP : constant := 4;
223 function sched_get_priority_min (Policy : int) return int;
224 pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
226 function sched_get_priority_max (Policy : int) return int;
227 pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
229 -------------
230 -- Process --
231 -------------
233 type pid_t is private;
235 function kill (pid : pid_t; sig : Signal) return int;
236 pragma Import (C, kill, "kill");
238 function getpid return pid_t;
239 pragma Import (C, getpid, "getpid");
241 -------------
242 -- Threads --
243 -------------
245 type Thread_Body is access
246 function (arg : System.Address) return System.Address;
248 function Thread_Body_Access is new
249 Unchecked_Conversion (System.Address, Thread_Body);
251 type pthread_t is private;
252 subtype Thread_Id is pthread_t;
254 type pthread_mutex_t is limited private;
255 type pthread_cond_t is limited private;
256 type pthread_attr_t is limited private;
257 type pthread_mutexattr_t is limited private;
258 type pthread_condattr_t is limited private;
259 type pthread_key_t is private;
261 PTHREAD_CREATE_DETACHED : constant := 1;
263 ---------------------------------------
264 -- Nonstandard Thread Initialization --
265 ---------------------------------------
267 procedure pthread_init;
268 pragma Inline (pthread_init);
269 -- This is a dummy procedure to share some GNULLI files
271 -------------------------
272 -- POSIX.1c Section 3 --
273 -------------------------
275 function sigwait
276 (set : access sigset_t;
277 sig : access Signal) return int;
278 pragma Import (C, sigwait, "sigwait");
280 function pthread_kill
281 (thread : pthread_t;
282 sig : Signal) return int;
283 pragma Import (C, pthread_kill, "pthread_kill");
285 function pthread_sigmask
286 (how : int;
287 set : sigset_t_ptr;
288 oset : sigset_t_ptr) return int;
289 pragma Import (C, pthread_sigmask, "pthread_sigmask");
291 --------------------------
292 -- POSIX.1c Section 11 --
293 --------------------------
295 function pthread_mutexattr_init
296 (attr : access pthread_mutexattr_t) return int;
297 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
299 function pthread_mutexattr_destroy
300 (attr : access pthread_mutexattr_t) return int;
301 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
303 function pthread_mutex_init
304 (mutex : access pthread_mutex_t;
305 attr : access pthread_mutexattr_t) return int;
306 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
308 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
309 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
311 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
312 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
314 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
315 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
317 function pthread_condattr_init
318 (attr : access pthread_condattr_t) return int;
319 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
321 function pthread_condattr_destroy
322 (attr : access pthread_condattr_t) return int;
323 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
325 function pthread_cond_init
326 (cond : access pthread_cond_t;
327 attr : access pthread_condattr_t) return int;
328 pragma Import (C, pthread_cond_init, "pthread_cond_init");
330 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
331 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
333 function pthread_cond_signal (cond : access pthread_cond_t) return int;
334 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
336 function pthread_cond_wait
337 (cond : access pthread_cond_t;
338 mutex : access pthread_mutex_t) return int;
339 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
341 function pthread_cond_timedwait
342 (cond : access pthread_cond_t;
343 mutex : access pthread_mutex_t;
344 abstime : access timespec) return int;
345 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
347 --------------------------
348 -- POSIX.1c Section 13 --
349 --------------------------
351 PTHREAD_PRIO_NONE : constant := 0;
352 PTHREAD_PRIO_PROTECT : constant := 2;
353 PTHREAD_PRIO_INHERIT : constant := 1;
355 function pthread_mutexattr_setprotocol
356 (attr : access pthread_mutexattr_t;
357 protocol : int) return int;
358 pragma Import (C, pthread_mutexattr_setprotocol);
360 function pthread_mutexattr_setprioceiling
361 (attr : access pthread_mutexattr_t;
362 prioceiling : int) return int;
363 pragma Import (C, pthread_mutexattr_setprioceiling);
365 type struct_sched_param is record
366 sched_priority : int;
367 end record;
368 pragma Convention (C, struct_sched_param);
370 function pthread_setschedparam
371 (thread : pthread_t;
372 policy : int;
373 param : access struct_sched_param)
374 return int;
375 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
377 function pthread_attr_setscope
378 (attr : access pthread_attr_t;
379 contentionscope : int) return int;
380 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
382 function pthread_attr_setinheritsched
383 (attr : access pthread_attr_t;
384 inheritsched : int) return int;
385 pragma Import
386 (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
388 function pthread_attr_setschedpolicy
389 (attr : access pthread_attr_t;
390 policy : int) return int;
391 pragma Import (C, pthread_attr_setschedpolicy);
393 function pthread_attr_setschedparam
394 (attr : access pthread_attr_t;
395 sched_param : access struct_sched_param)
396 return int;
397 pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
399 function sched_yield return int;
400 pragma Import (C, sched_yield, "sched_yield");
402 ---------------------------
403 -- P1003.1c - Section 16 --
404 ---------------------------
406 function pthread_attr_init (attributes : access pthread_attr_t) return int;
407 pragma Import (C, pthread_attr_init, "pthread_attr_init");
409 function pthread_attr_destroy
410 (attributes : access pthread_attr_t) return int;
411 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
413 function pthread_attr_setdetachstate
414 (attr : access pthread_attr_t;
415 detachstate : int) return int;
416 pragma Import (C, pthread_attr_setdetachstate);
418 function pthread_attr_setstacksize
419 (attr : access pthread_attr_t;
420 stacksize : size_t) return int;
421 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
423 function pthread_create
424 (thread : access pthread_t;
425 attributes : access pthread_attr_t;
426 start_routine : Thread_Body;
427 arg : System.Address) return int;
428 pragma Import (C, pthread_create, "pthread_create");
430 procedure pthread_exit (status : System.Address);
431 pragma Import (C, pthread_exit, "pthread_exit");
433 function pthread_self return pthread_t;
434 pragma Import (C, pthread_self, "pthread_self");
436 --------------------------
437 -- POSIX.1c Section 17 --
438 --------------------------
440 function pthread_setspecific
441 (key : pthread_key_t;
442 value : System.Address) return int;
443 pragma Import (C, pthread_setspecific, "pthread_setspecific");
445 function pthread_getspecific (key : pthread_key_t) return System.Address;
446 pragma Import (C, pthread_getspecific, "pthread_getspecific");
448 type destructor_pointer is access procedure (arg : System.Address);
450 function pthread_key_create
451 (key : access pthread_key_t;
452 destructor : destructor_pointer) return int;
453 pragma Import (C, pthread_key_create, "pthread_key_create");
455 -------------------
456 -- SGI Additions --
457 -------------------
459 -- Non portable SGI 6.5 additions to the pthread interface must be
460 -- executed from within the context of a system scope task.
462 function pthread_setrunon_np (cpu : int) return int;
463 pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
465 private
467 type array_type_1 is array (Integer range 0 .. 3) of unsigned;
468 type sigset_t is record
469 X_X_sigbits : array_type_1;
470 end record;
471 pragma Convention (C, sigset_t);
473 type pid_t is new long;
475 type time_t is new long;
477 type timespec is record
478 tv_sec : time_t;
479 tv_nsec : long;
480 end record;
481 pragma Convention (C, timespec);
483 type clockid_t is new int;
484 CLOCK_REALTIME : constant clockid_t := 1;
485 CLOCK_SGI_CYCLE : constant clockid_t := 2;
486 CLOCK_SGI_FAST : constant clockid_t := 3;
488 type struct_timeval is record
489 tv_sec : time_t;
490 tv_usec : time_t;
491 end record;
492 pragma Convention (C, struct_timeval);
494 type array_type_9 is array (Integer range 0 .. 4) of long;
495 type pthread_attr_t is record
496 X_X_D : array_type_9;
497 end record;
498 pragma Convention (C, pthread_attr_t);
500 type array_type_8 is array (Integer range 0 .. 1) of long;
501 type pthread_condattr_t is record
502 X_X_D : array_type_8;
503 end record;
504 pragma Convention (C, pthread_condattr_t);
506 type array_type_7 is array (Integer range 0 .. 1) of long;
507 type pthread_mutexattr_t is record
508 X_X_D : array_type_7;
509 end record;
510 pragma Convention (C, pthread_mutexattr_t);
512 type pthread_t is new unsigned;
514 type array_type_10 is array (Integer range 0 .. 7) of long;
515 type pthread_mutex_t is record
516 X_X_D : array_type_10;
517 end record;
518 pragma Convention (C, pthread_mutex_t);
520 type array_type_11 is array (Integer range 0 .. 7) of long;
521 type pthread_cond_t is record
522 X_X_D : array_type_11;
523 end record;
524 pragma Convention (C, pthread_cond_t);
526 type pthread_key_t is new int;
528 end System.OS_Interface;