OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-stable/] [gcc-4.5.1/] [gcc/] [ada/] [s-osinte-irix.ads] - Blame information for rev 826

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 281 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                 GNAT 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
--             Copyright (C) 1991-1994, Florida State University            --
10
--          Copyright (C) 1995-2008, 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,  51  Franklin  Street,  Fifth  Floor, --
21
-- Boston, MA 02110-1301, 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
------------------------------------------------------------------------------
34
 
35
--  This is the SGI Pthreads version of this package
36
 
37
--  This package encapsulates all direct interfaces to OS services that are
38
--  needed by the tasking run-time (libgnarl).
39
 
40
--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
41
--  Preelaborate. This package is designed to be a bottom-level (leaf) package.
42
 
43
with Ada.Unchecked_Conversion;
44
 
45
with Interfaces.C;
46
 
47
package System.OS_Interface is
48
 
49
   pragma Preelaborate;
50
 
51
   pragma Linker_Options ("-lpthread");
52
 
53
   subtype int            is Interfaces.C.int;
54
   subtype short          is Interfaces.C.short;
55
   subtype long           is Interfaces.C.long;
56
   subtype unsigned       is Interfaces.C.unsigned;
57
   subtype unsigned_short is Interfaces.C.unsigned_short;
58
   subtype unsigned_long  is Interfaces.C.unsigned_long;
59
   subtype unsigned_char  is Interfaces.C.unsigned_char;
60
   subtype plain_char     is Interfaces.C.plain_char;
61
   subtype size_t         is Interfaces.C.size_t;
62
 
63
   -----------
64
   -- Errno --
65
   -----------
66
 
67
   function errno return int;
68
   pragma Import (C, errno, "__get_errno");
69
 
70
   EINTR     : constant := 4;   --  interrupted system call
71
   EAGAIN    : constant := 11;  --  No more processes
72
   ENOMEM    : constant := 12;  --  Not enough core
73
   EINVAL    : constant := 22;  --  Invalid argument
74
   ETIMEDOUT : constant := 145; --  Connection timed out
75
 
76
   -------------
77
   -- Signals --
78
   -------------
79
 
80
   Max_Interrupt : constant := 64;
81
   type Signal is new int range 0 .. Max_Interrupt;
82
   for Signal'Size use int'Size;
83
 
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
   SIGK32     : constant := 32; --  reserved for kernel (IRIX)
119
   SIGCKPT    : constant := 33; --  Checkpoint warning
120
   SIGRESTART : constant := 34; --  Restart warning
121
   SIGUME     : constant := 35; --  Uncorrectable memory error
122
   --  Signals defined for Posix 1003.1c
123
   SIGPTINTR    : constant := 47;
124
   SIGPTRESCHED : constant := 48;
125
   --  Posix 1003.1b signals
126
   SIGRTMIN   : constant := 49; --  Posix 1003.1b signals
127
   SIGRTMAX   : constant := 64; --  Posix 1003.1b signals
128
 
129
   type sigset_t is private;
130
 
131
   function sigaddset (set : access sigset_t; sig : Signal) return int;
132
   pragma Import (C, sigaddset, "sigaddset");
133
 
134
   function sigdelset (set : access sigset_t; sig : Signal) return int;
135
   pragma Import (C, sigdelset, "sigdelset");
136
 
137
   function sigfillset (set : access sigset_t) return int;
138
   pragma Import (C, sigfillset, "sigfillset");
139
 
140
   function sigismember (set : access sigset_t; sig : Signal) return int;
141
   pragma Import (C, sigismember, "sigismember");
142
 
143
   function sigemptyset (set : access sigset_t) return int;
144
   pragma Import (C, sigemptyset, "sigemptyset");
145
 
146
   type array_type_2 is array (Integer range 0 .. 1) of int;
147
   type struct_sigaction is record
148
      sa_flags     : int;
149
      sa_handler   : System.Address;
150
      sa_mask      : sigset_t;
151
      sa_resv      : array_type_2;
152
   end record;
153
   pragma Convention (C, struct_sigaction);
154
 
155
   type struct_sigaction_ptr is access all struct_sigaction;
