i386-protos.h (x86_emit_floatuns): Declare.
[official-gcc.git] / gcc / ada / 51osinte.ads
blob7e2b16603fda55d4845bb70d8b52bdc1eb5dc5dc
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 -- --
10 -- Copyright (C) 1999-2001 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 a UnixWare (Native THREADS) 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
41 -- or remove the pragma Elaborate_Body.
42 -- It is designed to be a bottom-level (leaf) package.
44 with Interfaces.C;
45 package System.OS_Interface is
46 pragma Preelaborate;
48 pragma Linker_Options ("-lthread");
50 subtype int is Interfaces.C.int;
51 subtype char is Interfaces.C.char;
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 EAGAIN : constant := 11;
69 EINTR : constant := 4;
70 EINVAL : constant := 22;
71 ENOMEM : constant := 12;
72 ETIMEDOUT : constant := 145;
74 -------------
75 -- Signals --
76 -------------
78 Max_Interrupt : constant := 34;
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 SIGWAITING : constant := 32; -- all LWPs blocked interruptibly notific.
117 SIGLWP : constant := 33; -- signal reserved for thread lib impl.
118 SIGAIO : constant := 34; -- Asynchronous I/O signal
120 SIGADAABORT : constant := SIGABRT;
121 -- Change this if you want to use another signal for task abort.
122 -- SIGTERM might be a good one.
124 type Signal_Set is array (Natural range <>) of Signal;
126 Unmasked : constant Signal_Set :=
127 (SIGTRAP, SIGLWP, SIGWAITING, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF);
128 Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP);
130 type sigset_t is private;
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 struct_sigaction is record
148 sa_flags : int;
149 sa_handler : System.Address;
150 sa_mask : sigset_t;
151 sa_resv1 : int;
152 sa_resv2 : int;
153 end record;
154 pragma Convention (C, struct_sigaction);
155 type struct_sigaction_ptr is access all struct_sigaction;
157 SIG_BLOCK : constant := 1;
158 SIG_UNBLOCK : constant := 2;
159 SIG_SETMASK : constant := 3;
161 SIG_DFL : constant := 0;
162 SIG_IGN : constant := 1;
163 -- SIG_ERR : constant := -1;
164 -- not used
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 := False;
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 -- UnixWare threads don't have clock_gettime
189 -- We instead use gettimeofday()
191 function To_Duration (TS : timespec) return Duration;
192 pragma Inline (To_Duration);
194 function To_Timespec (D : Duration) return timespec;
195 pragma Inline (To_Timespec);
197 type struct_timezone is record
198 tz_minuteswest : int;
199 tz_dsttime : int;
200 end record;
201 pragma Convention (C, struct_timezone);
202 type struct_timezone_ptr is access all struct_timezone;
204 type struct_timeval is private;
205 -- This is needed on systems that do not have clock_gettime()
206 -- but do have gettimeofday().
208 function To_Duration (TV : struct_timeval) return Duration;
209 pragma Inline (To_Duration);
211 function To_Timeval (D : Duration) return struct_timeval;
212 pragma Inline (To_Timeval);
214 -------------------------
215 -- Priority Scheduling --
216 -------------------------
218 SCHED_FIFO : constant := 2;
219 SCHED_RR : constant := 3;
220 SCHED_OTHER : constant := 1;
222 -------------
223 -- Process --
224 -------------
226 type pid_t is private;
228 function kill (pid : pid_t; sig : Signal) return int;
229 pragma Import (C, kill, "kill");
231 function getpid return pid_t;
232 pragma Import (C, getpid, "getpid");
234 ---------
235 -- LWP --
236 ---------
238 function lwp_self return System.Address;
239 pragma Import (C, lwp_self, "_lwp_self");
241 -------------
242 -- Threads --
243 -------------
245 type Thread_Body is access
246 function (arg : System.Address) return System.Address;
247 type pthread_t is private;
248 subtype Thread_Id is pthread_t;
250 type pthread_mutex_t is limited private;
251 type pthread_cond_t is limited private;
252 type pthread_attr_t is limited private;
253 type pthread_mutexattr_t is limited private;
254 type pthread_condattr_t is limited private;
255 type pthread_key_t is private;
257 PTHREAD_CREATE_DETACHED : constant := 0;
259 -----------
260 -- Stack --
261 -----------
263 Stack_Base_Available : constant Boolean := False;
264 -- Indicates wether the stack base is available on this target.
266 function Get_Stack_Base (thread : pthread_t) return Address;
267 pragma Inline (Get_Stack_Base);
268 -- returns the stack base of the specified thread.
269 -- Only call this function when Stack_Base_Available is True.
271 function Get_Page_Size return size_t;
272 function Get_Page_Size return Address;
273 pragma Import (C, Get_Page_Size, "getpagesize");
274 -- returns the size of a page, or 0 if this is not relevant on this
275 -- target
277 PROT_NONE : constant := 0;
278 PROT_READ : constant := 1;
279 PROT_WRITE : constant := 2;
280 PROT_EXEC : constant := 4;
281 PROT_USER : constant := 8;
282 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC + PROT_USER;
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 -- POSIX.1c Section 3 --
292 -------------------------
294 function sigwait (set : access sigset_t; sig : access Signal) return int;
295 pragma Inline (sigwait);
296 -- UnixWare provides a non standard sigwait
298 function pthread_kill (thread : pthread_t; sig : Signal) return int;
299 pragma Inline (pthread_kill);
300 -- UnixWare provides a non standard pthread_kill
302 type sigset_t_ptr is access all sigset_t;
304 function pthread_sigmask
305 (how : int;
306 set : sigset_t_ptr;
307 oset : sigset_t_ptr) return int;
308 pragma Import (C, pthread_sigmask, "pthread_sigmask");
310 --------------------------
311 -- POSIX.1c Section 11 --
312 --------------------------
314 function pthread_mutexattr_init
315 (attr : access pthread_mutexattr_t) return int;
316 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
318 function pthread_mutexattr_destroy
319 (attr : access pthread_mutexattr_t) return int;
320 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
322 function pthread_mutex_init
323 (mutex : access pthread_mutex_t;
324 attr : access pthread_mutexattr_t) return int;
325 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
327 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
328 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
330 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
331 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
333 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
334 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
336 function pthread_condattr_init
337 (attr : access pthread_condattr_t) return int;
338 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
340 function pthread_condattr_destroy
341 (attr : access pthread_condattr_t) return int;
342 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
344 function pthread_cond_init
345 (cond : access pthread_cond_t;
346 attr : access pthread_condattr_t) return int;
347 pragma Import (C, pthread_cond_init, "pthread_cond_init");
349 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
350 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
352 function pthread_cond_signal (cond : access pthread_cond_t) return int;
353 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
355 function pthread_cond_wait
356 (cond : access pthread_cond_t;
357 mutex : access pthread_mutex_t) return int;
358 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
360 function pthread_cond_timedwait
361 (cond : access pthread_cond_t;
362 mutex : access pthread_mutex_t;
363 abstime : access timespec) return int;
364 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
366 Relative_Timed_Wait : constant Boolean := False;
367 -- pthread_cond_timedwait requires an absolute delay time
369 --------------------------
370 -- POSIX.1c Section 13 --
371 --------------------------
373 PTHREAD_PRIO_NONE : constant := 1;
374 PTHREAD_PRIO_INHERIT : constant := 2;
375 PTHREAD_PRIO_PROTECT : constant := 3;
377 function pthread_mutexattr_setprotocol
378 (attr : access pthread_mutexattr_t;
379 protocol : int) return int;
380 pragma Import (C, pthread_mutexattr_setprotocol);
382 function pthread_mutexattr_setprioceiling
383 (attr : access pthread_mutexattr_t;
384 prioceiling : int) return int;
385 pragma Import (C, pthread_mutexattr_setprioceiling);
387 type sched_union is record
388 sched_fifo : int;
389 sched_fcfs : int;
390 sched_other : int;
391 sched_ts : int;
392 policy_params : long;
393 end record;
395 type struct_sched_param is record
396 sched_priority : int;
397 sched_other_stuff : sched_union;
398 end record;
400 function pthread_setschedparam
401 (thread : pthread_t;
402 policy : int;
403 param : access struct_sched_param) return int;
404 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
406 function pthread_attr_setscope
407 (attr : access pthread_attr_t;
408 contentionscope : int) return int;
409 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
411 function pthread_attr_setinheritsched
412 (attr : access pthread_attr_t;
413 inheritsched : int) return int;
414 pragma Import (C, pthread_attr_setinheritsched);
416 function pthread_attr_setschedpolicy
417 (attr : access pthread_attr_t;
418 policy : int) return int;
419 pragma Import (C, pthread_attr_setschedpolicy);
421 function sched_yield return int;
422 pragma Import (C, sched_yield, "sched_yield");
424 ---------------------------
425 -- P1003.1c - Section 16 --
426 ---------------------------
428 function pthread_attr_init (attributes : access pthread_attr_t) return int;
429 pragma Import (C, pthread_attr_init, "pthread_attr_init");
431 function pthread_attr_destroy
432 (attributes : access pthread_attr_t) return int;
433 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
435 function pthread_attr_setdetachstate
436 (attr : access pthread_attr_t;
437 detachstate : int) return int;
438 pragma Import (C, pthread_attr_setdetachstate);
440 function pthread_attr_setstacksize
441 (attr : access pthread_attr_t;
442 stacksize : size_t) return int;
443 pragma Import (C, pthread_attr_setstacksize);
445 function pthread_create
446 (thread : access pthread_t;
447 attributes : access pthread_attr_t;
448 start_routine : Thread_Body;
449 arg : System.Address) return int;
450 pragma Import (C, pthread_create, "pthread_create");
452 procedure pthread_exit (status : System.Address);
453 pragma Import (C, pthread_exit, "pthread_exit");
455 function pthread_self return pthread_t;
456 pragma Import (C, pthread_self, "pthread_self");
458 --------------------------
459 -- POSIX.1c Section 17 --
460 --------------------------
462 function pthread_setspecific
463 (key : pthread_key_t;
464 value : System.Address) return int;
465 pragma Import (C, pthread_setspecific, "pthread_setspecific");
467 function pthread_getspecific (key : pthread_key_t) return System.Address;
468 pragma Import (C, pthread_getspecific, "pthread_getspecific");
470 type destructor_pointer is access procedure (arg : System.Address);
472 function pthread_key_create
473 (key : access pthread_key_t;
474 destructor : destructor_pointer) return int;
475 pragma Import (C, pthread_key_create, "pthread_key_create");
477 procedure pthread_init;
478 -- This is a dummy procedure to share some GNULLI files
480 private
482 type sigbit_array is array (1 .. 4) of unsigned;
483 type sigset_t is record
484 sa_sigbits : sigbit_array;
485 end record;
486 pragma Convention (C_Pass_By_Copy, sigset_t);
488 type pid_t is new unsigned;
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 := 0;
501 type struct_timeval is record
502 tv_sec : long;
503 tv_usec : long;
504 end record;
505 pragma Convention (C, struct_timeval);
507 type pthread_attr_t is record
508 pt_attr_status : int;
509 pt_attr_stacksize : size_t;
510 pt_attr_stackaddr : System.Address;
511 pt_attr_detachstate : int;
512 pt_attr_contentionscope : int;
513 pt_attr_inheritsched : int;
514 pt_attr_schedpolicy : int;
515 pt_attr_sched_param : struct_sched_param;
516 pt_attr_tlflags : int;
517 end record;
518 pragma Convention (C, pthread_attr_t);
520 type pthread_condattr_t is record
521 pt_condattr_status : int;
522 pt_condattr_pshared : int;
523 end record;
524 pragma Convention (C, pthread_condattr_t);
526 type pthread_mutexattr_t is record
527 pt_mutexattr_status : int;
528 pt_mutexattr_pshared : int;
529 pt_mutexattr_type : int;
530 end record;
531 pragma Convention (C, pthread_mutexattr_t);
533 type thread_t is new long;
534 type pthread_t is new thread_t;
536 type thrq_elt_t;
537 type thrq_elt_t_ptr is access all thrq_elt_t;
539 type thrq_elt_t is record
540 thrq_next : thrq_elt_t_ptr;
541 thrq_prev : thrq_elt_t_ptr;
542 end record;
543 pragma Convention (C, thrq_elt_t);
545 type lwp_mutex_t is record
546 wanted : char;
547 lock : unsigned_char;
548 end record;
549 pragma Convention (C, lwp_mutex_t);
550 pragma Volatile (lwp_mutex_t);
552 type mutex_t is record
553 m_lmutex : lwp_mutex_t;
554 m_sync_lock : lwp_mutex_t;
555 m_type : int;
556 m_sleepq : thrq_elt_t;
557 filler1 : int;
558 filler2 : int;
559 end record;
560 pragma Convention (C, mutex_t);
561 pragma Volatile (mutex_t);
563 type pthread_mutex_t is record
564 pt_mutex_mutex : mutex_t;
565 pt_mutex_pid : pid_t;
566 pt_mutex_owner : thread_t;
567 pt_mutex_depth : int;
568 pt_mutex_attr : pthread_mutexattr_t;
569 end record;
570 pragma Convention (C, pthread_mutex_t);
572 type lwp_cond_t is record
573 wanted : char;
574 end record;
575 pragma Convention (C, lwp_cond_t);
576 pragma Volatile (lwp_cond_t);
578 type cond_t is record
579 c_lcond : lwp_cond_t;
580 c_sync_lock : lwp_mutex_t;
581 c_type : int;
582 c_syncq : thrq_elt_t;
583 end record;
584 pragma Convention (C, cond_t);
585 pragma Volatile (cond_t);
587 type pthread_cond_t is record
588 pt_cond_cond : cond_t;
589 pt_cond_attr : pthread_condattr_t;
590 end record;
591 pragma Convention (C, pthread_cond_t);
593 type pthread_key_t is new unsigned;
595 end System.OS_Interface;