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

Subversion Repositories openrisc

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

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

Line No. Rev Author Line
1 706 jeremybenn
------------------------------------------------------------------------------
2
--                                                                          --
3
--                GNU ADA 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-2005,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 GNU/kFreeBSD (GNU/LinuxThreads) version of this package
36
 
37
--  This package encapsulates all direct interfaces to OS services
38
--  that are needed by children of System.
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
with Unchecked_Conversion;
45
 
46
package System.OS_Interface is
47
   pragma Preelaborate;
48
 
49
   pragma Linker_Options ("-lpthread");
50
 
51
   subtype int            is Interfaces.C.int;
52
   subtype char           is Interfaces.C.char;
53
   subtype short          is Interfaces.C.short;
54
   subtype long           is Interfaces.C.long;
55
   subtype unsigned       is Interfaces.C.unsigned;
56
   subtype unsigned_short is Interfaces.C.unsigned_short;
57
   subtype unsigned_long  is Interfaces.C.unsigned_long;
58
   subtype unsigned_char  is Interfaces.C.unsigned_char;
59
   subtype plain_char     is Interfaces.C.plain_char;
60
   subtype size_t         is Interfaces.C.size_t;
61
 
62
   -----------
63
   -- Errno --
64
   -----------
65
 
66
   function errno return int;
67
   pragma Import (C, errno, "__get_errno");
68
 
69
   EAGAIN   : constant := 35;
70
   EINTR    : constant := 4;
71
   EINVAL   : constant := 22;
72
   ENOMEM   : constant := 12;
73
   EPERM    : constant := 1;
74
   ETIMEDOUT    : constant := 60;
75
 
76
   -------------
77
   -- Signals --
78
   -------------
79
 
80
   Max_Interrupt : constant := 128;
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
   SIGURG     : constant := 16; --  urgent condition on IO channel
101
   SIGSTOP    : constant := 17; --  stop (cannot be caught or ignored)
102
   SIGTSTP    : constant := 18; --  user stop requested from tty
103
   SIGCONT    : constant := 19; --  stopped process has been continued
104
   SIGCLD     : constant := 20; --  alias for SIGCHLD
105
   SIGCHLD    : constant := 20; --  child status change
106
   SIGTTIN    : constant := 21; --  background tty read attempted
107
   SIGTTOU    : constant := 22; --  background tty write attempted
108
   SIGIO      : constant := 23; --  I/O possible (Solaris SIGPOLL alias)
109
   SIGXCPU    : constant := 24; --  CPU time limit exceeded
110
   SIGXFSZ    : constant := 25; --  filesize limit exceeded
111
   SIGVTALRM  : constant := 26; --  virtual timer expired
112
   SIGPROF    : constant := 27; --  profiling timer expired
113
   SIGWINCH   : constant := 28; --  window size change
114
   SIGINFO    : constant := 29; --  information request (NetBSD/FreeBSD)
115
   SIGUSR1    : constant := 30; --  user defined signal 1
116
   SIGUSR2    : constant := 31; --  user defined signal 2
117
   SIGLTHRRES : constant := 32; --  GNU/LinuxThreads restart signal
118
   SIGLTHRCAN : constant := 33; --  GNU/LinuxThreads cancel signal
119
   SIGLTHRDBG : constant := 34; --  GNU/LinuxThreads debugger signal
120
 
121
   SIGADAABORT : constant := SIGABRT;
122
   --  Change this if you want to use another signal for task abort.
123
   --  SIGTERM might be a good one.
124
 
125
   type Signal_Set is array (Natural range <>) of Signal;
126
 
127
   Unmasked    : constant Signal_Set := (
128
      SIGTRAP,
129
      --  To enable debugging on multithreaded applications, mark SIGTRAP to
130
      --  be kept unmasked.
131
 
132
      SIGBUS,
133
 
134
      SIGTTIN, SIGTTOU, SIGTSTP,
135
      --  Keep these three signals unmasked so that background processes
136
      --  and IO behaves as normal "C" applications
137
 
138
      SIGPROF,
139
      --  To avoid confusing the profiler
140
 
141
      SIGKILL, SIGSTOP,
142
      --  These two signals actually cannot be masked;
143
      --  POSIX simply won't allow it.
144
 
145
      SIGLTHRRES, SIGLTHRCAN, SIGLTHRDBG);
146
      --  These three signals are used by GNU/LinuxThreads starting from
147
      --  glibc 2.1 (future 2.2).
