Fix thinko
[official-gcc.git] / gcc / ada / 53osinte.ads
blob3643653b5a2c9345100198457db8e143b7967afc
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 -- Copyright (C) 1999-2002 Free Software Foundation, Inc. --
10 -- --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc. --
31 -- --
32 ------------------------------------------------------------------------------
34 -- This is a HPUX 11.0 (Native THREADS) version of this package.
36 -- This package encapsulates all direct interfaces to OS services
37 -- that are needed by children of System.
39 -- PLEASE DO NOT add any with-clauses to this package
40 -- or remove the pragma Elaborate_Body.
41 -- It is designed to be a bottom-level (leaf) package.
43 with Interfaces.C;
44 package System.OS_Interface is
45 pragma Preelaborate;
47 pragma Linker_Options ("-lpthread");
49 subtype int is Interfaces.C.int;
50 subtype short is Interfaces.C.short;
51 subtype long is Interfaces.C.long;
52 subtype unsigned is Interfaces.C.unsigned;
53 subtype unsigned_short is Interfaces.C.unsigned_short;
54 subtype unsigned_long is Interfaces.C.unsigned_long;
55 subtype unsigned_char is Interfaces.C.unsigned_char;
56 subtype plain_char is Interfaces.C.plain_char;
57 subtype size_t is Interfaces.C.size_t;
59 -----------
60 -- Errno --
61 -----------
63 function errno return int;
64 pragma Import (C, errno, "__get_errno");
66 EAGAIN : constant := 11;
67 EINTR : constant := 4;
68 EINVAL : constant := 22;
69 ENOMEM : constant := 12;
70 ETIMEDOUT : constant := 238;
72 -------------
73 -- Signals --
74 -------------
76 Max_Interrupt : constant := 44;
77 type Signal is new int range 0 .. Max_Interrupt;
78 for Signal'Size use int'Size;
80 SIGHUP : constant := 1; -- hangup
81 SIGINT : constant := 2; -- interrupt (rubout)
82 SIGQUIT : constant := 3; -- quit (ASCD FS)
83 SIGILL : constant := 4; -- illegal instruction (not reset)
84 SIGTRAP : constant := 5; -- trace trap (not reset)
85 SIGIOT : constant := 6; -- IOT instruction
86 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
87 SIGEMT : constant := 7; -- EMT instruction
88 SIGFPE : constant := 8; -- floating point exception
89 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
90 SIGBUS : constant := 10; -- bus error
91 SIGSEGV : constant := 11; -- segmentation violation
92 SIGSYS : constant := 12; -- bad argument to system call
93 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
94 SIGALRM : constant := 14; -- alarm clock
95 SIGTERM : constant := 15; -- software termination signal from kill
96 SIGUSR1 : constant := 16; -- user defined signal 1
97 SIGUSR2 : constant := 17; -- user defined signal 2
98 SIGCLD : constant := 18; -- alias for SIGCHLD
99 SIGCHLD : constant := 18; -- child status change
100 SIGPWR : constant := 19; -- power-fail restart
101 SIGVTALRM : constant := 20; -- virtual timer alarm
102 SIGPROF : constant := 21; -- profiling timer alarm
103 SIGIO : constant := 22; -- asynchronous I/O
104 SIGPOLL : constant := 22; -- pollable event occurred
105 SIGWINCH : constant := 23; -- window size change
106 SIGSTOP : constant := 24; -- stop (cannot be caught or ignored)
107 SIGTSTP : constant := 25; -- user stop requested from tty
108 SIGCONT : constant := 26; -- stopped process has been continued
109 SIGTTIN : constant := 27; -- background tty read attempted
110 SIGTTOU : constant := 28; -- background tty write attempted
111 SIGURG : constant := 29; -- urgent condition on IO channel
112 SIGLOST : constant := 30; -- remote lock lost (NFS)
113 SIGDIL : constant := 32; -- DIL signal
114 SIGXCPU : constant := 33; -- CPU time limit exceeded (setrlimit)
115 SIGXFSZ : constant := 34; -- file size limit exceeded (setrlimit)
116 SIGCANCEL : constant := 35; -- used for pthread cancellation.
117 SIGGFAULT : constant := 36; -- Graphics framebuffer fault
119 SIGADAABORT : constant := SIGABRT;
120 -- Note: on other targets, we usually use SIGABRT, but on HPUX, it
121 -- appears that SIGABRT can't be used in sigwait(), so we use SIGTERM.
123 type Signal_Set is array (Natural range <>) of Signal;
125 Unmasked : constant Signal_Set :=
126 (SIGABRT, SIGPIPE, SIGBUS, SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF,
127 SIGALRM, SIGVTALRM, SIGIO, SIGCHLD);
129 Reserved : constant Signal_Set := (SIGKILL, SIGSTOP);
131 type sigset_t is private;
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 struct_sigaction is record
149 sa_handler : System.Address;
150 sa_mask : sigset_t;
151 sa_flags : int;
152 end record;
153 pragma Convention (C, struct_sigaction);
154 type struct_sigaction_ptr is access all struct_sigaction;
156 SIG_BLOCK : constant := 0;
157 SIG_UNBLOCK : constant := 1;
158 SIG_SETMASK : constant := 2;
160 SIG_DFL : constant := 0;
161 SIG_IGN : constant := 1;
163 function sigaction
164 (sig : Signal;
165 act : struct_sigaction_ptr;
166 oact : struct_sigaction_ptr) return int;
167 pragma Import (C, sigaction, "sigaction");
169 ----------
170 -- Time --
171 ----------
173 Time_Slice_Supported : constant Boolean := True;
174 -- Indicates wether time slicing is supported
176 type timespec is private;
178 type clockid_t is private;
180 CLOCK_REALTIME : constant clockid_t;
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 res : 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 type struct_timezone is record
199 tz_minuteswest : int;
200 tz_dsttime : int;
201 end record;
202 pragma Convention (C, struct_timezone);
203 type struct_timezone_ptr is access all struct_timezone;
205 type struct_timeval is private;
206 -- This is needed on systems that do not have clock_gettime()
207 -- but do have gettimeofday().
209 function To_Duration (TV : struct_timeval) return Duration;
210 pragma Inline (To_Duration);
212 function To_Timeval (D : Duration) return struct_timeval;
213 pragma Inline (To_Timeval);
215 -------------------------
216 -- Priority Scheduling --
217 -------------------------
219 SCHED_FIFO : constant := 0;
220 SCHED_RR : constant := 1;
221 SCHED_OTHER : constant := 2;
223 -------------
224 -- Process --
225 -------------
227 type pid_t is private;
229 function kill (pid : pid_t; sig : Signal) return int;
230 pragma Import (C, kill, "kill");
232 function getpid return pid_t;
233 pragma Import (C, getpid, "getpid");
235 ---------
236 -- LWP --
237 ---------
239 function lwp_self return System.Address;
240 pragma Import (C, lwp_self, "_lwp_self");
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 := 16#de#;
260 -----------
261 -- Stack --
262 -----------
264 Stack_Base_Available : constant Boolean := False;
265 -- Indicates wether the stack base is available on this target.
267 function Get_Stack_Base (thread : pthread_t) return Address;
268 pragma Inline (Get_Stack_Base);
269 -- returns the stack base of the specified thread.
270 -- Only call this function when Stack_Base_Available is True.
272 function Get_Page_Size return size_t;
273 function Get_Page_Size return Address;
274 pragma Import (C, Get_Page_Size, "getpagesize");
275 -- returns the size of a page, or 0 if this is not relevant on this
276 -- target
278 PROT_NONE : constant := 0;
279 PROT_READ : constant := 1;
280 PROT_WRITE : constant := 2;
281 PROT_EXEC : constant := 4;
282 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
284 PROT_ON : constant := PROT_READ;
285 PROT_OFF : constant := PROT_ALL;
287 function mprotect (addr : Address; len : size_t; prot : int) return int;
288 pragma Import (C, mprotect);
290 ---------------------------------------
291 -- Nonstandard Thread Initialization --
292 ---------------------------------------
294 procedure pthread_init;
295 pragma Inline (pthread_init);
296 -- This is a dummy procedure to share some GNULLI files
298 -------------------------
299 -- POSIX.1c Section 3 --
300 -------------------------
302 function sigwait
303 (set : access sigset_t;
304 sig : access Signal) return int;
305 pragma Import (C, sigwait, "sigwait");
307 function pthread_kill
308 (thread : pthread_t;
309 sig : Signal) return int;
310 pragma Import (C, pthread_kill, "pthread_kill");
312 type sigset_t_ptr is access all sigset_t;
314 function pthread_sigmask
315 (how : int;
316 set : sigset_t_ptr;
317 oset : sigset_t_ptr) return int;
318 pragma Import (C, pthread_sigmask, "pthread_sigmask");
320 --------------------------
321 -- POSIX.1c Section 11 --
322 --------------------------
324 function pthread_mutexattr_init
325 (attr : access pthread_mutexattr_t) return int;
326 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
328 function pthread_mutexattr_destroy
329 (attr : access pthread_mutexattr_t) return int;
330 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
332 function pthread_mutex_init
333 (mutex : access pthread_mutex_t;
334 attr : access pthread_mutexattr_t) return int;
335 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
337 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
338 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
340 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
341 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
343 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
344 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
346 function pthread_condattr_init
347 (attr : access pthread_condattr_t) return int;
348 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
350 function pthread_condattr_destroy
351 (attr : access pthread_condattr_t) return int;
352 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
354 function pthread_cond_init
355 (cond : access pthread_cond_t;
356 attr : access pthread_condattr_t) return int;
357 pragma Import (C, pthread_cond_init, "pthread_cond_init");
359 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
360 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
362 function pthread_cond_signal (cond : access pthread_cond_t) return int;
363 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
365 function pthread_cond_wait
366 (cond : access pthread_cond_t;
367 mutex : access pthread_mutex_t) return int;
368 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
370 function pthread_cond_timedwait
371 (cond : access pthread_cond_t;
372 mutex : access pthread_mutex_t;
373 abstime : access timespec) return int;
374 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
376 Relative_Timed_Wait : constant Boolean := False;
377 -- pthread_cond_timedwait requires an absolute delay time
379 ----------------------------
380 -- POSIX.1c Section 13 --
381 ----------------------------
383 PTHREAD_PRIO_NONE : constant := 16#100#;
384 PTHREAD_PRIO_PROTECT : constant := 16#200#;
385 PTHREAD_PRIO_INHERIT : constant := 16#400#;
387 function pthread_mutexattr_setprotocol
388 (attr : access pthread_mutexattr_t;
389 protocol : int) return int;
390 pragma Import (C, pthread_mutexattr_setprotocol);
392 function pthread_mutexattr_setprioceiling
393 (attr : access pthread_mutexattr_t;
394 prioceiling : int) return int;
395 pragma Import (C, pthread_mutexattr_setprioceiling);
397 type Array_7_Int is array (0 .. 6) of int;
398 type struct_sched_param is record
399 sched_priority : int;
400 sched_reserved : Array_7_Int;
401 end record;
403 function pthread_setschedparam
404 (thread : pthread_t;
405 policy : int;
406 param : access struct_sched_param)
407 return int;
408 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
410 function pthread_attr_setscope
411 (attr : access pthread_attr_t;
412 contentionscope : int) return int;
413 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
415 function pthread_attr_setinheritsched
416 (attr : access pthread_attr_t;
417 inheritsched : int) return int;
418 pragma Import (C, pthread_attr_setinheritsched);
420 function pthread_attr_setschedpolicy
421 (attr : access pthread_attr_t;
422 policy : int) return int;
423 pragma Import (C, pthread_attr_setschedpolicy);
425 function sched_yield return int;
426 pragma Import (C, sched_yield, "sched_yield");
428 ---------------------------
429 -- P1003.1c - Section 16 --
430 ---------------------------
432 function pthread_attr_init
433 (attributes : access pthread_attr_t) return int;
434 pragma Import (C, pthread_attr_init, "__pthread_attr_init_system");
436 function pthread_attr_destroy
437 (attributes : access pthread_attr_t) return int;
438 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
440 function pthread_attr_setdetachstate
441 (attr : access pthread_attr_t;
442 detachstate : int) return int;
443 pragma Import (C, pthread_attr_setdetachstate);
445 function pthread_attr_setstacksize
446 (attr : access pthread_attr_t;
447 stacksize : size_t) return int;
448 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
450 function pthread_create
451 (thread : access pthread_t;
452 attributes : access pthread_attr_t;
453 start_routine : Thread_Body;
454 arg : System.Address) return int;
455 pragma Import (C, pthread_create, "__pthread_create_system");
457 procedure pthread_exit (status : System.Address);
458 pragma Import (C, pthread_exit, "pthread_exit");
460 function pthread_self return pthread_t;
461 pragma Import (C, pthread_self, "pthread_self");
463 --------------------------
464 -- POSIX.1c Section 17 --
465 --------------------------
467 function pthread_setspecific
468 (key : pthread_key_t;
469 value : System.Address) return int;
470 pragma Import (C, pthread_setspecific, "pthread_setspecific");
472 function pthread_getspecific (key : pthread_key_t) return System.Address;
473 pragma Import (C, pthread_getspecific, "pthread_getspecific");
475 type destructor_pointer is access procedure (arg : System.Address);
477 function pthread_key_create
478 (key : access pthread_key_t;
479 destructor : destructor_pointer) return int;
480 pragma Import (C, pthread_key_create, "pthread_key_create");
482 private
484 type unsigned_int_array_8 is array (0 .. 7) of unsigned;
485 type sigset_t is record
486 sigset : unsigned_int_array_8;
487 end record;
488 pragma Convention (C_Pass_By_Copy, sigset_t);
490 type pid_t is new int;
492 type time_t is new long;
494 type timespec is record
495 tv_sec : time_t;
496 tv_nsec : long;
497 end record;
498 pragma Convention (C, timespec);
500 type clockid_t is new int;
501 CLOCK_REALTIME : constant clockid_t := 1;
503 type struct_timeval is record
504 tv_sec : time_t;
505 tv_usec : time_t;
506 end record;
507 pragma Convention (C, struct_timeval);
509 type pthread_attr_t is new int;
510 type pthread_condattr_t is new int;
511 type pthread_mutexattr_t is new int;
512 type pthread_t is new int;
514 type short_array is array (Natural range <>) of short;
515 type int_array is array (Natural range <>) of int;
517 type pthread_mutex_t is record
518 m_short : short_array (0 .. 1);
519 m_int : int;
520 m_int1 : int_array (0 .. 3);
521 m_pad : int; -- needed for 32 bit ABI, but *not* for 64 bit
522 m_ptr : System.Address;
523 m_int2 : int_array (0 .. 1);
524 m_int3 : int_array (0 .. 3);
525 m_short2 : short_array (0 .. 1);
526 m_int4 : int_array (0 .. 4);
527 m_int5 : int_array (0 .. 1);
528 end record;
529 pragma Convention (C, pthread_mutex_t);
531 type pthread_cond_t is record
532 c_short : short_array (0 .. 1);
533 c_int : int;
534 c_int1 : int_array (0 .. 3);
535 m_pad : int; -- needed for 32 bit ABI, but *not* for 64 bit
536 m_ptr : System.Address;
537 c_int2 : int_array (0 .. 1);
538 c_int3 : int_array (0 .. 1);
539 c_int4 : int_array (0 .. 1);
540 end record;
541 pragma Convention (C, pthread_cond_t);
543 type pthread_key_t is new int;
545 end System.OS_Interface;