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

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc2/] [gcc/] [ada/] [s-osinte-vms.ads] - Blame information for rev 384

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-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 a OpenVMS/Alpha 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
with System.Aux_DEC;
48
 
49
package System.OS_Interface is
50
   pragma Preelaborate;
51
 
52
   pragma Linker_Options ("--for-linker=sys$library:pthread$rtl.exe");
53
   --  Link in the DEC threads library
54
 
55
   --  pragma Linker_Options ("--for-linker=/threads_enable");
56
   --  Enable upcalls and multiple kernel threads.
57
 
58
   subtype int            is Interfaces.C.int;
59
   subtype short          is Interfaces.C.short;
60
   subtype long           is Interfaces.C.long;
61
   subtype unsigned       is Interfaces.C.unsigned;
62
   subtype unsigned_short is Interfaces.C.unsigned_short;
63
   subtype unsigned_long  is Interfaces.C.unsigned_long;
64
   subtype unsigned_char  is Interfaces.C.unsigned_char;
65
   subtype plain_char     is Interfaces.C.plain_char;
66
   subtype size_t         is Interfaces.C.size_t;
67
 
68
   -----------------------------
69
   -- Signals (Interrupt IDs) --
70
   -----------------------------
71
 
72
   --  Type signal has an arbitrary limit of 31
73
 
74
   Max_Interrupt : constant := 31;
75
   type Signal is new unsigned range 0 .. Max_Interrupt;
76
   for Signal'Size use unsigned'Size;
77
 
78
   type sigset_t is array (Signal) of Boolean;
79
   pragma Pack (sigset_t);
80
 
81
   --  Interrupt_Number_Type
82
   --  Unsigned long integer denoting the number of an interrupt
83
 
84
   subtype Interrupt_Number_Type is unsigned_long;
85
 
86
   --  OpenVMS system services return values of type Cond_Value_Type
87
 
88
   subtype Cond_Value_Type is unsigned_long;
89
   subtype Short_Cond_Value_Type is unsigned_short;
90
 
91
   type IO_Status_Block_Type is record
92
      Status   : Short_Cond_Value_Type;
93
      Count    : unsigned_short;
94
      Dev_Info : unsigned_long;
95
   end record;
96
 
97
   type AST_Handler is access procedure (Param : Address);
98
   pragma Convention (C, AST_Handler);
99
   No_AST_Handler : constant AST_Handler := null;
100
 
101
   CMB_M_READONLY  : constant := 16#00000001#;
102
   CMB_M_WRITEONLY : constant := 16#00000002#;
103
   AGN_M_READONLY  : constant := 16#00000001#;
104
   AGN_M_WRITEONLY : constant := 16#00000002#;
105
 
106
   IO_WRITEVBLK : constant := 48;  --  WRITE VIRTUAL BLOCK
107
   IO_READVBLK  : constant := 49;  --  READ VIRTUAL BLOCK
108
 
109
   ----------------
110
   -- Sys_Assign --
111
   ----------------
112
   --
113
   --  Assign I/O Channel
114
   --
115
   --  Status = returned status
116
   --  Devnam = address  of  device  name  or  logical  name   string
117
   --               descriptor
118
   --  Chan   = address of word to receive channel number assigned
119
   --  Acmode = access mode associated with channel
120
   --  Mbxnam = address of mailbox logical name string descriptor, if
121
   --               mailbox associated with device
122
   --  Flags  = optional channel flags longword for specifying options
123
   --           for the $ASSIGN operation
124
   --
125
 
126
   procedure Sys_Assign
127
     (Status : out Cond_Value_Type;
128
      Devnam : String;
129
      Chan   : out unsigned_short;
130
      Acmode : unsigned_short := 0;
131
      Mbxnam : String := String'Null_Parameter;
132
      Flags  : unsigned_long := 0);
133
   pragma Interface (External, Sys_Assign);
134
   pragma Import_Valued_Procedure
135
     (Sys_Assign, "SYS$ASSIGN",
136
      (Cond_Value_Type, String,         unsigned_short,
137
       unsigned_short,  String,         unsigned_long),
138
      (Value,           Descriptor (s), Reference,
139
       Value,           Descriptor (s), Value),
140
      Flags);
141
 
142
   ----------------
143
   -- Sys_Cantim --
144
   ----------------
145
   --
146
   --  Cancel Timer
147
   --
148
   --  Status  = returned status