148
 
149
   Reserved    : constant Signal_Set :=
150
   --  I am not sure why the following signal is reserved.
151
   --  I guess they are not supported by this version of GNU/kFreeBSD.
152
     (0 .. 0 => SIGVTALRM);
153
 
154
   type sigset_t is private;
155
 
156
   function sigaddset (set : access sigset_t; sig : Signal) return int;
157
   pragma Import (C, sigaddset, "sigaddset");
158
 
159
   function sigdelset (set : access sigset_t; sig : Signal) return int;
160
   pragma Import (C, sigdelset, "sigdelset");
161
 
162
   function sigfillset (set : access sigset_t) return int;
163
   pragma Import (C, sigfillset, "sigfillset");
164
 
165
   function sigismember (set : access sigset_t; sig : Signal) return int;
166
   pragma Import (C, sigismember, "sigismember");
167
 
168
   function sigemptyset (set : access sigset_t) return int;
169
   pragma Import (C, sigemptyset, "sigemptyset");
170
 
171
   --  sigcontext is architecture dependent, so define it private
172
   type struct_sigcontext is private;
173
 
174
   type struct_sigaction is record
175
      sa_handler : System.Address;
176
      sa_flags   : int;
177
      sa_mask    : sigset_t;
178
   end record;
179
   pragma Convention (C, struct_sigaction);
180
 
181
   type struct_sigaction_ptr is access all struct_sigaction;
182
 
183
   SIG_BLOCK   : constant := 1;
184
   SIG_UNBLOCK : constant := 2;
185
   SIG_SETMASK : constant := 3;
186
 
187
   SIG_DFL : constant := 0;
188
   SIG_IGN : constant := 1;
189
 
190
   SA_SIGINFO : constant := 16#0040#;
191
   SA_ONSTACK : constant := 16#0001#;
192
 
193
   function sigaction
194
     (sig  : Signal;
195
      act  : struct_sigaction_ptr;
196
      oact : struct_sigaction_ptr) return int;
197
   pragma Import (C, sigaction, "sigaction");
198
 
199
   ----------
200
   -- Time --
201
   ----------
202
 
203
   type timespec is private;
204
 
205
   function To_Duration (TS : timespec) return Duration;
206
   pragma Inline (To_Duration);
207
 
208
   function To_Timespec (D : Duration) return timespec;
209
   pragma Inline (To_Timespec);
210
 
211
   function sysconf (name : int) return long;
212
   pragma Import (C, sysconf);
213
 
214
   SC_CLK_TCK          : constant := 2;
215
   SC_NPROCESSORS_ONLN : constant := 84;
216
 
217
   -------------------------
218
   -- Priority Scheduling --
219
   -------------------------
220
 
221
   SCHED_FIFO  : constant := 1;
222
   SCHED_OTHER : constant := 2;
223
   SCHED_RR    : constant := 3;
224
 
225
   function To_Target_Priority
226
     (Prio : System.Any_Priority) return Interfaces.C.int;
227
   --  Maps System.Any_Priority to a POSIX priority.
228
 
229
   -------------
230
   -- Process --
231
   -------------
232
 
233
   type pid_t is private;
234
 
235
   function kill (pid : pid_t; sig : Signal) return int;
236
   pragma Import (C, kill, "kill");
237
 
238
   function getpid return pid_t;
239
   pragma Import (C, getpid, "getpid");
240
 
241
   -------------
242
   -- Threads --
243
   -------------
244
 
245
   type Thread_Body is access
246
     function (arg : System.Address) return System.Address;
247
   pragma Convention (C, Thread_Body);
248
 
249
   function Thread_Body_Access is new
250
     Unchecked_Conversion (System.Address, Thread_Body);
251
 
252
   type pthread_t is new unsigned_long;
253
   subtype Thread_Id        is pthread_t;
254
 
255
   function To_pthread_t is new Unchecked_Conversion
256
     (unsigned_long, pthread_t);
257
 
258
   type pthread_mutex_t     is limited private;
259
   type pthread_cond_t      is limited private;
260
   type pthread_attr_t      is limited private;
261
   type pthread_mutexattr_t is limited private;
262
   type pthread_condattr_t  is limited private;
263
   type pthread_key_t       is private;
264
 
265
   PTHREAD_CREATE_DETACHED : constant := 1;
266
 
267
   -----------
268
   -- Stack --
269
   -----------
270
 
271
   type stack_t is record
