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

Subversion Repositories openrisc

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

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 Tru64 version of this package
34
 
35
--  This package encapsulates all direct interfaces to OS services
36
--  that are 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 Interfaces.C;
42
 
43
with Ada.Unchecked_Conversion;
44
 
45
package System.OS_Interface is
46
   pragma Preelaborate;
47
 
48
   pragma Linker_Options ("-lpthread");
49
   pragma Linker_Options ("-lmach");
50
   pragma Linker_Options ("-lexc");
51
   pragma Linker_Options ("-lrt");
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
   subtype char_array     is Interfaces.C.char_array;
63
 
64
   -----------
65
   -- Errno --
66
   -----------
67
 
68
   function errno return int;
69
   pragma Import (C, errno, "_Geterrno");
70
 
71
   EAGAIN    : constant := 35;
72
   EINTR     : constant := 4;
73
   EINVAL    : constant := 22;
74
   ENOMEM    : constant := 12;
75
   ETIMEDOUT : constant := 60;
76
 
77
   -------------
78
   -- Signals --
79
   -------------
80
 
81
   Max_Interrupt : constant := 48;
82
   type Signal is new int range 0 .. Max_Interrupt;
83
   for Signal'Size use int'Size;
84
 
85
   SIGHUP     : constant := 1; --  hangup
86
   SIGINT     : constant := 2; --  interrupt (rubout)
87
   SIGQUIT    : constant := 3; --  quit (ASCD FS)
88
   SIGILL     : constant := 4; --  illegal instruction (not reset)
89
   SIGTRAP    : constant := 5; --  trace trap (not reset)
90
   SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the  future
91
   SIGIOT     : constant := 6; --  abort (terminate) process
92
   SIGLOST    : constant := 6; --  old BSD signal ??
93
   SIGEMT     : constant := 7; --  EMT instruction
94
   SIGFPE     : constant := 8; --  floating point exception
95
   SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
96
   SIGBUS     : constant := 10; --  bus error
97
   SIGSEGV    : constant := 11; --  segmentation violation
98
   SIGSYS     : constant := 12; --  bad argument to system call
99
   SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
100
   SIGALRM    : constant := 14; --  alarm clock
101
   SIGTERM    : constant := 15; --  software termination signal from kill
102
   SIGURG     : constant := 16; --  urgent condition on IO channel
103
   SIGIOINT   : constant := 16; --  printer to backend error signal
104
   SIGSTOP    : constant := 17; --  stop (cannot be caught or ignored)
105
   SIGTSTP    : constant := 18; --  user stop requested from tty
106
   SIGCONT    : constant := 19; --  stopped process has been continued
107
   SIGCHLD    : constant := 20; --  child status change
108
   SIGTTIN    : constant := 21; --  background tty read attempted
109
   SIGTTOU    : constant := 22; --  background tty write attempted
110
   SIGPOLL    : constant := 23; --  I/O possible, or completed
111
   SIGIO      : constant := 23; --  STREAMS version of SIGPOLL
112
   SIGAIO     : constant := 23; --  base lan i/o
113
   SIGPTY     : constant := 23; --  pty i/o
114
   SIGXCPU    : constant := 24; --  CPU time limit exceeded
115
   SIGXFSZ    : constant := 25; --  filesize limit exceeded
116
   SIGVTALRM  : constant := 26; --  virtual timer expired
117
   SIGPROF    : constant := 27; --  profiling timer expired
118
   SIGWINCH   : constant := 28; --  window size change
119
   SIGINFO    : constant := 29; --  information request
120
   SIGPWR     : constant := 29; --  Power Fail/Restart -- SVID3/SVR4
121
   SIGUSR1    : constant := 30; --  user defined signal 1
122
   SIGUSR2    : constant := 31; --  user defined signal 2
123
   SIGRESV    : constant := 32; --  reserved by Digital for future use
124
 
125
   SIGADAABORT : constant := SIGABRT;
126
 
127
   type Signal_Set is array (Natural range <>) of Signal;
128
 
129
   Unmasked    : constant Signal_Set := (0 .. 0 => SIGTRAP);
130
   Reserved    : constant Signal_Set := (SIGALRM, SIGABRT, SIGKILL, SIGSTOP);
131
 
