Add x prefix to v850e case for handling --with-cpu=v850e.
[official-gcc.git] / gcc / ada / 5rosinte.ads
blobd9c5ff6ec8cc0b5f8093c1a39b0b9e4f17bf5103
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 -- The GNARL files that were developed for RTEMS are maintained by On-Line --
35 -- Applications Research Corporation (http://www.oarcorp.com) in coopera- --
36 -- tion with Ada Core Technologies Inc. and Florida State University. --
37 -- --
38 ------------------------------------------------------------------------------
40 -- This is the RTEMS version of this package
42 -- These are guesses based on what I think the GNARL team will want to
43 -- call the rtems configurations. We use CPU-rtems for the rtems
44 -- configurations.
46 -- This package encapsulates all direct interfaces to OS services
47 -- that are needed by children of System.
49 -- PLEASE DO NOT add any with-clauses to this package
50 -- or remove the pragma Elaborate_Body.
51 -- It is designed to be a bottom-level (leaf) package.
53 with Interfaces.C;
54 package System.OS_Interface is
55 pragma Preelaborate;
57 -- This interface assumes that "unsigned" is a 32-bit entity. This
58 -- will correspond to RTEMS object ids.
60 subtype rtems_id is Interfaces.C.unsigned;
62 subtype int is Interfaces.C.int;
63 subtype short is Interfaces.C.short;
64 subtype long is Interfaces.C.long;
65 subtype unsigned is Interfaces.C.unsigned;
66 subtype unsigned_short is Interfaces.C.unsigned_short;
67 subtype unsigned_long is Interfaces.C.unsigned_long;
68 subtype unsigned_char is Interfaces.C.unsigned_char;
69 subtype plain_char is Interfaces.C.plain_char;
70 subtype size_t is Interfaces.C.size_t;
72 -----------
73 -- Errno --
74 -----------
76 function errno return int;
77 pragma Import (C, errno, "__get_errno");
79 EAGAIN : constant := 11;
80 EINTR : constant := 4;
81 EINVAL : constant := 22;
82 ENOMEM : constant := 12;
83 ETIMEDOUT : constant := 116;
85 -------------
86 -- Signals --
87 -------------
89 Max_Interrupt : constant := 31;
90 type Signal is new int range 0 .. Max_Interrupt;
92 SIGHUP : constant := 1; -- hangup
93 SIGINT : constant := 2; -- interrupt (rubout)
94 SIGQUIT : constant := 3; -- quit (ASCD FS)
95 SIGILL : constant := 4; -- illegal instruction (not reset)
96 SIGTRAP : constant := 5; -- trace trap (not reset)
97 SIGIOT : constant := 6; -- IOT instruction
98 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
99 SIGEMT : constant := 7; -- EMT instruction
100 SIGFPE : constant := 8; -- floating point exception
101 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
102 SIGBUS : constant := 10; -- bus error
103 SIGSEGV : constant := 11; -- segmentation violation
104 SIGSYS : constant := 12; -- bad argument to system call
105 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
106 SIGALRM : constant := 14; -- alarm clock
107 SIGTERM : constant := 15; -- software termination signal from kill
108 SIGUSR1 : constant := 16; -- user defined signal 1
109 SIGUSR2 : constant := 17; -- user defined signal 2
111 SIGADAABORT : constant := SIGABRT;
113 type Signal_Set is array (Natural range <>) of Signal;
115 Unmasked : constant Signal_Set := (SIGTRAP, SIGALRM, SIGEMT);
116 Reserved : constant Signal_Set := (1 .. 1 => SIGKILL);
118 type sigset_t is private;
120 function sigaddset (set : access sigset_t; sig : Signal) return int;
121 pragma Import (C, sigaddset, "sigaddset");
123 function sigdelset (set : access sigset_t; sig : Signal) return int;
124 pragma Import (C, sigdelset, "sigdelset");
126 function sigfillset (set : access sigset_t) return int;
127 pragma Import (C, sigfillset, "sigfillset");
129 function sigismember (set : access sigset_t; sig : Signal) return int;
130 pragma Import (C, sigismember, "sigismember");
132 function sigemptyset (set : access sigset_t) return int;
133 pragma Import (C, sigemptyset, "sigemptyset");
135 type struct_sigaction is record
136 sa_flags : int;
137 sa_mask : sigset_t;
138 sa_handler : System.Address;
139 end record;
140 pragma Convention (C, struct_sigaction);
141 type struct_sigaction_ptr is access all struct_sigaction;
143 SIG_BLOCK : constant := 1;
144 SIG_UNBLOCK : constant := 2;
145 SIG_SETMASK : constant := 3;
147 SIG_DFL : constant := 0;
148 SIG_IGN : constant := 1;
150 function sigaction
151 (sig : Signal;
152 act : struct_sigaction_ptr;
153 oact : struct_sigaction_ptr) return int;
154 pragma Import (C, sigaction, "sigaction");
156 ----------
157 -- Time --
158 ----------
160 Time_Slice_Supported : constant Boolean := True;
161 -- Indicates wether time slicing is supported (i.e SCHED_RR is supported)
163 type timespec is private;
165 type clockid_t is private;
167 CLOCK_REALTIME : constant clockid_t;
169 function clock_gettime
170 (clock_id : clockid_t;
171 tp : access timespec) return int;
172 pragma Import (C, clock_gettime, "clock_gettime");
174 function To_Duration (TS : timespec) return Duration;
175 pragma Inline (To_Duration);
177 function To_Timespec (D : Duration) return timespec;
178 pragma Inline (To_Timespec);
180 type struct_timeval is private;
182 function To_Duration (TV : struct_timeval) return Duration;
183 pragma Inline (To_Duration);
185 function To_Timeval (D : Duration) return struct_timeval;
186 pragma Inline (To_Timeval);
188 -------------------------
189 -- Priority Scheduling --
190 -------------------------
192 SCHED_FIFO : constant := 1;
193 SCHED_RR : constant := 2;
194 SCHED_OTHER : constant := 0;
196 -------------
197 -- Process --
198 -------------
200 type pid_t is private;
202 function kill (pid : pid_t; sig : Signal) return int;
203 pragma Import (C, kill, "kill");
205 function getpid return pid_t;
206 pragma Import (C, getpid, "getpid");
208 ---------
209 -- LWP --
210 ---------
212 function lwp_self return System.Address;
213 -- lwp_self does not exist on this thread library, revert to pthread_self
214 -- which is the closest approximation (with getpid). This function is
215 -- needed to share 7staprop.adb across POSIX-like targets.
216 pragma Import (C, lwp_self, "pthread_self");
218 -------------
219 -- Threads --
220 -------------
222 type Thread_Body is access
223 function (arg : System.Address) return System.Address;
225 type pthread_t is private;
226 subtype Thread_Id is pthread_t;
228 type pthread_mutex_t is limited private;
229 type pthread_cond_t is limited private;
230 type pthread_attr_t is limited private;
231 type pthread_mutexattr_t is limited private;
232 type pthread_condattr_t is limited private;
233 type pthread_key_t is private;
235 PTHREAD_CREATE_DETACHED : constant := 0;
237 -----------
238 -- Stack --
239 -----------
241 Stack_Base_Available : constant Boolean := False;
242 -- Indicates wether the stack base is available on this target.
243 -- This allows us to share s-osinte.adb between all the FSU/RTEMS
244 -- run time.
245 -- Note that this value can only be true if pthread_t has a complete
246 -- definition that corresponds exactly to the C header files.
248 function Get_Stack_Base (thread : pthread_t) return Address;
249 pragma Inline (Get_Stack_Base);
250 -- returns the stack base of the specified thread.
251 -- Only call this function when Stack_Base_Available is True.
253 -- These two functions are only needed to share s-taprop.adb with
254 -- FSU threads.
256 function Get_Page_Size return size_t;
257 function Get_Page_Size return Address;
258 -- returns the size of a page, or 0 if this is not relevant on this
259 -- target (which is the case for RTEMS)
261 PROT_ON : constant := 0;
262 PROT_OFF : constant := 0;
264 function mprotect (addr : Address; len : size_t; prot : int) return int;
265 -- Do nothing on RTEMS.
267 -----------------------------------------
268 -- Nonstandard Thread Initialization --
269 -----------------------------------------
271 procedure pthread_init;
272 -- FSU_THREADS requires pthread_init, which is nonstandard
273 -- and this should be invoked during the elaboration of s-taprop.adb
275 -- RTEMS does not require this so we provide an empty Ada body.
277 -------------------------
278 -- POSIX.1c Section 3 --
279 -------------------------
281 function sigwait
282 (set : access sigset_t;
283 sig : access Signal) return int;
284 pragma Import (C, sigwait, "sigwait");
286 function pthread_kill
287 (thread : pthread_t;
288 sig : Signal) return int;
289 pragma Import (C, pthread_kill, "pthread_kill");
291 type sigset_t_ptr is access all sigset_t;
293 function pthread_sigmask
294 (how : int;
295 set : sigset_t_ptr;
296 oset : sigset_t_ptr) return int;
297 pragma Import (C, pthread_sigmask, "pthread_sigmask");
299 ----------------------------
300 -- POSIX.1c Section 11 --
301 ----------------------------
303 function pthread_mutexattr_init
304 (attr : access pthread_mutexattr_t) return int;
305 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
307 function pthread_mutexattr_destroy
308 (attr : access pthread_mutexattr_t) return int;
309 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
311 function pthread_mutex_init
312 (mutex : access pthread_mutex_t;
313 attr : access pthread_mutexattr_t) return int;
314 pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
316 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
317 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
319 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
320 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
322 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
323 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
325 function pthread_condattr_init
326 (attr : access pthread_condattr_t) return int;
327 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
329 function pthread_condattr_destroy
330 (attr : access pthread_condattr_t) return int;
331 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
333 function pthread_cond_init
334 (cond : access pthread_cond_t;
335 attr : access pthread_condattr_t) return int;
336 pragma Import (C, pthread_cond_init, "pthread_cond_init");
338 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
339 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
341 function pthread_cond_signal (cond : access pthread_cond_t) return int;
342 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
344 function pthread_cond_wait
345 (cond : access pthread_cond_t;
346 mutex : access pthread_mutex_t) return int;
347 pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
349 function pthread_cond_timedwait
350 (cond : access pthread_cond_t;
351 mutex : access pthread_mutex_t;
352 abstime : access timespec) return int;
353 pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
355 Relative_Timed_Wait : constant Boolean := False;
356 -- pthread_cond_timedwait requires an absolute delay time
358 --------------------------
359 -- POSIX.1c Section 13 --
360 --------------------------
362 PTHREAD_PRIO_NONE : constant := 0;
363 PTHREAD_PRIO_PROTECT : constant := 2;
364 PTHREAD_PRIO_INHERIT : constant := 1;
366 function pthread_mutexattr_setprotocol
367 (attr : access pthread_mutexattr_t;
368 protocol : int) return int;
369 pragma Import (C, pthread_mutexattr_setprotocol);
371 function pthread_mutexattr_setprioceiling
372 (attr : access pthread_mutexattr_t;
373 prioceiling : int) return int;
374 pragma Import
375 (C, pthread_mutexattr_setprioceiling,
376 "pthread_mutexattr_setprioceiling");
378 type struct_sched_param is record
379 sched_priority : int;
380 ss_low_priority : timespec;
381 ss_replenish_period : timespec;
382 ss_initial_budget : timespec;
383 end record;
384 pragma Convention (C, struct_sched_param);
386 function pthread_setschedparam
387 (thread : pthread_t;
388 policy : int;
389 param : access struct_sched_param) return int;
390 pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
392 function pthread_attr_setscope
393 (attr : access pthread_attr_t;
394 contentionscope : int) return int;
395 pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
397 function pthread_attr_setinheritsched
398 (attr : access pthread_attr_t;
399 inheritsched : int) return int;
400 pragma Import (C, pthread_attr_setinheritsched);
402 function pthread_attr_setschedpolicy
403 (attr : access pthread_attr_t;
404 policy : int) return int;
405 pragma Import (C, pthread_attr_setschedpolicy);
407 function pthread_attr_setschedparam
408 (attr : access pthread_attr_t;
409 sched_param : int) return int;
410 pragma Import (C, pthread_attr_setschedparam);
412 function sched_yield return int;
413 pragma Import (C, sched_yield, "sched_yield");
415 ---------------------------
416 -- P1003.1c - Section 16 --
417 ---------------------------
419 function pthread_attr_init (attributes : access pthread_attr_t) return int;
420 pragma Import (C, pthread_attr_init, "pthread_attr_init");
422 function pthread_attr_destroy
423 (attributes : access pthread_attr_t) return int;
424 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
426 function pthread_attr_setdetachstate
427 (attr : access pthread_attr_t;
428 detachstate : int) return int;
429 pragma Import (C, pthread_attr_setdetachstate);
431 function pthread_attr_setstacksize
432 (attr : access pthread_attr_t;
433 stacksize : size_t) return int;
434 pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
436 function pthread_create
437 (thread : access pthread_t;
438 attributes : access pthread_attr_t;
439 start_routine : Thread_Body;
440 arg : System.Address) return int;
441 pragma Import (C, pthread_create, "pthread_create");
443 procedure pthread_exit (status : System.Address);
444 pragma Import (C, pthread_exit, "pthread_exit");
446 function pthread_self return pthread_t;
447 pragma Import (C, pthread_self, "pthread_self");
449 --------------------------
450 -- POSIX.1c Section 17 --
451 --------------------------
453 function pthread_setspecific
454 (key : pthread_key_t;
455 value : System.Address) return int;
456 pragma Import (C, pthread_setspecific, "pthread_setspecific");
458 function pthread_getspecific (key : pthread_key_t) return System.Address;
459 pragma Import (C, pthread_getspecific, "pthread_getspecific");
461 type destructor_pointer is access procedure (arg : System.Address);
463 function pthread_key_create
464 (key : access pthread_key_t;
465 destructor : destructor_pointer) return int;
466 pragma Import (C, pthread_key_create, "pthread_key_create");
468 private
470 type sigset_t is new int;
472 type pid_t is new int;
474 type time_t is new long;
476 type timespec is record
477 tv_sec : time_t;
478 tv_nsec : long;
479 end record;
480 pragma Convention (C, timespec);
482 type clockid_t is new rtems_id;
483 CLOCK_REALTIME : constant clockid_t := 1;
485 type struct_timeval is record
486 tv_sec : int;
487 tv_usec : int;
488 end record;
489 pragma Convention (C, struct_timeval);
491 type pthread_attr_t is record
492 is_initialized : int;
493 stackaddr : System.Address;
494 stacksize : int;
495 contentionscope : int;
496 inheritsched : int;
497 schedpolicy : int;
498 schedparam : struct_sched_param;
499 cputime_clocked_allowed : int;
500 deatchstate : int;
501 end record;
502 pragma Convention (C, pthread_attr_t);
504 type pthread_condattr_t is record
505 flags : int;
506 end record;
507 pragma Convention (C, pthread_condattr_t);
509 type pthread_mutexattr_t is record
510 is_initialized : int;
511 process_shared : int;
512 prio_ceiling : int;
513 protocol : int;
514 recursive : int;
515 end record;
516 pragma Convention (C, pthread_mutexattr_t);
518 type pthread_t is new rtems_id;
520 type pthread_mutex_t is new rtems_id;
522 type pthread_cond_t is new rtems_id;
524 type pthread_key_t is new rtems_id;
526 end System.OS_Interface;