OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

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

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 (native) version of this package
36
 
37
--  This package includes 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 ("-lthread");
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
   EAGAIN    : constant := 11;
71
   EINTR     : constant := 4;
72
   EINVAL    : constant := 22;
73
   ENOMEM    : constant := 12;
74
   ETIME     : constant := 62;
75
   ETIMEDOUT : constant := 145;
76
 
77
   -------------
78
   -- Signals --
79
   -------------
80
 
81
   Max_Interrupt : constant := 45;
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
   SIGIOT     : constant := 6; --  IOT instruction
91
   SIGABRT    : constant := 6; --  used by abort, replace SIGIOT in the  future
92
   SIGEMT     : constant := 7; --  EMT instruction
93
   SIGFPE     : constant := 8; --  floating point exception
94
   SIGKILL    : constant := 9; --  kill (cannot be caught or ignored)
95
   SIGBUS     : constant := 10; --  bus error
96
   SIGSEGV    : constant := 11; --  segmentation violation
97
   SIGSYS     : constant := 12; --  bad argument to system call
98
   SIGPIPE    : constant := 13; --  write on a pipe with no one to read it
99
   SIGALRM    : constant := 14; --  alarm clock
100
   SIGTERM    : constant := 15; --  software termination signal from kill
101
   SIGUSR1    : constant := 16; --  user defined signal 1
102
   SIGUSR2    : constant := 17; --  user defined signal 2
103
   SIGCLD     : constant := 18; --  alias for SIGCHLD
104
   SIGCHLD    : constant := 18; --  child status change
105
   SIGPWR     : constant := 19; --  power-fail restart
106
   SIGWINCH   : constant := 20; --  window size change
107
   SIGURG     : constant := 21; --  urgent condition on IO channel
108
   SIGPOLL    : constant := 22; --  pollable event occurred
109
   SIGIO      : constant := 22; --  I/O possible (Solaris SIGPOLL alias)
110
   SIGSTOP    : constant := 23; --  stop (cannot be caught or ignored)
111
   SIGTSTP    : constant := 24; --  user stop requested from tty
112
   SIGCONT    : constant := 25; --  stopped process has been continued
113
   SIGTTIN    : constant := 26; --  background tty read attempted
114
   SIGTTOU    : constant := 27; --  background tty write attempted
115
   SIGVTALRM  : constant := 28; --  virtual timer expired
116
   SIGPROF    : constant := 29; --  profiling timer expired
117
   SIGXCPU    : constant := 30; --  CPU time limit exceeded
118
   SIGXFSZ    : constant := 31; --  filesize limit exceeded
119
   SIGWAITING : constant := 32; --  process's lwps blocked (Solaris)
120
   SIGLWP     : constant := 33; --  used by thread library (Solaris)
121
   SIGFREEZE  : constant := 34; --  used by CPR (Solaris)
122
   SIGTHAW    : constant := 35; --  used by CPR (Solaris)
123
   SIGCANCEL  : constant := 36; --  thread cancellation signal (libthread)
124
 
125
   type Signal_Set is array (Natural range <>) of Signal;
126
 
127
   Unmasked : constant Signal_Set := (SIGTRAP, SIGLWP, SIGPROF);
128
 
129
   --  Following signals should not be disturbed.
130
   --  See c-posix-signals.c in FLORIST.
131
 
132
   Reserved : constant Signal_Set :=
133
     (SIGKILL, SIGSTOP, SIGWAITING, SIGCANCEL, SIGTRAP, SIGSEGV);
134
 
135
   type sigset_t is private;
136
 
137
   function sigaddset (set : access sigset_t; sig : Signal) return int;
138
   pragma Import (C, sigaddset, "sigaddset");
139
 
140
   function sigdelset (set : access sigset_t; sig : Signal) return int;
141
   pragma Import (C, sigdelset, "sigdelset");
142
 
143
   function sigfillset (set : access sigset_t) return int;
144
   pragma Import (C, sigfillset, "sigfillset");
145
 
146
   function sigismember (set : access sigset_t; sig : Signal) return int;
147
   pragma Import (C, sigismember, "sigismember");
148
 
149
   function sigemptyset (set : access sigset_t) return int;
150
   pragma Import (C, sigemptyset, "sigemptyset");
151
 
152
   type union_type_3 is new String (1 .. 116);
153
   type siginfo_t is record
154
      si_signo     : int;
155
      si_code      : int;
156
      si_errno     : int;
157
      X_data       : union_type_3;
158
   end record;
159
   pragma Convention (C, siginfo_t);
160
 
161
   --  The types mcontext_t and gregset_t are part of the ucontext_t