132
   type sigset_t is private;
133
 
134
   function sigaddset (set : access sigset_t; sig : Signal) return int;
135
   pragma Import (C, sigaddset);
136
 
137
   function sigdelset (set : access sigset_t; sig : Signal) return int;
138
   pragma Import (C, sigdelset);
139
 
140
   function sigfillset (set : access sigset_t) return int;
141
   pragma Import (C, sigfillset);
142
 
143
   function sigismember (set : access sigset_t; sig : Signal) return int;
144
   pragma Import (C, sigismember);
145
 
146
   function sigemptyset (set : access sigset_t) return int;
147
   pragma Import (C, sigemptyset);
148
 
149
   type union_type_3 is new String (1 .. 116);
150
   type siginfo_t is record
151
      si_signo     : int;
152
      si_errno     : int;
153
      si_code      : int;
154
      X_data       : union_type_3;
155
   end record;
156
   for siginfo_t'Size use 8 * 128;
157
   pragma Convention (C, siginfo_t);
158
 
159
   type struct_sigaction is record
160
      sa_handler : System.Address;
161
      sa_mask    : sigset_t;
162
      sa_flags   : int;
163
      sa_signo   : int;
164
   end record;
165
   pragma Convention (C, struct_sigaction);
166
   type struct_sigaction_ptr is access all struct_sigaction;
167
 
168
   SIG_BLOCK   : constant := 1;
169
   SIG_UNBLOCK : constant := 2;
170
   SIG_SETMASK : constant := 3;
171
 
172
   SIG_DFL : constant := 0;
173
   SIG_IGN : constant := 1;
174
 
175
   SA_NODEFER : constant := 8;
176
   SA_SIGINFO : constant := 16#40#;
177
   SA_ONSTACK : constant := 16#01#;
178
 
179
   function sigaction
180
     (sig  : Signal;
181
      act  : struct_sigaction_ptr;
182
      oact : struct_sigaction_ptr) return int;
183
   pragma Import (C, sigaction);
184
 
185
   ----------
186
   -- Time --
187
   ----------
188
 
189
   type timespec is private;
190
 
191
   function nanosleep (rqtp, rmtp : access timespec)  return int;
192
   pragma Import (C, nanosleep);
193
 
194
   type clockid_t is new int;
195
 
196
   function clock_gettime
197
     (clock_id : clockid_t;
198
      tp       : access timespec) return int;
199
   pragma Import (C, clock_gettime);
200
 
201
   function To_Duration (TS : timespec) return Duration;
202
   pragma Inline (To_Duration);
203
 
204
   function To_Timespec (D : Duration) return timespec;
205
   pragma Inline (To_Timespec);
206
 
207
   type struct_timezone is record
208
      tz_minuteswest : int;
209
      tz_dsttime     : int;
210
   end record;
211
   pragma Convention (C, struct_timezone);
212
 
213
   -------------------------
214
   -- Priority Scheduling --
215
   -------------------------
216
 
217
   SCHED_FIFO  : constant := 1;
218
   SCHED_RR    : constant := 2;
219
   SCHED_OTHER : constant := 3;
220
   SCHED_LFI   : constant := 5;
221
 
222
   -------------
223
   -- Process --
224
   -------------
225
 
226
   type pid_t is private;
227
 
228
   function kill (pid : pid_t; sig : Signal) return int;
229
   pragma Import (C, kill);
230
 
231
   function getpid return pid_t;
232
   pragma Import (C, getpid);
233
 
234
   BIND_NO_INHERIT  : constant := 1;
235
 
236
   function bind_to_cpu
237
     (pid       : pid_t;
238
      cpu_mask  : unsigned_long;
239
      flag      : unsigned_long := BIND_NO_INHERIT) return int;
240
   pragma Import (C, bind_to_cpu);
241
 
242
   -------------
243
   -- Threads --
244
   -------------
245
 
246
   type Thread_Body is access
247
     function (arg : System.Address) return System.Address;
248
   pragma Convention (C, Thread_Body);
249
 
250
   function Thread_Body_Access is new
251
     Ada.Unchecked_Conversion (System.Address, Thread_Body);
252
 
253
   type pthread_t           is private;
254
   subtype Thread_Id        is pthread_t;
255
 
