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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [ada/] [s-osinte-solaris-posix.ads] - Blame information for rev 329

Go to most recent revision | 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-2009, 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 a Solaris (POSIX Threads) version of this package
36
 
37
--  This package encapsulates all direct interfaces to OS services
38
--  that are 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 Interfaces.C;
44
 
45
with Ada.Unchecked_Conversion;
46
 
47
package System.OS_Interface is
48
   pragma Preelaborate;
49
 
50
   pragma Linker_Options ("-lposix4");
51
   pragma Linker_Options ("-lpthread");
52
 
53
   --  The following is needed to allow --enable-threads=solaris
54
 
55
   pragma Linker_Options ("-lthread");
56
 
57
   subtype int            is Interfaces.C.int;
58
   subtype short          is Interfaces.C.short;
59
   subtype long           is Interfaces.C.long;
60
   subtype unsigned       is Interfaces.C.unsigned;
61
   subtype unsigned_short is Interfaces.C.unsigned_short;
62
   subtype unsigned_long  is Interfaces.C.unsigned_long;
63
   subtype unsigned_char  is Interfaces.C.unsigned_char;
64
   subtype plain_char     is Interfaces.C.plain_char;
65
   subtype size_t         is Interfaces.C.size_t;
66
 
67
   -----------
68
   -- Errno --
69
   -----------
70
 
71
   function errno return int;
72
   pragma Import (C, errno, "__get_errno");
73
 
74
   EAGAIN    : constant := 11;
75
   EINTR     : constant := 4;
76
   EINVAL    : constant := 22;
77
   ENOMEM    : constant := 12;
78
   ETIMEDOUT : constant := 145;
79
 
80
   -------------
81
   -- Signals --
82
   -------------
83
 
84
   Max_Interrupt : constant := 45;
85
   type Signal is new int range 0 .. Max_Interrupt;
86
   for Signal'Size use int'Size;
87
 
88
   SIGHUP      : constant := 1; --  hangup
89
   SIGINT      : constant := 2; --  interrupt (rubout)
90
   SIGQUIT     : constant := 3; --  quit (ASCD FS)
91
   SIGILL      : constant := 4; --  illegal instruction (not reset)
92
   SIGTRAP     : constant := 5; --  trace trap (not reset)
93
   SIGIOT      : constant := 6; --  IOT instruction
94
   SIGABRT     : constant := 6; --  used by abort, replace SIGIOT in the future
95
   SIGEMT      : constant := 7; --  EMT instruction
96
   SIGFPE      : constant := 8; --  floating point exception
97
   SIGKILL     : constant := 9; --  kill (cannot be caught or ignored)
98
   SIGBUS      : constant := 10; --  bus error
99
   SIGSEGV     : constant := 11; --  segmentation violation
100
   SIGSYS      : constant := 12; --  bad argument to system call
101
   SIGPIPE     : constant := 13; --  write on a pipe with no one to read it
102
   SIGALRM     : constant := 14; --  alarm clock
103
   SIGTERM     : constant := 15; --  software termination signal from kill
104
   SIGUSR1     : constant := 16; --  user defined signal 1
105
   SIGUSR2     : constant := 17; --  user defined signal 2
106
   SIGCLD      : constant := 18; --  alias for SIGCHLD
107
   SIGCHLD     : constant := 18; --  child status change
108
   SIGPWR      : constant := 19; --  power-fail restart
109
   SIGWINCH    : constant := 20; --  window size change
110
   SIGURG      : constant := 21; --  urgent condition on IO channel
111
   SIGPOLL     : constant := 22; --  pollable event occurred
112
   SIGIO       : constant := 22; --  I/O possible (Solaris SIGPOLL alias)
113
   SIGSTOP     : constant := 23; --  stop (cannot be caught or ignored)
114
   SIGTSTP     : constant := 24; --  user stop requested from tty
115
   SIGCONT     : constant := 25; --  stopped process has been continued