156
 
157
   SIG_BLOCK   : constant := 1;
158
   SIG_UNBLOCK : constant := 2;
159
   SIG_SETMASK : constant := 3;
160
 
161
   SIG_DFL : constant := 0;
162
   SIG_IGN : constant := 1;
163
 
164
   function sigaction
165
     (sig  : Signal;
166
      act  : struct_sigaction_ptr;
167
      oact : struct_sigaction_ptr := null) return int;
168
   pragma Import (C, sigaction, "sigaction");
169
 
170
   ----------
171
   -- Time --
172
   ----------
173
 
174
   type timespec is private;
175
   type timespec_ptr is access all timespec;
176
 
177
   type clockid_t is private;
178
 
179
   CLOCK_REALTIME  : constant clockid_t;
180
   CLOCK_SGI_FAST  : constant clockid_t;
181
   CLOCK_SGI_CYCLE : constant clockid_t;
182
 
183
   SGI_CYCLECNTR_SIZE : constant := 165;
184
 
185
   function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
186
   pragma Import (C, syssgi, "syssgi");
187
 
188
   function clock_gettime
189
     (clock_id : clockid_t;
190
      tp       : access timespec) return int;
191
   pragma Import (C, clock_gettime, "clock_gettime");
192
 
193
   function clock_getres
194
     (clock_id : clockid_t;
195
      tp       : access timespec) return int;
196
   pragma Import (C, clock_getres, "clock_getres");
197
 
198
   function To_Duration (TS : timespec) return Duration;
199
   pragma Inline (To_Duration);
200
 
201
   function To_Timespec (D : Duration) return timespec;
202
   pragma Inline (To_Timespec);
203
 
204
   -------------------------
205
   -- Priority Scheduling --
206
   -------------------------
207
 
208
   SCHED_FIFO  : constant := 1;
209
   SCHED_RR    : constant := 2;
210
   SCHED_TS    : constant := 3;
211
   SCHED_OTHER : constant := 3;
212
   SCHED_NP    : constant := 4;
213
 
214
   function sched_get_priority_min (Policy : int) return int;
215
   pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
216
 
217
   function sched_get_priority_max (Policy : int) return int;
218
   pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
219
 
220
   -------------
221
   -- Process --
222
   -------------
223
 
224
   type pid_t is private;
225
 
226
   function kill (pid : pid_t; sig : Signal) return int;
227
   pragma Import (C, kill, "kill");
228
 
229
   function getpid return pid_t;
230
   pragma Import (C, getpid, "getpid");
231
 
232
   -------------
233
   -- Threads --
234
   -------------
235
 
236
   type Thread_Body is access
237
     function (arg : System.Address) return System.Address;
238
   pragma Convention (C, Thread_Body);
239
 
240
   function Thread_Body_Access is new
241
     Ada.Unchecked_Conversion (System.Address, Thread_Body);
242
 
243
   type pthread_t           is private;
244
   subtype Thread_Id        is pthread_t;
245
 
246
   type pthread_mutex_t     is limited private;
247
   type pthread_cond_t      is limited private;
248
   type pthread_attr_t      is limited private;
249
   type pthread_mutexattr_t is limited private;
250
   type pthread_condattr_t  is limited private;
251
   type pthread_key_t       is private;
252
 
253
   PTHREAD_CREATE_DETACHED : constant := 1;
254
 
255
   -----------
256
   -- Stack --
257
   -----------
258
 
259
   Alternate_Stack_Size : constant := 0;
260
   --  No alternate signal stack is used on this platform
261
 
262
   ---------------------------------------
263
   -- Nonstandard Thread Initialization --
264
   ---------------------------------------
265
 
266
   procedure pthread_init;
267
   pragma Inline (pthread_init);
268
   --  This is a dummy procedure to share some GNULLI files
269
 
270
   -------------------------
271
   -- POSIX.1c  Section 3 --
272
   -------------------------
273
 
274
   function sigwait
275
     (set : access sigset_t;
276
      sig : access Signal) return int;
277
   pragma Import (C, sigwait, "sigwait");
278
 
279
   function pthread_kill