256
   type pthread_mutex_t     is limited private;
257
   type pthread_cond_t      is limited private;
258
   type pthread_attr_t      is limited private;
259
   type pthread_mutexattr_t is limited private;
260
   type pthread_condattr_t  is limited private;
261
   type pthread_key_t       is private;
262
 
263
   PTHREAD_CREATE_DETACHED : constant := 1;
264
 
265
   PTHREAD_SCOPE_PROCESS : constant := 0;
266
   PTHREAD_SCOPE_SYSTEM  : constant := 1;
267
 
268
   PTHREAD_EXPLICIT_SCHED : constant := 1;
269
 
270
   -----------
271
   -- Stack --
272
   -----------
273
 
274
   Stack_Base_Available : constant Boolean := False;
275
   --  Indicates if the stack base is available on this target
276
 
277
   function Get_Stack_Base (thread : pthread_t) return Address;
278
   pragma Inline (Get_Stack_Base);
279
   --  Returns the stack base of the specified thread. Only call this function
280
   --  when Stack_Base_Available is True.
281
 
282
   function Get_Page_Size return size_t;
283
   function Get_Page_Size return Address;
284
   pragma Import (C, Get_Page_Size, "getpagesize");
285
   --  Returns the size of a page
286
 
287
   PROT_NONE  : constant := 0;
288
   PROT_READ  : constant := 1;
289
   PROT_WRITE : constant := 2;
290
   PROT_EXEC  : constant := 4;
291
   PROT_ALL   : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
292
 
293
   PROT_ON    : constant := PROT_READ;
294
   PROT_OFF   : constant := PROT_ALL;
295
 
296
   function mprotect (addr : Address; len : size_t; prot : int) return int;
297
   pragma Import (C, mprotect);
298
 
299
   procedure Hide_Unhide_Yellow_Zone (Hide : Boolean);
300
   --  Every thread except the initial one features an overflow warning area
301
   --  (called the Yellow Zone) which is just above the overflow guard area
302
   --  on the stack (called the Red Zone). During task execution, we want
303
   --  signals from the Red Zone, so we need to hide the Yellow Zone. This
304
   --  procedure is called at the start of task execution (with Hide set True)
305
   --  to hide the Yellow Zone, and at the end of task execution (with Hide
306
   --  set False) to unhide the Yellow Zone.
307
 
308
   ---------------------------------------
309
   -- Nonstandard Thread Initialization --
310
   ---------------------------------------
311
 
312
   procedure pthread_init;
313
   pragma Inline (pthread_init);
314
   --  This is a dummy procedure to share some GNULLI files
315
 
316
   -------------------------
317
   -- POSIX.1c  Section 3 --
318
   -------------------------
319
 
320
   function sigwait
321
     (set : access sigset_t;
322
      sig : access Signal) return int;
323
   pragma Import (C, sigwait, "__sigwaitd10");
324
 
325
   function pthread_kill
326
     (thread : pthread_t;
327
      sig    : Signal) return int;
328
   pragma Import (C, pthread_kill);
329
 
330
   function pthread_sigmask
331
     (how  : int;
332
      set  : access sigset_t;
333
      oset : access sigset_t) return int;
334
   pragma Import (C, pthread_sigmask);
335
 
336
   --------------------------
337
   -- POSIX.1c  Section 11 --
338
   --------------------------
339
 
340
   function pthread_mutexattr_init (attr : access pthread_mutexattr_t)
341
     return int;
342
   pragma Import (C, pthread_mutexattr_init);
343
 
344
   function pthread_mutexattr_destroy
345
     (attr : access pthread_mutexattr_t) return int;
346
   pragma Import (C, pthread_mutexattr_destroy);
347
 
348
   function pthread_mutex_init
349
     (mutex : access pthread_mutex_t;
350
      attr  : access pthread_mutexattr_t) return int;
351
   pragma Import (C, pthread_mutex_init, "__pthread_mutex_init");
352
 
353
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
354
   pragma Import (C, pthread_mutex_destroy, "__pthread_mutex_destroy");
355
 
356
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
357
   pragma Import (C, pthread_mutex_lock, "__pthread_mutex_lock");
358
 
359
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
360
   pragma Import (C, pthread_mutex_unlock, "__pthread_mutex_unlock");