162
   --  information, which is specific to Solaris2.4 for SPARC
163
   --  The ucontext_t info seems to be used by the handler
164
   --  for SIGSEGV to decide whether it is a Storage_Error (stack overflow) or
165
   --  a Constraint_Error (bad pointer).  The original code that did this
166
   --  is suspect, so it is not clear whether we really need this part of
167
   --  the signal context information, or perhaps something else.
168
   --  More analysis is needed, after which these declarations may need to
169
   --  be changed.
170
 
171
   type greg_t is new int;
172
 
173
   type gregset_t is array (0 .. 18) of greg_t;
174
 
175
   type union_type_2 is new String (1 .. 128);
176
   type record_type_1 is record
177
      fpu_fr       : union_type_2;
178
      fpu_q        : System.Address;
179
      fpu_fsr      : unsigned;
180
      fpu_qcnt     : unsigned_char;
181
      fpu_q_entrysize  : unsigned_char;
182
      fpu_en       : unsigned_char;
183
   end record;
184
   pragma Convention (C, record_type_1);
185
 
186
   type array_type_7 is array (Integer range 0 .. 20) of long;
187
   type mcontext_t is record
188
      gregs        : gregset_t;
189
      gwins        : System.Address;
190
      fpregs       : record_type_1;
191
      filler       : array_type_7;
192
   end record;
193
   pragma Convention (C, mcontext_t);
194
 
195
   type record_type_2 is record
196
      ss_sp        : System.Address;
197
      ss_size      : int;
198
      ss_flags     : int;
199
   end record;
200
   pragma Convention (C, record_type_2);
201
 
202
   type array_type_8 is array (Integer range 0 .. 22) of long;
203
   type ucontext_t is record
204
      uc_flags     : unsigned_long;
205
      uc_link      : System.Address;
206
      uc_sigmask   : sigset_t;
207
      uc_stack     : record_type_2;
208
      uc_mcontext  : mcontext_t;
209
      uc_filler    : array_type_8;
210
   end record;
211
   pragma Convention (C, ucontext_t);
212
 
213
   type Signal_Handler is access procedure
214
     (signo   : Signal;
215
      info    : access siginfo_t;
216
      context : access ucontext_t);
217
 
218
   type union_type_1 is new plain_char;
219
   type array_type_2 is array (Integer range 0 .. 1) of int;
220
   type struct_sigaction is record
221
      sa_flags   : int;
222
      sa_handler : System.Address;
223
      sa_mask    : sigset_t;
224
      sa_resv    : array_type_2;
225
   end record;
226
   pragma Convention (C, struct_sigaction);
227
   type struct_sigaction_ptr is access all struct_sigaction;
228
 
229
   SIG_BLOCK   : constant := 1;
230
   SIG_UNBLOCK : constant := 2;
231
   SIG_SETMASK : constant := 3;
232
 
233
   SIG_DFL : constant := 0;
234
   SIG_IGN : constant := 1;
235
 
236
   function sigaction
237
     (sig  : Signal;
238
      act  : struct_sigaction_ptr;
239
      oact : struct_sigaction_ptr) return int;
240
   pragma Import (C, sigaction, "sigaction");
241
 
242
   ----------
243
   -- Time --
244
   ----------
245
 
246
   type timespec is private;
247
 
248
   type clockid_t is private;
249
 
250
   CLOCK_REALTIME : constant clockid_t;
251
 
252
   function clock_gettime
253
     (clock_id : clockid_t; tp : access timespec) return int;
254
   pragma Import (C, clock_gettime, "clock_gettime");
255
 
256
   function clock_getres
257
     (clock_id : clockid_t; res : access timespec) return int;
258
   pragma Import (C, clock_getres, "clock_getres");
259
 
260
   function To_Duration (TS : timespec) return Duration;
261
   pragma Inline (To_Duration);
262
 
263
   function To_Timespec (D : Duration) return timespec;
264
   pragma Inline (To_Timespec);
265
 
266
   -------------
267
   -- Process --
268
   -------------
269
 
270
   type pid_t is private;
271
 
272
   function kill (pid : pid_t; sig : Signal) return int;
273
   pragma Import (C, kill, "kill");
274
 
275
   function getpid return pid_t;
276
   pragma Import (C, getpid, "getpid");
277
 
278
   -------------
279
   -- Threads --
280
   -------------
281
 
282
   type Thread_Body is access
283
     function (arg : System.Address) return System.Address;
284
   pragma Convention (C, Thread_Body);
285
 
286
   function Thread_Body_Access is new
287
     Ada.Unchecked_Conversion (System.Address, Thread_Body);
288
 
289
   THR_DETACHED  : constant := 64;
