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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [ada/] [s-osinte-irix.ads] - Blame information for rev 717

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 706 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-2011, Free Software Foundation, Inc.         --
11
--                                                                          --
12
-- GNAT 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 3,  or (at your option) any later ver- --
15
-- sion.  GNAT 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.                                     --
18
--                                                                          --
19
-- As a special exception under Section 7 of GPL version 3, you are granted --
20
-- additional permissions described in the GCC Runtime Library Exception,   --
21
-- version 3.1, as published by the Free Software Foundation.               --
22
--                                                                          --
23
-- You should have received a copy of the GNU General Public License and    --
24
-- a copy of the GCC Runtime Library Exception along with this program;     --
25
-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
26
-- <http://www.gnu.org/licenses/>.                                          --
27
--                                                                          --
28
-- GNARL was developed by the GNARL team at Florida State University.       --
29
-- Extensive contributions were provided by Ada Core Technologies, Inc.     --
30
--                                                                          --
31
------------------------------------------------------------------------------
32
 
33
--  This is the SGI Pthreads version of this package
34
 
35
--  This package encapsulates all direct interfaces to OS services that are
36
--  needed by the tasking run-time (libgnarl).
37
 
38
--  PLEASE DO NOT add any with-clauses to this package or remove the pragma
39
--  Preelaborate. This package is designed to be a bottom-level (leaf) package.
40
 
41
with Ada.Unchecked_Conversion;
42
 
43
with Interfaces.C;
44
 
45
package System.OS_Interface is
46
 
47
   pragma Preelaborate;
48
 
49
   pragma Linker_Options ("-lpthread");
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
   EINTR     : constant := 4;   --  interrupted system call
69
   EAGAIN    : constant := 11;  --  No more processes
70
   ENOMEM    : constant := 12;  --  Not enough core
71
   EINVAL    : constant := 22;  --  Invalid argument
72
   ETIMEDOUT : constant := 145; --  Connection timed out
73
 
74
   -------------
75
   -- Signals --
76
   -------------
77
 
78
   Max_Interrupt : constant := 64;
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 := 16; --  user defined signal 1
99
   SIGUSR2    : constant := 17; --  user defined signal 2
100
   SIGCLD     : constant := 18; --  alias for SIGCHLD
101
   SIGCHLD    : constant := 18; --  child status change
102
   SIGPWR     : constant := 19; --  power-fail restart
103
   SIGWINCH   : constant := 20; --  window size change
104
   SIGURG     : constant := 21; --  urgent condition on IO channel
105
   SIGPOLL    : constant := 22; --  pollable event occurred
106
   SIGIO      : constant := 22; --  I/O possible (Solaris SIGPOLL alias)
107
   SIGSTOP    : constant := 23; --  stop (cannot be caught or ignored)
108
   SIGTSTP    : constant := 24; --  user stop requested from tty
109
   SIGCONT    : constant := 25; --  stopped process has been continued
110
   SIGTTIN    : constant := 26; --  background tty read attempted
111
   SIGTTOU    : constant := 27; --  background tty write attempted
112
   SIGVTALRM  : constant := 28; --  virtual timer expired
113
   SIGPROF    : constant := 29; --  profiling timer expired
114
   SIGXCPU    : constant := 30; --  CPU time limit exceeded
115
   SIGXFSZ    : constant := 31; --  filesize limit exceeded
116
   SIGK32     : constant := 32; --  reserved for kernel (IRIX)
117
   SIGCKPT    : constant := 33; --  Checkpoint warning
118
   SIGRESTART : constant := 34; --  Restart warning
119
   SIGUME     : constant := 35; --  Uncorrectable memory error
120
   --  Signals defined for Posix 1003.1c
121
   SIGPTINTR    : constant := 47;
122
   SIGPTRESCHED : constant := 48;
123
   --  Posix 1003.1b signals
124
   SIGRTMIN   : constant := 49; --  Posix 1003.1b signals
125
   SIGRTMAX   : constant := 64; --  Posix 1003.1b signals
126
 
127
   type sigset_t is private;
128
 
129
   function sigaddset (set : access sigset_t; sig : Signal) return int;
130
   pragma Import (C, sigaddset, "sigaddset");
131
 
132
   function sigdelset (set : access sigset_t; sig : Signal) return int;
133
   pragma Import (C, sigdelset, "sigdelset");
134
 
135
   function sigfillset (set : access sigset_t) return int;
136
   pragma Import (C, sigfillset, "sigfillset");
137
 