361
 
362
   function pthread_condattr_init
363
     (attr : access pthread_condattr_t) return int;
364
   pragma Import (C, pthread_condattr_init);
365
 
366
   function pthread_condattr_destroy
367
     (attr : access pthread_condattr_t) return int;
368
   pragma Import (C, pthread_condattr_destroy);
369
 
370
   function pthread_cond_init
371
     (cond : access pthread_cond_t;
372
      attr : access pthread_condattr_t) return int;
373
   pragma Import (C, pthread_cond_init, "__pthread_cond_init");
374
 
375
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
376
   pragma Import (C, pthread_cond_destroy, "__pthread_cond_destroy");
377
 
378
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
379
   pragma Import (C, pthread_cond_signal, "__pthread_cond_signal");
380
 
381
   function pthread_cond_wait
382
     (cond  : access pthread_cond_t;
383
      mutex : access pthread_mutex_t) return  int;
384
   pragma Import (C, pthread_cond_wait, "__pthread_cond_wait");
385
 
386
   function pthread_cond_timedwait
387
     (cond    : access pthread_cond_t;
388
      mutex   : access pthread_mutex_t;
389
      abstime : access timespec) return int;
390
   pragma Import (C, pthread_cond_timedwait, "__pthread_cond_timedwait");
391
 
392
   --------------------------
393
   -- POSIX.1c  Section 13 --
394
   --------------------------
395
 
396
   function pthread_mutexattr_setprotocol
397
     (attr     : access pthread_mutexattr_t;
398
      protocol : int) return int;
399
   pragma Import (C, pthread_mutexattr_setprotocol);
400
 
401
   function pthread_mutexattr_setprioceiling
402
     (attr     : access pthread_mutexattr_t;
403
      prioceiling : int) return int;
404
   pragma Import (C, pthread_mutexattr_setprioceiling);
405
 
406
   type struct_sched_param is record
407
      sched_priority : int;  --  scheduling priority
408
   end record;
409
 
410
   function pthread_setschedparam
411
     (thread : pthread_t;
412
      policy : int;
413
      param  : access struct_sched_param) return int;
414
   pragma Import (C, pthread_setschedparam);
415
 
416
   function pthread_attr_setscope
417
     (attr            : access pthread_attr_t;
418
      contentionscope : int) return int;
419
   pragma Import (C, pthread_attr_setscope);
420
 
421
   function pthread_attr_setinheritsched
422
     (attr            : access pthread_attr_t;
423
      inheritsched    : int) return int;
424
   pragma Import (C, pthread_attr_setinheritsched,
425
     "__pthread_attr_setinheritsched");
426
 
427
   function pthread_attr_setschedpolicy
428
     (attr : access pthread_attr_t; policy : int) return int;
429
   pragma Import (C, pthread_attr_setschedpolicy);
430
 
431
   function pthread_attr_setschedparam
432
     (attr        : access pthread_attr_t;
433
      sched_param : access struct_sched_param) return int;
434
   pragma Import (C, pthread_attr_setschedparam);
435
 
436
   function sched_yield return int;
437
   pragma Import (C, sched_yield);
438
 
439
   --------------------------
440
   -- P1003.1c  Section 16 --
441
   --------------------------
442
 
443
   function pthread_attr_init (attributes : access pthread_attr_t)
444
     return int;
445
   pragma Import (C, pthread_attr_init);
446
 
447
   function pthread_attr_destroy (attributes : access pthread_attr_t)
448
     return int;
449
   pragma Import (C, pthread_attr_destroy);
450
 
451
   function pthread_attr_setdetachstate
452
     (attr        : access pthread_attr_t;
453
      detachstate : int) return int;
454
   pragma Import (C, pthread_attr_setdetachstate);
455
 
456
   function pthread_attr_setstacksize
457
     (attr      : access pthread_attr_t;
458
      stacksize : size_t) return int;
459
   pragma Import (C, pthread_attr_setstacksize, "__pthread_attr_setstacksize");
460
 
461
   function pthread_create
462
     (thread        : access pthread_t;
463
      attributes    : access pthread_attr_t;
464
      start_routine : Thread_Body;
465
      arg           : System.Address) return int;
466
   pragma Import (C, pthread_create, "__pthread_create");