149
   --  Reqidt  = ID of timer to be cancelled
150
   --  Acmode  = Access mode
151
   --
152
   procedure Sys_Cantim
153
     (Status : out Cond_Value_Type;
154
      Reqidt : Address;
155
      Acmode : unsigned);
156
   pragma Interface (External, Sys_Cantim);
157
   pragma Import_Valued_Procedure
158
     (Sys_Cantim, "SYS$CANTIM",
159
      (Cond_Value_Type, Address, unsigned),
160
      (Value,           Value,   Value));
161
 
162
   ----------------
163
   -- Sys_Crembx --
164
   ----------------
165
   --
166
   --  Create mailbox
167
   --
168
   --     Status  = returned status
169
   --     Prmflg  = permanent flag
170
   --     Chan    = channel
171
   --     Maxmsg  = maximum message
172
   --     Bufquo  = buufer quote
173
   --     Promsk  = protection mast
174
   --     Acmode  = access mode
175
   --     Lognam  = logical name
176
   --     Flags   = flags
177
   --
178
   procedure Sys_Crembx
179
     (Status : out Cond_Value_Type;
180
      Prmflg : unsigned_char;
181
      Chan   : out unsigned_short;
182
      Maxmsg : unsigned_long := 0;
183
      Bufquo : unsigned_long := 0;
184
      Promsk : unsigned_short := 0;
185
      Acmode : unsigned_short := 0;
186
      Lognam : String;
187
      Flags  : unsigned_long := 0);
188
   pragma Interface (External, Sys_Crembx);
189
   pragma Import_Valued_Procedure
190
     (Sys_Crembx, "SYS$CREMBX",
191
      (Cond_Value_Type, unsigned_char,  unsigned_short,
192
       unsigned_long,   unsigned_long,  unsigned_short,
193
       unsigned_short,  String,         unsigned_long),
194
      (Value,           Value,          Reference,
195
       Value,           Value,          Value,
196
       Value,           Descriptor (s), Value));
197
 
198
   -------------
199
   -- Sys_QIO --
200
   -------------
201
   --
202
   --    Queue I/O
203
   --
204
   --     Status = Returned status of call
205
   --     EFN    = event flag to be set when I/O completes
206
   --     Chan   = channel
207
   --     Func   = function
208
   --     Iosb   = I/O status block
209
   --     Astadr = system trap to be generated when I/O completes
210
   --     Astprm = AST parameter
211
   --     P1-6   = optional parameters
212
 
213
   procedure Sys_QIO
214
     (Status : out Cond_Value_Type;
215
      EFN    : unsigned_long := 0;
216
      Chan   : unsigned_short;
217
      Func   : unsigned_long := 0;
218
      Iosb   : out IO_Status_Block_Type;
219
      Astadr : AST_Handler := No_AST_Handler;
220
      Astprm : Address := Null_Address;
221
      P1     : unsigned_long := 0;
222
      P2     : unsigned_long := 0;
223
      P3     : unsigned_long := 0;
224
      P4     : unsigned_long := 0;
225
      P5     : unsigned_long := 0;
226
      P6     : unsigned_long := 0);
227
 
228
   procedure Sys_QIO
229
     (Status : out Cond_Value_Type;
230
      EFN    : unsigned_long := 0;
231
      Chan   : unsigned_short;
232
      Func   : unsigned_long := 0;
233
      Iosb   : Address := Null_Address;
234
      Astadr : AST_Handler := No_AST_Handler;
235
      Astprm : Address := Null_Address;
236
      P1     : unsigned_long := 0;
237
      P2     : unsigned_long := 0;
238
      P3     : unsigned_long := 0;
239
      P4     : unsigned_long := 0;
240
      P5     : unsigned_long := 0;
241
      P6     : unsigned_long := 0);
242
 
243
   pragma Interface (External, Sys_QIO);
244
   pragma Import_Valued_Procedure
245
     (Sys_QIO, "SYS$QIO",
246
      (Cond_Value_Type,      unsigned_long, unsigned_short, unsigned_long,
247
       IO_Status_Block_Type, AST_Handler,   Address,
248
       unsigned_long,        unsigned_long, unsigned_long,
249
       unsigned_long,        unsigned_long, unsigned_long),
250
      (Value,                Value,         Value,          Value,
251
       Reference,            Value,         Value,
252
       Value,                Value,         Value,
253
       Value,                Value,         Value));
254
 
255
   pragma Import_Valued_Procedure
