Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
[official-gcc.git] / gcc / ada / 52osinte.ads
blobc22e2056f0f553a596c0b202b4659b8b897f48bc
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 LynxOS (Native) 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 ("-mthreads");
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 := 60;
74 -------------
75 -- Signals --
76 -------------
78 Max_Interrupt : constant := 63;
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 SIGBRK : constant := 6; -- break
88 SIGIOT : constant := 6; -- IOT instruction
89 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
90 SIGCORE : constant := 7; -- kill with core dump
91 SIGEMT : constant := 7; -- EMT instruction
92 SIGFPE : constant := 8; -- floating point exception
93 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
94 SIGBUS : constant := 10; -- bus error
95 SIGSEGV : constant := 11; -- segmentation violation
96 SIGSYS : constant := 12; -- bad argument to system call
97 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
98 SIGALRM : constant := 14; -- alarm clock
99 SIGTERM : constant := 15; -- software termination signal from kill
100 SIGURG : constant := 16; -- urgent condition on IO channel
101 SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
102 SIGTSTP : constant := 18; -- user stop requested from tty
103 SIGCONT : constant := 19; -- stopped process has been continued
104 SIGCLD : constant := 20; -- alias for SIGCHLD
105 SIGCHLD : constant := 20; -- child status change
106 SIGTTIN : constant := 21; -- background tty read attempted
107 SIGTTOU : constant := 22; -- background tty write attempted
108 SIGIO : constant := 23; -- I/O possible (Solaris SIGPOLL alias)
109 SIGPOLL : constant := 23; -- pollable event occurred
110 SIGXCPU : constant := 24; -- CPU time limit exceeded
111 SIGXFSZ : constant := 25; -- filesize limit exceeded
112 SIGVTALRM : constant := 26; -- virtual timer expired
113 SIGPROF : constant := 27; -- profiling timer expired
114 SIGWINCH : constant := 28; -- window size change
115 SIGLOST : constant := 29; -- SUN 4.1 compatibility
116 SIGUSR1 : constant := 30; -- user defined signal 1
117 SIGUSR2 : constant := 31; -- user defined signal 2
118 SIGPRIO : constant := 32; -- sent to a process with its priority or
119 -- group is changed
121 SIGADAABORT : constant := SIGABRT;
122 -- Change this if you want to use another signal for task abort.
123 -- SIGTERM might be a good one.
125 type Signal_Set is array (Natural range <>) of Signal;
127 Unmasked : constant Signal_Set :=
128 (SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF);
129 Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP, SIGPRIO);
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 Inline (clock_gettime);
186 -- LynxOS has non standard clock_gettime
188 function To_Duration (TS : timespec) return Duration;
189 pragma Inline (To_Duration);
191 function To_Timespec (D : Duration) return timespec;
192 pragma Inline (To_Timespec);
194 type struct_timezone is record
195 tz_minuteswest : int;
196 tz_dsttime : int;
197 end record;
198 pragma Convention (C, struct_timezone);
199 type struct_timezone_ptr is access all struct_timezone;
201 type struct_timeval is private;
202 -- This is needed on systems that do not have clock_gettime()
203 -- but do have gettimeofday().
205 function To_Duration (TV : struct_timeval) return Duration;
206 pragma Inline (To_Duration);
208 function To_Timeval (D : Duration) return struct_timeval;
209 pragma Inline (To_Timeval);
211 -------------------------
212 -- Priority Scheduling --
213 -------------------------
215 SCHED_FIFO : constant := 16#00200000#;
216 SCHED_RR : constant := 16#00100000#;
217 SCHED_OTHER : constant := 16#00400000#;
219 -------------
220 -- Process --
221 -------------
223 type pid_t is private;
225 function kill (pid : pid_t; sig : Signal) return int;
226 pragma Import (C, kill, "kill");
228 function getpid return pid_t;
229 pragma Import (C, getpid, "getpid");
231 ---------
232 -- LWP --
233 ---------
235 function lwp_self return System.Address;
236 -- lwp_self does not exist on this thread library, revert to pthread_self
237 -- which is the closest approximation (with getpid). This function is
238 -- needed to share 7staprop.adb across POSIX-like targets.
239 pragma Import (C, lwp_self, "pthread_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 st_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 := 0;
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_USER : constant := 8;
283 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC + PROT_USER;
285 PROT_ON : constant := PROT_READ;
286 PROT_OFF : constant := PROT_ALL;
288 function mprotect (addr : Address; len : size_t; prot : int) return int;
289 pragma Import (C, mprotect);
291 -------------------------
292 -- POSIX.1c Section 3 --
293 -------------------------
295 function sigwait
296 (set : access sigset_t;
297 sig : access Signal) return int;
298 pragma Inline (sigwait);
299 -- LynxOS has non standard sigwait
301 function pthread_kill (thread : pthread_t; sig : Signal) return int;
302 pragma Import (C, pthread_kill, "pthread_kill");
304 type sigset_t_ptr is access all sigset_t;
306 function pthread_sigmask
307 (how : int;
308 set : sigset_t_ptr;
309 oset : sigset_t_ptr) return int;
310 pragma Import (C, pthread_sigmask, "sigprocmask");
312 --------------------------
313 -- POSIX.1c Section 11 --
314 --------------------------
316 function pthread_mutexattr_init
317 (attr : access pthread_mutexattr_t) return int;
318 pragma Inline (pthread_mutexattr_init);
319 -- LynxOS has a nonstandard pthread_mutexattr_init
321 function pthread_mutexattr_destroy
322 (attr : access pthread_mutexattr_t) return int;
323 pragma Inline (pthread_mutexattr_destroy);
324 -- Lynxos has a nonstandard pthread_mutexattr_destroy
326 function pthread_mutex_init
327 (mutex : access pthread_mutex_t;
328 attr : access pthread_mutexattr_t) return int;
329 pragma Inline (pthread_mutex_init);
330 -- LynxOS has a nonstandard pthread_mutex_init
332 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
333 pragma Inline (pthread_mutex_destroy);
334 -- LynxOS has a nonstandard pthread_mutex_destroy
336 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
337 pragma Inline (pthread_mutex_lock);
338 -- LynxOS has a nonstandard pthread_mutex_lock
340 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
341 pragma Inline (pthread_mutex_unlock);
342 -- LynxOS has a nonstandard pthread_mutex_unlock
344 function pthread_condattr_init
345 (attr : access pthread_condattr_t) return int;
346 pragma Inline (pthread_condattr_init);
347 -- LynxOS has a nonstandard pthread_condattr_init
349 function pthread_condattr_destroy
350 (attr : access pthread_condattr_t) return int;
351 pragma Inline (pthread_condattr_destroy);
352 -- LynxOS has a nonstandard pthread_condattr_destroy
354 function pthread_cond_init
355 (cond : access pthread_cond_t;
356 attr : access pthread_condattr_t) return int;
357 pragma Inline (pthread_cond_init);
358 -- LynxOS has a non standard pthread_cond_init
360 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
361 pragma Inline (pthread_cond_destroy);
362 -- LynxOS has a nonstandard pthread_cond_destroy
364 function pthread_cond_signal (cond : access pthread_cond_t) return int;
365 pragma Inline (pthread_cond_signal);
366 -- LynxOS has a nonstandard pthread_cond_signal
368 function pthread_cond_wait
369 (cond : access pthread_cond_t;
370 mutex : access pthread_mutex_t) return int;
371 pragma Inline (pthread_cond_wait);
372 -- LynxOS has a nonstandard pthread_cond_wait
374 function pthread_cond_timedwait
375 (cond : access pthread_cond_t;
376 mutex : access pthread_mutex_t;
377 reltime : access timespec) return int;
378 pragma Inline (pthread_cond_timedwait);
379 -- LynxOS has a nonstandard pthrad_cond_timedwait
381 Relative_Timed_Wait : constant Boolean := True;
382 -- pthread_cond_timedwait requires a relative delay time
384 --------------------------
385 -- POSIX.1c Section 13 --
386 --------------------------
388 PTHREAD_PRIO_NONE : constant := 0;
389 PTHREAD_PRIO_INHERIT : constant := 0;
390 PTHREAD_PRIO_PROTECT : constant := 0;
392 type struct_sched_param is record
393 sched_priority : int; -- scheduling priority
394 end record;
396 function pthread_setschedparam
397 (thread : pthread_t;
398 policy : int;
399 param : access struct_sched_param) return int;
400 pragma Inline (pthread_setschedparam);
401 -- LynxOS doesn't have pthread_setschedparam.
402 -- Instead, use pthread_setscheduler
404 function pthread_mutexattr_setprotocol
405 (attr : access pthread_mutexattr_t;
406 protocol : int) return int;
407 pragma Inline (pthread_mutexattr_setprotocol);
408 -- LynxOS doesn't have pthread_mutexattr_setprotocol
410 function pthread_mutexattr_setprioceiling
411 (attr : access pthread_mutexattr_t;
412 prioceiling : int) return int;
413 pragma Inline (pthread_mutexattr_setprioceiling);
414 -- LynxOS doesn't have pthread_mutexattr_setprioceiling
416 function pthread_attr_setscope
417 (attr : access pthread_attr_t;
418 contentionscope : int) return int;
419 -- LynxOS doesn't have pthread_attr_setscope: all threads have system scope
420 pragma Inline (pthread_attr_setscope);
422 function pthread_attr_setschedpolicy
423 (attr : access pthread_attr_t;
424 policy : int) return int;
425 pragma Import (C, pthread_attr_setschedpolicy, "pthread_attr_setsched");
427 function sched_yield return int;
428 -- pragma Import (C, sched_yield, "sched_yield");
429 pragma Inline (sched_yield);
431 ---------------------------
432 -- P1003.1c - Section 16 --
433 ---------------------------
435 function pthread_attr_init (attributes : access pthread_attr_t) return int;
436 pragma Import (C, pthread_attr_init, "pthread_attr_create");
438 function pthread_attr_destroy
439 (attributes : access pthread_attr_t) return int;
440 pragma Import (C, pthread_attr_destroy, "pthread_attr_delete");
442 function pthread_attr_setdetachstate
443 (attr : access pthread_attr_t;
444 detachstate : int) return int;
445 pragma Inline (pthread_attr_setdetachstate);
446 -- LynxOS doesn't have pthread_attr_setdetachstate
448 function pthread_attr_setstacksize
449 (attr : access pthread_attr_t;
450 stacksize : size_t) return int;
451 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
453 function pthread_create
454 (thread : access pthread_t;
455 attributes : access pthread_attr_t;
456 start_routine : Thread_Body;
457 arg : System.Address) return int;
458 pragma Inline (pthread_create);
459 -- LynxOS has a non standard pthread_create
461 procedure pthread_exit (status : System.Address);
462 pragma Import (C, pthread_exit, "pthread_exit");
464 function pthread_self return pthread_t;
465 pragma Import (C, pthread_self, "pthread_self");
467 --------------------------
468 -- POSIX.1c Section 17 --
469 --------------------------
471 function pthread_setspecific
472 (key : pthread_key_t;
473 value : System.Address) return int;
474 pragma Inline (pthread_setspecific);
475 -- LynxOS has a non standard pthread_setspecific
477 function pthread_getspecific (key : pthread_key_t) return System.Address;
478 pragma Inline (pthread_getspecific);
479 -- LynxOS has a non standard pthread_getspecific
481 type destructor_pointer is access procedure (arg : System.Address);
483 function pthread_key_create
484 (key : access pthread_key_t;
485 destructor : destructor_pointer) return int;
486 pragma Inline (pthread_key_create);
487 -- LynxOS has a non standard pthread_keycreate
489 procedure pthread_init;
490 -- This is a dummy procedure to share some GNULLI files
492 private
494 type sigbit_array is array (1 .. 2) of long;
495 type sigset_t is record
496 sa_sigbits : sigbit_array;
497 end record;
498 pragma Convention (C_Pass_By_Copy, sigset_t);
500 type pid_t is new long;
502 type time_t is new long;
504 type timespec is record
505 tv_sec : time_t;
506 tv_nsec : long;
507 end record;
508 pragma Convention (C, timespec);
510 type clockid_t is new unsigned_char;
511 CLOCK_REALTIME : constant clockid_t := 0;
513 type struct_timeval is record
514 tv_sec : time_t;
515 tv_usec : time_t;
516 end record;
517 pragma Convention (C, struct_timeval);
519 type st_t is record
520 stksize : int;
521 prio : int;
522 inheritsched : int;
523 state : int;
524 sched : int;
525 end record;
526 pragma Convention (C, st_t);
528 type pthread_attr_t is record
529 st : st_t;
530 pthread_attr_scope : int; -- ignored
531 end record;
532 pragma Convention (C, pthread_attr_t);
534 type pthread_condattr_t is new int;
536 type pthread_mutexattr_t is new int;
538 type tid_t is new short;
539 type pthread_t is new tid_t;
541 type synch_ptr is access all pthread_mutex_t;
542 type pthread_mutex_t is record
543 w_count : int;
544 mut_owner : int;
545 id : unsigned;
546 next : synch_ptr;
547 end record;
548 pragma Convention (C, pthread_mutex_t);
550 type pthread_cond_t is new pthread_mutex_t;
552 type pthread_key_t is new int;
554 end System.OS_Interface;