280
     (thread : pthread_t;
281
      sig    : Signal) return int;
282
   pragma Import (C, pthread_kill, "pthread_kill");
283
 
284
   function pthread_sigmask
285
     (how  : int;
286
      set  : access sigset_t;
287
      oset : access sigset_t) return int;
288
   pragma Import (C, pthread_sigmask, "pthread_sigmask");
289
 
290
   --------------------------
291
   -- POSIX.1c  Section 11 --
292
   --------------------------
293
 
294
   function pthread_mutexattr_init
295
     (attr : access pthread_mutexattr_t) return int;
296
   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
297
 
298
   function pthread_mutexattr_destroy
299
     (attr : access pthread_mutexattr_t) return int;
300
   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
301
 
302
   function pthread_mutex_init
303
     (mutex : access pthread_mutex_t;
304
      attr  : access pthread_mutexattr_t) return int;
305
   pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
306
 
307
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
308
   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
309
 
310
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
311
   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
312
 
313
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
314
   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
315
 
316
   function pthread_condattr_init
317
     (attr : access pthread_condattr_t) return int;
318
   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
319
 
320
   function pthread_condattr_destroy
321
     (attr : access pthread_condattr_t) return int;
322
   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
323
 
324
   function pthread_cond_init
325
     (cond : access pthread_cond_t;
326
      attr : access pthread_condattr_t) return int;
327
   pragma Import (C, pthread_cond_init, "pthread_cond_init");
328
 
329
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
330
   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
331
 
332
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
333
   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
334
 
335
   function pthread_cond_wait
336
     (cond  : access pthread_cond_t;
337
      mutex : access pthread_mutex_t) return int;
338
   pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
339
 
340
   function pthread_cond_timedwait
341
     (cond    : access pthread_cond_t;
342
      mutex   : access pthread_mutex_t;
343
      abstime : access timespec) return int;
344
   pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
345
 
346
   --------------------------
347
   -- POSIX.1c  Section 13 --
348
   --------------------------
349
 
350
   PTHREAD_PRIO_NONE    : constant := 0;
351
   PTHREAD_PRIO_PROTECT : constant := 2;
352
   PTHREAD_PRIO_INHERIT : constant := 1;
353
 
354
   function pthread_mutexattr_setprotocol
355
     (attr     : access pthread_mutexattr_t;
356
      protocol : int) return int;
357
   pragma Import (C, pthread_mutexattr_setprotocol);
358
 
359
   function pthread_mutexattr_setprioceiling
360
     (attr     : access pthread_mutexattr_t;
361
      prioceiling : int) return int;
362
   pragma Import (C, pthread_mutexattr_setprioceiling);
363
 
364
   type struct_sched_param is record
365
      sched_priority : int;
366
   end record;
367
   pragma Convention (C, struct_sched_param);
368
 
369
   function pthread_setschedparam
370
     (thread : pthread_t;
371
      policy : int;
372
      param  : access struct_sched_param)
373
     return int;
374
   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
375
 
376
   function pthread_attr_setscope
377
     (attr            : access pthread_attr_t;
378
      contentionscope : int) return int;
379
   pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
380
 
381
   function pthread_attr_setinheritsched
382
     (attr         : access pthread_attr_t;
383
      inheritsched : int) return int;
384
   pragma Import
385
     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
386
 
387
   function pthread_attr_setschedpolicy
388
     (attr   : access pthread_attr_t;
389
      policy : int) return int;
390
   pragma Import (C, pthread_attr_setschedpolicy);
391
 
392
   function pthread_attr_setschedparam
393
     (attr        : access pthread_attr_t;
394
      sched_param : access struct_sched_param)
395
     return int;
396
   pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
397
 
398
   function sched_yield return int;
399
   pragma Import (C, sched_yield, "sched_yield");
400
 
401
   ---------------------------
402
   -- P1003.1c - Section 16 --
403
   ---------------------------
404
 
405
   function pthread_attr_init (attributes : access pthread_attr_t) return int;
406
   pragma Import (C, pthread_attr_init, "pthread_attr_init");
407
 
408
   function pthread_attr_destroy
409
     (attributes : access pthread_attr_t) return int;