256
     (Sys_QIO, "SYS$QIO",
257
      (Cond_Value_Type, unsigned_long, unsigned_short, unsigned_long,
258
       Address,         AST_Handler,   Address,
259
       unsigned_long,   unsigned_long, unsigned_long,
260
       unsigned_long,   unsigned_long, unsigned_long),
261
      (Value,           Value,         Value,          Value,
262
       Value,           Value,         Value,
263
       Value,           Value,         Value,
264
       Value,           Value,         Value));
265
 
266
   ----------------
267
   -- Sys_Setimr --
268
   ----------------
269
   --
270
   --    Set Timer
271
   --
272
   --     Status = Returned status of call
273
   --     EFN    = event flag to be set when timer expires
274
   --     Tim    = expiration time
275
   --     AST    = system trap to be generated when timer expires
276
   --     Redidt = returned ID of timer (e.g. to cancel timer)
277
   --     Flags  = flags
278
   --
279
   procedure Sys_Setimr
280
     (Status : out Cond_Value_Type;
281
      EFN    : unsigned_long;
282
      Tim    : Long_Integer;
283
      AST    : AST_Handler;
284
      Reqidt : Address;
285
      Flags  : unsigned_long);
286
   pragma Interface (External, Sys_Setimr);
287
   pragma Import_Valued_Procedure
288
     (Sys_Setimr, "SYS$SETIMR",
289
      (Cond_Value_Type, unsigned_long,     Long_Integer,
290
       AST_Handler,     Address,           unsigned_long),
291
      (Value,           Value,             Reference,
292
       Value,           Value,             Value));
293
 
294
   Interrupt_ID_0   : constant  := 0;
295
   Interrupt_ID_1   : constant  := 1;
296
   Interrupt_ID_2   : constant  := 2;
297
   Interrupt_ID_3   : constant  := 3;
298
   Interrupt_ID_4   : constant  := 4;
299
   Interrupt_ID_5   : constant  := 5;
300
   Interrupt_ID_6   : constant  := 6;
301
   Interrupt_ID_7   : constant  := 7;
302
   Interrupt_ID_8   : constant  := 8;
303
   Interrupt_ID_9   : constant  := 9;
304
   Interrupt_ID_10  : constant  := 10;
305
   Interrupt_ID_11  : constant  := 11;
306
   Interrupt_ID_12  : constant  := 12;
307
   Interrupt_ID_13  : constant  := 13;
308
   Interrupt_ID_14  : constant  := 14;
309
   Interrupt_ID_15  : constant  := 15;
310
   Interrupt_ID_16  : constant  := 16;
311
   Interrupt_ID_17  : constant  := 17;
312
   Interrupt_ID_18  : constant  := 18;
313
   Interrupt_ID_19  : constant  := 19;
314
   Interrupt_ID_20  : constant  := 20;
315
   Interrupt_ID_21  : constant  := 21;
316
   Interrupt_ID_22  : constant  := 22;
317
   Interrupt_ID_23  : constant  := 23;
318
   Interrupt_ID_24  : constant  := 24;
319
   Interrupt_ID_25  : constant  := 25;
320
   Interrupt_ID_26  : constant  := 26;
321
   Interrupt_ID_27  : constant  := 27;
322
   Interrupt_ID_28  : constant  := 28;
323
   Interrupt_ID_29  : constant  := 29;
324
   Interrupt_ID_30  : constant  := 30;
325
   Interrupt_ID_31  : constant  := 31;
326
 
327
   -----------
328
   -- Errno --
329
   -----------
330
 
331
   function errno return int;
332
   pragma Import (C, errno, "__get_errno");
333
 
334
   EINTR  : constant := 4;   --  Interrupted system call
335
   EAGAIN : constant := 11;  --  No more processes
336
   ENOMEM : constant := 12;  --  Not enough core
337
 
338
   -------------------------
339
   -- Priority Scheduling --
340
   -------------------------
341
 
342
   SCHED_FIFO  : constant := 1;
343
   SCHED_RR    : constant := 2;
344
   SCHED_OTHER : constant := 3;
345
   SCHED_BG    : constant := 4;
346
   SCHED_LFI   : constant := 5;
347
   SCHED_LRR   : constant := 6;
348
 
349
   -------------
350
   -- Process --
351
   -------------
352
 
353
   type pid_t is private;
354
 
355
   function kill (pid : pid_t; sig : Signal) return int;
