PR middle-end/20263
[official-gcc.git] / gcc / ada / s-osinte-tru64.ads
blob27d3eeea2bb9e3f8fd15b076aa69bc8ff39ee3ca
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) 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, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, 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 DEC Unix 4.0/5.1 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
47 pragma Preelaborate;
49 pragma Linker_Options ("-lpthread");
50 pragma Linker_Options ("-lmach");
51 pragma Linker_Options ("-lexc");
52 pragma Linker_Options ("-lrt");
54 subtype int is Interfaces.C.int;
55 subtype short is Interfaces.C.short;
56 subtype long is Interfaces.C.long;
57 subtype unsigned is Interfaces.C.unsigned;
58 subtype unsigned_short is Interfaces.C.unsigned_short;
59 subtype unsigned_long is Interfaces.C.unsigned_long;
60 subtype unsigned_char is Interfaces.C.unsigned_char;
61 subtype plain_char is Interfaces.C.plain_char;
62 subtype size_t is Interfaces.C.size_t;
63 subtype char_array is Interfaces.C.char_array;
65 -----------
66 -- Errno --
67 -----------
69 function errno return int;
70 pragma Import (C, errno, "_Geterrno");
72 EAGAIN : constant := 35;
73 EINTR : constant := 4;
74 EINVAL : constant := 22;
75 ENOMEM : constant := 12;
76 ETIMEDOUT : constant := 60;
78 -------------
79 -- Signals --
80 -------------
82 Max_Interrupt : constant := 48;
83 type Signal is new int range 0 .. Max_Interrupt;
84 for Signal'Size use int'Size;
86 SIGHUP : constant := 1; -- hangup
87 SIGINT : constant := 2; -- interrupt (rubout)
88 SIGQUIT : constant := 3; -- quit (ASCD FS)
89 SIGILL : constant := 4; -- illegal instruction (not reset)
90 SIGTRAP : constant := 5; -- trace trap (not reset)
91 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
92 SIGIOT : constant := 6; -- abort (terminate) process
93 SIGLOST : constant := 6; -- old BSD signal ??
94 SIGEMT : constant := 7; -- EMT instruction
95 SIGFPE : constant := 8; -- floating point exception
96 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
97 SIGBUS : constant := 10; -- bus error
98 SIGSEGV : constant := 11; -- segmentation violation
99 SIGSYS : constant := 12; -- bad argument to system call
100 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
101 SIGALRM : constant := 14; -- alarm clock
102 SIGTERM : constant := 15; -- software termination signal from kill
103 SIGURG : constant := 16; -- urgent condition on IO channel
104 SIGIOINT : constant := 16; -- printer to backend error signal
105 SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
106 SIGTSTP : constant := 18; -- user stop requested from tty
107 SIGCONT : constant := 19; -- stopped process has been continued
108 SIGCHLD : constant := 20; -- child status change
109 SIGTTIN : constant := 21; -- background tty read attempted
110 SIGTTOU : constant := 22; -- background tty write attempted
111 SIGPOLL : constant := 23; -- I/O possible, or completed
112 SIGIO : constant := 23; -- STREAMS version of SIGPOLL
113 SIGAIO : constant := 23; -- base lan i/o
114 SIGPTY : constant := 23; -- pty i/o
115 SIGXCPU : constant := 24; -- CPU time limit exceeded
116 SIGXFSZ : constant := 25; -- filesize limit exceeded
117 SIGVTALRM : constant := 26; -- virtual timer expired
118 SIGPROF : constant := 27; -- profiling timer expired
119 SIGWINCH : constant := 28; -- window size change
120 SIGINFO : constant := 29; -- information request
121 SIGPWR : constant := 29; -- Power Fail/Restart -- SVID3/SVR4
122 SIGUSR1 : constant := 30; -- user defined signal 1
123 SIGUSR2 : constant := 31; -- user defined signal 2
124 SIGRESV : constant := 32; -- reserved by Digital for future use
126 SIGADAABORT : constant := SIGABRT;
128 type Signal_Set is array (Natural range <>) of Signal;
130 Unmasked : constant Signal_Set := (0 .. 0 => SIGTRAP);
131 Reserved : constant Signal_Set := (SIGALRM, SIGABRT, SIGKILL, SIGSTOP);
133 type sigset_t is private;
135 function sigaddset (set : access sigset_t; sig : Signal) return int;
136 pragma Import (C, sigaddset);
138 function sigdelset (set : access sigset_t; sig : Signal) return int;
139 pragma Import (C, sigdelset);
141 function sigfillset (set : access sigset_t) return int;
142 pragma Import (C, sigfillset);
144 function sigismember (set : access sigset_t; sig : Signal) return int;
145 pragma Import (C, sigismember);
147 function sigemptyset (set : access sigset_t) return int;
148 pragma Import (C, sigemptyset);
150 type union_type_3 is new String (1 .. 116);
151 type siginfo_t is record
152 si_signo : int;
153 si_errno : int;
154 si_code : int;
155 X_data : union_type_3;
156 end record;
157 for siginfo_t'Size use 8 * 128;
158 pragma Convention (C, siginfo_t);
160 type struct_sigaction is record
161 sa_handler : System.Address;
162 sa_mask : sigset_t;
163 sa_flags : int;
164 sa_signo : int;
165 end record;
166 pragma Convention (C, struct_sigaction);
167 type struct_sigaction_ptr is access all struct_sigaction;
169 SIG_BLOCK : constant := 1;
170 SIG_UNBLOCK : constant := 2;
171 SIG_SETMASK : constant := 3;
173 SIG_DFL : constant := 0;
174 SIG_IGN : constant := 1;
176 SA_NODEFER : constant := 8;
177 SA_SIGINFO : constant := 16#40#;
179 function sigaction
180 (sig : Signal;
181 act : struct_sigaction_ptr;
182 oact : struct_sigaction_ptr) return int;
183 pragma Import (C, sigaction);
185 ----------
186 -- Time --
187 ----------
189 type timespec is private;
191 function nanosleep (rqtp, rmtp : access timespec) return int;
192 pragma Import (C, nanosleep);
194 type clockid_t is private;
196 CLOCK_REALTIME : constant clockid_t;
198 function clock_gettime
199 (clock_id : clockid_t;
200 tp : access timespec) return int;
201 pragma Import (C, clock_gettime);
203 function To_Duration (TS : timespec) return Duration;
204 pragma Inline (To_Duration);
206 function To_Timespec (D : Duration) return timespec;
207 pragma Inline (To_Timespec);
209 type struct_timezone is record
210 tz_minuteswest : int;
211 tz_dsttime : int;
212 end record;
213 pragma Convention (C, struct_timezone);
214 type struct_timeval is private;
215 -- This is needed on systems that do not have clock_gettime()
216 -- but do have gettimeofday().
218 function To_Duration (TV : struct_timeval) return Duration;
219 pragma Inline (To_Duration);
221 function To_Timeval (D : Duration) return struct_timeval;
222 pragma Inline (To_Timeval);
224 -------------------------
225 -- Priority Scheduling --
226 -------------------------
228 SCHED_FIFO : constant := 1;
229 SCHED_RR : constant := 2;
230 SCHED_OTHER : constant := 3;
231 SCHED_LFI : constant := 5;
233 -------------
234 -- Process --
235 -------------
237 type pid_t is private;
239 function kill (pid : pid_t; sig : Signal) return int;
240 pragma Import (C, kill);
242 function getpid return pid_t;
243 pragma Import (C, getpid);
245 BIND_NO_INHERIT : constant := 1;
247 function bind_to_cpu
248 (pid : pid_t;
249 cpu_mask : unsigned_long;
250 flag : unsigned_long := BIND_NO_INHERIT) return int;
251 pragma Import (C, bind_to_cpu);
253 -------------
254 -- Threads --
255 -------------
257 type Thread_Body is access
258 function (arg : System.Address) return System.Address;
260 function Thread_Body_Access is new
261 Unchecked_Conversion (System.Address, Thread_Body);
263 type pthread_t is private;
264 subtype Thread_Id is pthread_t;
266 type pthread_mutex_t is limited private;
267 type pthread_cond_t is limited private;
268 type pthread_attr_t is limited private;
269 type pthread_mutexattr_t is limited private;
270 type pthread_condattr_t is limited private;
271 type pthread_key_t is private;
273 PTHREAD_CREATE_DETACHED : constant := 1;
275 PTHREAD_SCOPE_PROCESS : constant := 0;
276 PTHREAD_SCOPE_SYSTEM : constant := 1;
278 PTHREAD_EXPLICIT_SCHED : constant := 1;
280 -----------
281 -- Stack --
282 -----------
284 Stack_Base_Available : constant Boolean := False;
285 -- Indicates wether the stack base is available on this target.
287 function Get_Stack_Base (thread : pthread_t) return Address;
288 pragma Inline (Get_Stack_Base);
289 -- returns the stack base of the specified thread.
290 -- Only call this function when Stack_Base_Available is True.
292 function Get_Page_Size return size_t;
293 function Get_Page_Size return Address;
294 pragma Import (C, Get_Page_Size, "getpagesize");
295 -- returns the size of a page, or 0 if this is not relevant on this
296 -- target
298 PROT_NONE : constant := 0;
299 PROT_READ : constant := 1;
300 PROT_WRITE : constant := 2;
301 PROT_EXEC : constant := 4;
302 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
304 PROT_ON : constant := PROT_READ;
305 PROT_OFF : constant := PROT_ALL;
307 function mprotect (addr : Address; len : size_t; prot : int) return int;
308 pragma Import (C, mprotect);
310 procedure Hide_Yellow_Zone;
311 -- Every thread except the initial one features an overflow warning area
312 -- just above the overflow guard area on the stack. They are called
313 -- the Yellow Zone and the Red Zone respectively. This procedure hides
314 -- the former so that the latter could be exposed to stack probing.
316 ---------------------------------------
317 -- Nonstandard Thread Initialization --
318 ---------------------------------------
320 procedure pthread_init;
321 pragma Inline (pthread_init);
322 -- This is a dummy procedure to share some GNULLI files
324 -------------------------
325 -- POSIX.1c Section 3 --
326 -------------------------
328 function sigwait
329 (set : access sigset_t;
330 sig : access Signal) return int;
331 pragma Import (C, sigwait, "__sigwaitd10");
333 function pthread_kill
334 (thread : pthread_t;
335 sig : Signal) return int;
336 pragma Import (C, pthread_kill);
338 type sigset_t_ptr is access all sigset_t;
340 function pthread_sigmask
341 (how : int;
342 set : sigset_t_ptr;
343 oset : sigset_t_ptr) return int;
344 pragma Import (C, pthread_sigmask);
346 --------------------------
347 -- POSIX.1c Section 11 --
348 --------------------------
350 function pthread_mutexattr_init (attr : access pthread_mutexattr_t)
351 return int;
352 pragma Import (C, pthread_mutexattr_init);
354 function pthread_mutexattr_destroy
355 (attr : access pthread_mutexattr_t) return int;
356 pragma Import (C, pthread_mutexattr_destroy);
358 function pthread_mutex_init
359 (mutex : access pthread_mutex_t;
360 attr : access pthread_mutexattr_t) return int;
361 pragma Import (C, pthread_mutex_init, "__pthread_mutex_init");
363 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
364 pragma Import (C, pthread_mutex_destroy, "__pthread_mutex_destroy");
366 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
367 pragma Import (C, pthread_mutex_lock, "__pthread_mutex_lock");
369 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
370 pragma Import (C, pthread_mutex_unlock, "__pthread_mutex_unlock");
372 function pthread_condattr_init
373 (attr : access pthread_condattr_t) return int;
374 pragma Import (C, pthread_condattr_init);
376 function pthread_condattr_destroy
377 (attr : access pthread_condattr_t) return int;
378 pragma Import (C, pthread_condattr_destroy);
380 function pthread_cond_init
381 (cond : access pthread_cond_t;
382 attr : access pthread_condattr_t) return int;
383 pragma Import (C, pthread_cond_init, "__pthread_cond_init");
385 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
386 pragma Import (C, pthread_cond_destroy, "__pthread_cond_destroy");
388 function pthread_cond_signal (cond : access pthread_cond_t) return int;
389 pragma Import (C, pthread_cond_signal, "__pthread_cond_signal");
391 function pthread_cond_wait
392 (cond : access pthread_cond_t;
393 mutex : access pthread_mutex_t) return int;
394 pragma Import (C, pthread_cond_wait, "__pthread_cond_wait");
396 function pthread_cond_timedwait
397 (cond : access pthread_cond_t;
398 mutex : access pthread_mutex_t;
399 abstime : access timespec) return int;
400 pragma Import (C, pthread_cond_timedwait, "__pthread_cond_timedwait");
402 --------------------------
403 -- POSIX.1c Section 13 --
404 --------------------------
406 function pthread_mutexattr_setprotocol
407 (attr : access pthread_mutexattr_t;
408 protocol : int) return int;
409 pragma Import (C, pthread_mutexattr_setprotocol);
411 function pthread_mutexattr_setprioceiling
412 (attr : access pthread_mutexattr_t;
413 prioceiling : int) return int;
414 pragma Import (C, pthread_mutexattr_setprioceiling);
416 type struct_sched_param is record
417 sched_priority : int; -- scheduling priority
418 end record;
420 function pthread_setschedparam
421 (thread : pthread_t;
422 policy : int;
423 param : access struct_sched_param) return int;
424 pragma Import (C, pthread_setschedparam);
426 function pthread_attr_setscope
427 (attr : access pthread_attr_t;
428 contentionscope : int) return int;
429 pragma Import (C, pthread_attr_setscope);
431 function pthread_attr_setinheritsched
432 (attr : access pthread_attr_t;
433 inheritsched : int) return int;
434 pragma Import (C, pthread_attr_setinheritsched,
435 "__pthread_attr_setinheritsched");
437 function pthread_attr_setschedpolicy
438 (attr : access pthread_attr_t; policy : int) return int;
439 pragma Import (C, pthread_attr_setschedpolicy);
441 function pthread_attr_setschedparam
442 (attr : access pthread_attr_t;
443 sched_param : access struct_sched_param) return int;
444 pragma Import (C, pthread_attr_setschedparam);
446 function sched_yield return int;
447 pragma Import (C, sched_yield);
449 --------------------------
450 -- P1003.1c Section 16 --
451 --------------------------
453 function pthread_attr_init (attributes : access pthread_attr_t)
454 return int;
455 pragma Import (C, pthread_attr_init);
457 function pthread_attr_destroy (attributes : access pthread_attr_t)
458 return int;
459 pragma Import (C, pthread_attr_destroy);
461 function pthread_attr_setdetachstate
462 (attr : access pthread_attr_t;
463 detachstate : int) return int;
464 pragma Import (C, pthread_attr_setdetachstate);
466 function pthread_attr_setstacksize
467 (attr : access pthread_attr_t;
468 stacksize : size_t) return int;
469 pragma Import (C, pthread_attr_setstacksize, "__pthread_attr_setstacksize");
471 function pthread_create
472 (thread : access pthread_t;
473 attributes : access pthread_attr_t;
474 start_routine : Thread_Body;
475 arg : System.Address) return int;
476 pragma Import (C, pthread_create, "__pthread_create");
478 procedure pthread_exit (status : System.Address);
479 pragma Import (C, pthread_exit, "__pthread_exit");
481 function pthread_self return pthread_t;
482 pragma Inline (pthread_self);
484 --------------------------
485 -- POSIX.1c Section 17 --
486 --------------------------
488 function pthread_setspecific
489 (key : pthread_key_t; value : System.Address) return int;
490 pragma Import (C, pthread_setspecific, "__pthread_setspecific");
492 function pthread_getspecific (key : pthread_key_t) return System.Address;
493 pragma Import (C, pthread_getspecific, "__pthread_getspecific");
495 type destructor_pointer is access procedure (arg : System.Address);
497 function pthread_key_create
498 (key : access pthread_key_t;
499 destructor : destructor_pointer) return int;
500 pragma Import (C, pthread_key_create);
502 private
504 type sigset_t is new unsigned_long;
506 type pid_t is new int;
508 type time_t is new int;
510 type timespec is record
511 tv_sec : time_t;
512 tv_nsec : long;
513 end record;
514 pragma Convention (C, timespec);
516 type clockid_t is new int;
517 CLOCK_REALTIME : constant clockid_t := 1;
519 type struct_timeval is record
520 tv_sec : time_t;
521 tv_usec : time_t;
522 end record;
523 pragma Convention (C, struct_timeval);
525 type unsigned_long_array is array (Natural range <>) of unsigned_long;
527 type pthread_t is new System.Address;
529 type pthread_teb_t is record
530 reserved1 : System.Address;
531 reserved2 : System.Address;
532 size : unsigned_short;
533 version : unsigned_char;
534 reserved3 : unsigned_char;
535 external : unsigned_char;
536 reserved4 : char_array (0 .. 1);
537 creator : unsigned_char;
538 sequence : unsigned_long;
539 reserved5 : unsigned_long_array (0 .. 1);
540 per_kt_area : System.Address;
541 stack_base : System.Address;
542 stack_reserve : System.Address;
543 stack_yellow : System.Address;
544 stack_guard : System.Address;
545 stack_size : unsigned_long;
546 tsd_values : System.Address;
547 tsd_count : unsigned_long;
548 reserved6 : unsigned;
549 reserved7 : unsigned;
550 thread_flags : unsigned;
551 thd_errno : int;
552 stack_hiwater : System.Address;
553 home_rad : unsigned_long;
554 end record;
555 pragma Convention (C, pthread_teb_t);
557 type pthread_cond_t is record
558 state : unsigned;
559 valid : unsigned;
560 name : System.Address;
561 arg : unsigned;
562 reserved1 : unsigned;
563 sequence : unsigned_long;
564 block : System.Address;
565 end record;
566 pragma Convention (C, pthread_cond_t);
568 type pthread_attr_t is record
569 valid : long;
570 name : System.Address;
571 arg : unsigned_long;
572 reserved : unsigned_long_array (0 .. 18);
573 end record;
574 pragma Convention (C, pthread_attr_t);
576 type pthread_mutex_t is record
577 lock : unsigned;
578 valid : unsigned;
579 name : System.Address;
580 arg : unsigned;
581 depth : unsigned;
582 sequence : unsigned_long;
583 owner : unsigned_long;
584 block : System.Address;
585 end record;
586 for pthread_mutex_t'Size use 8 * 48;
587 pragma Convention (C, pthread_mutex_t);
589 type pthread_mutexattr_t is record
590 valid : long;
591 reserved : unsigned_long_array (0 .. 14);
592 end record;
593 pragma Convention (C, pthread_mutexattr_t);
595 type pthread_condattr_t is record
596 valid : long;
597 reserved : unsigned_long_array (0 .. 12);
598 end record;
599 pragma Convention (C, pthread_condattr_t);
601 type pthread_key_t is new unsigned;
603 end System.OS_Interface;