410
   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
411
 
412
   function pthread_attr_setdetachstate
413
     (attr        : access pthread_attr_t;
414
      detachstate : int) return int;
415
   pragma Import (C, pthread_attr_setdetachstate);
416
 
417
   function pthread_attr_setstacksize
418
     (attr      : access pthread_attr_t;
419
      stacksize : size_t) return int;
420
   pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
421
 
422
   function pthread_create
423
     (thread        : access pthread_t;
424
      attributes    : access pthread_attr_t;
425
      start_routine : Thread_Body;
426
      arg           : System.Address) return int;
427
   pragma Import (C, pthread_create, "pthread_create");
428
 
429
   procedure pthread_exit (status : System.Address);
430
   pragma Import (C, pthread_exit, "pthread_exit");
431
 
432
   function pthread_self return pthread_t;
433
   pragma Import (C, pthread_self, "pthread_self");
434
 
435
   --------------------------
436
   -- POSIX.1c  Section 17 --
437
   --------------------------
438
 
439
   function pthread_setspecific
440
     (key   : pthread_key_t;
441
      value : System.Address) return int;
442
   pragma Import (C, pthread_setspecific, "pthread_setspecific");
443
 
444
   function pthread_getspecific (key : pthread_key_t) return System.Address;
445
   pragma Import (C, pthread_getspecific, "pthread_getspecific");
446
 
447
   type destructor_pointer is access procedure (arg : System.Address);
448
   pragma Convention (C, destructor_pointer);
449
 
450
   function pthread_key_create
451
     (key        : access pthread_key_t;
452
      destructor : destructor_pointer) return int;
453
   pragma Import (C, pthread_key_create, "pthread_key_create");
454
 
455
   -------------------
456
   -- SGI Additions --
457
   -------------------
458
 
459
   --  Non portable SGI 6.5 additions to the pthread interface must be
460
   --  executed from within the context of a system scope task.
461
 
462
   function pthread_setrunon_np (cpu : int) return int;
463
   pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
464
 
465
private
466
 
467
   type array_type_1 is array (Integer range 0 .. 3) of unsigned;
468
   type sigset_t is record
469
      X_X_sigbits : array_type_1;
470
   end record;
471
   pragma Convention (C, sigset_t);
472
 
473
   type pid_t is new long;
474
 
475
   type time_t is new long;
476
 
477
   type timespec is record
478
      tv_sec  : time_t;
479
      tv_nsec : long;
480
   end record;
481
   pragma Convention (C, timespec);
482
 
483
   type clockid_t is new int;
484
   CLOCK_REALTIME  : constant clockid_t := 1;
485
   CLOCK_SGI_CYCLE : constant clockid_t := 2;
486
   CLOCK_SGI_FAST  : constant clockid_t := 3;
487
 
488
   type array_type_9 is array (Integer range 0 .. 4) of long;
489
   type pthread_attr_t is record
490
      X_X_D : array_type_9;
491
   end record;
492
   pragma Convention (C, pthread_attr_t);
493
 
494
   type array_type_8 is array (Integer range 0 .. 1) of long;
495
   type pthread_condattr_t is record
496
      X_X_D : array_type_8;
497
   end record;
498
   pragma Convention (C, pthread_condattr_t);
499
 
500
   type array_type_7 is array (Integer range 0 .. 1) of long;
501
   type pthread_mutexattr_t is record
502
      X_X_D : array_type_7;
503
   end record;
504
   pragma Convention (C, pthread_mutexattr_t);
505
 
506
   type pthread_t is new unsigned;
507
 
508
   type array_type_10 is array (Integer range 0 .. 7) of long;
509
   type pthread_mutex_t is record
510
      X_X_D : array_type_10;
511
   end record;
512
   pragma Convention (C, pthread_mutex_t);
513
 
514
   type array_type_11 is array (Integer range 0 .. 7) of long;
515
   type pthread_cond_t is record
516
      X_X_D : array_type_11;
517
   end record;
518
   pragma Convention (C, pthread_cond_t);
519
 
520
   type pthread_key_t is new int;
521
 
522
end System.OS_Interface;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.