356
   pragma Import (C, kill);
357
 
358
   function getpid return pid_t;
359
   pragma Import (C, getpid);
360
 
361
   -------------
362
   -- Threads --
363
   -------------
364
 
365
   type Thread_Body is access
366
     function (arg : System.Address) return System.Address;
367
   pragma Convention (C, Thread_Body);
368
 
369
   function Thread_Body_Access is new
370
     Ada.Unchecked_Conversion (System.Aux_DEC.Short_Address, Thread_Body);
371
 
372
   type pthread_t           is private;
373
   subtype Thread_Id        is pthread_t;
374
 
375
   type pthread_mutex_t     is limited private;
376
   type pthread_cond_t      is limited private;
377
   type pthread_attr_t      is limited private;
378
   type pthread_mutexattr_t is limited private;
379
   type pthread_condattr_t  is limited private;
380
   type pthread_key_t       is private;
381
 
382
   PTHREAD_CREATE_JOINABLE     : constant := 0;
383
   PTHREAD_CREATE_DETACHED     : constant := 1;
384
 
385
   PTHREAD_CANCEL_DISABLE      : constant := 0;
386
   PTHREAD_CANCEL_ENABLE       : constant := 1;
387
 
388
   PTHREAD_CANCEL_DEFERRED     : constant := 0;
389
   PTHREAD_CANCEL_ASYNCHRONOUS : constant := 1;
390
 
391
   --  Don't use ERRORCHECK mutexes, they don't work when a thread is not
392
   --  the owner.  AST's, at least, unlock others threads mutexes. Even
393
   --  if the error is ignored, they don't work.
394
   PTHREAD_MUTEX_NORMAL_NP     : constant := 0;
395
   PTHREAD_MUTEX_RECURSIVE_NP  : constant := 1;
396
   PTHREAD_MUTEX_ERRORCHECK_NP : constant := 2;
397
 
398
   PTHREAD_INHERIT_SCHED       : constant := 0;
399
   PTHREAD_EXPLICIT_SCHED      : constant := 1;
400
 
401
   function pthread_cancel (thread : pthread_t) return int;
402
   pragma Import (C, pthread_cancel, "PTHREAD_CANCEL");
403
 
404
   procedure pthread_testcancel;
405
   pragma Import (C, pthread_testcancel, "PTHREAD_TESTCANCEL");
406
 
407
   function pthread_setcancelstate
408
     (newstate : int; oldstate : access int) return int;
409
   pragma Import (C, pthread_setcancelstate, "PTHREAD_SETCANCELSTATE");
410
 
411
   function pthread_setcanceltype
412
     (newtype : int; oldtype : access int) return int;
413
   pragma Import (C, pthread_setcanceltype, "PTHREAD_SETCANCELTYPE");
414
 
415
   -------------------------
416
   -- POSIX.1c  Section 3 --
417
   -------------------------
418
 
419
   function pthread_lock_global_np return int;
420
   pragma Import (C, pthread_lock_global_np, "PTHREAD_LOCK_GLOBAL_NP");
421
 
422
   function pthread_unlock_global_np return int;
423
   pragma Import (C, pthread_unlock_global_np, "PTHREAD_UNLOCK_GLOBAL_NP");
424
 
425
   --------------------------
426
   -- POSIX.1c  Section 11 --
427
   --------------------------
428
 
429
   function pthread_mutexattr_init
430
     (attr : access pthread_mutexattr_t) return int;
431
   pragma Import (C, pthread_mutexattr_init, "PTHREAD_MUTEXATTR_INIT");
432
 
433
   function pthread_mutexattr_destroy
434
     (attr : access pthread_mutexattr_t) return int;
435
   pragma Import (C, pthread_mutexattr_destroy, "PTHREAD_MUTEXATTR_DESTROY");
436
 
437
   function pthread_mutexattr_settype_np
438
     (attr      : access pthread_mutexattr_t;
439
      mutextype : int) return int;
440
   pragma Import (C, pthread_mutexattr_settype_np,
441
                     "PTHREAD_MUTEXATTR_SETTYPE_NP");
442
 
443
   function pthread_mutex_init
444
     (mutex : access pthread_mutex_t;
445
      attr  : access pthread_mutexattr_t) return int;
446
   pragma Import (C, pthread_mutex_init, "PTHREAD_MUTEX_INIT");
447
 
448
   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
449
   pragma Import (C, pthread_mutex_destroy, "PTHREAD_MUTEX_DESTROY");
