1------------------------------------------------------------------------------
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) 1997-2016 Free Software Foundation, Inc.          --
10--                                                                          --
11-- GNARL is free software; you can  redistribute it  and/or modify it under --
12-- terms of the  GNU General Public License as published  by the Free Soft- --
13-- ware  Foundation;  either version 3,  or (at your option) any later ver- --
14-- sion.  GNAT is distributed in the hope that it will be useful, but WITH- --
15-- OUT ANY WARRANTY;  without even the  implied warranty of MERCHANTABILITY --
16-- or FITNESS FOR A PARTICULAR PURPOSE.                                     --
17--                                                                          --
18-- As a special exception under Section 7 of GPL version 3, you are granted --
19-- additional permissions described in the GCC Runtime Library Exception,   --
20-- version 3.1, as published by the Free Software Foundation.               --
21--                                                                          --
22-- You should have received a copy of the GNU General Public License and    --
23-- a copy of the GCC Runtime Library Exception along with this program;     --
24-- see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see    --
25-- <http://www.gnu.org/licenses/>.                                          --
26--                                                                          --
27-- GNARL was developed by the GNARL team at Florida State University.       --
28-- Extensive contributions were provided by Ada Core Technologies Inc.      --
29--                                                                          --
30-- The GNARL files that were developed for RTEMS are maintained by  On-Line --
31-- Applications Research Corporation (http://www.oarcorp.com)  in  coopera- --
32-- tion with Ada Core Technologies Inc. and Florida State University.       --
33--                                                                          --
34------------------------------------------------------------------------------
35
36--  This is the RTEMS version of this package.
37--
38--  RTEMS target names are of the form CPU-rtems.
39--  This implementation is designed to work on ALL RTEMS targets.
40--  The RTEMS implementation is primarily based upon the POSIX threads
41--  API but there are also bindings to GNAT/RTEMS support routines
42--  to insulate this code from C API specific details and, in some
43--  cases, obtain target architecture and BSP specific information
44--  that is unavailable at the time this package is built.
45
46--  This package encapsulates all direct interfaces to OS services
47--  that are needed by children of System.
48
49--  PLEASE DO NOT add any with-clauses to this package
50--  or remove the pragma Preelaborate.
51--  It is designed to be a bottom-level (leaf) package.
52
53with Interfaces.C;
54with System.OS_Constants;
55
56package System.OS_Interface is
57   pragma Preelaborate;
58
59   --  This interface assumes that "unsigned" is a 32-bit entity.  This
60   --  will correspond to RTEMS object ids.
61
62   subtype rtems_id       is Interfaces.C.unsigned;
63
64   subtype int            is Interfaces.C.int;
65   subtype char           is Interfaces.C.char;
66   subtype short          is Interfaces.C.short;
67   subtype long           is Interfaces.C.long;
68   subtype unsigned       is Interfaces.C.unsigned;
69   subtype unsigned_short is Interfaces.C.unsigned_short;
70   subtype unsigned_long  is Interfaces.C.unsigned_long;
71   subtype unsigned_char  is Interfaces.C.unsigned_char;
72   subtype plain_char     is Interfaces.C.plain_char;
73   subtype size_t         is Interfaces.C.size_t;
74   -----------
75   -- Errno --
76   -----------
77
78   function errno return int;
79   pragma Import (C, errno, "__get_errno");
80
81   EAGAIN    : constant := System.OS_Constants.EAGAIN;
82   EINTR     : constant := System.OS_Constants.EINTR;
83   EINVAL    : constant := System.OS_Constants.EINVAL;
84   ENOMEM    : constant := System.OS_Constants.ENOMEM;
85   ETIMEDOUT : constant := System.OS_Constants.ETIMEDOUT;
86
87   -------------
88   -- Signals --
89   -------------
90
91   Num_HW_Interrupts : constant := 256;
92
93   Max_HW_Interrupt : constant := Num_HW_Interrupts - 1;
94   type HW_Interrupt is new int range 0 .. Max_HW_Interrupt;
95
96   Max_Interrupt : constant := Max_HW_Interrupt;
97
98   type Signal is new int range 0 .. Max_Interrupt;
99
100   SIGXCPU     : constant := 0; --  XCPU
101   SIGHUP      : constant := 1; --  hangup
102   SIGINT      : constant := 2; --  interrupt (rubout)
103   SIGQUIT     : constant := 3; --  quit (ASCD FS)
104   SIGILL      : constant := 4; --  illegal instruction (not reset)
105   SIGTRAP     : constant := 5; --  trace trap (not reset)
106   SIGIOT      : constant := 6; --  IOT instruction
107   SIGABRT     : constant := 6; --  used by abort, replace SIGIOT in the future
108   SIGEMT      : constant := 7; --  EMT instruction
109   SIGFPE      : constant := 8; --  floating point exception
110   SIGKILL     : constant := 9; --  kill (cannot be caught or ignored)
111   SIGBUS      : constant := 10; --  bus error
112   SIGSEGV     : constant := 11; --  segmentation violation
113   SIGSYS      : constant := 12; --  bad argument to system call
114   SIGPIPE     : constant := 13; --  write on a pipe with no one to read it
115   SIGALRM     : constant := 14; --  alarm clock
116   SIGTERM     : constant := 15; --  software termination signal from kill
117   SIGUSR1     : constant := 16; --  user defined signal 1
118   SIGUSR2     : constant := 17; --  user defined signal 2
119
120   SIGADAABORT : constant := SIGABRT;
121
122   type Signal_Set is array (Natural range <>) of Signal;
123
124   Unmasked    : constant Signal_Set := (SIGTRAP, SIGALRM, SIGEMT);
125   Reserved    : constant Signal_Set := (1 .. 1 => SIGKILL);
126
127   type sigset_t is private;
128
129   function sigaddset (set : access sigset_t; sig : Signal) return int;
130   pragma Import (C, sigaddset, "sigaddset");
131
132   function sigdelset (set : access sigset_t; sig : Signal) return int;
133   pragma Import (C, sigdelset, "sigdelset");
134
135   function sigfillset (set : access sigset_t) return int;
136   pragma Import (C, sigfillset, "sigfillset");
137
138   function sigismember (set : access sigset_t; sig : Signal) return int;
139   pragma Import (C, sigismember, "sigismember");
140
141   function sigemptyset (set : access sigset_t) return int;
142   pragma Import (C, sigemptyset, "sigemptyset");
143
144   type struct_sigaction is record
145      sa_flags   : int;
146      sa_mask    : sigset_t;
147      sa_handler : System.Address;
148   end record;
149   pragma Convention (C, struct_sigaction);
150   type struct_sigaction_ptr is access all struct_sigaction;
151
152   SA_SIGINFO  : constant := 16#02#;
153
154   SA_ONSTACK : constant := 16#00#;
155   --  SA_ONSTACK is not defined on RTEMS, but it is referred to in the POSIX
156   --  implementation of System.Interrupt_Management. Therefore we define a
157   --  dummy value of zero here so that setting this flag is a nop.
158
159   SIG_BLOCK   : constant := 1;
160   SIG_UNBLOCK : constant := 2;
161   SIG_SETMASK : constant := 3;
162
163   SIG_DFL : constant := 0;
164   SIG_IGN : constant := 1;
165
166   function sigaction
167     (sig  : Signal;
168      act  : struct_sigaction_ptr;
169      oact : struct_sigaction_ptr) return int;
170   pragma Import (C, sigaction, "sigaction");
171
172   ----------
173   -- Time --
174   ----------
175
176   Time_Slice_Supported : constant Boolean := True;
177   --  Indicates whether time slicing is supported (i.e SCHED_RR is supported)
178
179   type timespec is private;
180
181   type clockid_t is new int;
182
183   CLOCK_REALTIME  : constant clockid_t;
184   CLOCK_MONOTONIC : constant clockid_t;
185
186   function clock_gettime
187     (clock_id : clockid_t;
188      tp       : access timespec) return int;
189   pragma Import (C, clock_gettime, "clock_gettime");
190
191   function clock_getres
192     (clock_id : clockid_t;
193      res      : access timespec) return int;
194   pragma Import (C, clock_getres, "clock_getres");
195
196   function To_Duration (TS : timespec) return Duration;
197   pragma Inline (To_Duration);
198
199   function To_Timespec (D : Duration) return timespec;
200   pragma Inline (To_Timespec);
201
202   -------------------------
203   -- Priority Scheduling --
204   -------------------------
205
206   SCHED_FIFO  : constant := 1;
207   SCHED_RR    : constant := 2;
208   SCHED_OTHER : constant := 0;
209
210   function To_Target_Priority
211     (Prio : System.Any_Priority) return Interfaces.C.int;
212   --  Maps System.Any_Priority to a POSIX priority
213
214   -------------
215   -- Process --
216   -------------
217
218   type pid_t is private;
219
220   function kill (pid : pid_t; sig : Signal) return int;
221   pragma Import (C, kill, "kill");
222
223   function getpid return pid_t;
224   pragma Import (C, getpid, "getpid");
225
226   ---------
227   -- LWP --
228   ---------
229
230   function lwp_self return System.Address;
231   --  lwp_self does not exist on this thread library, revert to pthread_self
232   --  which is the closest approximation (with getpid). This function is
233   --  needed to share 7staprop.adb across POSIX-like targets.
234   pragma Import (C, lwp_self, "pthread_self");
235
236   -------------
237   -- Threads --
238   -------------
239
240   type Thread_Body is access
241     function (arg : System.Address) return System.Address;
242   pragma Convention (C, Thread_Body);
243
244   type pthread_t           is private;
245   subtype Thread_Id        is pthread_t;
246
247   type pthread_mutex_t      is limited private;
248   type pthread_rwlock_t     is limited private;
249   type pthread_cond_t       is limited private;
250   type pthread_attr_t       is limited private;
251   type pthread_mutexattr_t  is limited private;
252   type pthread_rwlockattr_t is limited private;
253   type pthread_condattr_t   is limited private;
254   type pthread_key_t        is private;
255
256   No_Key : constant pthread_key_t;
257
258   PTHREAD_CREATE_DETACHED : constant := 0;
259
260   PTHREAD_SCOPE_PROCESS : constant := 0;
261   PTHREAD_SCOPE_SYSTEM  : constant := 1;
262
263   -----------
264   -- Stack --
265   -----------
266
267   type stack_t is record
268      ss_sp    : System.Address;
269      ss_flags : int;
270      ss_size  : size_t;
271   end record;
272   pragma Convention (C, stack_t);
273
274   function sigaltstack
275     (ss  : not null access stack_t;
276      oss : access stack_t) return int;
277
278   Alternate_Stack : aliased System.Address;
279   --  This is a dummy definition, never used (Alternate_Stack_Size is null)
280
281   Alternate_Stack_Size : constant := 0;
282   --  No alternate signal stack is used on this platform
283
284   Stack_Base_Available : constant Boolean := False;
285   --  Indicates whether the stack base is available on this target.
286   --  This allows us to share s-osinte.adb between all the FSU/RTEMS
287   --  run time.
288   --  Note that this value can only be true if pthread_t has a complete
289   --  definition that corresponds exactly to the C header files.
290
291   function Get_Stack_Base (thread : pthread_t) return Address;
292   pragma Inline (Get_Stack_Base);
293   --  returns the stack base of the specified thread.
294   --  Only call this function when Stack_Base_Available is True.
295
296   --  These two functions are only needed to share s-taprop.adb with
297   --  FSU threads.
298
299   function Get_Page_Size return int;
300   pragma Import (C, Get_Page_Size, "getpagesize");
301   --  Returns the size of a page
302
303   PROT_ON  : constant := 0;
304   PROT_OFF : constant := 0;
305
306   function mprotect (addr : Address; len : size_t; prot : int) return int;
307   pragma Import (C, mprotect);
308
309   -----------------------------------------
310   --  Nonstandard Thread Initialization  --
311   -----------------------------------------
312
313   procedure pthread_init;
314   --  FSU_THREADS requires pthread_init, which is nonstandard
315   --  and this should be invoked during the elaboration of s-taprop.adb
316   --
317   --  RTEMS does not require this so we provide an empty Ada body.
318
319   -------------------------
320   -- POSIX.1c  Section 3 --
321   -------------------------
322
323   function sigwait
324     (set : access sigset_t;
325      sig : access Signal) return int;
326   pragma Import (C, sigwait, "sigwait");
327
328   function pthread_kill
329     (thread : pthread_t;
330      sig    : Signal) return int;
331   pragma Import (C, pthread_kill, "pthread_kill");
332
333   function pthread_sigmask
334     (how  : int;
335      set  : access sigset_t;
336      oset : access sigset_t) return int;
337   pragma Import (C, pthread_sigmask, "pthread_sigmask");
338
339   ----------------------------
340   --  POSIX.1c  Section 11  --
341   ----------------------------
342
343   function pthread_mutexattr_init
344     (attr : access pthread_mutexattr_t) return int;
345   pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init");
346
347   function pthread_mutexattr_destroy
348     (attr : access pthread_mutexattr_t) return int;
349   pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy");
350
351   function pthread_mutex_init
352     (mutex : access pthread_mutex_t;
353      attr  : access pthread_mutexattr_t) return int;
354   pragma Import (C, pthread_mutex_init, "pthread_mutex_init");
355
356   function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int;
357   pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy");
358
359   function pthread_mutex_lock (mutex : access pthread_mutex_t) return int;
360   pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock");
361
362   function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int;
363   pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock");
364
365   function pthread_rwlockattr_init
366     (attr : access pthread_rwlockattr_t) return int;
367   pragma Import (C, pthread_rwlockattr_init, "pthread_rwlockattr_init");
368
369   function pthread_rwlockattr_destroy
370     (attr : access pthread_rwlockattr_t) return int;
371   pragma Import (C, pthread_rwlockattr_destroy, "pthread_rwlockattr_destroy");
372
373   PTHREAD_RWLOCK_PREFER_READER_NP              : constant := 0;
374   PTHREAD_RWLOCK_PREFER_WRITER_NP              : constant := 1;
375   PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP : constant := 2;
376
377   function pthread_rwlockattr_setkind_np
378     (attr : access pthread_rwlockattr_t;
379      pref : int) return int;
380
381   function pthread_rwlock_init
382     (mutex : access pthread_rwlock_t;
383      attr  : access pthread_rwlockattr_t) return int;
384   pragma Import (C, pthread_rwlock_init, "pthread_rwlock_init");
385
386   function pthread_rwlock_destroy
387     (mutex : access pthread_rwlock_t) return int;
388   pragma Import (C, pthread_rwlock_destroy, "pthread_rwlock_destroy");
389
390   function pthread_rwlock_rdlock (mutex : access pthread_rwlock_t) return int;
391   pragma Import (C, pthread_rwlock_rdlock, "pthread_rwlock_rdlock");
392
393   function pthread_rwlock_wrlock (mutex : access pthread_rwlock_t) return int;
394   pragma Import (C, pthread_rwlock_wrlock, "pthread_rwlock_wrlock");
395
396   function pthread_rwlock_unlock (mutex : access pthread_rwlock_t) return int;
397   pragma Import (C, pthread_rwlock_unlock, "pthread_rwlock_unlock");
398
399   function pthread_condattr_init
400     (attr : access pthread_condattr_t) return int;
401   pragma Import (C, pthread_condattr_init, "pthread_condattr_init");
402
403   function pthread_condattr_destroy
404     (attr : access pthread_condattr_t) return int;
405   pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy");
406
407   function pthread_cond_init
408     (cond : access pthread_cond_t;
409      attr : access pthread_condattr_t) return int;
410   pragma Import (C, pthread_cond_init, "pthread_cond_init");
411
412   function pthread_cond_destroy (cond : access pthread_cond_t) return int;
413   pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy");
414
415   function pthread_cond_signal (cond : access pthread_cond_t) return int;
416   pragma Import (C, pthread_cond_signal, "pthread_cond_signal");
417
418   function pthread_cond_wait
419     (cond  : access pthread_cond_t;
420      mutex : access pthread_mutex_t) return int;
421   pragma Import (C, pthread_cond_wait, "pthread_cond_wait");
422
423   function pthread_cond_timedwait
424     (cond    : access pthread_cond_t;
425      mutex   : access pthread_mutex_t;
426      abstime : access timespec) return int;
427   pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait");
428
429   Relative_Timed_Wait : constant Boolean := False;
430   --  pthread_cond_timedwait requires an absolute delay time
431
432   --------------------------
433   -- POSIX.1c  Section 13 --
434   --------------------------
435
436   PTHREAD_PRIO_NONE    : constant := 0;
437   PTHREAD_PRIO_PROTECT : constant := 2;
438   PTHREAD_PRIO_INHERIT : constant := 1;
439
440   function pthread_mutexattr_setprotocol
441     (attr     : access pthread_mutexattr_t;
442      protocol : int) return int;
443   pragma Import (C, pthread_mutexattr_setprotocol);
444
445   function pthread_mutexattr_setprioceiling
446     (attr     : access pthread_mutexattr_t;
447      prioceiling : int) return int;
448   pragma Import
449     (C, pthread_mutexattr_setprioceiling,
450      "pthread_mutexattr_setprioceiling");
451
452   type struct_sched_param is record
453      sched_priority      : int;
454      ss_low_priority     : int;
455      ss_replenish_period : timespec;
456      ss_initial_budget   : timespec;
457      sched_ss_max_repl   : int;
458   end record;
459   pragma Convention (C, struct_sched_param);
460
461   function pthread_setschedparam
462     (thread : pthread_t;
463      policy : int;
464      param  : access struct_sched_param) return int;
465   pragma Import (C, pthread_setschedparam, "pthread_setschedparam");
466
467   function pthread_attr_setscope
468     (attr            : access pthread_attr_t;
469      contentionscope : int) return int;
470   pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope");
471
472   function pthread_attr_setinheritsched
473     (attr         : access pthread_attr_t;
474      inheritsched : int) return int;
475   pragma Import (C, pthread_attr_setinheritsched);
476
477   function pthread_attr_setschedpolicy
478     (attr   : access pthread_attr_t;
479      policy : int) return int;
480   pragma Import (C, pthread_attr_setschedpolicy);
481
482   function pthread_attr_setschedparam
483     (attr        : access pthread_attr_t;
484      sched_param : int) return int;
485   pragma Import (C, pthread_attr_setschedparam);
486
487   function sched_yield return int;
488   pragma Import (C, sched_yield, "sched_yield");
489
490   ---------------------------
491   -- P1003.1c - Section 16 --
492   ---------------------------
493
494   function pthread_attr_init (attributes : access pthread_attr_t) return int;
495   pragma Import (C, pthread_attr_init, "pthread_attr_init");
496
497   function pthread_attr_destroy
498     (attributes : access pthread_attr_t) return int;
499   pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy");
500
501   function pthread_attr_setdetachstate
502     (attr        : access pthread_attr_t;
503      detachstate : int) return int;
504   pragma Import (C, pthread_attr_setdetachstate);
505
506   function pthread_attr_setstacksize
507     (attr      : access pthread_attr_t;
508      stacksize : size_t) return int;
509   pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize");
510
511   function pthread_create
512     (thread        : access pthread_t;
513      attributes    : access pthread_attr_t;
514      start_routine : Thread_Body;
515      arg           : System.Address) return int;
516   pragma Import (C, pthread_create, "pthread_create");
517
518   procedure pthread_exit (status : System.Address);
519   pragma Import (C, pthread_exit, "pthread_exit");
520
521   function pthread_self return pthread_t;
522   pragma Import (C, pthread_self, "pthread_self");
523
524   --------------------------
525   -- POSIX.1c  Section 17 --
526   --------------------------
527
528   function pthread_setspecific
529     (key   : pthread_key_t;
530      value : System.Address) return int;
531   pragma Import (C, pthread_setspecific, "pthread_setspecific");
532
533   function pthread_getspecific (key : pthread_key_t) return System.Address;
534   pragma Import (C, pthread_getspecific, "pthread_getspecific");
535
536   type destructor_pointer is access procedure (arg : System.Address);
537   pragma Convention (C, destructor_pointer);
538
539   function pthread_key_create
540     (key        : access pthread_key_t;
541      destructor : destructor_pointer) return int;
542   pragma Import (C, pthread_key_create, "pthread_key_create");
543
544   ------------------------------------------------------------
545   --   Binary Semaphore Wrapper to Support Interrupt Tasks  --
546   ------------------------------------------------------------
547
548   type Binary_Semaphore_Id is new rtems_id;
549
550   function Binary_Semaphore_Create return Binary_Semaphore_Id;
551   pragma Import (
552      C,
553      Binary_Semaphore_Create,
554      "__gnat_binary_semaphore_create");
555
556   function Binary_Semaphore_Delete (ID : Binary_Semaphore_Id) return int;
557   pragma Import (
558      C,
559      Binary_Semaphore_Delete,
560      "__gnat_binary_semaphore_delete");
561
562   function Binary_Semaphore_Obtain (ID : Binary_Semaphore_Id) return int;
563   pragma Import (
564      C,
565      Binary_Semaphore_Obtain,
566      "__gnat_binary_semaphore_obtain");
567
568   function Binary_Semaphore_Release (ID : Binary_Semaphore_Id) return int;
569   pragma Import (
570      C,
571      Binary_Semaphore_Release,
572      "__gnat_binary_semaphore_release");
573
574   function Binary_Semaphore_Flush (ID : Binary_Semaphore_Id) return int;
575   pragma Import (
576      C,
577      Binary_Semaphore_Flush,
578      "__gnat_binary_semaphore_flush");
579
580   ------------------------------------------------------------
581   -- Hardware Interrupt Wrappers to Support Interrupt Tasks --
582   ------------------------------------------------------------
583
584   type Interrupt_Handler is access procedure (parameter : System.Address);
585   pragma Convention (C, Interrupt_Handler);
586   type Interrupt_Vector is new System.Address;
587
588   function Interrupt_Connect
589     (vector    : Interrupt_Vector;
590      handler   : Interrupt_Handler;
591      parameter : System.Address := System.Null_Address) return int;
592   pragma Import (C, Interrupt_Connect, "__gnat_interrupt_connect");
593   --  Use this to set up an user handler. The routine installs a
594   --  a user handler which is invoked after RTEMS has saved enough
595   --  context for a high-level language routine to be safely invoked.
596
597   function Interrupt_Vector_Get
598     (Vector : Interrupt_Vector) return Interrupt_Handler;
599   pragma Import (C, Interrupt_Vector_Get, "__gnat_interrupt_get");
600   --  Use this to get the existing handler for later restoral.
601
602   procedure Interrupt_Vector_Set
603     (Vector  : Interrupt_Vector;
604      Handler : Interrupt_Handler);
605   pragma Import (C, Interrupt_Vector_Set, "__gnat_interrupt_set");
606   --  Use this to restore a handler obtained using Interrupt_Vector_Get.
607
608   function Interrupt_Number_To_Vector (intNum : int) return Interrupt_Vector;
609   --  Convert a logical interrupt number to the hardware interrupt vector
610   --  number used to connect the interrupt.
611   pragma Import (
612      C,
613      Interrupt_Number_To_Vector,
614      "__gnat_interrupt_number_to_vector"
615   );
616
617private
618
619   type sigset_t is new int;
620
621   type pid_t is new int;
622
623   type time_t is new long;
624
625   type timespec is record
626      tv_sec  : time_t;
627      tv_nsec : long;
628   end record;
629   pragma Convention (C, timespec);
630
631   CLOCK_REALTIME :  constant clockid_t := System.OS_Constants.CLOCK_REALTIME;
632   CLOCK_MONOTONIC : constant clockid_t := System.OS_Constants.CLOCK_MONOTONIC;
633
634   subtype char_array is Interfaces.C.char_array;
635
636   type pthread_attr_t is record
637      Data : char_array (1 .. OS_Constants.PTHREAD_ATTR_SIZE);
638   end record;
639   pragma Convention (C, pthread_attr_t);
640   for pthread_attr_t'Alignment use Interfaces.C.double'Alignment;
641
642   type pthread_condattr_t is record
643      Data : char_array (1 .. OS_Constants.PTHREAD_CONDATTR_SIZE);
644   end record;
645   pragma Convention (C, pthread_condattr_t);
646   for pthread_condattr_t'Alignment use Interfaces.C.double'Alignment;
647
648   type pthread_mutexattr_t is record
649      Data : char_array (1 .. OS_Constants.PTHREAD_MUTEXATTR_SIZE);
650   end  record;
651   pragma Convention (C, pthread_mutexattr_t);
652   for pthread_mutexattr_t'Alignment use Interfaces.C.double'Alignment;
653
654   type pthread_rwlockattr_t is record
655      Data : char_array (1 .. OS_Constants.PTHREAD_RWLOCKATTR_SIZE);
656   end record;
657   pragma Convention (C, pthread_rwlockattr_t);
658   for pthread_rwlockattr_t'Alignment use Interfaces.C.double'Alignment;
659
660   type pthread_t is new rtems_id;
661
662   type pthread_mutex_t is new rtems_id;
663
664   type pthread_rwlock_t is new rtems_id;
665
666   type pthread_cond_t is new rtems_id;
667
668   type pthread_key_t is new rtems_id;
669
670   No_Key : constant pthread_key_t := 0;
671
672end System.OS_Interface;
673