]>
Commit | Line | Data |
---|---|---|
8d9a1ba7 PMR |
1 | ------------------------------------------------------------------------------ |
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 | -- -- | |
cccef051 | 9 | -- Copyright (C) 1995-2023, Free Software Foundation, Inc. -- |
8d9a1ba7 PMR |
10 | -- -- |
11 | -- GNAT 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 | ------------------------------------------------------------------------------ | |
31 | ||
32 | -- This is a QNX/Neutrino version of this package | |
33 | ||
34 | -- This package encapsulates all direct interfaces to OS services | |
35 | -- that are needed by the tasking run-time (libgnarl). | |
36 | ||
37 | -- PLEASE DO NOT add any with-clauses to this package or remove the pragma | |
38 | -- Preelaborate. This package is designed to be a bottom-level (leaf) package. | |
39 | ||
40 | with Ada.Unchecked_Conversion; | |
41 | with Interfaces.C; | |
42 | with System.OS_Constants; | |
175c2f98 | 43 | with System.Parameters; |
8d9a1ba7 PMR |
44 | |
45 | package System.OS_Interface is | |
46 | pragma Preelaborate; | |
47 | ||
48 | subtype int is Interfaces.C.int; | |
49 | subtype char is Interfaces.C.char; | |
50 | subtype short is Interfaces.C.short; | |
51 | subtype long is Interfaces.C.long; | |
52 | subtype unsigned is Interfaces.C.unsigned; | |
53 | subtype unsigned_short is Interfaces.C.unsigned_short; | |
54 | subtype unsigned_long is Interfaces.C.unsigned_long; | |
55 | subtype unsigned_char is Interfaces.C.unsigned_char; | |
56 | subtype plain_char is Interfaces.C.plain_char; | |
57 | subtype size_t is Interfaces.C.size_t; | |
58 | ||
59 | ----------- | |
60 | -- Errno -- | |
61 | ----------- | |
62 | ||
63 | function errno return int; | |
64 | pragma Import (C, errno, "__get_errno"); | |
65 | ||
66 | EPERM : constant := 1; | |
67 | EINTR : constant := 4; | |
68 | EAGAIN : constant := 11; | |
69 | ENOMEM : constant := 12; | |
70 | EINVAL : constant := 22; | |
71 | ETIMEDOUT : constant := 260; | |
72 | ||
73 | ------------- | |
74 | -- Signals -- | |
75 | ------------- | |
76 | ||
77 | Max_Interrupt : constant := 64; | |
78 | type Signal is new int range 0 .. Max_Interrupt; | |
79 | for Signal'Size use int'Size; | |
80 | ||
81 | SIGHUP : constant := 1; | |
82 | SIGINT : constant := 2; | |
83 | SIGQUIT : constant := 3; | |
84 | SIGILL : constant := 4; | |
85 | SIGTRAP : constant := 5; | |
86 | SIGIOT : constant := 6; | |
87 | SIGABRT : constant := 6; | |
88 | SIGDEADLK : constant := 7; | |
89 | SIGFPE : constant := 8; | |
90 | SIGKILL : constant := 9; | |
91 | SIGBUS : constant := 10; | |
92 | SIGSEGV : constant := 11; | |
93 | SIGSYS : constant := 12; | |
94 | SIGPIPE : constant := 13; | |
95 | SIGALRM : constant := 14; | |
96 | SIGTERM : constant := 15; | |
97 | SIGUSR1 : constant := 16; | |
98 | SIGUSR2 : constant := 17; | |
99 | SIGCLD : constant := 18; | |
100 | SIGCHLD : constant := 18; | |
101 | SIGPWR : constant := 19; | |
102 | SIGWINCH : constant := 20; | |
103 | SIGURG : constant := 21; | |
104 | SIGPOLL : constant := 22; | |
105 | SIGIO : constant := 22; | |
106 | SIGSTOP : constant := 23; | |
107 | SIGTSTP : constant := 24; | |
108 | SIGCONT : constant := 25; | |
109 | SIGTTIN : constant := 26; | |
110 | SIGTTOU : constant := 27; | |
111 | SIGVTALRM : constant := 28; | |
112 | SIGPROF : constant := 29; | |
113 | SIGXCPU : constant := 30; | |
114 | SIGXFSZ : constant := 31; | |
115 | ||
116 | SIGRTMIN : constant := 41; | |
117 | SITRTMAX : constant := 56; | |
118 | ||
119 | SIGSELECT : constant := 57; | |
120 | SIGPHOTON : constant := 58; | |
121 | ||
122 | SIGADAABORT : constant := SIGABRT; | |
123 | -- Change this to use another signal for task abort. SIGTERM might be a | |
124 | -- good one. | |
125 | ||
126 | type Signal_Set is array (Natural range <>) of Signal; | |
127 | ||
128 | Unmasked : constant Signal_Set := ( | |
129 | SIGTRAP, | |
130 | -- To enable debugging on multithreaded applications, mark SIGTRAP to | |
131 | -- be kept unmasked. | |
132 | ||
133 | SIGBUS, | |
134 | ||
135 | SIGTTIN, SIGTTOU, SIGTSTP, | |
136 | -- Keep these three signals unmasked so that background processes and IO | |
137 | -- behaves as normal "C" applications | |
138 | ||
139 | SIGPROF, | |
140 | -- To avoid confusing the profiler | |
141 | ||
142 | SIGKILL, SIGSTOP); | |
143 | -- These two signals actually can't be masked (POSIX won't allow it) | |
144 | ||
3ec54569 | 145 | Reserved : constant Signal_Set := (SIGABRT, SIGKILL, SIGSTOP, SIGSEGV); |
8d9a1ba7 PMR |
146 | |
147 | type sigset_t is private; | |
148 | ||
149 | function sigaddset (set : access sigset_t; sig : Signal) return int; | |
150 | pragma Import (C, sigaddset, "sigaddset"); | |
151 | ||
152 | function sigdelset (set : access sigset_t; sig : Signal) return int; | |
153 | pragma Import (C, sigdelset, "sigdelset"); | |
154 | ||
155 | function sigfillset (set : access sigset_t) return int; | |
156 | pragma Import (C, sigfillset, "sigfillset"); | |
157 | ||
158 | function sigismember (set : access sigset_t; sig : Signal) return int; | |
159 | pragma Import (C, sigismember, "sigismember"); | |
160 | ||
161 | function sigemptyset (set : access sigset_t) return int; | |
162 | pragma Import (C, sigemptyset, "sigemptyset"); | |
163 | ||
3ec54569 | 164 | type pad7 is array (1 .. 7) of int; |
8d9a1ba7 PMR |
165 | type siginfo_t is record |
166 | si_signo : int; | |
167 | si_code : int; | |
168 | si_errno : int; | |
3ec54569 | 169 | X_data : pad7; |
8d9a1ba7 PMR |
170 | end record; |
171 | pragma Convention (C, siginfo_t); | |
172 | ||
173 | type struct_sigaction is record | |
174 | sa_handler : System.Address; | |
3ec54569 | 175 | sa_flags : int; |
8d9a1ba7 PMR |
176 | sa_mask : sigset_t; |
177 | end record; | |
178 | pragma Convention (C, struct_sigaction); | |
179 | ||
180 | type struct_sigaction_ptr is access all struct_sigaction; | |
181 | ||
182 | SIG_BLOCK : constant := 0; | |
183 | SIG_UNBLOCK : constant := 1; | |
184 | SIG_SETMASK : constant := 2; | |
185 | SIG_PENDING : constant := 5; | |
186 | ||
187 | SA_NOCLDSTOP : constant := 16#0001#; | |
188 | SA_SIGINFO : constant := 16#0002#; | |
189 | SA_RESETHAND : constant := 16#0004#; | |
190 | SA_ONSTACK : constant := 16#0008#; | |
191 | SA_NODEFER : constant := 16#0010#; | |
192 | SA_NOCLDWAIT : constant := 16#0020#; | |
193 | ||
194 | SS_ONSTACK : constant := 1; | |
195 | SS_DISABLE : constant := 2; | |
196 | ||
197 | SIG_DFL : constant := 0; | |
198 | SIG_IGN : constant := 1; | |
199 | ||
200 | function sigaction | |
201 | (sig : Signal; | |
202 | act : struct_sigaction_ptr; | |
203 | oact : struct_sigaction_ptr) return int; | |
204 | pragma Import (C, sigaction, "sigaction"); | |
205 | ||
206 | ---------- | |
207 | -- Time -- | |
208 | ---------- | |
209 | ||
210 | Time_Slice_Supported : constant Boolean := True; | |
211 | -- Indicates whether time slicing is supported | |
212 | ||
213 | type timespec is private; | |
214 | ||
215 | type clockid_t is new int; | |
216 | ||
217 | function clock_gettime | |
218 | (clock_id : clockid_t; tp : access timespec) return int; | |
219 | pragma Import (C, clock_gettime, "clock_gettime"); | |
220 | ||
221 | function clock_getres | |
222 | (clock_id : clockid_t; | |
223 | res : access timespec) return int; | |
224 | pragma Import (C, clock_getres, "clock_getres"); | |
225 | ||
226 | function To_Duration (TS : timespec) return Duration; | |
227 | pragma Inline (To_Duration); | |
228 | ||
229 | function To_Timespec (D : Duration) return timespec; | |
230 | pragma Inline (To_Timespec); | |
231 | ||
8d9a1ba7 PMR |
232 | ------------------------- |
233 | -- Priority Scheduling -- | |
234 | ------------------------- | |
235 | ||
8d9a1ba7 PMR |
236 | SCHED_FIFO : constant := 1; |
237 | SCHED_RR : constant := 2; | |
3ec54569 | 238 | SCHED_OTHER : constant := 3; |
8d9a1ba7 PMR |
239 | |
240 | function To_Target_Priority | |
241 | (Prio : System.Any_Priority) return Interfaces.C.int | |
242 | with Inline_Always; | |
243 | -- Maps System.Any_Priority to a POSIX priority | |
244 | ||
245 | ------------- | |
246 | -- Process -- | |
247 | ------------- | |
248 | ||
249 | type pid_t is private; | |
250 | ||
251 | function kill (pid : pid_t; sig : Signal) return int; | |
252 | pragma Import (C, kill, "kill"); | |
253 | ||
254 | function getpid return pid_t; | |
255 | pragma Import (C, getpid, "getpid"); | |
256 | ||
257 | ------------- | |
258 | -- Threads -- | |
259 | ------------- | |
260 | ||
261 | type Thread_Body is access | |
262 | function (arg : System.Address) return System.Address; | |
263 | pragma Convention (C, Thread_Body); | |
264 | ||
265 | function Thread_Body_Access is new | |
266 | Ada.Unchecked_Conversion (System.Address, Thread_Body); | |
267 | ||
3ec54569 | 268 | type pthread_t is new int; |
8d9a1ba7 PMR |
269 | subtype Thread_Id is pthread_t; |
270 | ||
8d9a1ba7 PMR |
271 | type pthread_mutex_t is limited private; |
272 | type pthread_cond_t is limited private; | |
273 | type pthread_attr_t is limited private; | |
274 | type pthread_mutexattr_t is limited private; | |
275 | type pthread_condattr_t is limited private; | |
276 | type pthread_key_t is private; | |
277 | ||
278 | PTHREAD_CREATE_DETACHED : constant := 1; | |
279 | ||
3ec54569 PMR |
280 | PTHREAD_SCOPE_PROCESS : constant := 4; |
281 | PTHREAD_SCOPE_SYSTEM : constant := 0; | |
282 | ||
283 | PTHREAD_INHERIT_SCHED : constant := 0; | |
284 | PTHREAD_EXPLICIT_SCHED : constant := 2; | |
8d9a1ba7 PMR |
285 | |
286 | -- Read/Write lock not supported on Android. | |
287 | ||
288 | subtype pthread_rwlock_t is pthread_mutex_t; | |
289 | subtype pthread_rwlockattr_t is pthread_mutexattr_t; | |
290 | ||
291 | ----------- | |
292 | -- Stack -- | |
293 | ----------- | |
294 | ||
295 | type stack_t is record | |
296 | ss_sp : System.Address; | |
297 | ss_flags : int; | |
298 | ss_size : size_t; | |
299 | end record; | |
300 | pragma Convention (C, stack_t); | |
301 | ||
302 | function sigaltstack | |
303 | (ss : not null access stack_t; | |
3ec54569 | 304 | oss : access stack_t) return int |
3f89eb7f | 305 | with Inline; |
3ec54569 | 306 | -- Not supported on QNX |
8d9a1ba7 PMR |
307 | |
308 | Alternate_Stack : aliased System.Address; | |
309 | -- Dummy definition: alternate stack not available due to missing | |
3ec54569 | 310 | -- sigaltstack in QNX |
8d9a1ba7 PMR |
311 | |
312 | Alternate_Stack_Size : constant := 0; | |
ff7aeceb | 313 | -- This must be kept in sync with init.c:__gnat_alternate_stack |
8d9a1ba7 PMR |
314 | |
315 | Stack_Base_Available : constant Boolean := False; | |
316 | -- Indicates whether the stack base is available on this target | |
317 | ||
318 | function Get_Stack_Base (thread : pthread_t) return System.Address | |
3f89eb7f | 319 | with Inline; |
8d9a1ba7 PMR |
320 | -- This is a dummy procedure to share some GNULLI files |
321 | ||
322 | function Get_Page_Size return int; | |
323 | pragma Import (C, Get_Page_Size, "getpagesize"); | |
324 | -- Returns the size of a page | |
325 | ||
3ec54569 PMR |
326 | PROT_NONE : constant := 16#00_00#; |
327 | PROT_READ : constant := 16#01_00#; | |
328 | PROT_WRITE : constant := 16#02_00#; | |
329 | PROT_EXEC : constant := 16#04_00#; | |
8d9a1ba7 PMR |
330 | PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC; |
331 | PROT_ON : constant := PROT_READ; | |
332 | PROT_OFF : constant := PROT_ALL; | |
333 | ||
334 | function mprotect (addr : Address; len : size_t; prot : int) return int; | |
335 | pragma Import (C, mprotect); | |
336 | ||
337 | --------------------------------------- | |
338 | -- Nonstandard Thread Initialization -- | |
339 | --------------------------------------- | |
340 | ||
341 | procedure pthread_init with Inline_Always; | |
342 | ||
343 | ------------------------- | |
344 | -- POSIX.1c Section 3 -- | |
345 | ------------------------- | |
346 | ||
347 | function sigwait (set : access sigset_t; sig : access Signal) return int; | |
348 | pragma Import (C, sigwait, "sigwait"); | |
349 | ||
350 | function pthread_kill (thread : pthread_t; sig : Signal) return int; | |
351 | pragma Import (C, pthread_kill, "pthread_kill"); | |
352 | ||
353 | function pthread_sigmask | |
354 | (how : int; | |
355 | set : access sigset_t; | |
356 | oset : access sigset_t) return int; | |
3ec54569 | 357 | pragma Import (C, pthread_sigmask, "pthread_sigmask"); |
8d9a1ba7 PMR |
358 | |
359 | -------------------------- | |
360 | -- POSIX.1c Section 11 -- | |
361 | -------------------------- | |
362 | ||
363 | function pthread_mutexattr_init | |
364 | (attr : access pthread_mutexattr_t) return int; | |
365 | pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init"); | |
366 | ||
367 | function pthread_mutexattr_destroy | |
368 | (attr : access pthread_mutexattr_t) return int; | |
369 | pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy"); | |
370 | ||
371 | function pthread_mutex_init | |
372 | (mutex : access pthread_mutex_t; | |
373 | attr : access pthread_mutexattr_t) return int; | |
374 | pragma Import (C, pthread_mutex_init, "pthread_mutex_init"); | |
375 | ||
376 | function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; | |
377 | pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy"); | |
378 | ||
379 | function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; | |
380 | pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock"); | |
381 | ||
382 | function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; | |
383 | pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock"); | |
384 | ||
3ec54569 PMR |
385 | function pthread_mutex_setprioceiling |
386 | (mutex : access pthread_mutex_t; | |
387 | prioceiling : int; | |
388 | old_ceiling : access int) return int; | |
389 | pragma Import (C, pthread_mutex_setprioceiling); | |
390 | ||
8d9a1ba7 PMR |
391 | function pthread_condattr_init |
392 | (attr : access pthread_condattr_t) return int; | |
393 | pragma Import (C, pthread_condattr_init, "pthread_condattr_init"); | |
394 | ||
395 | function pthread_condattr_destroy | |
396 | (attr : access pthread_condattr_t) return int; | |
397 | pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy"); | |
398 | ||
399 | function pthread_cond_init | |
400 | (cond : access pthread_cond_t; | |
401 | attr : access pthread_condattr_t) return int; | |
402 | pragma Import (C, pthread_cond_init, "pthread_cond_init"); | |
403 | ||
404 | function pthread_cond_destroy (cond : access pthread_cond_t) return int; | |
405 | pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy"); | |
406 | ||
407 | function pthread_cond_signal (cond : access pthread_cond_t) return int; | |
408 | pragma Import (C, pthread_cond_signal, "pthread_cond_signal"); | |
409 | ||
410 | function pthread_cond_wait | |
411 | (cond : access pthread_cond_t; | |
412 | mutex : access pthread_mutex_t) return int; | |
413 | pragma Import (C, pthread_cond_wait, "pthread_cond_wait"); | |
414 | ||
415 | function pthread_cond_timedwait | |
416 | (cond : access pthread_cond_t; | |
417 | mutex : access pthread_mutex_t; | |
418 | abstime : access timespec) return int; | |
419 | pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); | |
420 | ||
8d9a1ba7 PMR |
421 | -------------------------- |
422 | -- POSIX.1c Section 13 -- | |
423 | -------------------------- | |
424 | ||
d0567dc0 PMR |
425 | PTHREAD_PRIO_INHERIT : constant := 0; |
426 | PTHREAD_PRIO_NONE : constant := 1; | |
427 | PTHREAD_PRIO_PROTECT : constant := 2; | |
8d9a1ba7 PMR |
428 | |
429 | function pthread_mutexattr_setprotocol | |
430 | (attr : access pthread_mutexattr_t; | |
3ec54569 PMR |
431 | protocol : int) return int; |
432 | pragma Import (C, pthread_mutexattr_setprotocol); | |
433 | ||
434 | function pthread_mutexattr_getprotocol | |
435 | (attr : access pthread_mutexattr_t; | |
436 | protocol : access int) return int; | |
437 | pragma Import (C, pthread_mutexattr_getprotocol); | |
8d9a1ba7 PMR |
438 | |
439 | function pthread_mutexattr_setprioceiling | |
440 | (attr : access pthread_mutexattr_t; | |
3ec54569 PMR |
441 | prioceiling : int) return int; |
442 | pragma Import (C, pthread_mutexattr_setprioceiling); | |
443 | ||
444 | function pthread_mutexattr_getprioceiling | |
445 | (attr : access pthread_mutexattr_t; | |
446 | prioceiling : access int) return int; | |
447 | pragma Import (C, pthread_mutexattr_getprioceiling); | |
448 | ||
449 | function pthread_mutex_getprioceiling | |
450 | (attr : access pthread_mutex_t; | |
451 | prioceiling : access int) return int; | |
452 | pragma Import (C, pthread_mutex_getprioceiling); | |
453 | ||
454 | type pad8 is array (1 .. 8) of int; | |
455 | pragma Convention (C, pad8); | |
8d9a1ba7 PMR |
456 | |
457 | type struct_sched_param is record | |
3ec54569 PMR |
458 | sched_priority : int := 0; -- scheduling priority |
459 | sched_curpriority : int := 0; | |
460 | reserved : pad8 := (others => 0); | |
8d9a1ba7 PMR |
461 | end record; |
462 | pragma Convention (C, struct_sched_param); | |
463 | ||
464 | function pthread_setschedparam | |
465 | (thread : pthread_t; | |
466 | policy : int; | |
467 | param : access struct_sched_param) return int; | |
468 | pragma Import (C, pthread_setschedparam, "pthread_setschedparam"); | |
469 | ||
3ec54569 PMR |
470 | function pthread_getschedparam |
471 | (thread : pthread_t; | |
472 | policy : access int; | |
473 | param : access struct_sched_param) return int; | |
474 | pragma Import (C, pthread_getschedparam, "pthread_getschedparam"); | |
475 | ||
476 | function pthread_setschedprio | |
477 | (thread : pthread_t; | |
478 | priority : int) return int; | |
479 | pragma Import (C, pthread_setschedprio); | |
480 | ||
481 | function pthread_attr_setschedparam | |
482 | (attr : access pthread_attr_t; | |
483 | param : access struct_sched_param) return int; | |
484 | pragma Import (C, pthread_attr_setschedparam); | |
485 | ||
486 | function pthread_attr_setinheritsched | |
487 | (attr : access pthread_attr_t; | |
488 | inheritsched : int) return int; | |
489 | pragma Import (C, pthread_attr_setinheritsched); | |
490 | ||
8d9a1ba7 PMR |
491 | function pthread_attr_setscope |
492 | (attr : access pthread_attr_t; | |
493 | scope : int) return int; | |
494 | pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope"); | |
495 | ||
496 | function pthread_attr_setschedpolicy | |
497 | (attr : access pthread_attr_t; | |
498 | policy : int) return int; | |
499 | pragma Import | |
500 | (C, pthread_attr_setschedpolicy, "pthread_attr_setschedpolicy"); | |
501 | ||
502 | function sched_yield return int; | |
503 | pragma Import (C, sched_yield, "sched_yield"); | |
504 | ||
505 | --------------------------- | |
506 | -- P1003.1c - Section 16 -- | |
507 | --------------------------- | |
508 | ||
509 | function pthread_attr_init | |
510 | (attributes : access pthread_attr_t) return int; | |
511 | pragma Import (C, pthread_attr_init, "pthread_attr_init"); | |
512 | ||
513 | function pthread_attr_destroy | |
514 | (attributes : access pthread_attr_t) return int; | |
515 | pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy"); | |
516 | ||
517 | function pthread_attr_setdetachstate | |
518 | (attr : access pthread_attr_t; | |
519 | detachstate : int) return int; | |
3ec54569 | 520 | pragma Import (C, pthread_attr_setdetachstate); |
8d9a1ba7 PMR |
521 | |
522 | function pthread_attr_setstacksize | |
523 | (attr : access pthread_attr_t; | |
524 | stacksize : size_t) return int; | |
3ec54569 | 525 | pragma Import (C, pthread_attr_setstacksize); |
8d9a1ba7 PMR |
526 | |
527 | function pthread_create | |
528 | (thread : access pthread_t; | |
529 | attributes : access pthread_attr_t; | |
530 | start_routine : Thread_Body; | |
531 | arg : System.Address) return int; | |
532 | pragma Import (C, pthread_create, "pthread_create"); | |
533 | ||
534 | procedure pthread_exit (status : System.Address); | |
535 | pragma Import (C, pthread_exit, "pthread_exit"); | |
536 | ||
537 | function pthread_self return pthread_t; | |
538 | pragma Import (C, pthread_self, "pthread_self"); | |
539 | ||
540 | function lwp_self return System.Address; | |
541 | pragma Import (C, lwp_self, "pthread_self"); | |
542 | ||
543 | -------------------------- | |
544 | -- POSIX.1c Section 17 -- | |
545 | -------------------------- | |
546 | ||
547 | function pthread_setspecific | |
548 | (key : pthread_key_t; | |
549 | value : System.Address) return int; | |
550 | pragma Import (C, pthread_setspecific, "pthread_setspecific"); | |
551 | ||
552 | function pthread_getspecific (key : pthread_key_t) return System.Address; | |
553 | pragma Import (C, pthread_getspecific, "pthread_getspecific"); | |
554 | ||
555 | type destructor_pointer is access procedure (arg : System.Address); | |
556 | pragma Convention (C, destructor_pointer); | |
557 | ||
558 | function pthread_key_create | |
559 | (key : access pthread_key_t; | |
560 | destructor : destructor_pointer) return int; | |
561 | pragma Import (C, pthread_key_create, "pthread_key_create"); | |
562 | ||
8d9a1ba7 PMR |
563 | private |
564 | ||
d874abd8 DR |
565 | type sigset_t is |
566 | array (0 .. OS_Constants.SIZEOF_sigset - 1) of unsigned_char; | |
8d9a1ba7 | 567 | pragma Convention (C, sigset_t); |
d874abd8 | 568 | for sigset_t'Alignment use Interfaces.C.unsigned_long'Alignment; |
8d9a1ba7 PMR |
569 | |
570 | type pid_t is new int; | |
571 | ||
175c2f98 DR |
572 | type time_t is range -2 ** (System.Parameters.time_t_bits - 1) |
573 | .. 2 ** (System.Parameters.time_t_bits - 1) - 1; | |
8d9a1ba7 PMR |
574 | |
575 | type timespec is record | |
576 | tv_sec : time_t; | |
577 | tv_nsec : long; | |
578 | end record; | |
579 | pragma Convention (C, timespec); | |
580 | ||
581 | type unsigned_long_long_t is mod 2 ** 64; | |
582 | -- Local type only used to get the alignment of this type below | |
583 | ||
584 | subtype char_array is Interfaces.C.char_array; | |
585 | ||
586 | type pthread_attr_t is record | |
587 | Data : char_array (1 .. OS_Constants.PTHREAD_ATTR_SIZE); | |
588 | end record; | |
589 | pragma Convention (C, pthread_attr_t); | |
590 | for pthread_attr_t'Alignment use Interfaces.C.unsigned_long'Alignment; | |
591 | ||
592 | type pthread_condattr_t is record | |
593 | Data : char_array (1 .. OS_Constants.PTHREAD_CONDATTR_SIZE); | |
594 | end record; | |
595 | pragma Convention (C, pthread_condattr_t); | |
596 | for pthread_condattr_t'Alignment use Interfaces.C.int'Alignment; | |
597 | ||
598 | type pthread_mutexattr_t is record | |
599 | Data : char_array (1 .. OS_Constants.PTHREAD_MUTEXATTR_SIZE); | |
7385cd35 | 600 | end record; |
8d9a1ba7 PMR |
601 | pragma Convention (C, pthread_mutexattr_t); |
602 | for pthread_mutexattr_t'Alignment use Interfaces.C.int'Alignment; | |
603 | ||
604 | type pthread_mutex_t is record | |
605 | Data : char_array (1 .. OS_Constants.PTHREAD_MUTEX_SIZE); | |
606 | end record; | |
607 | pragma Convention (C, pthread_mutex_t); | |
608 | for pthread_mutex_t'Alignment use Interfaces.C.unsigned_long'Alignment; | |
609 | ||
610 | type pthread_cond_t is record | |
611 | Data : char_array (1 .. OS_Constants.PTHREAD_COND_SIZE); | |
612 | end record; | |
613 | pragma Convention (C, pthread_cond_t); | |
614 | for pthread_cond_t'Alignment use unsigned_long_long_t'Alignment; | |
615 | ||
3ec54569 | 616 | type pthread_key_t is new int; |
8d9a1ba7 PMR |
617 | |
618 | end System.OS_Interface; |