290
   THR_BOUND     : constant := 1;
291
   THR_NEW_LWP   : constant := 2;
292
   USYNC_THREAD  : constant := 0;
293
 
294
   type thread_t is new unsigned;
295
   subtype Thread_Id is thread_t;
296
   --  These types should be commented ???
297
 
298
   function To_thread_t is new Ada.Unchecked_Conversion (Integer, thread_t);
299
 
300
   type mutex_t is limited private;
301
 
302
   type cond_t is limited private;
303
 
304
   type thread_key_t is private;
305
 
306
   function thr_create
307
     (stack_base    : System.Address;
308
      stack_size    : size_t;
309
      start_routine : Thread_Body;
310
      arg           : System.Address;
311
      flags         : int;
312
      new_thread    : access thread_t) return int;
313
   pragma Import (C, thr_create, "thr_create");
314
 
315
   function thr_min_stack return size_t;
316
   pragma Import (C, thr_min_stack, "thr_min_stack");
317
 
318
   function thr_self return thread_t;
319
   pragma Import (C, thr_self, "thr_self");
320
 
321
   function mutex_init
322
     (mutex : access mutex_t;
323
      mtype : int;
324
      arg   : System.Address) return int;
325
   pragma Import (C, mutex_init, "mutex_init");
326
 
327
   function mutex_destroy (mutex : access mutex_t) return int;
328
   pragma Import (C, mutex_destroy, "mutex_destroy");
329
 
330
   function mutex_lock (mutex : access mutex_t) return int;
331
   pragma Import (C, mutex_lock, "mutex_lock");
332
 
333
   function mutex_unlock (mutex : access mutex_t) return int;
334
   pragma Import (C, mutex_unlock, "mutex_unlock");
335
 
336
   function cond_init
337
     (cond  : access cond_t;
338
      ctype : int;
339
      arg   : int) return int;
340
   pragma Import (C, cond_init, "cond_init");
341
 
342
   function cond_wait
343
     (cond : access cond_t; mutex : access mutex_t) return int;
344
   pragma Import (C, cond_wait, "cond_wait");
345
 
346
   function cond_timedwait
347
     (cond    : access cond_t;
348
      mutex   : access mutex_t;
349
      abstime : access timespec) return int;
350
   pragma Import (C, cond_timedwait, "cond_timedwait");
351
 
352
   function cond_signal (cond : access cond_t) return int;
353
   pragma Import (C, cond_signal, "cond_signal");
354
 
355
   function cond_destroy (cond : access cond_t) return int;
356
   pragma Import (C, cond_destroy, "cond_destroy");
357
 
358
   function thr_setspecific
359
     (key : thread_key_t; value : System.Address) return int;
360
   pragma Import (C, thr_setspecific, "thr_setspecific");
361
 
362
   function thr_getspecific
363
     (key   : thread_key_t;
364
      value : access System.Address) return int;
365
   pragma Import (C, thr_getspecific, "thr_getspecific");
366
 
367
   function thr_keycreate
368
     (key : access thread_key_t; destructor : System.Address) return int;
369
   pragma Import (C, thr_keycreate, "thr_keycreate");
370
 
371
   function thr_setprio (thread : thread_t; priority : int) return int;
372
   pragma Import (C, thr_setprio, "thr_setprio");
373
 
374
   procedure thr_exit (status : System.Address);
375
   pragma Import (C, thr_exit, "thr_exit");
376
 
377
   function thr_setconcurrency (new_level : int) return int;
378
   pragma Import (C, thr_setconcurrency, "thr_setconcurrency");
379
 
380
   function sigwait (set : access sigset_t; sig : access Signal) return int;
381
   pragma Import (C, sigwait, "__posix_sigwait");
382
 
383
   function thr_kill (thread : thread_t; sig : Signal) return int;
384
   pragma Import (C, thr_kill, "thr_kill");
385
 
386
   function thr_sigsetmask
387
     (how  : int;
388
      set  : access sigset_t;
389
      oset : access sigset_t) return int;
390
   pragma Import (C, thr_sigsetmask, "thr_sigsetmask");
391
 
392
   function pthread_sigmask
393
     (how  : int;
394
      set  : access sigset_t;
395
      oset : access sigset_t) return int;
396
   pragma Import (C, pthread_sigmask, "thr_sigsetmask");
397
 
398
   function thr_suspend (target_thread : thread_t) return int;
399
   pragma Import (C, thr_suspend, "thr_suspend");
400
 
401
   function thr_continue (target_thread : thread_t) return int;
402
   pragma Import (C, thr_continue, "thr_continue");
403
 
404
   procedure thr_yield;
