* opts.c (finish_options): Remove duplicate sorry.
[official-gcc.git] / gcc / ada / s-osinte-irix.ads
blob365a3de2dcab9876f4ca24159aa722e170953a05
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-2011, Free Software Foundation, Inc. --
11 -- --
12 -- GNAT 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 3, or (at your option) any later ver- --
15 -- sion. GNAT 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. --
18 -- --
19 -- As a special exception under Section 7 of GPL version 3, you are granted --
20 -- additional permissions described in the GCC Runtime Library Exception, --
21 -- version 3.1, as published by the Free Software Foundation. --
22 -- --
23 -- You should have received a copy of the GNU General Public License and --
24 -- a copy of the GCC Runtime Library Exception along with this program; --
25 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
26 -- <http://www.gnu.org/licenses/>. --
27 -- --
28 -- GNARL was developed by the GNARL team at Florida State University. --
29 -- Extensive contributions were provided by Ada Core Technologies, Inc. --
30 -- --
31 ------------------------------------------------------------------------------
33 -- This is the SGI Pthreads version of this package
35 -- This package encapsulates all direct interfaces to OS services that are
36 -- needed by the tasking run-time (libgnarl).
38 -- PLEASE DO NOT add any with-clauses to this package or remove the pragma
39 -- Preelaborate. This package is designed to be a bottom-level (leaf) package.
41 with Ada.Unchecked_Conversion;
43 with Interfaces.C;
45 package System.OS_Interface is
47 pragma Preelaborate;
49 pragma Linker_Options ("-lpthread");
51 subtype int is Interfaces.C.int;
52 subtype short is Interfaces.C.short;
53 subtype long is Interfaces.C.long;
54 subtype unsigned is Interfaces.C.unsigned;
55 subtype unsigned_short is Interfaces.C.unsigned_short;
56 subtype unsigned_long is Interfaces.C.unsigned_long;
57 subtype unsigned_char is Interfaces.C.unsigned_char;
58 subtype plain_char is Interfaces.C.plain_char;
59 subtype size_t is Interfaces.C.size_t;
61 -----------
62 -- Errno --
63 -----------
65 function errno return int;
66 pragma Import (C, errno, "__get_errno");
68 EINTR : constant := 4; -- interrupted system call
69 EAGAIN : constant := 11; -- No more processes
70 ENOMEM : constant := 12; -- Not enough core
71 EINVAL : constant := 22; -- Invalid argument
72 ETIMEDOUT : constant := 145; -- Connection timed out
74 -------------
75 -- Signals --
76 -------------
78 Max_Interrupt : constant := 64;
79 type Signal is new int range 0 .. Max_Interrupt;
80 for Signal'Size use int'Size;
82 SIGHUP : constant := 1; -- hangup
83 SIGINT : constant := 2; -- interrupt (rubout)
84 SIGQUIT : constant := 3; -- quit (ASCD FS)
85 SIGILL : constant := 4; -- illegal instruction (not reset)
86 SIGTRAP : constant := 5; -- trace trap (not reset)
87 SIGIOT : constant := 6; -- IOT instruction
88 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
89 SIGEMT : constant := 7; -- EMT instruction
90 SIGFPE : constant := 8; -- floating point exception
91 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
92 SIGBUS : constant := 10; -- bus error
93 SIGSEGV : constant := 11; -- segmentation violation
94 SIGSYS : constant := 12; -- bad argument to system call
95 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
96 SIGALRM : constant := 14; -- alarm clock
97 SIGTERM : constant := 15; -- software termination signal from kill
98 SIGUSR1 : constant := 16; -- user defined signal 1
99 SIGUSR2 : constant := 17; -- user defined signal 2
100 SIGCLD : constant := 18; -- alias for SIGCHLD
101 SIGCHLD : constant := 18; -- child status change
102 SIGPWR : constant := 19; -- power-fail restart
103 SIGWINCH : constant := 20; -- window size change
104 SIGURG : constant := 21; -- urgent condition on IO channel
105 SIGPOLL : constant := 22; -- pollable event occurred
106 SIGIO : constant := 22; -- I/O possible (Solaris SIGPOLL alias)
107 SIGSTOP : constant := 23; -- stop (cannot be caught or ignored)
108 SIGTSTP : constant := 24; -- user stop requested from tty
109 SIGCONT : constant := 25; -- stopped process has been continued
110 SIGTTIN : constant := 26; -- background tty read attempted
111 SIGTTOU : constant := 27; -- background tty write attempted
112 SIGVTALRM : constant := 28; -- virtual timer expired
113 SIGPROF : constant := 29; -- profiling timer expired
114 SIGXCPU : constant := 30; -- CPU time limit exceeded
115 SIGXFSZ : constant := 31; -- filesize limit exceeded
116 SIGK32 : constant := 32; -- reserved for kernel (IRIX)
117 SIGCKPT : constant := 33; -- Checkpoint warning
118 SIGRESTART : constant := 34; -- Restart warning
119 SIGUME : constant := 35; -- Uncorrectable memory error
120 -- Signals defined for Posix 1003.1c
121 SIGPTINTR : constant := 47;
122 SIGPTRESCHED : constant := 48;
123 -- Posix 1003.1b signals
124 SIGRTMIN : constant := 49; -- Posix 1003.1b signals
125 SIGRTMAX : constant := 64; -- Posix 1003.1b signals
127 type sigset_t is private;
129 function sigaddset (set : access sigset_t; sig : Signal) return int;
130 pragma Import (C, sigaddset, "sigaddset");
132 function sigdelset (set : access sigset_t; sig : Signal) return int;
133 pragma Import (C, sigdelset, "sigdelset");
135 function sigfillset (set : access sigset_t) return int;
136 pragma Import (C, sigfillset, "sigfillset");
138 function sigismember (set : access sigset_t; sig : Signal) return int;
139 pragma Import (C, sigismember, "sigismember");
141 function sigemptyset (set : access sigset_t) return int;
142 pragma Import (C, sigemptyset, "sigemptyset");
144 type array_type_2 is array (Integer range 0 .. 1) of int;
145 type struct_sigaction is record
146 sa_flags : int;
147 sa_handler : System.Address;
148 sa_mask : sigset_t;
149 sa_resv : array_type_2;
150 end record;
151 pragma Convention (C, struct_sigaction);
153 type struct_sigaction_ptr is access all struct_sigaction;
155 SIG_BLOCK : constant := 1;
156 SIG_UNBLOCK : constant := 2;
157 SIG_SETMASK : constant := 3;
159 SIG_DFL : constant := 0;
160 SIG_IGN : constant := 1;
162 function sigaction
163 (sig : Signal;
164 act : struct_sigaction_ptr;
165 oact : struct_sigaction_ptr := null) return int;
166 pragma Import (C, sigaction, "sigaction");
168 ----------
169 -- Time --
170 ----------
172 type timespec is private;
173 type timespec_ptr is access all timespec;
175 type clockid_t is new int;
177 SGI_CYCLECNTR_SIZE : constant := 165;
179 function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
180 pragma Import (C, syssgi, "syssgi");
182 function clock_gettime
183 (clock_id : clockid_t;
184 tp : access timespec) return int;
185 pragma Import (C, clock_gettime, "clock_gettime");
187 function clock_getres
188 (clock_id : clockid_t;
189 tp : access timespec) return int;
190 pragma Import (C, clock_getres, "clock_getres");
192 function To_Duration (TS : timespec) return Duration;
193 pragma Inline (To_Duration);
195 function To_Timespec (D : Duration) return timespec;
196 pragma Inline (To_Timespec);
198 -------------------------
199 -- Priority Scheduling --
200 -------------------------
202 SCHED_FIFO : constant := 1;
203 SCHED_RR : constant := 2;
204 SCHED_TS : constant := 3;
205 SCHED_OTHER : constant := 3;
206 SCHED_NP : constant := 4;
208 function sched_get_priority_min (Policy : int) return int;
209 pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
211 function sched_get_priority_max (Policy : int) return int;
212 pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
214 -------------
215 -- Process --
216 -------------
218 type pid_t is private;
220 function kill (pid : pid_t; sig : Signal) return int;
221 pragma Import (C, kill, "kill");
223 function getpid return pid_t;
224 pragma Import (C, getpid, "getpid");
226 -------------
227 -- Threads --
228 -------------
230 type Thread_Body is access
231 function (arg : System.Address) return System.Address;
232 pragma Convention (C, Thread_Body);
234 function Thread_Body_Access is new
235 Ada.Unchecked_Conversion (System.Address, Thread_Body);
237 type pthread_t is private;
238 subtype Thread_Id is pthread_t;
240 type pthread_mutex_t is limited private;
241 type pthread_cond_t is limited private;
242 type pthread_attr_t is limited private;
243 type pthread_mutexattr_t is limited private;
244 type pthread_condattr_t is limited private;
245 type pthread_key_t is private;
247 PTHREAD_CREATE_DETACHED : constant := 1;
249 -- Read/Write lock not supported on SGI. To add support both types
250 -- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
251 -- with the associated routines pthread_rwlock_[init/destroy] and
252 -- pthread_rwlock_[rdlock/wrlock/unlock].
254 subtype pthread_rwlock_t is pthread_mutex_t;
255 subtype pthread_rwlockattr_t is pthread_mutexattr_t;
257 -----------
258 -- Stack --
259 -----------
261 Alternate_Stack_Size : constant := 0;
262 -- No alternate signal stack is used on this platform
264 ---------------------------------------
265 -- Nonstandard Thread Initialization --
266 ---------------------------------------
268 procedure pthread_init;
269 pragma Inline (pthread_init);
270 -- This is a dummy procedure to share some GNULLI files
272 -------------------------
273 -- POSIX.1c Section 3 --
274 -------------------------
276 function sigwait
277 (set : access sigset_t;
278 sig : access Signal) return int;
279 pragma Import (C, sigwait, "sigwait");
281 function pthread_kill
282 (thread : pthread_t;
283 sig : Signal) return int;
284 pragma Import (C, pthread_kill, "pthread_kill");
286 function pthread_sigmask
287 (how : int;
288 set : access sigset_t;
289 oset : access sigset_t) return int;
290 pragma Import (C, pthread_sigmask, "pthread_sigmask");
292 --------------------------
293 -- POSIX.1c Section 11 --
294 --------------------------
296 function pthread_mutexattr_init
297 (attr : access pthread_mutexattr_t) return int;
298 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
300 function pthread_mutexattr_destroy
301 (attr : access pthread_mutexattr_t) return int;
302 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
304 function pthread_mutex_init
305 (mutex : access pthread_mutex_t;
306 attr : access pthread_mutexattr_t) return int;
307 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
309 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
310 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
312 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
313 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
315 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
316 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
318 function pthread_condattr_init
319 (attr : access pthread_condattr_t) return int;
320 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
322 function pthread_condattr_destroy
323 (attr : access pthread_condattr_t) return int;
324 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
326 function pthread_cond_init
327 (cond : access pthread_cond_t;
328 attr : access pthread_condattr_t) return int;
329 pragma Import (C, pthread_cond_init, "pthread_cond_init");
331 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
332 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
334 function pthread_cond_signal (cond : access pthread_cond_t) return int;
335 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
337 function pthread_cond_wait
338 (cond : access pthread_cond_t;
339 mutex : access pthread_mutex_t) return int;
340 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
342 function pthread_cond_timedwait
343 (cond : access pthread_cond_t;
344 mutex : access pthread_mutex_t;
345 abstime : access timespec) return int;
346 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
348 --------------------------
349 -- POSIX.1c Section 13 --
350 --------------------------
352 PTHREAD_PRIO_NONE : constant := 0;
353 PTHREAD_PRIO_PROTECT : constant := 2;
354 PTHREAD_PRIO_INHERIT : constant := 1;
356 function pthread_mutexattr_setprotocol
357 (attr : access pthread_mutexattr_t;
358 protocol : int) return int;
359 pragma Import (C, pthread_mutexattr_setprotocol);
361 function pthread_mutexattr_setprioceiling
362 (attr : access pthread_mutexattr_t;
363 prioceiling : int) return int;
364 pragma Import (C, pthread_mutexattr_setprioceiling);
366 type struct_sched_param is record
367 sched_priority : int;
368 end record;
369 pragma Convention (C, struct_sched_param);
371 function pthread_setschedparam
372 (thread : pthread_t;
373 policy : int;
374 param : access struct_sched_param)
375 return int;
376 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
378 function pthread_attr_setscope
379 (attr : access pthread_attr_t;
380 contentionscope : int) return int;
381 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
383 function pthread_attr_setinheritsched
384 (attr : access pthread_attr_t;
385 inheritsched : int) return int;
386 pragma Import
387 (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
389 function pthread_attr_setschedpolicy
390 (attr : access pthread_attr_t;
391 policy : int) return int;
392 pragma Import (C, pthread_attr_setschedpolicy);
394 function pthread_attr_setschedparam
395 (attr : access pthread_attr_t;
396 sched_param : access struct_sched_param)
397 return int;
398 pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
400 function sched_yield return int;
401 pragma Import (C, sched_yield, "sched_yield");
403 ---------------------------
404 -- P1003.1c - Section 16 --
405 ---------------------------
407 function pthread_attr_init (attributes : access pthread_attr_t) return int;
408 pragma Import (C, pthread_attr_init, "pthread_attr_init");
410 function pthread_attr_destroy
411 (attributes : access pthread_attr_t) return int;
412 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
414 function pthread_attr_setdetachstate
415 (attr : access pthread_attr_t;
416 detachstate : int) return int;
417 pragma Import (C, pthread_attr_setdetachstate);
419 function pthread_attr_setstacksize
420 (attr : access pthread_attr_t;
421 stacksize : size_t) return int;
422 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
424 function pthread_create
425 (thread : access pthread_t;
426 attributes : access pthread_attr_t;
427 start_routine : Thread_Body;
428 arg : System.Address) return int;
429 pragma Import (C, pthread_create, "pthread_create");
431 procedure pthread_exit (status : System.Address);
432 pragma Import (C, pthread_exit, "pthread_exit");
434 function pthread_self return pthread_t;
435 pragma Import (C, pthread_self, "pthread_self");
437 --------------------------
438 -- POSIX.1c Section 17 --
439 --------------------------
441 function pthread_setspecific
442 (key : pthread_key_t;
443 value : System.Address) return int;
444 pragma Import (C, pthread_setspecific, "pthread_setspecific");
446 function pthread_getspecific (key : pthread_key_t) return System.Address;
447 pragma Import (C, pthread_getspecific, "pthread_getspecific");
449 type destructor_pointer is access procedure (arg : System.Address);
450 pragma Convention (C, destructor_pointer);
452 function pthread_key_create
453 (key : access pthread_key_t;
454 destructor : destructor_pointer) return int;
455 pragma Import (C, pthread_key_create, "pthread_key_create");
457 -------------------
458 -- SGI Additions --
459 -------------------
461 -- Non portable SGI 6.5 additions to the pthread interface must be
462 -- executed from within the context of a system scope task.
464 function pthread_setrunon_np (cpu : int) return int;
465 pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
467 private
469 type array_type_1 is array (Integer range 0 .. 3) of unsigned;
470 type sigset_t is record
471 X_X_sigbits : array_type_1;
472 end record;
473 pragma Convention (C, sigset_t);
475 type pid_t is new long;
477 type time_t is new long;
479 type timespec is record
480 tv_sec : time_t;
481 tv_nsec : long;
482 end record;
483 pragma Convention (C, timespec);
485 type array_type_9 is array (Integer range 0 .. 4) of long;
486 type pthread_attr_t is record
487 X_X_D : array_type_9;
488 end record;
489 pragma Convention (C, pthread_attr_t);
491 type array_type_8 is array (Integer range 0 .. 1) of long;
492 type pthread_condattr_t is record
493 X_X_D : array_type_8;
494 end record;
495 pragma Convention (C, pthread_condattr_t);
497 type array_type_7 is array (Integer range 0 .. 1) of long;
498 type pthread_mutexattr_t is record
499 X_X_D : array_type_7;
500 end record;
501 pragma Convention (C, pthread_mutexattr_t);
503 type pthread_t is new unsigned;
505 type array_type_10 is array (Integer range 0 .. 7) of long;
506 type pthread_mutex_t is record
507 X_X_D : array_type_10;
508 end record;
509 pragma Convention (C, pthread_mutex_t);
511 type array_type_11 is array (Integer range 0 .. 7) of long;
512 type pthread_cond_t is record
513 X_X_D : array_type_11;
514 end record;
515 pragma Convention (C, pthread_cond_t);
517 type pthread_key_t is new int;
519 end System.OS_Interface;