OSDN Git Service

* reload1.c (reload_cse_simplify): Fix typo in rtx code check.
[pf3gnuchains/gcc-fork.git] / gcc / ada / 5uosinte.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 Sun OS (FSU THREADS) 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    pragma Linker_Options ("-lmalloc");
51
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
62    -----------
63    -- Errno --
64    -----------
65
66    function errno return int;
67    pragma Import (C, errno, "__get_errno");
68
69    EAGAIN    : constant := 11;
70    EINTR     : constant := 4;
71    EINVAL    : constant := 22;
72    ENOMEM    : constant := 12;
73    ETIMEDOUT : constant := 60;
74
75    -------------
76    -- Signals --
77    -------------
78
79    Max_Interrupt : constant := 31;
80    type Signal is new int range 0 .. Max_Interrupt;
81    for Signal'Size use int'Size;
82
83    SIGHUP     : constant := 1; --  hangup
84    SIGINT     : constant := 2; --  interrupt (rubout)
85    SIGQUIT    : constant := 3; --  quit (ASCD FS)
86    SIGILL     : constant := 4; --  illegal instruction (not reset)
87    SIGTRAP    : constant := 5; --  trace trap (not reset)
88    SIGIOT     : constant := 6; --  IOT instruction
89    SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the  future
90    SIGEMT     : constant := 7; --  EMT instruction
91    SIGFPE     : constant := 8; --  floating point exception
92    SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
93    SIGBUS     : constant := 10; --  bus error
94    SIGSEGV    : constant := 11; --  segmentation violation
95    SIGSYS     : constant := 12; --  bad argument to system call
96    SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
97    SIGALRM    : constant := 14; --  alarm clock
98    SIGTERM    : constant := 15; --  software termination signal from kill
99    SIGUSR1    : constant := 30; --  user defined signal 1
100    SIGUSR2    : constant := 31; --  user defined signal 2
101    SIGCLD     : constant := 20; --  alias for SIGCHLD
102    SIGCHLD    : constant := 20; --  child status change
103    SIGWINCH   : constant := 28; --  window size change
104    SIGURG     : constant := 16; --  urgent condition on IO channel
105    SIGPOLL    : constant := 23; --  pollable event occurred
106    SIGIO      : constant := 23; --  I/O possible (Solaris SIGPOLL alias)
107    SIGSTOP    : constant := 17; --  stop (cannot be caught or ignored)
108    SIGTSTP    : constant := 18; --  user stop requested from tty
109    SIGCONT    : constant := 19; --  stopped process has been continued
110    SIGTTIN    : constant := 21; --  background tty read attempted
111    SIGTTOU    : constant := 22; --  background tty write attempted
112    SIGVTALRM  : constant := 26; --  virtual timer expired
113    SIGPROF    : constant := 27; --  profiling timer expired
114    SIGXCPU    : constant := 24; --  CPU time limit exceeded
115    SIGXFSZ    : constant := 25; --  filesize limit exceeded
116
117    type sigset_t is private;
118
119    function sigaddset (set : access sigset_t; sig : Signal) return int;
120    pragma Import (C, sigaddset, "sigaddset");
121
122    function sigdelset (set : access sigset_t; sig : Signal) return int;
123    pragma Import (C, sigdelset, "sigdelset");
124
125    function sigfillset (set : access sigset_t) return int;
126    pragma Import (C, sigfillset, "sigfillset");
127
128    function sigismember (set : access sigset_t; sig : Signal) return int;
129    pragma Import (C, sigismember, "sigismember");
130
131    function sigemptyset (set : access sigset_t) return int;
132    pragma Import (C, sigemptyset, "sigemptyset");
133
134    type struct_sigaction is record
135       sa_handler : System.Address;
136       sa_mask    : sigset_t;
137       sa_flags   : int;
138    end record;
139    pragma Convention (C, struct_sigaction);
140    type struct_sigaction_ptr is access all struct_sigaction;
141
142    SIG_BLOCK   : constant := 1;
143    SIG_UNBLOCK : constant := 2;
144    SIG_SETMASK : constant := 4;
145
146    SIG_DFL : constant := 0;
147    SIG_IGN : constant := 1;
148
149    function sigaction
150      (sig  : Signal;
151       act  : struct_sigaction_ptr;
152       oact : struct_sigaction_ptr) return int;
153    pragma Import (C, sigaction, "sigaction");
154
155    ----------
156    -- Time --
157    ----------
158
159    Time_Slice_Supported : constant Boolean := False;
160    --  Indicates wether time slicing is supported (i.e FSU threads have been
161    --  compiled with DEF_RR)
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 := 0;
193    SCHED_RR    : constant := 1;
194    SCHED_OTHER : constant := 2;
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    type pthread_t           is private;
225    subtype Thread_Id        is pthread_t;
226
227    type pthread_mutex_t     is limited private;
228    type pthread_cond_t      is limited private;
229    type pthread_attr_t      is limited private;
230    type pthread_mutexattr_t is limited private;
231    type pthread_condattr_t  is limited private;
232    type pthread_key_t       is private;
233
234    PTHREAD_CREATE_DETACHED : constant := 1;
235
236    -----------
237    -- Stack --
238    -----------
239
240    Stack_Base_Available : constant Boolean := False;
241    --  Indicates wether the stack base is available on this target.
242    --  This allows us to share s-osinte.adb between all the FSU run time.
243    --  Note that this value can only be true if pthread_t has a complete
244    --  definition that corresponds exactly to the C header files.
245
246    function Get_Stack_Base (thread : pthread_t) return Address;
247    pragma Inline (Get_Stack_Base);
248    --  returns the stack base of the specified thread.
249    --  Only call this function when Stack_Base_Available is True.
250
251    function Get_Page_Size return size_t;
252    function Get_Page_Size return Address;
253    pragma Import (C, Get_Page_Size, "getpagesize");
254    --  returns the size of a page, or 0 if this is not relevant on this
255    --  target
256
257    PROT_NONE  : constant := 0;
258    PROT_READ  : constant := 1;
259    PROT_WRITE : constant := 2;
260    PROT_EXEC  : constant := 4;
261    PROT_ALL   : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
262
263    PROT_ON    : constant := PROT_NONE;
264    PROT_OFF   : constant := PROT_ALL;
265
266    function mprotect (addr : Address; len : size_t; prot : int) return int;
267    pragma Import (C, mprotect);
268
269    ---------------------------------------
270    -- Nonstandard Thread Initialization --
271    ---------------------------------------
272    --  FSU_THREADS requires pthread_init, which is nonstandard
273    --  and this should be invoked during the elaboration of s-taprop.adb
274    procedure pthread_init;
275    pragma Import (C, pthread_init, "pthread_init");
276
277    -------------------------
278    -- POSIX.1c  Section 3 --
279    -------------------------
280
281    function sigwait (set : access sigset_t; sig : access Signal) return int;
282    --  FSU_THREADS has a nonstandard sigwait
283
284    function pthread_kill (thread : pthread_t; sig : Signal) return int;
285    pragma Import (C, pthread_kill, "pthread_kill");
286
287    --  FSU threads does not have pthread_sigmask. Instead, it uses
288    --  sigprocmask to do the signal handling when the thread library is
289    --  sucked in.
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, "sigprocmask");
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    --  FSU_THREADS has nonstandard pthread_mutex_lock
321
322    function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
323    --  FSU_THREADS has nonstandard pthread_mutex_lock
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    --  FSU_THREADS has a nonstandard 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    --  FSU_THREADS has a nonstandard 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_setprio_ceiling");
377
378    type struct_sched_param is record
379       sched_priority : int;  --  scheduling priority
380    end record;
381
382    function pthread_setschedparam
383      (thread : pthread_t;
384       policy : int;
385       param  : access struct_sched_param) return int;
386    --  FSU_THREADS does not have pthread_setschedparam
387
388    function pthread_attr_setscope
389      (attr            : access pthread_attr_t;
390       contentionscope : int) return int;
391    pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
392
393    function pthread_attr_setinheritsched
394      (attr            : access pthread_attr_t;
395       inheritsched : int) return int;
396    pragma Import (C, pthread_attr_setinheritsched);
397
398    function pthread_attr_setschedpolicy
399      (attr   : access pthread_attr_t;
400       policy : int) return int;
401    pragma Import (C, pthread_attr_setschedpolicy, "pthread_attr_setsched");
402
403    function pthread_attr_setschedparam
404      (attr        : access pthread_attr_t;
405       sched_param : int) return int;
406    pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
407
408    function sched_yield return int;
409    --  FSU_THREADS does not have sched_yield;
410
411    ---------------------------
412    -- P1003.1c - Section 16 --
413    ---------------------------
414
415    function pthread_attr_init (attributes : access pthread_attr_t) return int;
416    pragma Import (C, pthread_attr_init, "pthread_attr_init");
417
418    function pthread_attr_destroy
419      (attributes : access pthread_attr_t) return int;
420    pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
421
422    function pthread_attr_setdetachstate
423      (attr        : access pthread_attr_t;
424       detachstate : int) return int;
425    --  FSU_THREADS has a nonstandard pthread_attr_setdetachstate
426
427    function pthread_attr_setstacksize
428      (attr      : access pthread_attr_t;
429       stacksize : size_t) return int;
430    pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
431
432    function pthread_create
433      (thread        : access pthread_t;
434       attributes    : access pthread_attr_t;
435       start_routine : Thread_Body;
436       arg           : System.Address) return int;
437    pragma Import (C, pthread_create, "pthread_create");
438
439    procedure pthread_exit (status : System.Address);
440    pragma Import (C, pthread_exit, "pthread_exit");
441
442    function pthread_self return pthread_t;
443    pragma Import (C, pthread_self, "pthread_self");
444
445    --------------------------
446    -- POSIX.1c  Section 17 --
447    --------------------------
448
449    function pthread_setspecific
450      (key   : pthread_key_t;
451       value : System.Address) return int;
452    pragma Import (C, pthread_setspecific, "pthread_setspecific");
453
454    function pthread_getspecific (key : pthread_key_t) return System.Address;
455    --  FSU_THREADS has a nonstandard pthread_getspecific
456
457    type destructor_pointer is access procedure (arg : System.Address);
458
459    function pthread_key_create
460      (key        : access pthread_key_t;
461       destructor : destructor_pointer)
462      return int;
463    pragma Import (C, pthread_key_create, "pthread_key_create");
464
465 private
466
467    type sigset_t is new int;
468
469    type pid_t is new int;
470
471    type time_t is new long;
472
473    type timespec is record
474       tv_sec  : time_t;
475       tv_nsec : long;
476    end record;
477    pragma Convention (C, timespec);
478
479    type clockid_t is new int;
480    CLOCK_REALTIME : constant clockid_t := 0;
481
482    type struct_timeval is record
483       tv_sec  : long;
484       tv_usec : long;
485    end record;
486    pragma Convention (C, struct_timeval);
487
488    type pthread_attr_t is record
489       flags           : int;
490       stacksize       : int;
491       contentionscope : int;
492       inheritsched    : int;
493       detachstate     : int;
494       sched           : int;
495       prio            : int;
496       starttime       : timespec;
497       deadline        : timespec;
498       period          : timespec;
499    end record;
500    pragma Convention (C, pthread_attr_t);
501
502    type pthread_condattr_t is record
503       flags : int;
504    end record;
505    pragma Convention (C, pthread_condattr_t);
506
507    type pthread_mutexattr_t is record
508       flags        : int;
509       prio_ceiling : int;
510       protocol     : int;
511    end record;
512    pragma Convention (C, pthread_mutexattr_t);
513
514    type sigjmp_buf is array (Integer range 0 .. 9) of int;
515
516    type pthread_t_struct is record
517       context    : sigjmp_buf;
518       pbody      : sigjmp_buf;
519       errno      : int;
520       ret        : int;
521       stack_base : System.Address;
522    end record;
523    pragma Convention (C, pthread_t_struct);
524
525    type pthread_t is access all pthread_t_struct;
526
527    type queue_t is record
528       head : System.Address;
529       tail : System.Address;
530    end record;
531    pragma Convention (C, queue_t);
532
533    type pthread_mutex_t is record
534       queue                 : queue_t;
535       lock                  : plain_char;
536       owner                 : System.Address;
537       flags                 : int;
538       prio_ceiling          : int;
539       protocol              : int;
540       prev_max_ceiling_prio : int;
541    end record;
542    pragma Convention (C, pthread_mutex_t);
543
544    type pthread_cond_t is record
545       queue        : queue_t;
546       flags        : int;
547       waiters      : int;
548       mutex        : System.Address;
549    end record;
550    pragma Convention (C, pthread_cond_t);
551
552    type pthread_key_t is new int;
553
554 end System.OS_Interface;