cselib.c (cselib_current_insn_in_libcall): New static variable.
[official-gcc.git] / gcc / ada / 5losinte.ads
blobf101cce0d10ef0dce6a6d9632fa5e743eaac0068
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) 1991-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 GNU/Linux (FSU 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 ("-lgthreads");
49 pragma Linker_Options ("-lmalloc");
51 subtype int is Interfaces.C.int;
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 := 110;
74 -------------
75 -- Signals --
76 -------------
78 Max_Interrupt : constant := 31;
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 SIGFPE : constant := 8; -- floating point exception
90 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
91 SIGBUS : constant := 7; -- bus error
92 SIGSEGV : constant := 11; -- segmentation violation
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 := 10; -- user defined signal 1
97 SIGUSR2 : constant := 12; -- user defined signal 2
98 SIGCLD : constant := 17; -- alias for SIGCHLD
99 SIGCHLD : constant := 17; -- child status change
100 SIGPWR : constant := 30; -- power-fail restart
101 SIGWINCH : constant := 28; -- window size change
102 SIGURG : constant := 23; -- urgent condition on IO channel
103 SIGPOLL : constant := 29; -- pollable event occurred
104 SIGIO : constant := 29; -- I/O now possible (4.2 BSD)
105 SIGLOST : constant := 29; -- File lock lost
106 SIGSTOP : constant := 19; -- stop (cannot be caught or ignored)
107 SIGTSTP : constant := 20; -- user stop requested from tty
108 SIGCONT : constant := 18; -- stopped process has been continued
109 SIGTTIN : constant := 21; -- background tty read attempted
110 SIGTTOU : constant := 22; -- background tty write attempted
111 SIGVTALRM : constant := 26; -- virtual timer expired
112 SIGPROF : constant := 27; -- profiling timer expired
113 SIGXCPU : constant := 24; -- CPU time limit exceeded
114 SIGXFSZ : constant := 25; -- filesize limit exceeded
115 SIGUNUSED : constant := 31; -- unused signal (GNU/Linux)
116 SIGSTKFLT : constant := 16; -- coprocessor stack fault (GNU/Linux)
118 SIGADAABORT : constant := SIGABRT;
119 -- Change this if you want to use another signal for task abort.
120 -- SIGTERM might be a good one.
122 type Signal_Set is array (Natural range <>) of Signal;
124 Unmasked : constant Signal_Set :=
125 (SIGTRAP, SIGBUS, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF);
127 Reserved : constant Signal_Set :=
128 (SIGKILL, SIGSTOP, SIGALRM, SIGVTALRM, SIGUNUSED);
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_handler : System.Address;
149 sa_mask : sigset_t;
150 sa_flags : unsigned_long;
151 sa_restorer : System.Address;
152 end record;
153 pragma Convention (C, struct_sigaction);
154 type struct_sigaction_ptr is access all struct_sigaction;
156 type Machine_State is record
157 eip : unsigned_long;
158 ebx : unsigned_long;
159 esp : unsigned_long;
160 ebp : unsigned_long;
161 esi : unsigned_long;
162 edi : unsigned_long;
163 end record;
164 type Machine_State_Ptr is access all Machine_State;
166 SIG_BLOCK : constant := 0;
167 SIG_UNBLOCK : constant := 1;
168 SIG_SETMASK : constant := 2;
170 SIG_DFL : constant := 0;
171 SIG_IGN : constant := 1;
173 function sigaction
174 (sig : Signal;
175 act : struct_sigaction_ptr;
176 oact : struct_sigaction_ptr) return int;
177 pragma Import (C, sigaction, "sigaction");
179 ----------
180 -- Time --
181 ----------
183 Time_Slice_Supported : constant Boolean := False;
184 -- Indicates wether time slicing is supported (i.e FSU threads have been
185 -- compiled with DEF_RR)
187 type timespec is private;
189 type clockid_t is private;
191 CLOCK_REALTIME : constant clockid_t;
193 function clock_gettime
194 (clock_id : clockid_t;
195 tp : access timespec) return int;
196 pragma Import (C, clock_gettime, "clock_gettime");
198 function To_Duration (TS : timespec) return Duration;
199 pragma Inline (To_Duration);
201 function To_Timespec (D : Duration) return timespec;
202 pragma Inline (To_Timespec);
204 type struct_timeval is private;
206 function To_Duration (TV : struct_timeval) return Duration;
207 pragma Inline (To_Duration);
209 function To_Timeval (D : Duration) return struct_timeval;
210 pragma Inline (To_Timeval);
212 -------------------------
213 -- Priority Scheduling --
214 -------------------------
216 SCHED_FIFO : constant := 0;
217 SCHED_RR : constant := 1;
218 SCHED_OTHER : constant := 2;
220 -------------
221 -- Process --
222 -------------
224 type pid_t is private;
226 function kill (pid : pid_t; sig : Signal) return int;
227 pragma Import (C, kill, "kill");
229 function getpid return pid_t;
230 pragma Import (C, getpid, "getpid");
232 ---------
233 -- LWP --
234 ---------
236 function lwp_self return System.Address;
237 -- lwp_self does not exist on this thread library, revert to pthread_self
238 -- which is the closest approximation (with getpid). This function is
239 -- needed to share 7staprop.adb across POSIX-like targets.
240 pragma Import (C, lwp_self, "pthread_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 := 1;
260 -----------
261 -- Stack --
262 -----------
264 Stack_Base_Available : constant Boolean := False;
265 -- Indicates wether the stack base is available on this target.
266 -- This allows us to share s-osinte.adb between all the FSU run time.
267 -- Note that this value can only be true if pthread_t has a complete
268 -- definition that corresponds exactly to the C header files.
270 function Get_Stack_Base (thread : pthread_t) return Address;
271 pragma Inline (Get_Stack_Base);
272 -- returns the stack base of the specified thread.
273 -- Only call this function when Stack_Base_Available is True.
275 function Get_Page_Size return size_t;
276 function Get_Page_Size return Address;
277 pragma Import (C, Get_Page_Size, "getpagesize");
278 -- returns the size of a page, or 0 if this is not relevant on this
279 -- target
281 PROT_NONE : constant := 0;
282 PROT_READ : constant := 1;
283 PROT_WRITE : constant := 2;
284 PROT_EXEC : constant := 4;
285 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
287 PROT_ON : constant := PROT_NONE;
288 PROT_OFF : constant := PROT_ALL;
290 function mprotect (addr : Address; len : size_t; prot : int) return int;
291 pragma Import (C, mprotect);
293 ---------------------------------------
294 -- Nonstandard Thread Initialization --
295 ---------------------------------------
297 procedure pthread_init;
298 -- FSU_THREADS requires pthread_init, which is nonstandard
299 -- and this should be invoked during the elaboration of s-taprop.adb
300 pragma Import (C, pthread_init, "pthread_init");
302 -------------------------
303 -- POSIX.1c Section 3 --
304 -------------------------
306 function sigwait
307 (set : access sigset_t;
308 sig : access Signal) return int;
309 pragma Inline (sigwait);
310 -- FSU_THREADS has a nonstandard sigwait
312 function pthread_kill
313 (thread : pthread_t;
314 sig : Signal) return int;
315 pragma Import (C, pthread_kill, "pthread_kill");
317 -- FSU threads does not have pthread_sigmask. Instead, it uses
318 -- sigprocmask to do the signal handling when the thread library is
319 -- sucked in.
321 type sigset_t_ptr is access all sigset_t;
323 function pthread_sigmask
324 (how : int;
325 set : sigset_t_ptr;
326 oset : sigset_t_ptr) return int;
327 pragma Import (C, pthread_sigmask, "sigprocmask");
329 --------------------------
330 -- POSIX.1c Section 11 --
331 --------------------------
333 function pthread_mutexattr_init
334 (attr : access pthread_mutexattr_t) return int;
335 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
337 function pthread_mutexattr_destroy
338 (attr : access pthread_mutexattr_t) return int;
339 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
341 function pthread_mutex_init
342 (mutex : access pthread_mutex_t;
343 attr : access pthread_mutexattr_t) return int;
344 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
346 function pthread_mutex_destroy
347 (mutex : access pthread_mutex_t) return int;
348 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
350 function pthread_mutex_lock
351 (mutex : access pthread_mutex_t) return int;
352 pragma Inline (pthread_mutex_lock);
353 -- FSU_THREADS has nonstandard pthread_mutex_lock
355 function pthread_mutex_unlock
356 (mutex : access pthread_mutex_t) return int;
357 pragma Inline (pthread_mutex_unlock);
358 -- FSU_THREADS has nonstandard pthread_mutex_lock
360 function pthread_condattr_init
361 (attr : access pthread_condattr_t) return int;
362 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
364 function pthread_condattr_destroy
365 (attr : access pthread_condattr_t) return int;
366 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
368 function pthread_cond_init
369 (cond : access pthread_cond_t;
370 attr : access pthread_condattr_t) return int;
371 pragma Import (C, pthread_cond_init, "pthread_cond_init");
373 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
374 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
376 function pthread_cond_signal (cond : access pthread_cond_t) return int;
377 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
379 function pthread_cond_wait
380 (cond : access pthread_cond_t;
381 mutex : access pthread_mutex_t) return int;
382 pragma Inline (pthread_cond_wait);
383 -- FSU_THREADS has a nonstandard pthread_cond_wait
385 function pthread_cond_timedwait
386 (cond : access pthread_cond_t;
387 mutex : access pthread_mutex_t;
388 abstime : access timespec) return int;
389 pragma Inline (pthread_cond_timedwait);
390 -- FSU_THREADS has a nonstandard pthread_cond_timedwait
392 Relative_Timed_Wait : constant Boolean := False;
393 -- pthread_cond_timedwait requires an absolute delay time
395 --------------------------
396 -- POSIX.1c Section 13 --
397 --------------------------
399 PTHREAD_PRIO_NONE : constant := 0;
400 PTHREAD_PRIO_PROTECT : constant := 2;
401 PTHREAD_PRIO_INHERIT : constant := 1;
403 function pthread_mutexattr_setprotocol
404 (attr : access pthread_mutexattr_t;
405 protocol : int) return int;
406 pragma Import (C, pthread_mutexattr_setprotocol);
408 function pthread_mutexattr_setprioceiling
409 (attr : access pthread_mutexattr_t;
410 prioceiling : int) return int;
411 pragma Import
412 (C, pthread_mutexattr_setprioceiling,
413 "pthread_mutexattr_setprio_ceiling");
415 type struct_sched_param is record
416 sched_priority : int; -- scheduling priority
417 end record;
419 function pthread_setschedparam
420 (thread : pthread_t;
421 policy : int;
422 param : access struct_sched_param) return int;
423 pragma Inline (pthread_setschedparam);
424 -- FSU_THREADS does not have 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, "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);
436 function pthread_attr_setschedpolicy
437 (attr : access pthread_attr_t;
438 policy : int) return int;
439 pragma Import (C, pthread_attr_setschedpolicy, "pthread_attr_setsched");
441 function sched_yield return int;
442 pragma Inline (sched_yield);
443 -- FSU_THREADS does not have sched_yield;
445 ---------------------------
446 -- P1003.1c - Section 16 --
447 ---------------------------
449 function pthread_attr_init (attributes : access pthread_attr_t) return int;
450 pragma Import (C, pthread_attr_init, "pthread_attr_init");
452 function pthread_attr_destroy
453 (attributes : access pthread_attr_t) return int;
454 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
456 function pthread_attr_setdetachstate
457 (attr : access pthread_attr_t;
458 detachstate : int) return int;
459 pragma Inline (pthread_attr_setdetachstate);
460 -- FSU_THREADS has a nonstandard pthread_attr_setdetachstate
462 function pthread_attr_setstacksize
463 (attr : access pthread_attr_t;
464 stacksize : size_t) return int;
465 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
467 function pthread_create
468 (thread : access pthread_t;
469 attributes : access pthread_attr_t;
470 start_routine : Thread_Body;
471 arg : System.Address) return int;
472 pragma Import (C, pthread_create, "pthread_create");
474 procedure pthread_exit (status : System.Address);
475 pragma Import (C, pthread_exit, "pthread_exit");
477 function pthread_self return pthread_t;
478 pragma Import (C, pthread_self, "pthread_self");
480 --------------------------
481 -- POSIX.1c Section 17 --
482 --------------------------
484 function pthread_setspecific
485 (key : pthread_key_t;
486 value : System.Address) return int;
487 pragma Import (C, pthread_setspecific, "pthread_setspecific");
489 function pthread_getspecific (key : pthread_key_t) return System.Address;
490 pragma Inline (pthread_getspecific);
491 -- FSU_THREADS has a nonstandard pthread_getspecific
493 type destructor_pointer is access procedure (arg : System.Address);
495 function pthread_key_create
496 (key : access pthread_key_t;
497 destructor : destructor_pointer) return int;
498 pragma Import (C, pthread_key_create, "pthread_key_create");
500 private
502 type sigset_t is array (0 .. 31) of unsigned_long;
503 pragma Convention (C, sigset_t);
504 -- This is for GNU libc version 2 but should be backward compatible with
505 -- other libc where sigset_t is smaller.
507 type pid_t is new int;
509 type time_t is new long;
511 type timespec is record
512 tv_sec : time_t;
513 tv_nsec : long;
514 end record;
515 pragma Convention (C, timespec);
517 type clockid_t is new int;
518 CLOCK_REALTIME : constant clockid_t := 0;
520 type struct_timeval is record
521 tv_sec : long;
522 tv_usec : long;
523 end record;
524 pragma Convention (C, struct_timeval);
526 type pthread_attr_t is record
527 flags : int;
528 stacksize : int;
529 contentionscope : int;
530 inheritsched : int;
531 detachstate : int;
532 sched : int;
533 prio : int;
534 starttime : timespec;
535 deadline : timespec;
536 period : timespec;
537 end record;
538 pragma Convention (C_Pass_By_Copy, pthread_attr_t);
540 type pthread_condattr_t is record
541 flags : int;
542 end record;
543 pragma Convention (C, pthread_condattr_t);
545 type pthread_mutexattr_t is record
546 flags : int;
547 prio_ceiling : int;
548 protocol : int;
549 end record;
550 pragma Convention (C, pthread_mutexattr_t);
552 type sigjmp_buf is array (Integer range 0 .. 38) of int;
554 type pthread_t_struct is record
555 context : sigjmp_buf;
556 pbody : sigjmp_buf;
557 errno : int;
558 ret : int;
559 stack_base : System.Address;
560 end record;
561 pragma Convention (C, pthread_t_struct);
563 type pthread_t is access all pthread_t_struct;
565 type queue_t is record
566 head : System.Address;
567 tail : System.Address;
568 end record;
569 pragma Convention (C, queue_t);
571 type pthread_mutex_t is record
572 queue : queue_t;
573 lock : plain_char;
574 owner : System.Address;
575 flags : int;
576 prio_ceiling : int;
577 protocol : int;
578 prev_max_ceiling_prio : int;
579 end record;
580 pragma Convention (C, pthread_mutex_t);
582 type pthread_cond_t is record
583 queue : queue_t;
584 flags : int;
585 waiters : int;
586 mutex : System.Address;
587 end record;
588 pragma Convention (C, pthread_cond_t);
590 type pthread_key_t is new int;
592 end System.OS_Interface;