OSDN Git Service

* reload1.c (reload_cse_simplify): Fix typo in rtx code check.
[pf3gnuchains/gcc-fork.git] / gcc / ada / 5mosinte.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-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 ------------------------------------------------------------------------------
35
36 --  This is a MACOS (FSU THREAD) version of this package.
37
38 --  This package encapsulates all direct interfaces to OS services
39 --  that are needed by children of System.
40
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.
44
45 with Interfaces.C;
46 package System.OS_Interface is
47    pragma Preelaborate;
48
49    pragma Linker_Options ("-lgthreads");
50
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;
60
61    -----------
62    -- Errno --
63    -----------
64
65    function errno return int;
66    pragma Import (C, errno, "__get_errno");
67
68    EAGAIN    : constant := 35;
69    EINTR     : constant := 4;
70    EINVAL    : constant := 22;
71    ENOMEM    : constant := 12;
72    ETIMEDOUT : constant := 60;
73
74    -------------
75    -- Signals --
76    -------------
77
78    Max_Interrupt : constant := 31;
79    type Signal is new int range 0 .. Max_Interrupt;
80    for Signal'Size use int'Size;
81
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 := 30; --  user defined signal 1
99    SIGUSR2     : constant := 31; --  user defined signal 2
100    SIGCLD      : constant := 20; --  alias for SIGCHLD
101    SIGCHLD     : constant := 20; --  child status change
102    SIGWINCH    : constant := 28; --  window size change
103    SIGURG      : constant := 16; --  urgent condition on IO channel
104    SIGIO       : constant := 23; --  I/O possible (Solaris SIGPOLL alias)
105    SIGSTOP     : constant := 17; --  stop (cannot be caught or ignored)
106    SIGTSTP     : constant := 18; --  user stop requested from tty
107    SIGCONT     : constant := 19; --  stopped process has been continued
108    SIGTTIN     : constant := 21; --  background tty read attempted
109    SIGTTOU     : constant := 22; --  background tty write attempted
110    SIGVTALRM   : constant := 26; --  virtual timer expired
111    SIGPROF     : constant := 27; --  profiling timer expired
112    SIGXCPU     : constant := 24; --  CPU time limit exceeded
113    SIGXFSZ     : constant := 25; --  filesize limit exceeded
114
115    SIGADAABORT : constant := SIGABRT;
116
117    type Signal_Set is array (Natural range <>) of Signal;
118
119    Unmasked    : constant Signal_Set := (SIGTRAP, SIGALRM, SIGEMT, SIGCHLD);
120    Reserved    : constant Signal_Set := (SIGKILL, SIGSTOP);
121
122    type sigset_t is private;
123
124    function sigaddset (set : access sigset_t; sig : Signal) return int;
125    pragma Import (C, sigaddset, "sigaddset");
126
127    function sigdelset (set : access sigset_t; sig : Signal) return int;
128    pragma Import (C, sigdelset, "sigdelset");
129
130    function sigfillset (set : access sigset_t) return int;
131    pragma Import (C, sigfillset, "sigfillset");
132
133    function sigismember (set : access sigset_t; sig : Signal) return int;
134    pragma Import (C, sigismember, "sigismember");
135
136    function sigemptyset (set : access sigset_t) return int;
137    pragma Import (C, sigemptyset, "sigemptyset");
138
139    type struct_sigaction is record
140       sa_handler : System.Address;
141       sa_mask    : sigset_t;
142       sa_flags   : int;
143    end record;
144    pragma Convention (C, struct_sigaction);
145    type struct_sigaction_ptr is access all struct_sigaction;
146
147    SIG_BLOCK   : constant := 1;
148    SIG_UNBLOCK : constant := 2;
149    SIG_SETMASK : constant := 3;
150
151    SIG_DFL : constant := 0;
152    SIG_IGN : constant := 1;
153
154    function sigaction
155      (sig  : Signal;
156       act  : struct_sigaction_ptr;
157       oact : struct_sigaction_ptr) return int;
158    pragma Import (C, sigaction, "sigaction");
159
160    ----------
161    -- Time --
162    ----------
163
164    Time_Slice_Supported : constant Boolean := False;
165    --  Indicates wether time slicing is supported (i.e FSU threads have been
166    --  compiled with DEF_RR)
167
168    type timespec is private;
169
170    type clockid_t is private;
171
172    CLOCK_REALTIME : constant clockid_t;
173
174    function clock_gettime
175      (clock_id : clockid_t;
176       tp       : access timespec) return int;
177    pragma Import (C, clock_gettime, "clock_gettime");
178
179    function To_Duration (TS : timespec) return Duration;
180    pragma Inline (To_Duration);
181
182    function To_Timespec (D : Duration) return timespec;
183    pragma Inline (To_Timespec);
184
185    type struct_timeval is private;
186
187    function To_Duration (TV : struct_timeval) return Duration;
188    pragma Inline (To_Duration);
189
190    function To_Timeval (D : Duration) return struct_timeval;
191    pragma Inline (To_Timeval);
192
193    -------------------------
194    -- Priority Scheduling --
195    -------------------------
196
197    SCHED_FIFO  : constant := 0;
198    SCHED_RR    : constant := 1;
199    SCHED_OTHER : constant := 2;
200
201    -------------
202    -- Process --
203    -------------
204
205    type pid_t is private;
206
207    function kill (pid : pid_t; sig : Signal) return int;
208    pragma Import (C, kill, "kill");
209
210    function getpid return pid_t;
211    pragma Import (C, getpid, "getpid");
212
213    ---------
214    -- LWP --
215    ---------
216
217    function lwp_self return System.Address;
218    --  lwp_self does not exist on this thread library, revert to pthread_self
219    --  which is the closest approximation (with getpid). This function is
220    --  needed to share 7staprop.adb across POSIX-like targets.
221    pragma Import (C, lwp_self, "pthread_self");
222
223    -------------
224    -- Threads --
225    -------------
226
227    type Thread_Body is access
228      function (arg : System.Address) return System.Address;
229
230    type pthread_t           is private;
231    subtype Thread_Id        is pthread_t;
232
233    type pthread_mutex_t     is limited private;
234    type pthread_cond_t      is limited private;
235    type pthread_attr_t      is limited private;
236    type pthread_mutexattr_t is limited private;
237    type pthread_condattr_t  is limited private;
238    type pthread_key_t       is private;
239
240    PTHREAD_CREATE_DETACHED : constant := 1;
241
242    -----------
243    -- Stack --
244    -----------
245
246    Stack_Base_Available : constant Boolean := False;
247    --  Indicates wether the stack base is available on this target.
248    --  This allows us to share s-osinte.adb between all the FSU run time.
249    --  Note that this value can only be true if pthread_t has a complete
250    --  definition that corresponds exactly to the C header files.
251
252    function Get_Stack_Base (thread : pthread_t) return Address;
253    pragma Inline (Get_Stack_Base);
254    --  returns the stack base of the specified thread.
255    --  Only call this function when Stack_Base_Available is True.
256
257    function Get_Page_Size return size_t;
258    function Get_Page_Size return Address;
259    pragma Import (C, Get_Page_Size, "getpagesize");
260    --  returns the size of a page, or 0 if this is not relevant on this
261    --  target
262
263    PROT_NONE  : constant := 0;
264    PROT_READ  : constant := 1;
265    PROT_WRITE : constant := 2;
266    PROT_EXEC  : constant := 4;
267    PROT_ALL   : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
268
269    PROT_ON    : constant := PROT_NONE;
270    PROT_OFF   : constant := PROT_ALL;
271
272    function mprotect (addr : Address; len : size_t; prot : int) return int;
273    pragma Import (C, mprotect);
274
275    ---------------------------------------
276    -- Nonstandard Thread Initialization --
277    ---------------------------------------
278
279    procedure pthread_init;
280    --  FSU_THREADS requires pthread_init, which is nonstandard
281    --  and this should be invoked during the elaboration of s-taprop.adb
282    pragma Import (C, pthread_init, "pthread_init");
283
284    -------------------------
285    -- POSIX.1c  Section 3 --
286    -------------------------
287
288    function sigwait
289      (set : access sigset_t;
290       sig : access Signal) return int;
291    --  FSU_THREADS has a nonstandard sigwait
292
293    function pthread_kill
294      (thread : pthread_t;
295       sig    : Signal) return int;
296    pragma Import (C, pthread_kill, "pthread_kill");
297
298    type sigset_t_ptr is access all sigset_t;
299
300    function pthread_sigmask
301      (how  : int;
302       set  : sigset_t_ptr;
303       oset : sigset_t_ptr)
304       return int;
305    pragma Import (C, pthread_sigmask, "sigprocmask");
306
307    --------------------------
308    -- POSIX.1c  Section 11 --
309    --------------------------
310
311    function pthread_mutexattr_init
312      (attr : access pthread_mutexattr_t) return int;
313    pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
314
315    function pthread_mutexattr_destroy
316      (attr : access pthread_mutexattr_t) return int;
317    pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
318
319    function pthread_mutex_init
320      (mutex : access pthread_mutex_t;
321       attr  : access pthread_mutexattr_t) return int;
322    pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
323
324    function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
325    pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
326
327    function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
328    --  FSU_THREADS has nonstandard pthread_mutex_lock
329
330    function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
331    --  FSU_THREADS has nonstandard pthread_mutex_lock
332
333    function pthread_condattr_init
334      (attr : access pthread_condattr_t) return int;
335    pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
336
337    function pthread_condattr_destroy
338      (attr : access pthread_condattr_t) return int;
339    pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
340
341    function pthread_cond_init
342      (cond : access pthread_cond_t;
343       attr : access pthread_condattr_t) return int;
344    pragma Import (C, pthread_cond_init, "pthread_cond_init");
345
346    function pthread_cond_destroy (cond : access pthread_cond_t) return int;
347    pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
348
349    function pthread_cond_signal (cond : access pthread_cond_t) return int;
350    pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
351
352    function pthread_cond_wait
353      (cond  : access pthread_cond_t;
354       mutex : access pthread_mutex_t) return int;
355    --  FSU_THREADS has a nonstandard pthread_cond_wait
356
357    function pthread_cond_timedwait
358      (cond    : access pthread_cond_t;
359       mutex   : access pthread_mutex_t;
360       abstime : access timespec) return int;
361    --  FSU_THREADS has a nonstandard pthread_cond_timedwait
362
363    Relative_Timed_Wait : constant Boolean := False;
364    --  pthread_cond_timedwait requires an absolute delay time
365
366    --------------------------
367    -- POSIX.1c  Section 13 --
368    --------------------------
369
370    PTHREAD_PRIO_NONE    : constant := 0;
371    PTHREAD_PRIO_PROTECT : constant := 2;
372    PTHREAD_PRIO_INHERIT : constant := 1;
373
374    function pthread_mutexattr_setprotocol
375      (attr     : access pthread_mutexattr_t;
376       protocol : int) return int;
377    pragma Import (C, pthread_mutexattr_setprotocol);
378
379    function pthread_mutexattr_setprioceiling
380      (attr     : access pthread_mutexattr_t;
381       prioceiling : int) return int;
382    pragma Import
383      (C, pthread_mutexattr_setprioceiling,
384       "pthread_mutexattr_setprio_ceiling");
385
386    type struct_sched_param is record
387       sched_priority : int;  --  scheduling priority
388    end record;
389
390    function pthread_setschedparam
391      (thread : pthread_t;
392       policy : int;
393       param  : access struct_sched_param) return int;
394    --  FSU_THREADS does not have pthread_setschedparam
395
396    function pthread_attr_setscope
397      (attr            : access pthread_attr_t;
398       contentionscope : int) return int;
399    pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
400
401    function pthread_attr_setinheritsched
402      (attr            : access pthread_attr_t;
403       inheritsched : int) return int;
404    pragma Import (C, pthread_attr_setinheritsched);
405
406    function pthread_attr_setschedpolicy
407      (attr   : access pthread_attr_t;
408       policy : int) return int;
409    pragma Import (C, pthread_attr_setschedpolicy, "pthread_attr_setsched");
410
411    function pthread_attr_setschedparam
412      (attr        : access pthread_attr_t;
413       sched_param : int) return int;
414    pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
415
416    function sched_yield return int;
417    --  FSU_THREADS does not have sched_yield;
418
419    ---------------------------
420    -- P1003.1c - Section 16 --
421    ---------------------------
422
423    function pthread_attr_init (attributes : access pthread_attr_t) return int;
424    pragma Import (C, pthread_attr_init, "pthread_attr_init");
425
426    function pthread_attr_destroy
427      (attributes : access pthread_attr_t) return int;
428    pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
429
430    function pthread_attr_setdetachstate
431      (attr        : access pthread_attr_t;
432       detachstate : int) return int;
433    --  FSU_THREADS has a nonstandard pthread_attr_setdetachstate
434
435    function pthread_attr_setstacksize
436      (attr      : access pthread_attr_t;
437       stacksize : size_t) return int;
438    pragma Import (C, pthread_attr_setstacksize);
439
440    function pthread_create
441      (thread        : access pthread_t;
442       attributes    : access pthread_attr_t;
443       start_routine : Thread_Body;
444       arg           : System.Address) return int;
445    pragma Import (C, pthread_create, "pthread_create");
446
447    procedure pthread_exit (status : System.Address);
448    pragma Import (C, pthread_exit, "pthread_exit");
449
450    function pthread_self return pthread_t;
451    pragma Import (C, pthread_self, "pthread_self");
452
453    --------------------------
454    -- POSIX.1c  Section 17 --
455    --------------------------
456
457    function pthread_setspecific
458      (key   : pthread_key_t;
459       value : System.Address) return int;
460    pragma Import (C, pthread_setspecific, "pthread_setspecific");
461
462    function pthread_getspecific (key : pthread_key_t) return System.Address;
463    --  FSU_THREADS has a nonstandard pthread_getspecific
464
465    type destructor_pointer is access procedure (arg : System.Address);
466
467    function pthread_key_create
468      (key        : access pthread_key_t;
469       destructor : destructor_pointer) return int;
470    pragma Import (C, pthread_key_create, "pthread_key_create");
471
472 private
473
474    type sigset_t is new int;
475
476    type pid_t is new int;
477
478    type time_t is new long;
479
480    type timespec is record
481       tv_sec  : time_t;
482       tv_nsec : long;
483    end record;
484    pragma Convention (C, timespec);
485
486    type clockid_t is new int;
487    CLOCK_REALTIME : constant clockid_t := 0;
488
489    type struct_timeval is record
490       tv_sec       : long;
491       tv_usec      : long;
492    end record;
493    pragma Convention (C, struct_timeval);
494
495    type pthread_attr_t is record
496       flags           : int;
497       stacksize       : int;
498       contentionscope : int;
499       inheritsched    : int;
500       detachstate     : int;
501       sched           : int;
502       prio            : int;
503       starttime       : timespec;
504       deadline        : timespec;
505       period          : timespec;
506    end record;
507    pragma Convention (C, pthread_attr_t);
508
509    type pthread_condattr_t is record
510       flags : int;
511    end record;
512    pragma Convention (C, pthread_condattr_t);
513
514    type pthread_mutexattr_t is record
515       flags        : int;
516       prio_ceiling : int;
517       protocol     : int;
518    end record;
519    pragma Convention (C, pthread_mutexattr_t);
520
521    type sigjmp_buf is array (Integer range 0 .. 9) of int;
522
523    type pthread_t_struct is record
524       context    : sigjmp_buf;
525       pbody      : sigjmp_buf;
526       errno      : int;
527       ret        : int;
528       stack_base : System.Address;
529    end record;
530    pragma Convention (C, pthread_t_struct);
531
532    type pthread_t is access all pthread_t_struct;
533
534    type queue_t is record
535       head : System.Address;
536       tail : System.Address;
537    end record;
538    pragma Convention (C, queue_t);
539
540    type pthread_mutex_t is record
541       queue        : queue_t;
542       lock         : plain_char;
543       owner        : System.Address;
544       flags        : int;
545       prio_ceiling : int;
546       protocol     : int;
547       prev_max_ceiling_prio  : int;
548    end record;
549    pragma Convention (C, pthread_mutex_t);
550
551    type pthread_cond_t is record
552       queue   : queue_t;
553       flags   : int;
554       waiters : int;
555       mutex   : System.Address;
556    end record;
557    pragma Convention (C, pthread_cond_t);
558
559    type pthread_key_t is new int;
560
561 end System.OS_Interface;