405
   pragma Import (C, thr_yield, "thr_yield");
406
 
407
   ---------
408
   -- LWP --
409
   ---------
410
 
411
   P_PID   : constant := 0;
412
   P_LWPID : constant := 8;
413
 
414
   PC_GETCID    : constant := 0;
415
   PC_GETCLINFO : constant := 1;
416
   PC_SETPARMS  : constant := 2;
417
   PC_GETPARMS  : constant := 3;
418
   PC_ADMIN     : constant := 4;
419
 
420
   PC_CLNULL : constant := -1;
421
 
422
   RT_NOCHANGE : constant := -1;
423
   RT_TQINF    : constant := -2;
424
   RT_TQDEF    : constant := -3;
425
 
426
   PC_CLNMSZ : constant := 16;
427
 
428
   PC_VERSION : constant := 1;
429
 
430
   type lwpid_t is new int;
431
 
432
   type pri_t is new short;
433
 
434
   type id_t is new long;
435
 
436
   P_MYID : constant := -1;
437
   --  The specified LWP or process is the current one
438
 
439
   type struct_pcinfo is record
440
      pc_cid    : id_t;
441
      pc_clname : String (1 .. PC_CLNMSZ);
442
      rt_maxpri : short;
443
   end record;
444
   pragma Convention (C, struct_pcinfo);
445
 
446
   type struct_pcparms is record
447
      pc_cid     : id_t;
448
      rt_pri     : pri_t;
449
      rt_tqsecs  : long;
450
      rt_tqnsecs : long;
451
   end record;
452
   pragma Convention (C, struct_pcparms);
453
 
454
   function priocntl
455
     (ver     : int;
456
      id_type : int;
457
      id      : lwpid_t;
458
      cmd     : int;
459
      arg     : System.Address) return Interfaces.C.long;
460
   pragma Import (C, priocntl, "__priocntl");
461
 
462
   function lwp_self return lwpid_t;
463
   pragma Import (C, lwp_self, "_lwp_self");
464
 
465
   type processorid_t is new int;
466
   type processorid_t_ptr is access all processorid_t;
467
 
468
   --  Constants for function processor_bind
469
 
470
   PBIND_QUERY : constant processorid_t := -2;
471
   --  The processor bindings are not changed
472
 
473
   PBIND_NONE  : constant processorid_t := -1;
474
   --  The processor bindings of the specified LWPs are cleared
475
 
476
   --  Flags for function p_online
477
 
478
   PR_OFFLINE : constant int := 1;
479
   --  Processor is offline, as quiet as possible
480
 
481
   PR_ONLINE  : constant int := 2;
482
   --  Processor online
483
 
484
   PR_STATUS  : constant int := 3;
485
   --  Value passed to p_online to request status
486
 
487
   function p_online (processorid : processorid_t; flag : int) return int;
488
   pragma Import (C, p_online, "p_online");
489
 
490
   function processor_bind
491
     (id_type : int;
492
      id      : id_t;
493
      proc_id : processorid_t;
494
      obind   : processorid_t_ptr) return int;
495
   pragma Import (C, processor_bind, "processor_bind");
496
 
497
   procedure pthread_init;
498
   --  Dummy procedure to share s-intman.adb with other Solaris targets
499
 
500
private
501
 
502
   type array_type_1 is array (0 .. 3) of unsigned_long;
503
   type sigset_t is record
504
      X_X_sigbits : array_type_1;
505
   end record;
506
   pragma Convention (C, sigset_t);
507
 
508
   type pid_t is new long;
509
 
510
   type time_t is new long;
511
 
512
   type timespec is record
513
      tv_sec  : time_t;
514
      tv_nsec : long;
515
   end record;
516
   pragma Convention (C, timespec);
517
 
518
   type clockid_t is new int;
519
   CLOCK_REALTIME : constant clockid_t := 0;
520
 
521
   type array_type_9 is array (0 .. 3) of unsigned_char;
522
   type record_type_3 is record
523
      flag  : array_type_9;
524
      Xtype : unsigned_long;
525
   end record;
526
   pragma Convention (C, record_type_3);
527
 
528
   type mutex_t is record
529
      flags : record_type_3;
530
      lock  : String (1 .. 8);
531
      data  : String (1 .. 8);
532
   end record;
533
   pragma Convention (C, mutex_t);
534
 
535
   type cond_t is record
536
      flag  : array_type_9;
537
      Xtype : unsigned_long;
538
      data  : String (1 .. 8);
539
   end record;
540
   pragma Convention (C, cond_t);
541
 
542
   type thread_key_t is new unsigned;
543
 
544
end System.OS_Interface;

powered by: WebSVN 2.1.0

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