272
      ss_sp    : System.Address;
273
      ss_size  : size_t;
274
      ss_flags : int;
275
   end record;
276
   pragma Convention (C, stack_t);
277
 
278
   function sigaltstack
279
     (ss  : not null access stack_t;
280
      oss : access stack_t) return int;
281
   pragma Import (C, sigaltstack, "sigaltstack");
282
 
283
   Alternate_Stack : aliased System.Address;
284
   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
285
 
286
   Alternate_Stack_Size : constant := 0;
287
   --  No alternate signal stack is used on this platform
288
 
289
   function Get_Stack_Base (thread : pthread_t) return Address;
290
   pragma Inline (Get_Stack_Base);
291
   --  This is a dummy procedure to share some GNULLI files
292
 
293
   ---------------------------------------
294
   -- Nonstandard Thread Initialization --
295
   ---------------------------------------
296
 
297
   procedure pthread_init;
298
   pragma Inline (pthread_init);
299
   --  This is a dummy procedure to share some GNULLI files
300
 
301
   -------------------------
302
   -- POSIX.1c  Section 3 --
303
   -------------------------
304
 
305
   function sigwait (set : access sigset_t; sig : access Signal) return int;
306
   pragma Import (C, sigwait, "sigwait");
307
 
308
   function pthread_kill (thread : pthread_t; sig : Signal) return int;
309
   pragma Import (C, pthread_kill, "pthread_kill");
310
 
311
   function pthread_sigmask
312
     (how  : int;
313
      set  : access sigset_t;
314
      oset : access sigset_t) return int;
315
   pragma Import (C, pthread_sigmask, "pthread_sigmask");
316
 
317
   --------------------------
318
   -- POSIX.1c  Section 11 --
319
   --------------------------
320
 
321
   function pthread_mutexattr_init
322
     (attr : access pthread_mutexattr_t) return int;
323
   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
324
 
325
   function pthread_mutexattr_destroy
326
     (attr : access pthread_mutexattr_t) return int;
327
   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
328
 
329
   function pthread_mutex_init
330
     (mutex : access pthread_mutex_t;
331
      attr  : access pthread_mutexattr_t) return int;
332
   pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
333
 
334
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
335
   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
336
 
337
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
338
   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
339
 
340
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
341
   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
342
 
343
   function pthread_condattr_init
344
     (attr : access pthread_condattr_t) return int;
345
   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
346
 
347
   function pthread_condattr_destroy
348
     (attr : access pthread_condattr_t) return int;
349
   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
350
 
351
   function pthread_cond_init
352
     (cond : access pthread_cond_t;
353
      attr : access pthread_condattr_t) return int;
354
   pragma Import (C, pthread_cond_init, "pthread_cond_init");
355
 
356
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
357
   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
358
 
359
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
360
   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
361
 
362
   function pthread_cond_wait
363
     (cond  : access pthread_cond_t;
364
      mutex : access pthread_mutex_t) return int;
365
   pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
366
 
367
   function pthread_cond_timedwait
368
     (cond    : access pthread_cond_t;
369
      mutex   : access pthread_mutex_t;
370
      abstime : access timespec) return int;
371
   pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
372
 
373
   Relative_Timed_Wait : constant Boolean := False;
374
   --  pthread_cond_timedwait requires an absolute delay time
375
 
376
   --------------------------
377
   -- POSIX.1c  Section 13 --
378
   --------------------------
379
 
380
   type struct_sched_param is record
381
      sched_priority : int;  --  scheduling priority
382
   end record;
383
   pragma Convention (C, struct_sched_param);
384
 
385
   function pthread_setschedparam
386
     (thread : pthread_t;
387
      policy : int;
388
      param  : access struct_sched_param) return int;
389
   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
390
 
391
   function pthread_attr_setschedpolicy
392
     (attr   : access pthread_attr_t;
393
      policy : int) return int;
394
   pragma Import