138
   function sigismember (set : access sigset_t; sig : Signal) return int;
139
   pragma Import (C, sigismember, "sigismember");
140
 
141
   function sigemptyset (set : access sigset_t) return int;
142
   pragma Import (C, sigemptyset, "sigemptyset");
143
 
144
   type array_type_2 is array (Integer range 0 .. 1) of int;
145
   type struct_sigaction is record
146
      sa_flags     : int;
147
      sa_handler   : System.Address;
148
      sa_mask      : sigset_t;
149
      sa_resv      : array_type_2;
150
   end record;
151
   pragma Convention (C, struct_sigaction);
152
 
153
   type struct_sigaction_ptr is access all struct_sigaction;
154
 
155
   SIG_BLOCK   : constant := 1;
156
   SIG_UNBLOCK : constant := 2;
157
   SIG_SETMASK : constant := 3;
158
 
159
   SIG_DFL : constant := 0;
160
   SIG_IGN : constant := 1;
161
 
162
   function sigaction
163
     (sig  : Signal;
164
      act  : struct_sigaction_ptr;
165
      oact : struct_sigaction_ptr := null) return int;
166
   pragma Import (C, sigaction, "sigaction");
167
 
168
   ----------
169
   -- Time --
170
   ----------
171
 
172
   type timespec is private;
173
   type timespec_ptr is access all timespec;
174
 
175
   type clockid_t is new int;
176
 
177
   SGI_CYCLECNTR_SIZE : constant := 165;
178
 
179
   function syssgi (request : Interfaces.C.int) return Interfaces.C.ptrdiff_t;
180
   pragma Import (C, syssgi, "syssgi");
181
 
182
   function clock_gettime
183
     (clock_id : clockid_t;
184
      tp       : access timespec) return int;
185
   pragma Import (C, clock_gettime, "clock_gettime");
186
 
187
   function clock_getres
188
     (clock_id : clockid_t;
189
      tp       : access timespec) return int;
190
   pragma Import (C, clock_getres, "clock_getres");
191
 
192
   function To_Duration (TS : timespec) return Duration;
193
   pragma Inline (To_Duration);
194
 
195
   function To_Timespec (D : Duration) return timespec;
196
   pragma Inline (To_Timespec);
197
 
198
   -------------------------
199
   -- Priority Scheduling --
200
   -------------------------
201
 
202
   SCHED_FIFO  : constant := 1;
203
   SCHED_RR    : constant := 2;
204
   SCHED_TS    : constant := 3;
205
   SCHED_OTHER : constant := 3;
206
   SCHED_NP    : constant := 4;
207
 
208
   function sched_get_priority_min (Policy : int) return int;
209
   pragma Import (C, sched_get_priority_min, "sched_get_priority_min");
210
 
211
   function sched_get_priority_max (Policy : int) return int;
212
   pragma Import (C, sched_get_priority_max, "sched_get_priority_max");
213
 
214
   -------------
215
   -- Process --
216
   -------------
217
 
218
   type pid_t is private;
219
 
220
   function kill (pid : pid_t; sig : Signal) return int;
221
   pragma Import (C, kill, "kill");
222
 
223
   function getpid return pid_t;
224
   pragma Import (C, getpid, "getpid");
225
 
226
   -------------
227
   -- Threads --
228
   -------------
229
 
230
   type Thread_Body is access
231
     function (arg : System.Address) return System.Address;
232
   pragma Convention (C, Thread_Body);
233
 
234
   function Thread_Body_Access is new
235
     Ada.Unchecked_Conversion (System.Address, Thread_Body);
236
 
237
   type pthread_t           is private;
238
   subtype Thread_Id        is pthread_t;
239
 
240
   type pthread_mutex_t     is limited private;
241
   type pthread_cond_t      is limited private;
242
   type pthread_attr_t      is limited private;
243
   type pthread_mutexattr_t is limited private;
244
   type pthread_condattr_t  is limited private;
245
   type pthread_key_t       is private;
246
 
247
   PTHREAD_CREATE_DETACHED : constant := 1;
248
 
249
   --  Read/Write lock not supported on SGI. To add support both types
250
   --  pthread_rwlock_t and pthread_rwlockattr_t must properly be defined
251
   --  with the associated routines pthread_rwlock_[init/destroy] and
252
   --  pthread_rwlock_[rdlock/wrlock/unlock].
253
 
254
   subtype pthread_rwlock_t     is pthread_mutex_t;
255
   subtype pthread_rwlockattr_t is pthread_mutexattr_t;
256
 
