Remove some compile time warnings about duplicate definitions.
[official-gcc.git] / gcc / ada / 53osinte.ads
blob2b7c6d9d2ae0977775d77bced6c5dfc6d32c4676
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.10 $
10 -- --
11 -- Copyright (C) 1999-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 a HPUX 11.0 (Native THREADS) 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
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 EAGAIN : constant := 11;
70 EINTR : constant := 4;
71 EINVAL : constant := 22;
72 ENOMEM : constant := 12;
73 ETIMEDOUT : constant := 238;
75 -------------
76 -- Signals --
77 -------------
79 Max_Interrupt : constant := 44;
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 future
90 SIGEMT : constant := 7; -- EMT instruction
91 SIGFPE : constant := 8; -- floating point exception
92 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
93 SIGBUS : constant := 10; -- bus error
94 SIGSEGV : constant := 11; -- segmentation violation
95 SIGSYS : constant := 12; -- bad argument to system call
96 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
97 SIGALRM : constant := 14; -- alarm clock
98 SIGTERM : constant := 15; -- software termination signal from kill
99 SIGUSR1 : constant := 16; -- user defined signal 1
100 SIGUSR2 : constant := 17; -- user defined signal 2
101 SIGCLD : constant := 18; -- alias for SIGCHLD
102 SIGCHLD : constant := 18; -- child status change
103 SIGPWR : constant := 19; -- power-fail restart
104 SIGVTALRM : constant := 20; -- virtual timer alarm
105 SIGPROF : constant := 21; -- profiling timer alarm
106 SIGIO : constant := 22; -- asynchronous I/O
107 SIGPOLL : constant := 22; -- pollable event occurred
108 SIGWINCH : constant := 23; -- window size change
109 SIGSTOP : constant := 24; -- stop (cannot be caught or ignored)
110 SIGTSTP : constant := 25; -- user stop requested from tty
111 SIGCONT : constant := 26; -- stopped process has been continued
112 SIGTTIN : constant := 27; -- background tty read attempted
113 SIGTTOU : constant := 28; -- background tty write attempted
114 SIGURG : constant := 29; -- urgent condition on IO channel
115 SIGLOST : constant := 30; -- remote lock lost (NFS)
116 SIGDIL : constant := 32; -- DIL signal
117 SIGXCPU : constant := 33; -- CPU time limit exceeded (setrlimit)
118 SIGXFSZ : constant := 34; -- file size limit exceeded (setrlimit)
119 SIGCANCEL : constant := 35; -- used for pthread cancellation.
120 SIGGFAULT : constant := 36; -- Graphics framebuffer fault
122 SIGADAABORT : constant := SIGABRT;
123 -- Note: on other targets, we usually use SIGABRT, but on HPUX, it
124 -- appears that SIGABRT can't be used in sigwait(), so we use SIGTERM.
126 type Signal_Set is array (Natural range <>) of Signal;
128 Unmasked : constant Signal_Set :=
129 (SIGABRT, SIGPIPE, SIGBUS, SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF,
130 SIGALRM, SIGVTALRM, SIGIO, SIGCHLD);
132 Reserved : constant Signal_Set := (SIGKILL, SIGSTOP);
134 type sigset_t is private;
136 function sigaddset (set : access sigset_t; sig : Signal) return int;
137 pragma Import (C, sigaddset, "sigaddset");
139 function sigdelset (set : access sigset_t; sig : Signal) return int;
140 pragma Import (C, sigdelset, "sigdelset");
142 function sigfillset (set : access sigset_t) return int;
143 pragma Import (C, sigfillset, "sigfillset");
145 function sigismember (set : access sigset_t; sig : Signal) return int;
146 pragma Import (C, sigismember, "sigismember");
148 function sigemptyset (set : access sigset_t) return int;
149 pragma Import (C, sigemptyset, "sigemptyset");
151 type struct_sigaction is record
152 sa_handler : System.Address;
153 sa_mask : sigset_t;
154 sa_flags : int;
155 end record;
156 pragma Convention (C, struct_sigaction);
157 type struct_sigaction_ptr is access all struct_sigaction;
159 SIG_BLOCK : constant := 0;
160 SIG_UNBLOCK : constant := 1;
161 SIG_SETMASK : constant := 2;
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) return int;
170 pragma Import (C, sigaction, "sigaction");
172 ----------
173 -- Time --
174 ----------
176 Time_Slice_Supported : constant Boolean := True;
177 -- Indicates wether time slicing is supported
179 type timespec is private;
181 type clockid_t is private;
183 CLOCK_REALTIME : constant clockid_t;
185 function clock_gettime
186 (clock_id : clockid_t;
187 tp : access timespec) return int;
188 pragma Import (C, clock_gettime, "clock_gettime");
190 function To_Duration (TS : timespec) return Duration;
191 pragma Inline (To_Duration);
193 function To_Timespec (D : Duration) return timespec;
194 pragma Inline (To_Timespec);
196 type struct_timezone is record
197 tz_minuteswest : int;
198 tz_dsttime : int;
199 end record;
200 pragma Convention (C, struct_timezone);
201 type struct_timezone_ptr is access all struct_timezone;
203 type struct_timeval is private;
204 -- This is needed on systems that do not have clock_gettime()
205 -- but do have gettimeofday().
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 := 0;
218 SCHED_RR : constant := 1;
219 SCHED_OTHER : constant := 2;
221 -------------
222 -- Process --
223 -------------
225 type pid_t is private;
227 function kill (pid : pid_t; sig : Signal) return int;
228 pragma Import (C, kill, "kill");
230 function getpid return pid_t;
231 pragma Import (C, getpid, "getpid");
233 ---------
234 -- LWP --
235 ---------
237 function lwp_self return System.Address;
238 pragma Import (C, lwp_self, "_lwp_self");
240 -------------
241 -- Threads --
242 -------------
244 type Thread_Body is access
245 function (arg : System.Address) return System.Address;
246 type pthread_t is private;
247 subtype Thread_Id is pthread_t;
249 type pthread_mutex_t is limited private;
250 type pthread_cond_t is limited private;
251 type pthread_attr_t is limited private;
252 type pthread_mutexattr_t is limited private;
253 type pthread_condattr_t is limited private;
254 type pthread_key_t is private;
256 PTHREAD_CREATE_DETACHED : constant := 16#de#;
258 -----------
259 -- Stack --
260 -----------
262 Stack_Base_Available : constant Boolean := False;
263 -- Indicates wether the stack base is available on this target.
265 function Get_Stack_Base (thread : pthread_t) return Address;
266 pragma Inline (Get_Stack_Base);
267 -- returns the stack base of the specified thread.
268 -- Only call this function when Stack_Base_Available is True.
270 function Get_Page_Size return size_t;
271 function Get_Page_Size return Address;
272 pragma Import (C, Get_Page_Size, "getpagesize");
273 -- returns the size of a page, or 0 if this is not relevant on this
274 -- target
276 PROT_NONE : constant := 0;
277 PROT_READ : constant := 1;
278 PROT_WRITE : constant := 2;
279 PROT_EXEC : constant := 4;
280 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
282 PROT_ON : constant := PROT_READ;
283 PROT_OFF : constant := PROT_ALL;
285 function mprotect (addr : Address; len : size_t; prot : int) return int;
286 pragma Import (C, mprotect);
288 ---------------------------------------
289 -- Nonstandard Thread Initialization --
290 ---------------------------------------
292 procedure pthread_init;
293 pragma Inline (pthread_init);
294 -- This is a dummy procedure to share some GNULLI files
296 -------------------------
297 -- POSIX.1c Section 3 --
298 -------------------------
300 function sigwait
301 (set : access sigset_t;
302 sig : access Signal) return int;
303 pragma Import (C, sigwait, "sigwait");
305 function pthread_kill
306 (thread : pthread_t;
307 sig : Signal) return int;
308 pragma Import (C, pthread_kill, "pthread_kill");
310 type sigset_t_ptr is access all sigset_t;
312 function pthread_sigmask
313 (how : int;
314 set : sigset_t_ptr;
315 oset : sigset_t_ptr) return int;
316 pragma Import (C, pthread_sigmask, "pthread_sigmask");
318 --------------------------
319 -- POSIX.1c Section 11 --
320 --------------------------
322 function pthread_mutexattr_init
323 (attr : access pthread_mutexattr_t) return int;
324 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
326 function pthread_mutexattr_destroy
327 (attr : access pthread_mutexattr_t) return int;
328 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
330 function pthread_mutex_init
331 (mutex : access pthread_mutex_t;
332 attr : access pthread_mutexattr_t) return int;
333 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
335 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
336 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
338 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
339 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
341 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
342 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
344 function pthread_condattr_init
345 (attr : access pthread_condattr_t) return int;
346 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
348 function pthread_condattr_destroy
349 (attr : access pthread_condattr_t) return int;
350 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
352 function pthread_cond_init
353 (cond : access pthread_cond_t;
354 attr : access pthread_condattr_t) return int;
355 pragma Import (C, pthread_cond_init, "pthread_cond_init");
357 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
358 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
360 function pthread_cond_signal (cond : access pthread_cond_t) return int;
361 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
363 function pthread_cond_wait
364 (cond : access pthread_cond_t;
365 mutex : access pthread_mutex_t) return int;
366 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
368 function pthread_cond_timedwait
369 (cond : access pthread_cond_t;
370 mutex : access pthread_mutex_t;
371 abstime : access timespec) return int;
372 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
374 Relative_Timed_Wait : constant Boolean := False;
375 -- pthread_cond_timedwait requires an absolute delay time
377 ----------------------------
378 -- POSIX.1c Section 13 --
379 ----------------------------
381 PTHREAD_PRIO_NONE : constant := 16#100#;
382 PTHREAD_PRIO_PROTECT : constant := 16#200#;
383 PTHREAD_PRIO_INHERIT : constant := 16#400#;
385 function pthread_mutexattr_setprotocol
386 (attr : access pthread_mutexattr_t;
387 protocol : int) return int;
388 pragma Import (C, pthread_mutexattr_setprotocol);
390 function pthread_mutexattr_setprioceiling
391 (attr : access pthread_mutexattr_t;
392 prioceiling : int) return int;
393 pragma Import (C, pthread_mutexattr_setprioceiling);
395 type Array_7_Int is array (0 .. 6) of int;
396 type struct_sched_param is record
397 sched_priority : int;
398 sched_reserved : Array_7_Int;
399 end record;
401 function pthread_setschedparam
402 (thread : pthread_t;
403 policy : int;
404 param : access struct_sched_param)
405 return int;
406 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
408 function pthread_attr_setscope
409 (attr : access pthread_attr_t;
410 contentionscope : int) return int;
411 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
413 function pthread_attr_setinheritsched
414 (attr : access pthread_attr_t;
415 inheritsched : int) return int;
416 pragma Import (C, pthread_attr_setinheritsched);
418 function pthread_attr_setschedpolicy
419 (attr : access pthread_attr_t;
420 policy : int) return int;
421 pragma Import (C, pthread_attr_setschedpolicy);
423 function sched_yield return int;
424 pragma Import (C, sched_yield, "sched_yield");
426 ---------------------------
427 -- P1003.1c - Section 16 --
428 ---------------------------
430 function pthread_attr_init
431 (attributes : access pthread_attr_t) return int;
432 pragma Import (C, pthread_attr_init, "__pthread_attr_init_system");
434 function pthread_attr_destroy
435 (attributes : access pthread_attr_t) return int;
436 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
438 function pthread_attr_setdetachstate
439 (attr : access pthread_attr_t;
440 detachstate : int) return int;
441 pragma Import (C, pthread_attr_setdetachstate);
443 function pthread_attr_setstacksize
444 (attr : access pthread_attr_t;
445 stacksize : size_t) return int;
446 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
448 function pthread_create
449 (thread : access pthread_t;
450 attributes : access pthread_attr_t;
451 start_routine : Thread_Body;
452 arg : System.Address) return int;
453 pragma Import (C, pthread_create, "__pthread_create_system");
455 procedure pthread_exit (status : System.Address);
456 pragma Import (C, pthread_exit, "pthread_exit");
458 function pthread_self return pthread_t;
459 pragma Import (C, pthread_self, "pthread_self");
461 --------------------------
462 -- POSIX.1c Section 17 --
463 --------------------------
465 function pthread_setspecific
466 (key : pthread_key_t;
467 value : System.Address) return int;
468 pragma Import (C, pthread_setspecific, "pthread_setspecific");
470 function pthread_getspecific (key : pthread_key_t) return System.Address;
471 pragma Import (C, pthread_getspecific, "pthread_getspecific");
473 type destructor_pointer is access procedure (arg : System.Address);
475 function pthread_key_create
476 (key : access pthread_key_t;
477 destructor : destructor_pointer) return int;
478 pragma Import (C, pthread_key_create, "pthread_key_create");
480 private
482 type unsigned_int_array_8 is array (0 .. 7) of unsigned;
483 type sigset_t is record
484 sigset : unsigned_int_array_8;
485 end record;
486 pragma Convention (C_Pass_By_Copy, sigset_t);
488 type pid_t is new int;
490 type time_t is new long;
492 type timespec is record
493 tv_sec : time_t;
494 tv_nsec : long;
495 end record;
496 pragma Convention (C, timespec);
498 type clockid_t is new int;
499 CLOCK_REALTIME : constant clockid_t := 1;
501 type struct_timeval is record
502 tv_sec : time_t;
503 tv_usec : time_t;
504 end record;
505 pragma Convention (C, struct_timeval);
507 type pthread_attr_t is new int;
508 type pthread_condattr_t is new int;
509 type pthread_mutexattr_t is new int;
510 type pthread_t is new int;
512 type short_array is array (Natural range <>) of short;
513 type int_array is array (Natural range <>) of int;
515 type pthread_mutex_t is record
516 m_short : short_array (0 .. 1);
517 m_int : int;
518 m_int1 : int_array (0 .. 3);
519 m_pad : int; -- needed for 32 bit ABI, but *not* for 64 bit
520 m_ptr : System.Address;
521 m_int2 : int_array (0 .. 1);
522 m_int3 : int_array (0 .. 3);
523 m_short2 : short_array (0 .. 1);
524 m_int4 : int_array (0 .. 4);
525 m_int5 : int_array (0 .. 1);
526 end record;
527 pragma Convention (C, pthread_mutex_t);
529 type pthread_cond_t is record
530 c_short : short_array (0 .. 1);
531 c_int : int;
532 c_int1 : int_array (0 .. 3);
533 m_pad : int; -- needed for 32 bit ABI, but *not* for 64 bit
534 m_ptr : System.Address;
535 c_int2 : int_array (0 .. 1);
536 c_int3 : int_array (0 .. 1);
537 c_int4 : int_array (0 .. 1);
538 end record;
539 pragma Convention (C, pthread_cond_t);
541 type pthread_key_t is new int;
543 end System.OS_Interface;