395
     (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy");
396
 
397
   function sched_yield return int;
398
   pragma Import (C, sched_yield, "sched_yield");
399
 
400
   ---------------------------
401
   -- P1003.1c - Section 16 --
402
   ---------------------------
403
 
404
   function pthread_attr_init
405
     (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
416
     (C, pthread_attr_setdetachstate, "pthread_attr_setdetachstate");
417
 
418
   function pthread_attr_setstacksize
419
     (attr      : access pthread_attr_t;
420
      stacksize : size_t) return int;
421
   pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
422
 
423
   function pthread_create
424
     (thread        : access pthread_t;
425
      attributes    : access pthread_attr_t;
426
      start_routine : Thread_Body;
427
      arg           : System.Address) return int;
428
   pragma Import (C, pthread_create, "pthread_create");
429
 
430
   procedure pthread_exit (status : System.Address);
431
   pragma Import (C, pthread_exit, "pthread_exit");
432
 
433
   function pthread_self return pthread_t;
434
   pragma Import (C, pthread_self, "pthread_self");
435
 
436
   --------------------------
437
   -- POSIX.1c  Section 17 --
438
   --------------------------
439
 
440
   function pthread_setspecific
441
     (key   : pthread_key_t;
442
      value : System.Address) return int;
443
   pragma Import (C, pthread_setspecific, "pthread_setspecific");
444
 
445
   function pthread_getspecific (key : pthread_key_t) return System.Address;
446
   pragma Import (C, pthread_getspecific, "pthread_getspecific");
447
 
448
   type destructor_pointer is access procedure (arg : System.Address);
449
   pragma Convention (C, destructor_pointer);
450
 
451
   function pthread_key_create
452
     (key        : access pthread_key_t;
453
      destructor : destructor_pointer) return int;
454
   pragma Import (C, pthread_key_create, "pthread_key_create");
455
 
456
   CPU_SETSIZE : constant := 1_024;
457
 
458
   type bit_field is array (1 .. CPU_SETSIZE) of Boolean;
459
   for bit_field'Size use CPU_SETSIZE;
460
   pragma Pack (bit_field);
461
   pragma Convention (C, bit_field);
462
 
463
   type cpu_set_t is record
464
      bits : bit_field;
465
   end record;
466
   pragma Convention (C, cpu_set_t);
467
 
468
   function pthread_setaffinity_np
469
     (thread     : pthread_t;
470
      cpusetsize : size_t;
471
      cpuset     : access cpu_set_t) return int;
472
   pragma Import (C, pthread_setaffinity_np, "__gnat_pthread_setaffinity_np");
473
 
474
private
475
 
476
   type sigset_t is array (1 .. 4) of unsigned;
477
 
478
   --  In FreeBSD the component sa_handler turns out to
479
   --  be one a union type, and the selector is a macro:
480
   --  #define sa_handler __sigaction_u._handler
481
   --  #define sa_sigaction __sigaction_u._sigaction
482
 
483
   --  Should we add a signal_context type here ?
484
   --  How could it be done independent of the CPU architecture ?
485
   --  sigcontext type is opaque, so it is architecturally neutral.
486
   --  It is always passed as an access type, so define it as an empty record
487
   --  since the contents are not used anywhere.
488
   type struct_sigcontext is null record;
489
   pragma Convention (C, struct_sigcontext);
490
 
491
   type pid_t is new int;
492
 
493
   type time_t is new long;
494
 
495
   type timespec is record
496
      tv_sec  : time_t;
497
      tv_nsec : long;
498
   end record;
499
   pragma Convention (C, timespec);
500
 
501
   type pthread_attr_t is record
502
      detachstate   : int;
503
      schedpolicy   : int;
504
      schedparam    : struct_sched_param;
505
      inheritsched  : int;
506
      scope         : int;
507
      guardsize     : size_t;
508
      stackaddr_set : int;
509
      stackaddr     : System.Address;
510
      stacksize     : size_t;
511
   end record;
512
   pragma Convention (C, pthread_attr_t);
513
 
514
   type pthread_condattr_t is record
515
      dummy : int;
516
   end record;
517
   pragma Convention (C, pthread_condattr_t);
518
 
519
   type pthread_mutexattr_t is record
520
      mutexkind : int;
521
   end record;
522
   pragma Convention (C, pthread_mutexattr_t);
523
 
524
   type struct_pthread_fast_lock is record
525
      status   : long;
526
      spinlock : int;
527
   end record;
528
   pragma Convention (C, struct_pthread_fast_lock);
529
 
530
   type pthread_mutex_t is record
531
      m_reserved : int;
532
      m_count    : int;
533
      m_owner    : System.Address;
534
      m_kind     : int;
535
      m_lock     : struct_pthread_fast_lock;
536
   end record;
537
   pragma Convention (C, pthread_mutex_t);
538
 
539
   type pthread_cond_t is array (0 .. 47) of unsigned_char;
540
   pragma Convention (C, pthread_cond_t);
541
 
542
   type pthread_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.