450
 
451
   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
452
   pragma Import (C, pthread_mutex_lock, "PTHREAD_MUTEX_LOCK");
453
 
454
   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
455
   pragma Import (C, pthread_mutex_unlock, "PTHREAD_MUTEX_UNLOCK");
456
 
457
   function pthread_condattr_init
458
     (attr : access pthread_condattr_t) return int;
459
   pragma Import (C, pthread_condattr_init, "PTHREAD_CONDATTR_INIT");
460
 
461
   function pthread_condattr_destroy
462
     (attr : access pthread_condattr_t) return int;
463
   pragma Import (C, pthread_condattr_destroy, "PTHREAD_CONDATTR_DESTROY");
464
 
465
   function pthread_cond_init
466
     (cond : access pthread_cond_t;
467
      attr : access pthread_condattr_t) return int;
468
   pragma Import (C, pthread_cond_init, "PTHREAD_COND_INIT");
469
 
470
   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
471
   pragma Import (C, pthread_cond_destroy, "PTHREAD_COND_DESTROY");
472
 
473
   function pthread_cond_signal (cond : access pthread_cond_t) return int;
474
   pragma Import (C, pthread_cond_signal, "PTHREAD_COND_SIGNAL");
475
 
476
   function pthread_cond_signal_int_np
477
     (cond : access pthread_cond_t) return int;
478
   pragma Import (C, pthread_cond_signal_int_np,
479
                  "PTHREAD_COND_SIGNAL_INT_NP");
480
 
481
   function pthread_cond_wait
482
     (cond  : access pthread_cond_t;
483
      mutex : access pthread_mutex_t) return int;
484
   pragma Import (C, pthread_cond_wait, "PTHREAD_COND_WAIT");
485
 
486
   --------------------------
487
   -- POSIX.1c  Section 13 --
488
   --------------------------
489
 
490
   function pthread_mutexattr_setprotocol
491
     (attr : access pthread_mutexattr_t; protocol : int) return int;
492
   pragma Import (C, pthread_mutexattr_setprotocol,
493
                     "PTHREAD_MUTEXATTR_SETPROTOCOL");
494
 
495
   type struct_sched_param is record
496
      sched_priority : int;  --  scheduling priority
497
   end record;
498
   for struct_sched_param'Size use 8*4;
499
   pragma Convention (C, struct_sched_param);
500
 
501
   function pthread_setschedparam
502
     (thread : pthread_t;
503
      policy : int;
504
      param  : access struct_sched_param) return int;
505
   pragma Import (C, pthread_setschedparam, "PTHREAD_SETSCHEDPARAM");
506
 
507
   function pthread_attr_setscope
508
     (attr            : access pthread_attr_t;
509
      contentionscope : int) return int;
510
   pragma Import (C, pthread_attr_setscope, "PTHREAD_ATTR_SETSCOPE");
511
 
512
   function pthread_attr_setinheritsched
513
     (attr            : access pthread_attr_t;
514
      inheritsched : int) return int;
515
   pragma Import (C, pthread_attr_setinheritsched,
516
                     "PTHREAD_ATTR_SETINHERITSCHED");
517
 
518
   function pthread_attr_setschedpolicy
519
     (attr : access pthread_attr_t; policy : int) return int;
520
   pragma Import (C, pthread_attr_setschedpolicy,
521
                     "PTHREAD_ATTR_SETSCHEDPOLICY");
522
 
523
   function pthread_attr_setschedparam
524
     (attr        : access pthread_attr_t;
525
      sched_param : int) return int;
526
   pragma Import (C, pthread_attr_setschedparam, "PTHREAD_ATTR_SETSCHEDPARAM");
527
 
528
   function sched_yield return int;
529
 
530
   --------------------------
531
   -- P1003.1c  Section 16 --
532
   --------------------------
533
 
534
   function pthread_attr_init (attributes : access pthread_attr_t) return int;
535
   pragma Import (C, pthread_attr_init, "PTHREAD_ATTR_INIT");
536
 
537
   function pthread_attr_destroy
538
     (attributes : access pthread_attr_t) return int;
539
   pragma Import (C, pthread_attr_destroy, "PTHREAD_ATTR_DESTROY");
540
 
541
   function pthread_attr_setdetachstate
542
     (attr        : access pthread_attr_t;
543
      detachstate : int) return int;
