]> gcc.gnu.org Git - gcc.git/blob - gcc/ada/5rosinte.ads
5rosinte.ads: Add SIGXCPU.
[gcc.git] / gcc / ada / 5rosinte.ads
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-2003 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 -- The GNARL files that were developed for RTEMS are maintained by On-Line --
34 -- Applications Research Corporation (http://www.oarcorp.com) in coopera- --
35 -- tion with Ada Core Technologies Inc. and Florida State University. --
36 -- --
37 ------------------------------------------------------------------------------
38
39 -- This is the RTEMS version of this package
40
41 -- These are guesses based on what I think the GNARL team will want to
42 -- call the rtems configurations. We use CPU-rtems for the rtems
43 -- configurations.
44
45 -- This package encapsulates all direct interfaces to OS services
46 -- that are needed by children of System.
47
48 -- PLEASE DO NOT add any with-clauses to this package
49 -- or remove the pragma Elaborate_Body.
50 -- It is designed to be a bottom-level (leaf) package.
51
52 with Interfaces.C;
53 package System.OS_Interface is
54 pragma Preelaborate;
55
56 -- This interface assumes that "unsigned" is a 32-bit entity. This
57 -- will correspond to RTEMS object ids.
58
59 subtype rtems_id is Interfaces.C.unsigned;
60
61 subtype int is Interfaces.C.int;
62 subtype short is Interfaces.C.short;
63 subtype long is Interfaces.C.long;
64 subtype unsigned is Interfaces.C.unsigned;
65 subtype unsigned_short is Interfaces.C.unsigned_short;
66 subtype unsigned_long is Interfaces.C.unsigned_long;
67 subtype unsigned_char is Interfaces.C.unsigned_char;
68 subtype plain_char is Interfaces.C.plain_char;
69 subtype size_t is Interfaces.C.size_t;
70
71 -----------
72 -- Errno --
73 -----------
74
75 function errno return int;
76 pragma Import (C, errno, "__get_errno");
77
78 EAGAIN : constant := 11;
79 EINTR : constant := 4;
80 EINVAL : constant := 22;
81 ENOMEM : constant := 12;
82 ETIMEDOUT : constant := 116;
83
84 -------------
85 -- Signals --
86 -------------
87
88 Max_Interrupt : constant := 31;
89 type Signal is new int range 0 .. Max_Interrupt;
90
91 SIGHUP : constant := 1; -- hangup
92 SIGINT : constant := 2; -- interrupt (rubout)
93 SIGQUIT : constant := 3; -- quit (ASCD FS)
94 SIGILL : constant := 4; -- illegal instruction (not reset)
95 SIGTRAP : constant := 5; -- trace trap (not reset)
96 SIGIOT : constant := 6; -- IOT instruction
97 SIGABRT : constant := 6; -- used by abort, replace SIGIOT in the future
98 SIGEMT : constant := 7; -- EMT instruction
99 SIGFPE : constant := 8; -- floating point exception
100 SIGKILL : constant := 9; -- kill (cannot be caught or ignored)
101 SIGBUS : constant := 10; -- bus error
102 SIGSEGV : constant := 11; -- segmentation violation
103 SIGSYS : constant := 12; -- bad argument to system call
104 SIGPIPE : constant := 13; -- write on a pipe with no one to read it
105 SIGALRM : constant := 14; -- alarm clock
106 SIGTERM : constant := 15; -- software termination signal from kill
107 SIGUSR1 : constant := 16; -- user defined signal 1
108 SIGUSR2 : constant := 17; -- user defined signal 2
109 SIGXCPU : constant := 0; -- XCPU
110
111 SIGADAABORT : constant := SIGABRT;
112
113 type Signal_Set is array (Natural range <>) of Signal;
114
115 Unmasked : constant Signal_Set := (SIGTRAP, SIGALRM, SIGEMT);
116 Reserved : constant Signal_Set := (1 .. 1 => SIGKILL);
117
118 type sigset_t is private;
119
120 function sigaddset (set : access sigset_t; sig : Signal) return int;
121 pragma Import (C, sigaddset, "sigaddset");
122
123 function sigdelset (set : access sigset_t; sig : Signal) return int;
124 pragma Import (C, sigdelset, "sigdelset");
125
126 function sigfillset (set : access sigset_t) return int;
127 pragma Import (C, sigfillset, "sigfillset");
128
129 function sigismember (set : access sigset_t; sig : Signal) return int;
130 pragma Import (C, sigismember, "sigismember");
131
132 function sigemptyset (set : access sigset_t) return int;
133 pragma Import (C, sigemptyset, "sigemptyset");
134
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;
142
143 SIG_BLOCK : constant := 1;
144 SIG_UNBLOCK : constant := 2;
145 SIG_SETMASK : constant := 3;
146
147 SIG_DFL : constant := 0;
148 SIG_IGN : constant := 1;
149
150 function sigaction
151 (sig : Signal;
152 act : struct_sigaction_ptr;
153 oact : struct_sigaction_ptr) return int;
154 pragma Import (C, sigaction, "sigaction");
155
156 ----------
157 -- Time --
158 ----------
159
160 Time_Slice_Supported : constant Boolean := True;
161 -- Indicates wether time slicing is supported (i.e SCHED_RR is supported)
162
163 type timespec is private;
164
165 type clockid_t is private;
166
167 CLOCK_REALTIME : constant clockid_t;
168
169 function clock_gettime
170 (clock_id : clockid_t;
171 tp : access timespec) return int;
172 pragma Import (C, clock_gettime, "clock_gettime");
173
174 function To_Duration (TS : timespec) return Duration;
175 pragma Inline (To_Duration);
176
177 function To_Timespec (D : Duration) return timespec;
178 pragma Inline (To_Timespec);
179
180 type struct_timeval is private;
181
182 function To_Duration (TV : struct_timeval) return Duration;
183 pragma Inline (To_Duration);
184
185 function To_Timeval (D : Duration) return struct_timeval;
186 pragma Inline (To_Timeval);
187
188 -------------------------
189 -- Priority Scheduling --
190 -------------------------
191
192 SCHED_FIFO : constant := 1;
193 SCHED_RR : constant := 2;
194 SCHED_OTHER : constant := 0;
195
196 -------------
197 -- Process --
198 -------------
199
200 type pid_t is private;
201
202 function kill (pid : pid_t; sig : Signal) return int;
203 pragma Import (C, kill, "kill");
204
205 function getpid return pid_t;
206 pragma Import (C, getpid, "getpid");
207
208 ---------
209 -- LWP --
210 ---------
211
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");
217
218 -------------
219 -- Threads --
220 -------------
221
222 type Thread_Body is access
223 function (arg : System.Address) return System.Address;
224
225 type pthread_t is private;
226 subtype Thread_Id is pthread_t;
227
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;
234
235 PTHREAD_CREATE_DETACHED : constant := 0;
236
237 -----------
238 -- Stack --
239 -----------
240
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.
247
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.
252
253 -- These two functions are only needed to share s-taprop.adb with
254 -- FSU threads.
255
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)
260
261 PROT_ON : constant := 0;
262 PROT_OFF : constant := 0;
263
264 function mprotect (addr : Address; len : size_t; prot : int) return int;
265 -- Do nothing on RTEMS.
266
267 -----------------------------------------
268 -- Nonstandard Thread Initialization --
269 -----------------------------------------
270
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
274 --
275 -- RTEMS does not require this so we provide an empty Ada body.
276
277 -------------------------
278 -- POSIX.1c Section 3 --
279 -------------------------
280
281 function sigwait
282 (set : access sigset_t;
283 sig : access Signal) return int;
284 pragma Import (C, sigwait, "sigwait");
285
286 function pthread_kill
287 (thread : pthread_t;
288 sig : Signal) return int;
289 pragma Import (C, pthread_kill, "pthread_kill");
290
291 type sigset_t_ptr is access all sigset_t;
292
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");
298
299 ----------------------------
300 -- POSIX.1c Section 11 --
301 ----------------------------
302
303 function pthread_mutexattr_init
304 (attr : access pthread_mutexattr_t) return int;
305 pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
306
307 function pthread_mutexattr_destroy
308 (attr : access pthread_mutexattr_t) return int;
309 pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
310
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");
315
316 function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
317 pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
318
319 function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
320 pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
321
322 function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
323 pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
324
325 function pthread_condattr_init
326 (attr : access pthread_condattr_t) return int;
327 pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
328
329 function pthread_condattr_destroy
330 (attr : access pthread_condattr_t) return int;
331 pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
332
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");
337
338 function pthread_cond_destroy (cond : access pthread_cond_t) return int;
339 pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
340
341 function pthread_cond_signal (cond : access pthread_cond_t) return int;
342 pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
343
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");
348
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");
354
355 Relative_Timed_Wait : constant Boolean := False;
356 -- pthread_cond_timedwait requires an absolute delay time
357
358 --------------------------
359 -- POSIX.1c Section 13 --
360 --------------------------
361
362 PTHREAD_PRIO_NONE : constant := 0;
363 PTHREAD_PRIO_PROTECT : constant := 2;
364 PTHREAD_PRIO_INHERIT : constant := 1;
365
366 function pthread_mutexattr_setprotocol
367 (attr : access pthread_mutexattr_t;
368 protocol : int) return int;
369 pragma Import (C, pthread_mutexattr_setprotocol);
370
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");
377
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);
385
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");
391
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");
396
397 function pthread_attr_setinheritsched
398 (attr : access pthread_attr_t;
399 inheritsched : int) return int;
400 pragma Import (C, pthread_attr_setinheritsched);
401
402 function pthread_attr_setschedpolicy
403 (attr : access pthread_attr_t;
404 policy : int) return int;
405 pragma Import (C, pthread_attr_setschedpolicy);
406
407 function pthread_attr_setschedparam
408 (attr : access pthread_attr_t;
409 sched_param : int) return int;
410 pragma Import (C, pthread_attr_setschedparam);
411
412 function sched_yield return int;
413 pragma Import (C, sched_yield, "sched_yield");
414
415 ---------------------------
416 -- P1003.1c - Section 16 --
417 ---------------------------
418
419 function pthread_attr_init (attributes : access pthread_attr_t) return int;
420 pragma Import (C, pthread_attr_init, "pthread_attr_init");
421
422 function pthread_attr_destroy
423 (attributes : access pthread_attr_t) return int;
424 pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
425
426 function pthread_attr_setdetachstate
427 (attr : access pthread_attr_t;
428 detachstate : int) return int;
429 pragma Import (C, pthread_attr_setdetachstate);
430
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");
435
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");
442
443 procedure pthread_exit (status : System.Address);
444 pragma Import (C, pthread_exit, "pthread_exit");
445
446 function pthread_self return pthread_t;
447 pragma Import (C, pthread_self, "pthread_self");
448
449 --------------------------
450 -- POSIX.1c Section 17 --
451 --------------------------
452
453 function pthread_setspecific
454 (key : pthread_key_t;
455 value : System.Address) return int;
456 pragma Import (C, pthread_setspecific, "pthread_setspecific");
457
458 function pthread_getspecific (key : pthread_key_t) return System.Address;
459 pragma Import (C, pthread_getspecific, "pthread_getspecific");
460
461 type destructor_pointer is access procedure (arg : System.Address);
462
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");
467
468 private
469
470 type sigset_t is new int;
471
472 type pid_t is new int;
473
474 type time_t is new long;
475
476 type timespec is record
477 tv_sec : time_t;
478 tv_nsec : long;
479 end record;
480 pragma Convention (C, timespec);
481
482 type clockid_t is new rtems_id;
483 CLOCK_REALTIME : constant clockid_t := 1;
484
485 type struct_timeval is record
486 tv_sec : int;
487 tv_usec : int;
488 end record;
489 pragma Convention (C, struct_timeval);
490
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);
503
504 type pthread_condattr_t is record
505 flags : int;
506 end record;
507 pragma Convention (C, pthread_condattr_t);
508
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);
517
518 type pthread_t is new rtems_id;
519
520 type pthread_mutex_t is new rtems_id;
521
522 type pthread_cond_t is new rtems_id;
523
524 type pthread_key_t is new rtems_id;
525
526 end System.OS_Interface;
This page took 0.055246 seconds and 5 git commands to generate.