467
 
468
   procedure pthread_exit (status : System.Address);
469
   pragma Import (C, pthread_exit, "__pthread_exit");
470
 
471
   function pthread_self return pthread_t;
472
   pragma Inline (pthread_self);
473
 
474
   --------------------------
475
   -- POSIX.1c  Section 17 --
476
   --------------------------
477
 
478
   function pthread_setspecific
479
     (key : pthread_key_t; value : System.Address) return int;
480
   pragma Import (C, pthread_setspecific, "__pthread_setspecific");
481
 
482
   function pthread_getspecific (key : pthread_key_t) return System.Address;
483
   pragma Import (C, pthread_getspecific, "__pthread_getspecific");
484
 
485
   type destructor_pointer is access procedure (arg : System.Address);
486
   pragma Convention (C, destructor_pointer);
487
 
488
   function pthread_key_create
489
     (key        : access pthread_key_t;
490
      destructor : destructor_pointer) return int;
491
   pragma Import (C, pthread_key_create);
492
 
493
private
494
 
495
   type sigset_t is new unsigned_long;
496
 
497
   type pid_t is new int;
498
 
499
   type time_t is new int;
500
 
501
   type timespec is record
502
      tv_sec  : time_t;
503
      tv_nsec : long;
504
   end record;
505
   pragma Convention (C, timespec);
506
 
507
   type unsigned_long_array is array (Natural range <>) of unsigned_long;
508
 
509
   type pthread_t is new System.Address;
510
 
511
   type pthread_teb_t is record
512
      reserved1     : System.Address;
513
      reserved2     : System.Address;
514
      size          : unsigned_short;
515
      version       : unsigned_char;
516
      reserved3     : unsigned_char;
517
      external      : unsigned_char;
518
      reserved4     : char_array (0 .. 1);
519
      creator       : unsigned_char;
520
      sequence      : unsigned_long;
521
      reserved5     : unsigned_long_array (0 .. 1);
522
      per_kt_area   : System.Address;
523
      stack_base    : System.Address;
524
      stack_reserve : System.Address;
525
      stack_yellow  : System.Address;
526
      stack_guard   : System.Address;
527
      stack_size    : unsigned_long;
528
      tsd_values    : System.Address;
529
      tsd_count     : unsigned_long;
530
      reserved6     : unsigned;
531
      reserved7     : unsigned;
532
      thread_flags  : unsigned;
533
      thd_errno     : int;
534
      stack_hiwater : System.Address;
535
      home_rad      : unsigned_long;
536
   end record;
537
   pragma Convention (C, pthread_teb_t);
538
 
539
   type pthread_cond_t is record
540
      state     : unsigned;
541
      valid     : unsigned;
542
      name      : System.Address;
543
      arg       : unsigned;
544
      reserved1 : unsigned;
545
      sequence  : unsigned_long;
546
      block     : System.Address;
547
   end record;
548
   pragma Convention (C, pthread_cond_t);
549
 
550
   type pthread_attr_t is record
551
      valid    : long;
552
      name     : System.Address;
553
      arg      : unsigned_long;
554
      reserved : unsigned_long_array (0 .. 18);
555
   end record;
556
   pragma Convention (C, pthread_attr_t);
557
 
558
   type pthread_mutex_t is record
559
      lock     : unsigned;
560
      valid    : unsigned;
561
      name     : System.Address;
562
      arg      : unsigned;
563
      depth    : unsigned;
564
      sequence : unsigned_long;
565
      owner    : unsigned_long;
566
      block    : System.Address;
567
   end record;
568
   for pthread_mutex_t'Size use 8 * 48;
569
   pragma Convention (C, pthread_mutex_t);
570
 
571
   type pthread_mutexattr_t is record
572
      valid    : long;
573
      reserved : unsigned_long_array (0 .. 14);
574
   end record;
575
   pragma Convention (C, pthread_mutexattr_t);
576
 
577
   type pthread_condattr_t is record
578
      valid    : long;
579
      reserved : unsigned_long_array (0 .. 12);
580
   end record;
581
   pragma Convention (C, pthread_condattr_t);
582
 
583
   type pthread_key_t is new unsigned;
584
 
585
end System.OS_Interface;

powered by: WebSVN 2.1.0

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