Add an UNSPEC_PROLOGUE_USE to prevent the link register from being considered dead.
[official-gcc.git] / gcc / ada / 5aosinte.ads
blob815c5ac9c4bab2077ed90d147ac51aa7eecbf5a1
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) 1998-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 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
41 -- It is designed to be a bottom-level (leaf) package.
43 with Interfaces.C;
44 package System.OS_Interface is
45 pragma Preelaborate;
47 pragma Linker_Options ("-lpthread");
48 pragma Linker_Options ("-lmach");
49 pragma Linker_Options ("-lexc");
50 pragma Linker_Options ("-lrt");
52 subtype int is Interfaces.C.int;
53 subtype short is Interfaces.C.short;
54 subtype long is Interfaces.C.long;
55 subtype unsigned is Interfaces.C.unsigned;
56 subtype unsigned_short is Interfaces.C.unsigned_short;
57 subtype unsigned_long is Interfaces.C.unsigned_long;
58 subtype unsigned_char is Interfaces.C.unsigned_char;
59 subtype plain_char is Interfaces.C.plain_char;
60 subtype size_t is Interfaces.C.size_t;
61 subtype char_array is Interfaces.C.char_array;
63 -----------
64 -- Errno --
65 -----------
67 function errno return int;
68 pragma Import (C, errno, "_Geterrno");
70 EAGAIN : constant := 35;
71 EINTR : constant := 4;
72 EINVAL : constant := 22;
73 ENOMEM : constant := 12;
74 ETIMEDOUT : constant := 60;
76 -------------
77 -- Signals --
78 -------------
80 Max_Interrupt : constant := 48;
81 type Signal is new int range 0 .. Max_Interrupt;
82 for Signal'Size use int'Size;
84 SIGHUP : constant := 1; -- hangup
85 SIGINT : constant := 2; -- interrupt (rubout)
86 SIGQUIT : constant := 3; -- quit (ASCD FS)
87 SIGILL : constant := 4; -- illegal instruction (not reset)
88 SIGTRAP : constant := 5; -- trace trap (not reset)
89 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
90 SIGIOT : constant := 6; -- abort (terminate) process
91 SIGLOST : constant := 6; -- old BSD signal ??
92 SIGEMT : constant := 7; -- EMT instruction
93 SIGFPE : constant := 8; -- floating point exception
94 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
95 SIGBUS : constant := 10; -- bus error
96 SIGSEGV : constant := 11; -- segmentation violation
97 SIGSYS : constant := 12; -- bad argument to system call
98 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
99 SIGALRM : constant := 14; -- alarm clock
100 SIGTERM : constant := 15; -- software termination signal from kill
101 SIGURG : constant := 16; -- urgent condition on IO channel
102 SIGIOINT : constant := 16; -- printer to backend error signal
103 SIGSTOP : constant := 17; -- stop (cannot be caught or ignored)
104 SIGTSTP : constant := 18; -- user stop requested from tty
105 SIGCONT : constant := 19; -- stopped process has been continued
106 SIGCHLD : constant := 20; -- child status change
107 SIGTTIN : constant := 21; -- background tty read attempted
108 SIGTTOU : constant := 22; -- background tty write attempted
109 SIGPOLL : constant := 23; -- I/O possible, or completed
110 SIGIO : constant := 23; -- STREAMS version of SIGPOLL
111 SIGAIO : constant := 23; -- base lan i/o
112 SIGPTY : constant := 23; -- pty i/o
113 SIGXCPU : constant := 24; -- CPU time limit exceeded
114 SIGXFSZ : constant := 25; -- filesize limit exceeded
115 SIGVTALRM : constant := 26; -- virtual timer expired
116 SIGPROF : constant := 27; -- profiling timer expired
117 SIGWINCH : constant := 28; -- window size change
118 SIGINFO : constant := 29; -- information request
119 SIGPWR : constant := 29; -- Power Fail/Restart -- SVID3/SVR4
120 SIGUSR1 : constant := 30; -- user defined signal 1
121 SIGUSR2 : constant := 31; -- user defined signal 2
122 SIGRESV : constant := 32; -- reserved by Digital for future use
124 SIGADAABORT : constant := SIGABRT;
126 type Signal_Set is array (Natural range <>) of Signal;
128 Unmasked : constant Signal_Set := (0 .. 0 => SIGTRAP);
129 Reserved : constant Signal_Set := (SIGALRM, SIGABRT, SIGKILL, SIGSTOP);
131 type sigset_t is private;
133 function sigaddset (set : access sigset_t; sig : Signal) return int;
134 pragma Import (C, sigaddset);
136 function sigdelset (set : access sigset_t; sig : Signal) return int;
137 pragma Import (C, sigdelset);
139 function sigfillset (set : access sigset_t) return int;
140 pragma Import (C, sigfillset);
142 function sigismember (set : access sigset_t; sig : Signal) return int;
143 pragma Import (C, sigismember);
145 function sigemptyset (set : access sigset_t) return int;
146 pragma Import (C, sigemptyset);
148 type union_type_3 is new String (1 .. 116);
149 type siginfo_t is record
150 si_signo : int;
151 si_errno : int;
152 si_code : int;
153 X_data : union_type_3;
154 end record;
155 for siginfo_t'Size use 8 * 128;
156 pragma Convention (C, siginfo_t);
158 type struct_sigaction is record
159 sa_handler : System.Address;
160 sa_mask : sigset_t;
161 sa_flags : int;
162 sa_signo : int;
163 end record;
164 pragma Convention (C, struct_sigaction);
165 type struct_sigaction_ptr is access all struct_sigaction;
167 SIG_BLOCK : constant := 1;
168 SIG_UNBLOCK : constant := 2;
169 SIG_SETMASK : constant := 3;
171 SIG_DFL : constant := 0;
172 SIG_IGN : constant := 1;
174 SA_NODEFER : constant := 8;
175 SA_SIGINFO : constant := 16#40#;
177 function sigaction
178 (sig : Signal;
179 act : struct_sigaction_ptr;
180 oact : struct_sigaction_ptr) return int;
181 pragma Import (C, sigaction);
183 ----------
184 -- Time --
185 ----------
187 type timespec is private;
189 function nanosleep (rqtp, rmtp : access timespec) return int;
190 pragma Import (C, nanosleep);
192 type clockid_t is private;
194 CLOCK_REALTIME : constant clockid_t;
196 function clock_gettime
197 (clock_id : clockid_t;
198 tp : access timespec) return int;
199 pragma Import (C, clock_gettime);
201 function To_Duration (TS : timespec) return Duration;
202 pragma Inline (To_Duration);
204 function To_Timespec (D : Duration) return timespec;
205 pragma Inline (To_Timespec);
207 type struct_timezone is record
208 tz_minuteswest : int;
209 tz_dsttime : int;
210 end record;
211 pragma Convention (C, struct_timezone);
212 type struct_timeval is private;
213 -- This is needed on systems that do not have clock_gettime()
214 -- but do have gettimeofday().
216 function To_Duration (TV : struct_timeval) return Duration;
217 pragma Inline (To_Duration);
219 function To_Timeval (D : Duration) return struct_timeval;
220 pragma Inline (To_Timeval);
222 -------------------------
223 -- Priority Scheduling --
224 -------------------------
226 SCHED_FIFO : constant := 1;
227 SCHED_RR : constant := 2;
228 SCHED_OTHER : constant := 3;
229 SCHED_LFI : constant := 5;
231 -------------
232 -- Process --
233 -------------
235 type pid_t is private;
237 function kill (pid : pid_t; sig : Signal) return int;
238 pragma Import (C, kill);
240 function getpid return pid_t;
241 pragma Import (C, getpid);
243 BIND_NO_INHERIT : constant := 1;
245 function bind_to_cpu
246 (pid : pid_t;
247 cpu_mask : unsigned_long;
248 flag : unsigned_long := BIND_NO_INHERIT) return int;
249 pragma Import (C, bind_to_cpu);
251 -------------
252 -- Threads --
253 -------------
255 type Thread_Body is access
256 function (arg : System.Address) return System.Address;
257 type pthread_t is private;
258 subtype Thread_Id is pthread_t;
260 type pthread_mutex_t is limited private;
261 type pthread_cond_t is limited private;
262 type pthread_attr_t is limited private;
263 type pthread_mutexattr_t is limited private;
264 type pthread_condattr_t is limited private;
265 type pthread_key_t is private;
267 PTHREAD_CREATE_DETACHED : constant := 1;
269 PTHREAD_SCOPE_PROCESS : constant := 0;
270 PTHREAD_SCOPE_SYSTEM : constant := 1;
272 PTHREAD_EXPLICIT_SCHED : constant := 1;
274 ---------------------------------------
275 -- Nonstandard Thread Initialization --
276 ---------------------------------------
278 procedure pthread_init;
279 pragma Inline (pthread_init);
280 -- This is a dummy procedure to share some GNULLI files
282 ---------------------------
283 -- POSIX.1c Section 3 --
284 ---------------------------
286 function sigwait
287 (set : access sigset_t;
288 sig : access Signal) return int;
289 pragma Import (C, sigwait, "__sigwaitd10");
291 function pthread_kill
292 (thread : pthread_t;
293 sig : Signal) return int;
294 pragma Import (C, pthread_kill);
296 type sigset_t_ptr is access all sigset_t;
298 function pthread_sigmask
299 (how : int;
300 set : sigset_t_ptr;
301 oset : sigset_t_ptr) return int;
302 pragma Import (C, pthread_sigmask);
304 ----------------------------
305 -- POSIX.1c Section 11 --
306 ----------------------------
308 function pthread_mutexattr_init (attr : access pthread_mutexattr_t)
309 return int;
310 pragma Import (C, pthread_mutexattr_init);
312 function pthread_mutexattr_destroy
313 (attr : access pthread_mutexattr_t) return int;
314 pragma Import (C, pthread_mutexattr_destroy);
316 function pthread_mutex_init
317 (mutex : access pthread_mutex_t;
318 attr : access pthread_mutexattr_t) return int;
319 pragma Import (C, pthread_mutex_init, "__pthread_mutex_init");
321 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
322 pragma Import (C, pthread_mutex_destroy, "__pthread_mutex_destroy");
324 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
325 pragma Import (C, pthread_mutex_lock, "__pthread_mutex_lock");
327 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
328 pragma Import (C, pthread_mutex_unlock, "__pthread_mutex_unlock");
330 function pthread_condattr_init
331 (attr : access pthread_condattr_t) return int;
332 pragma Import (C, pthread_condattr_init);
334 function pthread_condattr_destroy
335 (attr : access pthread_condattr_t) return int;
336 pragma Import (C, pthread_condattr_destroy);
338 function pthread_cond_init
339 (cond : access pthread_cond_t;
340 attr : access pthread_condattr_t) return int;
341 pragma Import (C, pthread_cond_init, "__pthread_cond_init");
343 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
344 pragma Import (C, pthread_cond_destroy, "__pthread_cond_destroy");
346 function pthread_cond_signal (cond : access pthread_cond_t) return int;
347 pragma Import (C, pthread_cond_signal, "__pthread_cond_signal");
349 function pthread_cond_wait
350 (cond : access pthread_cond_t;
351 mutex : access pthread_mutex_t) return int;
352 pragma Import (C, pthread_cond_wait, "__pthread_cond_wait");
354 function pthread_cond_timedwait
355 (cond : access pthread_cond_t;
356 mutex : access pthread_mutex_t;
357 abstime : access timespec) return int;
358 pragma Import (C, pthread_cond_timedwait, "__pthread_cond_timedwait");
360 ----------------------------
361 -- POSIX.1c Section 13 --
362 ----------------------------
364 function pthread_mutexattr_setprotocol
365 (attr : access pthread_mutexattr_t;
366 protocol : int) return int;
367 pragma Import (C, pthread_mutexattr_setprotocol);
369 function pthread_mutexattr_setprioceiling
370 (attr : access pthread_mutexattr_t;
371 prioceiling : int) return int;
372 pragma Import (C, pthread_mutexattr_setprioceiling);
374 type struct_sched_param is record
375 sched_priority : int; -- scheduling priority
376 end record;
378 function pthread_setschedparam
379 (thread : pthread_t;
380 policy : int;
381 param : access struct_sched_param) return int;
382 pragma Import (C, pthread_setschedparam);
384 function pthread_attr_setscope
385 (attr : access pthread_attr_t;
386 contentionscope : int) return int;
387 pragma Import (C, pthread_attr_setscope);
389 function pthread_attr_setinheritsched
390 (attr : access pthread_attr_t;
391 inheritsched : int) return int;
392 pragma Import (C, pthread_attr_setinheritsched,
393 "__pthread_attr_setinheritsched");
395 function pthread_attr_setschedpolicy
396 (attr : access pthread_attr_t; policy : int) return int;
397 pragma Import (C, pthread_attr_setschedpolicy);
399 function pthread_attr_setschedparam
400 (attr : access pthread_attr_t;
401 sched_param : access struct_sched_param) return int;
402 pragma Import (C, pthread_attr_setschedparam);
404 function sched_yield return int;
405 pragma Import (C, sched_yield);
407 ---------------------------
408 -- P1003.1c - Section 16 --
409 ---------------------------
411 function pthread_attr_init (attributes : access pthread_attr_t)
412 return int;
413 pragma Import (C, pthread_attr_init);
415 function pthread_attr_destroy (attributes : access pthread_attr_t)
416 return int;
417 pragma Import (C, pthread_attr_destroy);
419 function pthread_attr_setdetachstate
420 (attr : access pthread_attr_t;
421 detachstate : int) return int;
422 pragma Import (C, pthread_attr_setdetachstate);
424 function pthread_attr_setstacksize
425 (attr : access pthread_attr_t;
426 stacksize : size_t) return int;
427 pragma Import (C, pthread_attr_setstacksize, "__pthread_attr_setstacksize");
429 function pthread_create
430 (thread : access pthread_t;
431 attributes : access pthread_attr_t;
432 start_routine : Thread_Body;
433 arg : System.Address) return int;
434 pragma Import (C, pthread_create, "__pthread_create");
436 procedure pthread_exit (status : System.Address);
437 pragma Import (C, pthread_exit, "__pthread_exit");
439 function pthread_self return pthread_t;
440 pragma Import (C, pthread_self, "__pthread_self");
442 --------------------------
443 -- POSIX.1c Section 17 --
444 --------------------------
446 function pthread_setspecific
447 (key : pthread_key_t; value : System.Address) return int;
448 pragma Import (C, pthread_setspecific, "__pthread_setspecific");
450 function pthread_getspecific (key : pthread_key_t) return System.Address;
451 pragma Import (C, pthread_getspecific, "__pthread_getspecific");
453 type destructor_pointer is access procedure (arg : System.Address);
455 function pthread_key_create
456 (key : access pthread_key_t;
457 destructor : destructor_pointer) return int;
458 pragma Import (C, pthread_key_create);
460 private
462 type sigset_t is new unsigned_long;
464 type pid_t is new int;
466 type time_t is new int;
468 type timespec is record
469 tv_sec : time_t;
470 tv_nsec : long;
471 end record;
472 pragma Convention (C, timespec);
474 type clockid_t is new int;
475 CLOCK_REALTIME : constant clockid_t := 1;
477 type struct_timeval is record
478 tv_sec : time_t;
479 tv_usec : time_t;
480 end record;
481 pragma Convention (C, struct_timeval);
483 type unsigned_long_array is array (Natural range <>) of unsigned_long;
485 type pthread_t is new System.Address;
487 type pthread_cond_t is record
488 state : unsigned;
489 valid : unsigned;
490 name : System.Address;
491 arg : unsigned;
492 reserved1 : unsigned;
493 sequence : unsigned_long;
494 block : System.Address;
495 end record;
496 pragma Convention (C, pthread_cond_t);
498 type pthread_attr_t is record
499 valid : long;
500 name : System.Address;
501 arg : unsigned_long;
502 reserved : unsigned_long_array (0 .. 18);
503 end record;
504 pragma Convention (C, pthread_attr_t);
506 type pthread_mutex_t is record
507 lock : unsigned;
508 valid : unsigned;
509 name : System.Address;
510 arg : unsigned;
511 depth : unsigned;
512 sequence : unsigned_long;
513 owner : unsigned_long;
514 block : System.Address;
515 end record;
516 for pthread_mutex_t'Size use 8 * 48;
517 pragma Convention (C, pthread_mutex_t);
519 type pthread_mutexattr_t is record
520 valid : long;
521 reserved : unsigned_long_array (0 .. 14);
522 end record;
523 pragma Convention (C, pthread_mutexattr_t);
525 type pthread_condattr_t is record
526 valid : long;
527 reserved : unsigned_long_array (0 .. 12);
528 end record;
529 pragma Convention (C, pthread_condattr_t);
531 type pthread_key_t is new unsigned;
533 end System.OS_Interface;