257
   -----------
258
   -- Stack --
259
   -----------
260
 
261
   Alternate_Stack_Size : constant := 0;
262
   --  No alternate signal stack is used on this platform
263
 
264
   ---------------------------------------
265
   -- Nonstandard Thread Initialization --
266
   ---------------------------------------
267
 
268
   procedure pthread_init;
269
   pragma Inline (pthread_init);
270
   --  This is a dummy procedure to share some GNULLI files
271
 
272
   -------------------------
273
   -- POSIX.1c  Section 3 --
274
   -------------------------
275
 
276
   function sigwait
277
     (set : access sigset_t;
278
      sig : access Signal) return int;
279
   pragma Import (C, sigwait, "sigwait");
280
 
281
   function pthread_kill
282
     (thread : pthread_t;
283
      sig    : Signal) return int;
284
   pragma Import (C, pthread_kill, "pthread_kill");
285
 
286
   function pthread_sigmask
287
     (how  : int;
288
      set  : access sigset_t;
289
      oset : access sigset_t) return int;
290
   pragma Import (C, pthread_sigmask, "pthread_sigmask");
291
 
292
   --------------------------
293
   -- POSIX.1c  Section 11 --
294
   --------------------------
295
 
296
   function pthread_mutexattr_init
297
     (attr : access pthread_mutexattr_t) return int;
298
   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
299
 
300
   function pthread_mutexattr_destroy
301
     (attr : access pthread_mutexattr_t) return int;
302
   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
303
 
304
   function pthread_mutex_init
305
     (mutex : access pthread_mutex_t;
306
      attr  : access pthread_mutexattr_t) return int;
307
   pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
308
 
309
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
310
   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
311
 
312
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
313
   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
314
 
315
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
316
   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
317
 
318
   function pthread_condattr_init
319
     (attr : access pthread_condattr_t) return int;
320
   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
321
 
322
   function pthread_condattr_destroy
323
     (attr : access pthread_condattr_t) return int;
324
   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
325
 
326
   function pthread_cond_init
327
     (cond : access pthread_cond_t;
328
      attr : access pthread_condattr_t) return int;
329
   pragma Import (C, pthread_cond_init, "pthread_cond_init");
330
 
331
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
332
   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
333
 
334
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
335
   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
336
 
337
   function pthread_cond_wait
338
     (cond  : access pthread_cond_t;
339
      mutex : access pthread_mutex_t) return int;
340
   pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
341
 
342
   function pthread_cond_timedwait
343
     (cond    : access pthread_cond_t;
344
      mutex   : access pthread_mutex_t;
345
      abstime : access timespec) return int;
346
   pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
347
 
348
   --------------------------
349
   -- POSIX.1c  Section 13 --
350
   --------------------------
351
 
352
   PTHREAD_PRIO_NONE    : constant := 0;
353
   PTHREAD_PRIO_PROTECT : constant := 2;
354
   PTHREAD_PRIO_INHERIT : constant := 1;
355
 
356
   function pthread_mutexattr_setprotocol
357
     (attr     : access pthread_mutexattr_t;
358
      protocol : int) return int;
359
   pragma Import (C, pthread_mutexattr_setprotocol);
360
 
361
   function pthread_mutexattr_setprioceiling
362
     (attr     : access pthread_mutexattr_t;
363
      prioceiling : int) return int;
364
   pragma Import (C, pthread_mutexattr_setprioceiling);
365
 
366
   type struct_sched_param is record
367
      sched_priority : int;
368
   end record;
369
   pragma Convention (C, struct_sched_param);
370
 
371
   function pthread_setschedparam
372
     (thread : pthread_t;
373
      policy : int;
374
      param  : access struct_sched_param)
375
     return int;
376
   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
377
 
378
   function pthread_attr_setscope
379
     (attr            : access pthread_attr_t;
380
      contentionscope : int) return int;
381
   pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
382
 
383
   function pthread_attr_setinheritsched
384
     (attr         : access pthread_attr_t;
385
      inheritsched : int) return int;
386
   pragma Import
387
     (C, pthread_attr_setinheritsched, "pthread_attr_setinheritsched");
388
 
389
   function pthread_attr_setschedpolicy
390
     (attr   : access pthread_attr_t;
391
      policy : int) return int;
392
   pragma Import (C, pthread_attr_setschedpolicy);
393
 
394
   function pthread_attr_setschedparam
395
     (attr        : access pthread_attr_t;
396
      sched_param : access struct_sched_param)
397
     return int;