544
   pragma Import (C, pthread_attr_setdetachstate,
545
                     "PTHREAD_ATTR_SETDETACHSTATE");
546
 
547
   function pthread_attr_setstacksize
548
     (attr      : access pthread_attr_t;
549
      stacksize : size_t) return int;
550
   pragma Import (C, pthread_attr_setstacksize, "PTHREAD_ATTR_SETSTACKSIZE");
551
 
552
   function pthread_create
553
     (thread        : access pthread_t;
554
      attributes    : access pthread_attr_t;
555
      start_routine : Thread_Body;
556
      arg           : System.Address) return int;
557
   pragma Import (C, pthread_create, "PTHREAD_CREATE");
558
 
559
   procedure pthread_exit (status : System.Address);
560
   pragma Import (C, pthread_exit, "PTHREAD_EXIT");
561
 
562
   function pthread_self return pthread_t;
563
 
564
   --------------------------
565
   -- POSIX.1c  Section 17 --
566
   --------------------------
567
 
568
   function pthread_setspecific
569
     (key   : pthread_key_t;
570
      value : System.Address) return  int;
571
   pragma Import (C, pthread_setspecific, "PTHREAD_SETSPECIFIC");
572
 
573
   function pthread_getspecific (key : pthread_key_t) return System.Address;
574
   pragma Import (C, pthread_getspecific, "PTHREAD_GETSPECIFIC");
575
 
576
   type destructor_pointer is access procedure (arg : System.Address);
577
   pragma Convention (C, destructor_pointer);
578
 
579
   function pthread_key_create
580
     (key        : access pthread_key_t;
581
      destructor : destructor_pointer) return int;
582
   pragma Import (C, pthread_key_create, "PTHREAD_KEY_CREATE");
583
 
584
private
585
 
586
   type pid_t is new int;
587
 
588
   type pthreadLongAddr_p is mod 2 ** Long_Integer'Size;
589
 
590
   type pthreadLongAddr_t is mod 2 ** Long_Integer'Size;
591
   type pthreadLongAddr_t_ptr is mod 2 ** Long_Integer'Size;
592
 
593
   type pthreadLongString_t is mod 2 ** Long_Integer'Size;
594
 
595
   type pthreadLongUint_t is mod 2 ** Long_Integer'Size;
596
   type pthreadLongUint_array is array (Natural range <>)
597
     of pthreadLongUint_t;
598
 
599
   type pthread_t is mod 2 ** Long_Integer'Size;
600
 
601
   type pthread_cond_t is record
602
      state    : unsigned;
603
      valid    : unsigned;
604
      name     : pthreadLongString_t;
605
      arg      : unsigned;
606
      sequence : unsigned;
607
      block    : pthreadLongAddr_t_ptr;
608
   end record;
609
   for pthread_cond_t'Size use 8*32;
610
   pragma Convention (C, pthread_cond_t);
611
 
612
   type pthread_attr_t is record
613
      valid    : long;
614
      name     : pthreadLongString_t;
615
      arg      : pthreadLongUint_t;
616
      reserved : pthreadLongUint_array (0 .. 18);
617
   end record;
618
   for pthread_attr_t'Size use 8*176;
619
   pragma Convention (C, pthread_attr_t);
620
 
621
   type pthread_mutex_t is record
622
      lock     : unsigned;
623
      valid    : unsigned;
624
      name     : pthreadLongString_t;
625
      arg      : unsigned;
626
      sequence : unsigned;
627
      block    : pthreadLongAddr_p;
628
      owner    : unsigned;
629
      depth    : unsigned;
630
   end record;
631
   for pthread_mutex_t'Size use 8*40;
632
   pragma Convention (C, pthread_mutex_t);
633
 
634
   type pthread_mutexattr_t is record
635
      valid    : long;
636
      reserved : pthreadLongUint_array (0 .. 14);
637
   end record;
638
   for pthread_mutexattr_t'Size use 8*128;
639
   pragma Convention (C, pthread_mutexattr_t);
640
 
641
   type pthread_condattr_t is record
642
      valid    : long;
643
      reserved : pthreadLongUint_array (0 .. 12);
644
   end record;
645
   for pthread_condattr_t'Size use 8*112;
646
   pragma Convention (C, pthread_condattr_t);
647
 
648
   type pthread_key_t is new unsigned;
649
 
650
   pragma Inline (pthread_self);
651
 
652
end System.OS_Interface;

powered by: WebSVN 2.1.0

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