* config/xtensa/linux.h (TARGET_OS_CPP_BUILTINS): Remove definition of
[official-gcc.git] / gcc / ada / 54osinte.ads
blobd13eed4cc11e5efeff36c2d4ba923bbbc74de5b2
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) 2000-2002 Ada Core Technologies, Inc. --
10 -- --
11 -- GNARL is free software; you can redistribute it and/or modify it under --
12 -- terms of the GNU General Public License as published by the Free Soft- --
13 -- ware Foundation; either version 2, or (at your option) any later ver- --
14 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
16 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
17 -- for more details. You should have received a copy of the GNU General --
18 -- Public License distributed with GNARL; see file COPYING. If not, write --
19 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20 -- MA 02111-1307, USA. --
21 -- --
22 -- As a special exception, if other files instantiate generics from this --
23 -- unit, or you link this unit with other files to produce an executable, --
24 -- this unit does not by itself cause the resulting executable to be --
25 -- covered by the GNU General Public License. This exception does not --
26 -- however invalidate any other reasons why the executable file might be --
27 -- covered by the GNU Public License. --
28 -- --
29 -- GNARL was developed by the GNARL team at Florida State University. It is --
30 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
31 -- State University (http://www.gnat.com). --
32 -- --
33 ------------------------------------------------------------------------------
35 -- This is a Solaris (POSIX 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 ("-lposix4");
49 pragma Linker_Options ("-lpthread");
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 := 145;
74 -------------
75 -- Signals --
76 -------------
78 Max_Interrupt : constant := 45;
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; -- process's lwps blocked (Solaris)
117 SIGLWP : constant := 33; -- used by thread library (Solaris)
118 SIGFREEZE : constant := 34; -- used by CPR (Solaris)
119 SIGTHAW : constant := 35; -- used by CPR (Solaris)
120 SIGCANCEL : constant := 36; -- thread cancellation signal (libthread)
122 SIGADAABORT : constant := SIGABRT;
124 type Signal_Set is array (Natural range <>) of Signal;
126 Unmasked : constant Signal_Set := (SIGTRAP, SIGLWP, SIGPROF);
128 -- Following signals should not be disturbed.
129 -- See c-posix-signals.c in FLORIST
131 Reserved : constant Signal_Set :=
132 (SIGKILL, SIGSTOP, SIGWAITING, SIGCANCEL);
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_flags : int;
153 sa_handler : System.Address;
154 sa_mask : sigset_t;
155 sa_resv1 : int;
156 sa_resv2 : int;
157 end record;
158 pragma Convention (C, struct_sigaction);
159 type struct_sigaction_ptr is access all struct_sigaction;
161 SIG_BLOCK : constant := 1;
162 SIG_UNBLOCK : constant := 2;
163 SIG_SETMASK : constant := 3;
165 SIG_DFL : constant := 0;
166 SIG_IGN : constant := 1;
168 function sigaction
169 (sig : Signal;
170 act : struct_sigaction_ptr;
171 oact : struct_sigaction_ptr) return int;
172 pragma Import (C, sigaction, "sigaction");
174 ----------
175 -- Time --
176 ----------
178 Time_Slice_Supported : constant Boolean := True;
179 -- Indicates wether time slicing is supported
181 type timespec is private;
183 type clockid_t is private;
185 CLOCK_REALTIME : constant clockid_t;
187 function clock_gettime
188 (clock_id : clockid_t;
189 tp : access timespec) return int;
190 pragma Import (C, clock_gettime, "clock_gettime");
192 function To_Duration (TS : timespec) return Duration;
193 pragma Inline (To_Duration);
195 function To_Timespec (D : Duration) return timespec;
196 pragma Inline (To_Timespec);
198 type struct_timeval is private;
200 function To_Duration (TV : struct_timeval) return Duration;
201 pragma Inline (To_Duration);
203 function To_Timeval (D : Duration) return struct_timeval;
204 pragma Inline (To_Timeval);
206 -------------------------
207 -- Priority Scheduling --
208 -------------------------
210 SCHED_FIFO : constant := 1;
211 SCHED_RR : constant := 2;
212 SCHED_OTHER : constant := 0;
214 -------------
215 -- Process --
216 -------------
218 type pid_t is private;
220 function kill (pid : pid_t; sig : Signal) return int;
221 pragma Import (C, kill, "kill");
223 function getpid return pid_t;
224 pragma Import (C, getpid, "getpid");
226 ---------
227 -- LWP --
228 ---------
230 function lwp_self return System.Address;
231 pragma Import (C, lwp_self, "_lwp_self");
233 -------------
234 -- Threads --
235 -------------
237 type Thread_Body is access
238 function (arg : System.Address) return System.Address;
239 type pthread_t is private;
240 subtype Thread_Id is pthread_t;
242 type pthread_mutex_t is limited private;
243 type pthread_cond_t is limited private;
244 type pthread_attr_t is limited private;
245 type pthread_mutexattr_t is limited private;
246 type pthread_condattr_t is limited private;
247 type pthread_key_t is private;
249 PTHREAD_CREATE_DETACHED : constant := 16#40#;
251 -----------
252 -- Stack --
253 -----------
255 Stack_Base_Available : constant Boolean := False;
256 -- Indicates wether the stack base is available on this target.
258 function Get_Stack_Base (thread : pthread_t) return Address;
259 pragma Inline (Get_Stack_Base);
260 -- returns the stack base of the specified thread.
261 -- Only call this function when Stack_Base_Available is True.
263 function Get_Page_Size return size_t;
264 function Get_Page_Size return Address;
265 pragma Import (C, Get_Page_Size, "getpagesize");
266 -- returns the size of a page, or 0 if this is not relevant on this
267 -- target
269 PROT_NONE : constant := 0;
270 PROT_READ : constant := 1;
271 PROT_WRITE : constant := 2;
272 PROT_EXEC : constant := 4;
273 PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
275 PROT_ON : constant := PROT_READ;
276 PROT_OFF : constant := PROT_ALL;
278 function mprotect (addr : Address; len : size_t; prot : int) return int;
279 pragma Import (C, mprotect);
281 ---------------------------------------
282 -- Nonstandard Thread Initialization --
283 ---------------------------------------
285 procedure pthread_init;
286 -- This is a dummy procedure to share some GNULLI files
288 -------------------------
289 -- POSIX.1c Section 3 --
290 -------------------------
292 function sigwait
293 (set : access sigset_t;
294 sig : access Signal) return int;
295 pragma Import (C, sigwait, "__posix_sigwait");
297 function pthread_kill
298 (thread : pthread_t;
299 sig : Signal) return int;
300 pragma Import (C, pthread_kill, "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 := 0;
374 PTHREAD_PRIO_INHERIT : constant := 16#10#;
375 PTHREAD_PRIO_PROTECT : constant := 16#20#;
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 Array_8_Int is array (0 .. 7) of int;
388 type struct_sched_param is record
389 sched_priority : int;
390 sched_pad : Array_8_Int;
391 end record;
393 function pthread_setschedparam
394 (thread : pthread_t;
395 policy : int;
396 param : access struct_sched_param) return int;
397 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
399 function pthread_attr_setscope
400 (attr : access pthread_attr_t;
401 contentionscope : int) return int;
402 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
404 function pthread_attr_setinheritsched
405 (attr : access pthread_attr_t;
406 inheritsched : int) return int;
407 pragma Import (C, pthread_attr_setinheritsched);
409 function pthread_attr_setschedpolicy
410 (attr : access pthread_attr_t;
411 policy : int) return int;
412 pragma Import (C, pthread_attr_setschedpolicy);
414 function sched_yield return int;
415 pragma Import (C, sched_yield, "sched_yield");
417 ---------------------------
418 -- P1003.1c - Section 16 --
419 ---------------------------
421 function pthread_attr_init (attributes : access pthread_attr_t) return int;
422 pragma Import (C, pthread_attr_init, "pthread_attr_init");
424 function pthread_attr_destroy
425 (attributes : access pthread_attr_t) return int;
426 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
428 function pthread_attr_setdetachstate
429 (attr : access pthread_attr_t;
430 detachstate : int) return int;
431 pragma Import (C, pthread_attr_setdetachstate);
433 function pthread_attr_setstacksize
434 (attr : access pthread_attr_t;
435 stacksize : size_t) return int;
436 pragma Import (C, pthread_attr_setstacksize);
438 function pthread_create
439 (thread : access pthread_t;
440 attributes : access pthread_attr_t;
441 start_routine : Thread_Body;
442 arg : System.Address) return int;
443 pragma Import (C, pthread_create, "pthread_create");
445 procedure pthread_exit (status : System.Address);
446 pragma Import (C, pthread_exit, "pthread_exit");
448 function pthread_self return pthread_t;
449 pragma Import (C, pthread_self, "pthread_self");
451 --------------------------
452 -- POSIX.1c Section 17 --
453 --------------------------
455 function pthread_setspecific
456 (key : pthread_key_t;
457 value : System.Address) return int;
458 pragma Import (C, pthread_setspecific, "pthread_setspecific");
460 function pthread_getspecific (key : pthread_key_t) return System.Address;
461 pragma Import (C, pthread_getspecific, "pthread_getspecific");
463 type destructor_pointer is access procedure (arg : System.Address);
465 function pthread_key_create
466 (key : access pthread_key_t;
467 destructor : destructor_pointer) return int;
468 pragma Import (C, pthread_key_create, "pthread_key_create");
470 private
472 type array_type_1 is array (Integer range 0 .. 3) of unsigned_long;
473 type sigset_t is record
474 X_X_sigbits : array_type_1;
475 end record;
476 pragma Convention (C, sigset_t);
478 type pid_t is new long;
480 type time_t is new long;
482 type timespec is record
483 tv_sec : time_t;
484 tv_nsec : long;
485 end record;
486 pragma Convention (C, timespec);
488 type clockid_t is new int;
489 CLOCK_REALTIME : constant clockid_t := 0;
491 type struct_timeval is record
492 tv_sec : time_t;
493 tv_usec : time_t;
494 end record;
495 pragma Convention (C, struct_timeval);
497 type pthread_attr_t is record
498 pthread_attrp : System.Address;
499 end record;
500 pragma Convention (C, pthread_attr_t);
502 type pthread_condattr_t is record
503 pthread_condattrp : System.Address;
504 end record;
505 pragma Convention (C, pthread_condattr_t);
507 type pthread_mutexattr_t is record
508 pthread_mutexattrp : System.Address;
509 end record;
510 pragma Convention (C, pthread_mutexattr_t);
512 type pthread_t is new unsigned;
514 type uint64_t is mod 2 ** 64;
516 type pthread_mutex_t is record
517 pthread_mutex_flags : uint64_t;
518 pthread_mutex_owner64 : uint64_t;
519 pthread_mutex_data : uint64_t;
520 end record;
521 pragma Convention (C, pthread_mutex_t);
522 type pthread_mutex_t_ptr is access pthread_mutex_t;
524 type pthread_cond_t is record
525 pthread_cond_flags : uint64_t;
526 pthread_cond_data : uint64_t;
527 end record;
528 pragma Convention (C, pthread_cond_t);
530 type pthread_key_t is new unsigned;
532 end System.OS_Interface;