398
   pragma Import (C, pthread_attr_setschedparam, "pthread_attr_setschedparam");
399
 
400
   function sched_yield return int;
401
   pragma Import (C, sched_yield, "sched_yield");
402
 
403
   ---------------------------
404
   -- P1003.1c - Section 16 --
405
   ---------------------------
406
 
407
   function pthread_attr_init (attributes : access pthread_attr_t) return int;
408
   pragma Import (C, pthread_attr_init, "pthread_attr_init");
409
 
410
   function pthread_attr_destroy
411
     (attributes : access pthread_attr_t) return int;
412
   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
413
 
414
   function pthread_attr_setdetachstate
415
     (attr        : access pthread_attr_t;
416
      detachstate : int) return int;
417
   pragma Import (C, pthread_attr_setdetachstate);
418
 
419
   function pthread_attr_setstacksize
420
     (attr      : access pthread_attr_t;
421
      stacksize : size_t) return int;
422
   pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
423
 
424
   function pthread_create
425
     (thread        : access pthread_t;
426
      attributes    : access pthread_attr_t;
427
      start_routine : Thread_Body;
428
      arg           : System.Address) return int;
429
   pragma Import (C, pthread_create, "pthread_create");
430
 
431
   procedure pthread_exit (status : System.Address);
432
   pragma Import (C, pthread_exit, "pthread_exit");
433
 
434
   function pthread_self return pthread_t;
435
   pragma Import (C, pthread_self, "pthread_self");
436
 
437
   --------------------------
438
   -- POSIX.1c  Section 17 --
439
   --------------------------
440
 
441
   function pthread_setspecific
442
     (key   : pthread_key_t;
443
      value : System.Address) return int;
444
   pragma Import (C, pthread_setspecific, "pthread_setspecific");
445
 
446
   function pthread_getspecific (key : pthread_key_t) return System.Address;
447
   pragma Import (C, pthread_getspecific, "pthread_getspecific");
448
 
449
   type destructor_pointer is access procedure (arg : System.Address);
450
   pragma Convention (C, destructor_pointer);
451
 
452
   function pthread_key_create
453
     (key        : access pthread_key_t;
454
      destructor : destructor_pointer) return int;
455
   pragma Import (C, pthread_key_create, "pthread_key_create");
456
 
457
   -------------------
458
   -- SGI Additions --
459
   -------------------
460
 
461
   --  Non portable SGI 6.5 additions to the pthread interface must be
462
   --  executed from within the context of a system scope task.
463
 
464
   function pthread_setrunon_np (cpu : int) return int;
465
   pragma Import (C, pthread_setrunon_np, "pthread_setrunon_np");
466
 
467
private
468
 
469
   type array_type_1 is array (Integer range 0 .. 3) of unsigned;
470
   type sigset_t is record
471
      X_X_sigbits : array_type_1;
472
   end record;
473
   pragma Convention (C, sigset_t);
474
 
475
   type pid_t is new long;
476
 
477
   type time_t is new long;
478
 
479
   type timespec is record
480
      tv_sec  : time_t;
481
      tv_nsec : long;
482
   end record;
483
   pragma Convention (C, timespec);
484
 
485
   type array_type_9 is array (Integer range 0 .. 4) of long;
486
   type pthread_attr_t is record
487
      X_X_D : array_type_9;
488
   end record;
489
   pragma Convention (C, pthread_attr_t);
490
 
491
   type array_type_8 is array (Integer range 0 .. 1) of long;
492
   type pthread_condattr_t is record
493
      X_X_D : array_type_8;
494
   end record;
495
   pragma Convention (C, pthread_condattr_t);
496
 
497
   type array_type_7 is array (Integer range 0 .. 1) of long;
498
   type pthread_mutexattr_t is record
499
      X_X_D : array_type_7;
500
   end record;
501
   pragma Convention (C, pthread_mutexattr_t);
502
 
503
   type pthread_t is new unsigned;
504
 
505
   type array_type_10 is array (Integer range 0 .. 7) of long;
506
   type pthread_mutex_t is record
507
      X_X_D : array_type_10;
508
   end record;
509
   pragma Convention (C, pthread_mutex_t);
510
 
511
   type array_type_11 is array (Integer range 0 .. 7) of long;
512
   type pthread_cond_t is record
513
      X_X_D : array_type_11;
514
   end record;
515
   pragma Convention (C, pthread_cond_t);
516
 
517
   type pthread_key_t is new int;
518
 
519
end System.OS_Interface;

powered by: WebSVN 2.1.0

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