Add hppa-openbsd target
[official-gcc.git] / gcc / ada / 5sosinte.ads
blobe151065c3a8d210569434a0f639cd83485ce75a9
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) 1997-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. It is --
31 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
32 -- State University (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This is a Solaris (native) version of this package
38 -- This package includes all direct interfaces to OS services
39 -- that are needed by children of System.
41 -- PLEASE DO NOT add any with-clauses to this package
42 -- or remove the pragma Elaborate_Body.
43 -- It is designed to be a bottom-level (leaf) package.
45 with Interfaces.C;
46 package System.OS_Interface is
47 pragma Preelaborate;
49 pragma Linker_Options ("-lposix4");
50 pragma Linker_Options ("-lthread");
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;
62 -----------
63 -- Errno --
64 -----------
66 function errno return int;
67 pragma Import (C, errno, "__get_errno");
69 EAGAIN : constant := 11;
70 EINTR : constant := 4;
71 EINVAL : constant := 22;
72 ENOMEM : constant := 12;
73 ETIME : constant := 62;
74 ETIMEDOUT : constant := 145;
76 -------------
77 -- Signals --
78 -------------
80 Max_Interrupt : constant := 45;
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 SIGIOT : constant := 6; -- IOT instruction
90 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
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 SIGUSR1 : constant := 16; -- user defined signal 1
101 SIGUSR2 : constant := 17; -- user defined signal 2
102 SIGCLD : constant := 18; -- alias for SIGCHLD
103 SIGCHLD : constant := 18; -- child status change
104 SIGPWR : constant := 19; -- power-fail restart
105 SIGWINCH : constant := 20; -- window size change
106 SIGURG : constant := 21; -- urgent condition on IO channel
107 SIGPOLL : constant := 22; -- pollable event occurred
108 SIGIO : constant := 22; -- I/O possible (Solaris SIGPOLL alias)
109 SIGSTOP : constant := 23; -- stop (cannot be caught or ignored)
110 SIGTSTP : constant := 24; -- user stop requested from tty
111 SIGCONT : constant := 25; -- stopped process has been continued
112 SIGTTIN : constant := 26; -- background tty read attempted
113 SIGTTOU : constant := 27; -- background tty write attempted
114 SIGVTALRM : constant := 28; -- virtual timer expired
115 SIGPROF : constant := 29; -- profiling timer expired
116 SIGXCPU : constant := 30; -- CPU time limit exceeded
117 SIGXFSZ : constant := 31; -- filesize limit exceeded
118 SIGWAITING : constant := 32; -- process's lwps blocked (Solaris)
119 SIGLWP : constant := 33; -- used by thread library (Solaris)
120 SIGFREEZE : constant := 34; -- used by CPR (Solaris)
121 SIGTHAW : constant := 35; -- used by CPR (Solaris)
122 SIGCANCEL : constant := 36; -- thread cancellation signal (libthread)
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 := (SIGKILL, SIGSTOP, SIGWAITING, SIGCANCEL);
133 type sigset_t is private;
135 function sigaddset (set : access sigset_t; sig : Signal) return int;
136 pragma Import (C, sigaddset, "sigaddset");
138 function sigdelset (set : access sigset_t; sig : Signal) return int;
139 pragma Import (C, sigdelset, "sigdelset");
141 function sigfillset (set : access sigset_t) return int;
142 pragma Import (C, sigfillset, "sigfillset");
144 function sigismember (set : access sigset_t; sig : Signal) return int;
145 pragma Import (C, sigismember, "sigismember");
147 function sigemptyset (set : access sigset_t) return int;
148 pragma Import (C, sigemptyset, "sigemptyset");
150 type union_type_3 is new String (1 .. 116);
151 type siginfo_t is record
152 si_signo : int;
153 si_code : int;
154 si_errno : int;
155 X_data : union_type_3;
156 end record;
157 pragma Convention (C, siginfo_t);
159 -- The types mcontext_t and gregset_t are part of the ucontext_t
160 -- information, which is specific to Solaris2.4 for SPARC
161 -- The ucontext_t info seems to be used by the handler
162 -- for SIGSEGV to decide whether it is a Storage_Error (stack overflow) or
163 -- a Constraint_Error (bad pointer). The original code that did this
164 -- is suspect, so it is not clear whether we really need this part of
165 -- the signal context information, or perhaps something else.
166 -- More analysis is needed, after which these declarations may need to
167 -- be changed.
169 FPE_INTDIV : constant := 1; -- integer divide by zero
170 FPE_INTOVF : constant := 2; -- integer overflow
171 FPE_FLTDIV : constant := 3; -- floating point divide by zero
172 FPE_FLTOVF : constant := 4; -- floating point overflow
173 FPE_FLTUND : constant := 5; -- floating point underflow
174 FPE_FLTRES : constant := 6; -- floating point inexact result
175 FPE_FLTINV : constant := 7; -- invalid floating point operation
176 FPE_FLTSUB : constant := 8; -- subscript out of range
178 type greg_t is new int;
180 type gregset_t is array (0 .. 18) of greg_t;
182 type union_type_2 is new String (1 .. 128);
183 type record_type_1 is record
184 fpu_fr : union_type_2;
185 fpu_q : System.Address;
186 fpu_fsr : unsigned;
187 fpu_qcnt : unsigned_char;
188 fpu_q_entrysize : unsigned_char;
189 fpu_en : unsigned_char;
190 end record;
191 pragma Convention (C, record_type_1);
193 type array_type_7 is array (Integer range 0 .. 20) of long;
194 type mcontext_t is record
195 gregs : gregset_t;
196 gwins : System.Address;
197 fpregs : record_type_1;
198 filler : array_type_7;
199 end record;
200 pragma Convention (C, mcontext_t);
202 type record_type_2 is record
203 ss_sp : System.Address;
204 ss_size : int;
205 ss_flags : int;
206 end record;
207 pragma Convention (C, record_type_2);
209 type array_type_8 is array (Integer range 0 .. 22) of long;
210 type ucontext_t is record
211 uc_flags : unsigned_long;
212 uc_link : System.Address;
213 uc_sigmask : sigset_t;
214 uc_stack : record_type_2;
215 uc_mcontext : mcontext_t;
216 uc_filler : array_type_8;
217 end record;
218 pragma Convention (C, ucontext_t);
220 type Signal_Handler is access procedure
221 (signo : Signal;
222 info : access siginfo_t;
223 context : access ucontext_t);
225 type union_type_1 is new plain_char;
226 type array_type_2 is array (Integer range 0 .. 1) of int;
227 type struct_sigaction is record
228 sa_flags : int;
229 sa_handler : System.Address;
230 sa_mask : sigset_t;
231 sa_resv : array_type_2;
232 end record;
233 pragma Convention (C, struct_sigaction);
234 type struct_sigaction_ptr is access all struct_sigaction;
236 SIG_BLOCK : constant := 1;
237 SIG_UNBLOCK : constant := 2;
238 SIG_SETMASK : constant := 3;
240 SIG_DFL : constant := 0;
241 SIG_IGN : constant := 1;
243 function sigaction
244 (sig : Signal;
245 act : struct_sigaction_ptr;
246 oact : struct_sigaction_ptr) return int;
247 pragma Import (C, sigaction, "sigaction");
249 ----------
250 -- Time --
251 ----------
253 type timespec is private;
255 type clockid_t is private;
257 CLOCK_REALTIME : constant clockid_t;
259 function clock_gettime
260 (clock_id : clockid_t; tp : access timespec) return int;
261 pragma Import (C, clock_gettime, "clock_gettime");
263 function To_Duration (TS : timespec) return Duration;
264 pragma Inline (To_Duration);
266 function To_Timespec (D : Duration) return timespec;
267 pragma Inline (To_Timespec);
269 type struct_timeval is private;
270 -- This is needed on systems that do not have clock_gettime()
271 -- but do have gettimeofday().
273 function To_Duration (TV : struct_timeval) return Duration;
274 pragma Inline (To_Duration);
276 function To_Timeval (D : Duration) return struct_timeval;
277 pragma Inline (To_Timeval);
279 -------------
280 -- Process --
281 -------------
283 type pid_t is private;
285 function kill (pid : pid_t; sig : Signal) return int;
286 pragma Import (C, kill, "kill");
288 function getpid return pid_t;
289 pragma Import (C, getpid, "getpid");
291 -------------
292 -- Threads --
293 -------------
295 type Thread_Body is access
296 function (arg : System.Address) return System.Address;
298 THR_DETACHED : constant := 64;
299 THR_BOUND : constant := 1;
300 THR_NEW_LWP : constant := 2;
301 USYNC_THREAD : constant := 0;
303 type thread_t is private;
304 subtype Thread_Id is thread_t;
306 type mutex_t is limited private;
308 type cond_t is limited private;
310 type thread_key_t is private;
312 function thr_create
313 (stack_base : System.Address;
314 stack_size : size_t;
315 start_routine : Thread_Body;
316 arg : System.Address;
317 flags : int;
318 new_thread : access thread_t) return int;
319 pragma Import (C, thr_create, "thr_create");
321 function thr_min_stack return size_t;
322 pragma Import (C, thr_min_stack, "thr_min_stack");
324 function thr_self return thread_t;
325 pragma Import (C, thr_self, "thr_self");
327 function mutex_init
328 (mutex : access mutex_t;
329 mtype : int;
330 arg : System.Address) return int;
331 pragma Import (C, mutex_init, "mutex_init");
333 function mutex_destroy (mutex : access mutex_t) return int;
334 pragma Import (C, mutex_destroy, "mutex_destroy");
336 function mutex_lock (mutex : access mutex_t) return int;
337 pragma Import (C, mutex_lock, "mutex_lock");
339 function mutex_unlock (mutex : access mutex_t) return int;
340 pragma Import (C, mutex_unlock, "mutex_unlock");
342 function cond_init
343 (cond : access cond_t;
344 ctype : int;
345 arg : int) return int;
346 pragma Import (C, cond_init, "cond_init");
348 function cond_wait
349 (cond : access cond_t; mutex : access mutex_t) return int;
350 pragma Import (C, cond_wait, "cond_wait");
352 function cond_timedwait
353 (cond : access cond_t;
354 mutex : access mutex_t;
355 abstime : access timespec) return int;
356 pragma Import (C, cond_timedwait, "cond_timedwait");
358 function cond_signal (cond : access cond_t) return int;
359 pragma Import (C, cond_signal, "cond_signal");
361 function cond_destroy (cond : access cond_t) return int;
362 pragma Import (C, cond_destroy, "cond_destroy");
364 function thr_setspecific
365 (key : thread_key_t; value : System.Address) return int;
366 pragma Import (C, thr_setspecific, "thr_setspecific");
368 function thr_getspecific
369 (key : thread_key_t;
370 value : access System.Address) return int;
371 pragma Import (C, thr_getspecific, "thr_getspecific");
373 function thr_keycreate
374 (key : access thread_key_t; destructor : System.Address) return int;
375 pragma Import (C, thr_keycreate, "thr_keycreate");
377 function thr_setprio (thread : thread_t; priority : int) return int;
378 pragma Import (C, thr_setprio, "thr_setprio");
380 procedure thr_exit (status : System.Address);
381 pragma Import (C, thr_exit, "thr_exit");
383 function thr_setconcurrency (new_level : int) return int;
384 pragma Import (C, thr_setconcurrency, "thr_setconcurrency");
386 function sigwait (set : access sigset_t; sig : access Signal) return int;
387 pragma Import (C, sigwait, "__posix_sigwait");
389 function thr_kill (thread : thread_t; sig : Signal) return int;
390 pragma Import (C, thr_kill, "thr_kill");
392 type sigset_t_ptr is access all sigset_t;
394 function thr_sigsetmask
395 (how : int;
396 set : sigset_t_ptr;
397 oset : sigset_t_ptr) return int;
398 pragma Import (C, thr_sigsetmask, "thr_sigsetmask");
400 function pthread_sigmask
401 (how : int;
402 set : sigset_t_ptr;
403 oset : sigset_t_ptr) return int;
404 pragma Import (C, pthread_sigmask, "thr_sigsetmask");
406 function thr_suspend (target_thread : thread_t) return int;
407 pragma Import (C, thr_suspend, "thr_suspend");
409 function thr_continue (target_thread : thread_t) return int;
410 pragma Import (C, thr_continue, "thr_continue");
412 procedure thr_yield;
413 pragma Import (C, thr_yield, "thr_yield");
415 ---------
416 -- LWP --
417 ---------
419 P_PID : constant := 0;
420 P_LWPID : constant := 8;
422 PC_GETCID : constant := 0;
423 PC_GETCLINFO : constant := 1;
424 PC_SETPARMS : constant := 2;
425 PC_GETPARMS : constant := 3;
426 PC_ADMIN : constant := 4;
428 PC_CLNULL : constant := -1;
430 RT_NOCHANGE : constant := -1;
431 RT_TQINF : constant := -2;
432 RT_TQDEF : constant := -3;
434 PC_CLNMSZ : constant := 16;
436 PC_VERSION : constant := 1;
438 type lwpid_t is new int;
440 type pri_t is new short;
442 type id_t is new long;
444 P_MYID : constant := -1;
445 -- the specified LWP or process is the current one.
447 type struct_pcinfo is record
448 pc_cid : id_t;
449 pc_clname : String (1 .. PC_CLNMSZ);
450 rt_maxpri : short;
451 end record;
452 pragma Convention (C, struct_pcinfo);
454 type struct_pcparms is record
455 pc_cid : id_t;
456 rt_pri : pri_t;
457 rt_tqsecs : long;
458 rt_tqnsecs : long;
459 end record;
460 pragma Convention (C, struct_pcparms);
462 function priocntl
463 (ver : int;
464 id_type : int;
465 id : lwpid_t;
466 cmd : int;
467 arg : System.Address) return Interfaces.C.long;
468 pragma Import (C, priocntl, "__priocntl");
470 function lwp_self return lwpid_t;
471 pragma Import (C, lwp_self, "_lwp_self");
473 type processorid_t is new int;
474 type processorid_t_ptr is access all processorid_t;
476 -- Constants for function processor_bind
478 PBIND_QUERY : constant processorid_t := -2;
479 -- the processor bindings are not changed.
481 PBIND_NONE : constant processorid_t := -1;
482 -- the processor bindings of the specified LWPs are cleared.
484 -- Flags for function p_online
486 PR_OFFLINE : constant int := 1;
487 -- processor is offline, as quiet as possible
489 PR_ONLINE : constant int := 2;
490 -- processor online
492 PR_STATUS : constant int := 3;
493 -- value passed to p_online to request status
495 function p_online (processorid : processorid_t; flag : int) return int;
496 pragma Import (C, p_online, "p_online");
498 function processor_bind
499 (id_type : int;
500 id : id_t;
501 proc_id : processorid_t;
502 obind : processorid_t_ptr) return int;
503 pragma Import (C, processor_bind, "processor_bind");
505 procedure pthread_init;
506 -- dummy procedure to share s-intman.adb with other Solaris targets.
508 private
510 type array_type_1 is array (0 .. 3) of unsigned_long;
511 type sigset_t is record
512 X_X_sigbits : array_type_1;
513 end record;
514 pragma Convention (C, sigset_t);
516 type pid_t is new long;
518 type time_t is new long;
520 type timespec is record
521 tv_sec : time_t;
522 tv_nsec : long;
523 end record;
524 pragma Convention (C, timespec);
526 type clockid_t is new int;
527 CLOCK_REALTIME : constant clockid_t := 0;
529 type struct_timeval is record
530 tv_sec : long;
531 tv_usec : long;
532 end record;
533 pragma Convention (C, struct_timeval);
535 type thread_t is new unsigned;
537 type array_type_9 is array (0 .. 3) of unsigned_char;
538 type record_type_3 is record
539 flag : array_type_9;
540 Xtype : unsigned_long;
541 end record;
542 pragma Convention (C, record_type_3);
544 type mutex_t is record
545 flags : record_type_3;
546 lock : String (1 .. 8);
547 data : String (1 .. 8);
548 end record;
549 pragma Convention (C, mutex_t);
551 type cond_t is record
552 flag : array_type_9;
553 Xtype : unsigned_long;
554 data : String (1 .. 8);
555 end record;
556 pragma Convention (C, cond_t);
558 type thread_key_t is new unsigned;
560 end System.OS_Interface;