116
   SIGTTIN     : constant := 26; --  background tty read attempted
117
   SIGTTOU     : constant := 27; --  background tty write attempted
118
   SIGVTALRM   : constant := 28; --  virtual timer expired
119
   SIGPROF     : constant := 29; --  profiling timer expired
120
   SIGXCPU     : constant := 30; --  CPU time limit exceeded
121
   SIGXFSZ     : constant := 31; --  filesize limit exceeded
122
   SIGWAITING  : constant := 32; --  process's lwps blocked (Solaris)
123
   SIGLWP      : constant := 33; --  used by thread library (Solaris)
124
   SIGFREEZE   : constant := 34; --  used by CPR (Solaris)
125
   SIGTHAW     : constant := 35; --  used by CPR (Solaris)
126
   SIGCANCEL   : constant := 36; --  thread cancellation signal (libthread)
127
 
128
   SIGADAABORT : constant := SIGABRT;
129
 
130
   type Signal_Set is array (Natural range <>) of Signal;
131
 
132
   Unmasked    : constant Signal_Set := (SIGTRAP, SIGLWP, SIGPROF);
133
 
134
   --  Following signals should not be disturbed.
135
   --  See c-posix-signals.c in FLORIST
136
 
137
   Reserved    : constant Signal_Set :=
138
     (SIGKILL, SIGSTOP, SIGWAITING, SIGCANCEL);
139
 
140
   type sigset_t is private;
141
 
142
   function sigaddset (set : access sigset_t; sig : Signal) return int;
143
   pragma Import (C, sigaddset, "sigaddset");
144
 
145
   function sigdelset (set : access sigset_t; sig : Signal) return int;
146
   pragma Import (C, sigdelset, "sigdelset");
147
 
148
   function sigfillset (set : access sigset_t) return int;
149
   pragma Import (C, sigfillset, "sigfillset");
150
 
151
   function sigismember (set : access sigset_t; sig : Signal) return int;
152
   pragma Import (C, sigismember, "sigismember");
153
 
154
   function sigemptyset (set : access sigset_t) return int;
155
   pragma Import (C, sigemptyset, "sigemptyset");
156
 
157
   type struct_sigaction is record
158
      sa_flags   : int;
159
      sa_handler : System.Address;
160
      sa_mask    : sigset_t;
161
      sa_resv1   : int;
162
      sa_resv2   : int;
163
   end record;
164
   pragma Convention (C, struct_sigaction);
165
   type struct_sigaction_ptr is access all struct_sigaction;
166
 
167
   SA_SIGINFO : constant := 16#0008#;
168
   SA_ONSTACK : constant := 16#0001#;
169
 
170
   SIG_BLOCK   : constant := 1;
171
   SIG_UNBLOCK : constant := 2;
172
   SIG_SETMASK : constant := 3;
173
 
174
   SIG_DFL : constant := 0;
175
   SIG_IGN : constant := 1;
176
 
177
   function sigaction
178
     (sig  : Signal;
179
      act  : struct_sigaction_ptr;
180
      oact : struct_sigaction_ptr) return int;
181
   pragma Import (C, sigaction, "sigaction");
182
 
183
   ----------
184
   -- Time --
185
   ----------
186
 
187
   Time_Slice_Supported : constant Boolean := True;
188
   --  Indicates whether time slicing is supported
189
 
190
   type timespec is private;
191
 
192
   type clockid_t is private;
193
 
194
   CLOCK_REALTIME : constant clockid_t;
195
 
196
   function clock_gettime
197
     (clock_id : clockid_t;
198
      tp       : access timespec) return int;
199
   pragma Import (C, clock_gettime, "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
   -------------------------
208
   -- Priority Scheduling --
209
   -------------------------
210
 
211
   SCHED_FIFO  : constant := 1;
212
   SCHED_RR    : constant := 2;
213
   SCHED_OTHER : constant := 0;
214
 
215
   function To_Target_Priority
216
     (Prio : System.Any_Priority) return Interfaces.C.int;
217
   --  Maps System.Any_Priority to a POSIX priority
218
 
219
   -------------
220
   -- Process --
221
   -------------
222
 
223
   type pid_t is private;
224
 
225
   function kill (pid : pid_t; sig : Signal) return int;
226
   pragma Import (C, kill, "kill");
227
 
228
   function getpid return pid_t;
229
   pragma Import (C, getpid, "getpid");
230
 
231
   ---------
232
   -- LWP --
233
   ---------
234
 
235
   function lwp_self return System.Address;
236
   pragma Import (C, lwp_self, "_lwp_self");
237
 
238
   -------------
239
   -- Threads --
240
   -------------
241
 
242
   type Thread_Body is access
243
     function (arg : System.Address) return System.Address;
244
   pragma Convention (C, Thread_Body);
245
 
246
   function Thread_Body_Access is new
247
     Ada.Unchecked_Conversion (System.Address, Thread_Body);
248
 
249
   type pthread_t           is private;
250
   subtype Thread_Id        is pthread_t;
251
 
252
   type pthread_mutex_t     is limited private;
253
   type pthread_cond_t      is limited private;
254
   type pthread_attr_t      is limited private;
255
   type pthread_mutexattr_t is limited private;
256
   type pthread_condattr_t  is limited private;
257
   type pthread_key_t       is private;
258
 
259
   PTHREAD_CREATE_DETACHED : constant := 16#40#;
260
 
261
   PTHREAD_SCOPE_PROCESS : constant := 0;
262
   PTHREAD_SCOPE_SYSTEM  : constant := 1;
263
 
264
   -----------
265
   -- Stack --
266
   -----------
267
 
268
   type stack_t is record
269
      ss_sp    : System.Address;
270
      ss_size  : size_t;
271
      ss_flags : int;
272
   end record;
273
   pragma Convention (C, stack_t);
274
 
275
   function sigaltstack
276
     (ss  : not null access stack_t;
277
      oss : access stack_t) return int;
278
   pragma Import (C, sigaltstack, "sigaltstack");
279
 
280
   Alternate_Stack : aliased System.Address;
281
   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
282
 
283
   Alternate_Stack_Size : constant := 0;
284
   --  No alternate signal stack is used on this platform
285
 
286
   Stack_Base_Available : constant Boolean := False;
287
   --  Indicates whether the stack base is available on this target
288
 
289
   function Get_Stack_Base (thread : pthread_t) return Address;
290
   pragma Inline (Get_Stack_Base);
291
   --  Returns the stack base of the specified thread. Only call this function
292
   --  when Stack_Base_Available is True.
293
 
294
   function Get_Page_Size return size_t;
295
   function Get_Page_Size return Address;
296
   pragma Import (C, Get_Page_Size, "getpagesize");
297
   --  Returns the size of a page
298
 
299
   PROT_NONE  : constant := 0;
300
   PROT_READ  : constant := 1;
301
   PROT_WRITE : constant := 2;
302
   PROT_EXEC  : constant := 4;
303
   PROT_ALL   : constant := PROT_READ + PROT_WRITE + PROT_EXEC;
304
   PROT_ON    : constant := PROT_READ;
305
   PROT_OFF   : constant := PROT_ALL;
306
 
307
   function mprotect (addr : Address; len : size_t; prot : int) return int;
308
   pragma Import (C, mprotect);
309
 
310
   ---------------------------------------
311
   -- Nonstandard Thread Initialization --
312
   ---------------------------------------
313
 
314
   procedure pthread_init;
315
   --  This is a dummy procedure to share some GNULLI files
316
 
317
   -------------------------
318
   -- POSIX.1c  Section 3 --
319
   -------------------------
320
 
321
   function sigwait
322
     (set : access sigset_t;
323
      sig : access Signal) return int;
324
   pragma Import (C, sigwait, "__posix_sigwait");
325
 
326
   function pthread_kill
327
     (thread : pthread_t;
328
      sig    : Signal) return int;
329
   pragma Import (C, pthread_kill, "pthread_kill");
330
 
331
   function pthread_sigmask
332
     (how  : int;
333
      set  : access sigset_t;
334
      oset : access sigset_t) return int;
335
   pragma Import (C, pthread_sigmask, "pthread_sigmask");
336
 
337
   --------------------------
338
   -- POSIX.1c  Section 11 --
339
   --------------------------
340
 
341
   function pthread_mutexattr_init
342
     (attr : access pthread_mutexattr_t) return int;
343
   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
344
 
345
   function pthread_mutexattr_destroy
346
     (attr : access pthread_mutexattr_t) return int;
347
   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
348
 
349
   function pthread_mutex_init
350
     (mutex : access pthread_mutex_t;
351
      attr  : access pthread_mutexattr_t) return int;
352
   pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
353
 
354
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
355
   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
356
 
357
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
358
   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
359
 
360
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
361
   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
362
 
363
   function pthread_condattr_init
364
     (attr : access pthread_condattr_t) return int;
365
   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
366
 
367
   function pthread_condattr_destroy
368
     (attr : access pthread_condattr_t) return int;
369
   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
370
 
371
   function pthread_cond_init
372
     (cond : access pthread_cond_t;
373
      attr : access pthread_condattr_t) return int;
374
   pragma Import (C, pthread_cond_init, "pthread_cond_init");
375
 
376
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
377
   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
378
 
379
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
380
   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
381
 
382
   function pthread_cond_wait
383
     (cond  : access pthread_cond_t;
384
      mutex : access pthread_mutex_t) return int;
385
   pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
386
 
387
   function pthread_cond_timedwait
388
     (cond    : access pthread_cond_t;
389
      mutex   : access pthread_mutex_t;
390
      abstime : access timespec) return int;
391
   pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
392
 
393
   Relative_Timed_Wait : constant Boolean := False;
394
   --  pthread_cond_timedwait requires an absolute delay time
395
 
396
   --------------------------
397
   -- POSIX.1c  Section 13 --
398
   --------------------------
399
 
400
   PTHREAD_PRIO_NONE    : constant := 0;
401
   PTHREAD_PRIO_INHERIT : constant := 16#10#;
402
   PTHREAD_PRIO_PROTECT : constant := 16#20#;
403
 
404
   function pthread_mutexattr_setprotocol
405
     (attr     : access pthread_mutexattr_t;
406
      protocol : int) return int;
407
   pragma Import (C, pthread_mutexattr_setprotocol);
408
 
409
   function pthread_mutexattr_setprioceiling
410
     (attr        : access pthread_mutexattr_t;
411
      prioceiling : int) return int;
412
   pragma Import (C, pthread_mutexattr_setprioceiling);
413
 
414
   type Array_8_Int is array (0 .. 7) of int;
415
   type struct_sched_param is record
416
      sched_priority : int;
417
      sched_pad      : Array_8_Int;
418
   end record;
419
 
420
   function pthread_setschedparam
421
     (thread : pthread_t;
422
      policy : int;
423
      param  : access struct_sched_param) return int;
424
   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
425
 
426
   function pthread_attr_setscope
427
     (attr            : access pthread_attr_t;
428
      contentionscope : int) return int;
429
   pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
430
 
431
   function pthread_attr_setinheritsched
432
     (attr         : access pthread_attr_t;
433
      inheritsched : int) return int;
434
   pragma Import (C, pthread_attr_setinheritsched);
435
 
436
   function pthread_attr_setschedpolicy
437
     (attr   : access pthread_attr_t;
438
      policy : int) return int;
439
   pragma Import (C, pthread_attr_setschedpolicy);
440
 
441
   function sched_yield return int;
442
   pragma Import (C, sched_yield, "sched_yield");
443
 
444
   ---------------------------
445
   -- P1003.1c - Section 16 --
446
   ---------------------------
447
 
448
   function pthread_attr_init (attributes : access pthread_attr_t) return int;
449
   pragma Import (C, pthread_attr_init, "pthread_attr_init");
450
 
451
   function pthread_attr_destroy
452
     (attributes : access pthread_attr_t) return int;
453
   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
454
 
455
   function pthread_attr_setdetachstate
456
     (attr        : access pthread_attr_t;
457
      detachstate : int) return int;
458
   pragma Import (C, pthread_attr_setdetachstate);
459
 
460
   function pthread_attr_setstacksize
461
     (attr      : access pthread_attr_t;
462
      stacksize : size_t) return int;
463
   pragma Import (C, pthread_attr_setstacksize);
464
 
465
   function pthread_create
466
     (thread        : access pthread_t;
467
      attributes    : access pthread_attr_t;
468
      start_routine : Thread_Body;
469
      arg           : System.Address) return int;
470
   pragma Import (C, pthread_create, "pthread_create");
471
 
472
   procedure pthread_exit (status : System.Address);
473
   pragma Import (C, pthread_exit, "pthread_exit");
474
 
475
   function pthread_self return pthread_t;
476
   pragma Import (C, pthread_self, "pthread_self");
477
 
478
   --------------------------
479
   -- POSIX.1c  Section 17 --
480
   --------------------------
481
 
482
   function pthread_setspecific
483
     (key   : pthread_key_t;
484
      value : System.Address) return int;
485
   pragma Import (C, pthread_setspecific, "pthread_setspecific");
486
 
487
   function pthread_getspecific (key : pthread_key_t) return System.Address;
488
   pragma Import (C, pthread_getspecific, "pthread_getspecific");
489
 
490
   type destructor_pointer is access procedure (arg : System.Address);
491
   pragma Convention (C, destructor_pointer);
492
 
493
   function pthread_key_create
494
     (key        : access pthread_key_t;
495
      destructor : destructor_pointer) return int;
496
   pragma Import (C, pthread_key_create, "pthread_key_create");
497
 
498
private
499
 
500
   type array_type_1 is array (Integer range 0 .. 3) of unsigned_long;
501
   type sigset_t is record
502
      X_X_sigbits  : array_type_1;
503
   end record;
504
   pragma Convention (C, sigset_t);
505
 
506
   type pid_t is new long;
507
 
508
   type time_t is new long;
509
 
510
   type timespec is record
511
      tv_sec  : time_t;
512
      tv_nsec : long;
513
   end record;
514
   pragma Convention (C, timespec);
515
 
516
   type clockid_t is new int;
517
   CLOCK_REALTIME : constant clockid_t := 0;
518
 
519
   type pthread_attr_t is record
520
      pthread_attrp : System.Address;
521
   end record;
522
   pragma Convention (C, pthread_attr_t);
523
 
524
   type pthread_condattr_t is record
525
      pthread_condattrp : System.Address;
526
   end record;
527
   pragma Convention (C, pthread_condattr_t);
528
 
529
   type pthread_mutexattr_t is record
530
      pthread_mutexattrp : System.Address;
531
   end record;
532
   pragma Convention (C, pthread_mutexattr_t);
533
 
534
   type pthread_t is new unsigned;
535
 
536
   type uint64_t is mod 2 ** 64;
537
 
538
   type pthread_mutex_t is record
539
      pthread_mutex_flags   : uint64_t;
540
      pthread_mutex_owner64 : uint64_t;
541
      pthread_mutex_data    : uint64_t;
542
   end record;
543
   pragma Convention (C, pthread_mutex_t);
544
   type pthread_mutex_t_ptr is access pthread_mutex_t;
545
 
546
   type pthread_cond_t is record
547
      pthread_cond_flags : uint64_t;
548
      pthread_cond_data  : uint64_t;
549
   end record;
550
   pragma Convention (C, pthread_cond_t);
551
 
552
   type pthread_key_t is new unsigned;
553
 
554
end System.OS_Interface;

powered by: WebSVN 2.1.0

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