| 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 |
-- -- |
| 9 |
-- Copyright (C) 1991-2017, Florida State University -- |
| 10 |
-- Copyright (C) 1995-2025, Free Software Foundation, Inc. -- |
| 11 |
-- -- |
| 12 |
-- GNAT 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 3, or (at your option) any later ver- -- |
| 15 |
-- sion. GNAT 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. -- |
| 18 |
-- -- |
| 19 |
-- As a special exception under Section 7 of GPL version 3, you are granted -- |
| 20 |
-- additional permissions described in the GCC Runtime Library Exception, -- |
| 21 |
-- version 3.1, as published by the Free Software Foundation. -- |
| 22 |
-- -- |
| 23 |
-- You should have received a copy of the GNU General Public License and -- |
| 24 |
-- a copy of the GCC Runtime Library Exception along with this program; -- |
| 25 |
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- |
| 26 |
-- <http://www.gnu.org/licenses/>. -- |
| 27 |
-- -- |
| 28 |
-- GNARL was developed by the GNARL team at Florida State University. -- |
| 29 |
-- Extensive contributions were provided by Ada Core Technologies, Inc. -- |
| 30 |
-- -- |
| 31 |
------------------------------------------------------------------------------ |
| 32 |
|
| 33 |
-- This is a HPUX 11.0 (Native THREADS) version of this package |
| 34 |
|
| 35 |
-- This package encapsulates all direct interfaces to OS services that are |
| 36 |
-- needed by the tasking run-time (libgnarl). |
| 37 |
|
| 38 |
-- PLEASE DO NOT add any with-clauses to this package or remove the pragma |
| 39 |
-- Preelaborate. This package is designed to be a bottom-level (leaf) package. |
| 40 |
|
| 41 |
with Ada.Unchecked_Conversion; |
| 42 |
|
| 43 |
with Interfaces.C; |
| 44 |
|
| 45 |
with System.OS_Locks; |
| 46 |
with System.Parameters; |
| 47 |
|
| 48 |
package System.OS_Interface is |
| 49 |
pragma Preelaborate; |
| 50 |
|
| 51 |
pragma Linker_Options ("-lpthread"); |
| 52 |
|
| 53 |
subtype int is Interfaces.C.int; |
| 54 |
subtype short is Interfaces.C.short; |
| 55 |
subtype long is Interfaces.C.long; |
| 56 |
subtype unsigned is Interfaces.C.unsigned; |
| 57 |
subtype unsigned_short is Interfaces.C.unsigned_short; |
| 58 |
subtype unsigned_long is Interfaces.C.unsigned_long; |
| 59 |
subtype unsigned_char is Interfaces.C.unsigned_char; |
| 60 |
subtype plain_char is Interfaces.C.plain_char; |
| 61 |
subtype size_t is Interfaces.C.size_t; |
| 62 |
|
| 63 |
----------- |
| 64 |
-- Errno -- |
| 65 |
----------- |
| 66 |
|
| 67 |
function errno return int; |
| 68 |
pragma Import (C, errno, "__get_errno"); |
| 69 |
|
| 70 |
EAGAIN : constant := 11; |
| 71 |
EINTR : constant := 4; |
| 72 |
EINVAL : constant := 22; |
| 73 |
ENOMEM : constant := 12; |
| 74 |
ETIMEDOUT : constant := 238; |
| 75 |
|
| 76 |
------------- |
| 77 |
-- Signals -- |
| 78 |
------------- |
| 79 |
|
| 80 |
Max_Interrupt : constant := 44; |
| 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 |
SIGUSR1 : constant := 16; -- user defined signal 1 |
| 101 |
SIGUSR2 : constant := 17; -- user defined signal 2 |
| 102 |
SIGCLD : constant := 18; -- alias for SIGCHLD |
| 103 |
SIGCHLD : constant := 18; -- child status change |
| 104 |
SIGPWR : constant := 19; -- power-fail restart |
| 105 |
SIGVTALRM : constant := 20; -- virtual timer alarm |
| 106 |
SIGPROF : constant := 21; -- profiling timer alarm |
| 107 |
SIGIO : constant := 22; -- asynchronous I/O |
| 108 |
SIGPOLL : constant := 22; -- pollable event occurred |
| 109 |
SIGWINCH : constant := 23; -- window size change |
| 110 |
SIGSTOP : constant := 24; -- stop (cannot be caught or ignored) |
| 111 |
SIGTSTP : constant := 25; -- user stop requested from tty |
| 112 |
SIGCONT : constant := 26; -- stopped process has been continued |
| 113 |
SIGTTIN : constant := 27; -- background tty read attempted |
| 114 |
SIGTTOU : constant := 28; -- background tty write attempted |
| 115 |
SIGURG : constant := 29; -- urgent condition on IO channel |
| 116 |
SIGLOST : constant := 30; -- remote lock lost (NFS) |
| 117 |
SIGDIL : constant := 32; -- DIL signal |
| 118 |
SIGXCPU : constant := 33; -- CPU time limit exceeded (setrlimit) |
| 119 |
SIGXFSZ : constant := 34; -- file size limit exceeded (setrlimit) |
| 120 |
SIGCANCEL : constant := 35; -- used for pthread cancellation. |
| 121 |
SIGGFAULT : constant := 36; -- Graphics framebuffer fault |
| 122 |
|
| 123 |
SIGADAABORT : constant := SIGABRT; |
| 124 |
-- Note: on other targets, we usually use SIGABRT, but on HPUX, it |
| 125 |
-- appears that SIGABRT can't be used in sigwait(), so we use SIGTERM. |
| 126 |
-- Do we use SIGTERM or SIGABRT??? |
| 127 |
|
| 128 |
type Signal_Set is array (Natural range <>) of Signal; |
| 129 |
|
| 130 |
Unmasked : constant Signal_Set := |
| 131 |
(SIGABRT, SIGPIPE, SIGBUS, SIGTRAP, SIGTTIN, SIGTTOU, SIGTSTP, SIGPROF, |
| 132 |
SIGALRM, SIGVTALRM, SIGIO, SIGCHLD); |
| 133 |
|
| 134 |
Reserved : constant Signal_Set := (SIGKILL, SIGSTOP); |
| 135 |
|
| 136 |
type sigset_t is private; |
| 137 |
|
| 138 |
function sigaddset (set : access sigset_t; sig : Signal) return int; |
| 139 |
pragma Import (C, sigaddset, "sigaddset"); |
| 140 |
|
| 141 |
function sigdelset (set : access sigset_t; sig : Signal) return int; |
| 142 |
pragma Import (C, sigdelset, "sigdelset"); |
| 143 |
|
| 144 |
function sigfillset (set : access sigset_t) return int; |
| 145 |
pragma Import (C, sigfillset, "sigfillset"); |
| 146 |
|
| 147 |
function sigismember (set : access sigset_t; sig : Signal) return int; |
| 148 |
pragma Import (C, sigismember, "sigismember"); |
| 149 |
|
| 150 |
function sigemptyset (set : access sigset_t) return int; |
| 151 |
pragma Import (C, sigemptyset, "sigemptyset"); |
| 152 |
|
| 153 |
type struct_sigaction is record |
| 154 |
sa_handler : System.Address; |
| 155 |
sa_mask : sigset_t; |
| 156 |
sa_flags : int; |
| 157 |
end record; |
| 158 |
pragma Convention (C, struct_sigaction); |
| 159 |
type struct_sigaction_ptr is access all struct_sigaction; |
| 160 |
|
| 161 |
SA_SIGINFO : constant := 16#10#; |
| 162 |
SA_ONSTACK : constant := 16#01#; |
| 163 |
|
| 164 |
SIG_BLOCK : constant := 0; |
| 165 |
SIG_UNBLOCK : constant := 1; |
| 166 |
SIG_SETMASK : constant := 2; |
| 167 |
|
| 168 |
SIG_DFL : constant := 0; |
| 169 |
SIG_IGN : constant := 1; |
| 170 |
|
| 171 |
function sigaction |
| 172 |
(sig : Signal; |
| 173 |
act : struct_sigaction_ptr; |
| 174 |
oact : struct_sigaction_ptr) return int; |
| 175 |
pragma Import (C, sigaction, "sigaction"); |
| 176 |
|
| 177 |
---------- |
| 178 |
-- Time -- |
| 179 |
---------- |
| 180 |
|
| 181 |
Time_Slice_Supported : constant Boolean := True; |
| 182 |
-- Indicates whether time slicing is supported |
| 183 |
|
| 184 |
type timespec is private; |
| 185 |
|
| 186 |
type clockid_t is new int; |
| 187 |
|
| 188 |
function clock_gettime |
| 189 |
(clock_id : clockid_t; |
| 190 |
tp : access timespec) return int; |
| 191 |
pragma Import (C, clock_gettime, "clock_gettime"); |
| 192 |
|
| 193 |
function clock_getres |
| 194 |
(clock_id : clockid_t; |
| 195 |
res : access timespec) return int; |
| 196 |
pragma Import (C, clock_getres, "clock_getres"); |
| 197 |
|
| 198 |
function To_Duration (TS : timespec) return Duration; |
| 199 |
pragma Inline (To_Duration); |
| 200 |
|
| 201 |
function To_Timespec (D : Duration) return timespec; |
| 202 |
pragma Inline (To_Timespec); |
| 203 |
|
| 204 |
type struct_timezone is record |
| 205 |
tz_minuteswest : int; |
| 206 |
tz_dsttime : int; |
| 207 |
end record; |
| 208 |
pragma Convention (C, struct_timezone); |
| 209 |
type struct_timezone_ptr is access all struct_timezone; |
| 210 |
|
| 211 |
------------------------- |
| 212 |
-- Priority Scheduling -- |
| 213 |
------------------------- |
| 214 |
|
| 215 |
SCHED_FIFO : constant := 0; |
| 216 |
SCHED_RR : constant := 1; |
| 217 |
SCHED_OTHER : constant := 2; |
| 218 |
|
| 219 |
function To_Target_Priority |
| 220 |
(Prio : System.Any_Priority) return Interfaces.C.int; |
| 221 |
-- Maps System.Any_Priority to a POSIX priority |
| 222 |
|
| 223 |
------------- |
| 224 |
-- Process -- |
| 225 |
------------- |
| 226 |
|
| 227 |
type pid_t is private; |
| 228 |
|
| 229 |
function kill (pid : pid_t; sig : Signal) return int; |
| 230 |
pragma Import (C, kill, "kill"); |
| 231 |
|
| 232 |
function getpid return pid_t; |
| 233 |
pragma Import (C, getpid, "getpid"); |
| 234 |
|
| 235 |
--------- |
| 236 |
-- LWP -- |
| 237 |
--------- |
| 238 |
|
| 239 |
function lwp_self return System.Address; |
| 240 |
pragma Import (C, lwp_self, "_lwp_self"); |
| 241 |
|
| 242 |
------------- |
| 243 |
-- Threads -- |
| 244 |
------------- |
| 245 |
|
| 246 |
type Thread_Body is access |
| 247 |
function (arg : System.Address) return System.Address; |
| 248 |
pragma Convention (C, Thread_Body); |
| 249 |
|
| 250 |
function Thread_Body_Access is new |
| 251 |
Ada.Unchecked_Conversion (System.Address, Thread_Body); |
| 252 |
|
| 253 |
type pthread_t is private; |
| 254 |
subtype Thread_Id is pthread_t; |
| 255 |
|
| 256 |
subtype pthread_mutex_t is System.OS_Locks.pthread_mutex_t; |
| 257 |
type pthread_cond_t is limited private; |
| 258 |
type pthread_attr_t is limited private; |
| 259 |
type pthread_mutexattr_t is limited private; |
| 260 |
type pthread_condattr_t is limited private; |
| 261 |
type pthread_key_t is private; |
| 262 |
|
| 263 |
PTHREAD_CREATE_DETACHED : constant := 16#de#; |
| 264 |
|
| 265 |
PTHREAD_SCOPE_PROCESS : constant := 2; |
| 266 |
PTHREAD_SCOPE_SYSTEM : constant := 1; |
| 267 |
|
| 268 |
-- Read/Write lock not supported on HPUX. To add support both types |
| 269 |
-- pthread_rwlock_t and pthread_rwlockattr_t must properly be defined |
| 270 |
-- with the associated routines pthread_rwlock_[init/destroy] and |
| 271 |
-- pthread_rwlock_[rdlock/wrlock/unlock]. |
| 272 |
|
| 273 |
subtype pthread_rwlock_t is pthread_mutex_t; |
| 274 |
subtype pthread_rwlockattr_t is pthread_mutexattr_t; |
| 275 |
|
| 276 |
----------- |
| 277 |
-- Stack -- |
| 278 |
----------- |
| 279 |
|
| 280 |
type stack_t is record |
| 281 |
ss_sp : System.Address; |
| 282 |
ss_flags : int; |
| 283 |
ss_size : size_t; |
| 284 |
end record; |
| 285 |
pragma Convention (C, stack_t); |
| 286 |
|
| 287 |
function sigaltstack |
| 288 |
(ss : not null access stack_t; |
| 289 |
oss : access stack_t) return int; |
| 290 |
pragma Import (C, sigaltstack, "sigaltstack"); |
| 291 |
|
| 292 |
Alternate_Stack : aliased System.Address; |
| 293 |
pragma Import (C, Alternate_Stack, "__gnat_alternate_stack"); |
| 294 |
-- The alternate signal stack for stack overflows |
| 295 |
|
| 296 |
Alternate_Stack_Size : constant := 128 * 1024; |
| 297 |
-- This must be in keeping with init.c:__gnat_alternate_stack |
| 298 |
|
| 299 |
Stack_Base_Available : constant Boolean := False; |
| 300 |
-- Indicates whether the stack base is available on this target |
| 301 |
|
| 302 |
function Get_Stack_Base (thread : pthread_t) return Address; |
| 303 |
pragma Inline (Get_Stack_Base); |
| 304 |
-- Returns the stack base of the specified thread. Only call this function |
| 305 |
-- when Stack_Base_Available is True. |
| 306 |
|
| 307 |
function Get_Page_Size return int; |
| 308 |
pragma Import (C, Get_Page_Size, "getpagesize"); |
| 309 |
-- Returns the size of a page |
| 310 |
|
| 311 |
PROT_NONE : constant := 0; |
| 312 |
PROT_READ : constant := 1; |
| 313 |
PROT_WRITE : constant := 2; |
| 314 |
PROT_EXEC : constant := 4; |
| 315 |
PROT_ALL : constant := PROT_READ + PROT_WRITE + PROT_EXEC; |
| 316 |
PROT_ON : constant := PROT_READ; |
| 317 |
PROT_OFF : constant := PROT_ALL; |
| 318 |
|
| 319 |
function mprotect (addr : Address; len : size_t; prot : int) return int; |
| 320 |
pragma Import (C, mprotect); |
| 321 |
|
| 322 |
--------------------------------------- |
| 323 |
-- Nonstandard Thread Initialization -- |
| 324 |
--------------------------------------- |
| 325 |
|
| 326 |
procedure pthread_init; |
| 327 |
pragma Inline (pthread_init); |
| 328 |
-- This is a dummy procedure to share some GNULLI files |
| 329 |
|
| 330 |
------------------------- |
| 331 |
-- POSIX.1c Section 3 -- |
| 332 |
------------------------- |
| 333 |
|
| 334 |
function sigwait |
| 335 |
(set : access sigset_t; |
| 336 |
sig : access Signal) return int; |
| 337 |
pragma Import (C, sigwait, "sigwait"); |
| 338 |
|
| 339 |
function pthread_kill |
| 340 |
(thread : pthread_t; |
| 341 |
sig : Signal) return int; |
| 342 |
pragma Import (C, pthread_kill, "pthread_kill"); |
| 343 |
|
| 344 |
function pthread_sigmask |
| 345 |
(how : int; |
| 346 |
set : access sigset_t; |
| 347 |
oset : access sigset_t) return int; |
| 348 |
pragma Import (C, pthread_sigmask, "pthread_sigmask"); |
| 349 |
|
| 350 |
-------------------------- |
| 351 |
-- POSIX.1c Section 11 -- |
| 352 |
-------------------------- |
| 353 |
|
| 354 |
function pthread_mutexattr_init |
| 355 |
(attr : access pthread_mutexattr_t) return int; |
| 356 |
pragma Import (C, pthread_mutexattr_init, "pthread_mutexattr_init"); |
| 357 |
|
| 358 |
function pthread_mutexattr_destroy |
| 359 |
(attr : access pthread_mutexattr_t) return int; |
| 360 |
pragma Import (C, pthread_mutexattr_destroy, "pthread_mutexattr_destroy"); |
| 361 |
|
| 362 |
function pthread_mutex_init |
| 363 |
(mutex : access pthread_mutex_t; |
| 364 |
attr : access pthread_mutexattr_t) return int; |
| 365 |
pragma Import (C, pthread_mutex_init, "pthread_mutex_init"); |
| 366 |
|
| 367 |
function pthread_mutex_destroy (mutex : access pthread_mutex_t) return int; |
| 368 |
pragma Import (C, pthread_mutex_destroy, "pthread_mutex_destroy"); |
| 369 |
|
| 370 |
function pthread_mutex_lock (mutex : access pthread_mutex_t) return int; |
| 371 |
pragma Import (C, pthread_mutex_lock, "pthread_mutex_lock"); |
| 372 |
|
| 373 |
function pthread_mutex_unlock (mutex : access pthread_mutex_t) return int; |
| 374 |
pragma Import (C, pthread_mutex_unlock, "pthread_mutex_unlock"); |
| 375 |
|
| 376 |
function pthread_condattr_init |
| 377 |
(attr : access pthread_condattr_t) return int; |
| 378 |
pragma Import (C, pthread_condattr_init, "pthread_condattr_init"); |
| 379 |
|
| 380 |
function pthread_condattr_destroy |
| 381 |
(attr : access pthread_condattr_t) return int; |
| 382 |
pragma Import (C, pthread_condattr_destroy, "pthread_condattr_destroy"); |
| 383 |
|
| 384 |
function pthread_cond_init |
| 385 |
(cond : access pthread_cond_t; |
| 386 |
attr : access pthread_condattr_t) return int; |
| 387 |
pragma Import (C, pthread_cond_init, "pthread_cond_init"); |
| 388 |
|
| 389 |
function pthread_cond_destroy (cond : access pthread_cond_t) return int; |
| 390 |
pragma Import (C, pthread_cond_destroy, "pthread_cond_destroy"); |
| 391 |
|
| 392 |
function pthread_cond_signal (cond : access pthread_cond_t) return int; |
| 393 |
pragma Import (C, pthread_cond_signal, "pthread_cond_signal"); |
| 394 |
|
| 395 |
function pthread_cond_wait |
| 396 |
(cond : access pthread_cond_t; |
| 397 |
mutex : access pthread_mutex_t) return int; |
| 398 |
pragma Import (C, pthread_cond_wait, "pthread_cond_wait"); |
| 399 |
|
| 400 |
function pthread_cond_timedwait |
| 401 |
(cond : access pthread_cond_t; |
| 402 |
mutex : access pthread_mutex_t; |
| 403 |
abstime : access timespec) return int; |
| 404 |
pragma Import (C, pthread_cond_timedwait, "pthread_cond_timedwait"); |
| 405 |
|
| 406 |
-------------------------- |
| 407 |
-- POSIX.1c Section 13 -- |
| 408 |
-------------------------- |
| 409 |
|
| 410 |
PTHREAD_PRIO_NONE : constant := 16#100#; |
| 411 |
PTHREAD_PRIO_PROTECT : constant := 16#200#; |
| 412 |
PTHREAD_PRIO_INHERIT : constant := 16#400#; |
| 413 |
|
| 414 |
function pthread_mutexattr_setprotocol |
| 415 |
(attr : access pthread_mutexattr_t; |
| 416 |
protocol : int) return int; |
| 417 |
pragma Import (C, pthread_mutexattr_setprotocol); |
| 418 |
|
| 419 |
function pthread_mutexattr_setprioceiling |
| 420 |
(attr : access pthread_mutexattr_t; |
| 421 |
prioceiling : int) return int; |
| 422 |
pragma Import (C, pthread_mutexattr_setprioceiling); |
| 423 |
|
| 424 |
type Array_7_Int is array (0 .. 6) of int; |
| 425 |
type struct_sched_param is record |
| 426 |
sched_priority : int; |
| 427 |
sched_reserved : Array_7_Int; |
| 428 |
end record; |
| 429 |
|
| 430 |
function pthread_setschedparam |
| 431 |
(thread : pthread_t; |
| 432 |
policy : int; |
| 433 |
param : access struct_sched_param) |
| 434 |
return int; |
| 435 |
pragma Import (C, pthread_setschedparam, "pthread_setschedparam"); |
| 436 |
|
| 437 |
function pthread_attr_setscope |
| 438 |
(attr : access pthread_attr_t; |
| 439 |
contentionscope : int) return int; |
| 440 |
pragma Import (C, pthread_attr_setscope, "pthread_attr_setscope"); |
| 441 |
|
| 442 |
function pthread_attr_setinheritsched |
| 443 |
(attr : access pthread_attr_t; |
| 444 |
inheritsched : int) return int; |
| 445 |
pragma Import (C, pthread_attr_setinheritsched); |
| 446 |
|
| 447 |
function pthread_attr_setschedpolicy |
| 448 |
(attr : access pthread_attr_t; |
| 449 |
policy : int) return int; |
| 450 |
pragma Import (C, pthread_attr_setschedpolicy); |
| 451 |
|
| 452 |
function sched_yield return int; |
| 453 |
pragma Import (C, sched_yield, "sched_yield"); |
| 454 |
|
| 455 |
-------------------------- |
| 456 |
-- P1003.1c Section 16 -- |
| 457 |
-------------------------- |
| 458 |
|
| 459 |
function pthread_attr_init |
| 460 |
(attributes : access pthread_attr_t) return int; |
| 461 |
pragma Import (C, pthread_attr_init, "__pthread_attr_init_system"); |
| 462 |
|
| 463 |
function pthread_attr_destroy |
| 464 |
(attributes : access pthread_attr_t) return int; |
| 465 |
pragma Import (C, pthread_attr_destroy, "pthread_attr_destroy"); |
| 466 |
|
| 467 |
function pthread_attr_setdetachstate |
| 468 |
(attr : access pthread_attr_t; |
| 469 |
detachstate : int) return int; |
| 470 |
pragma Import (C, pthread_attr_setdetachstate); |
| 471 |
|
| 472 |
function pthread_attr_setstacksize |
| 473 |
(attr : access pthread_attr_t; |
| 474 |
stacksize : size_t) return int; |
| 475 |
pragma Import (C, pthread_attr_setstacksize, "pthread_attr_setstacksize"); |
| 476 |
|
| 477 |
function pthread_create |
| 478 |
(thread : access pthread_t; |
| 479 |
attributes : access pthread_attr_t; |
| 480 |
start_routine : Thread_Body; |
| 481 |
arg : System.Address) return int; |
| 482 |
pragma Import (C, pthread_create, "__pthread_create_system"); |
| 483 |
|
| 484 |
procedure pthread_exit (status : System.Address); |
| 485 |
pragma Import (C, pthread_exit, "pthread_exit"); |
| 486 |
|
| 487 |
function pthread_self return pthread_t; |
| 488 |
pragma Import (C, pthread_self, "pthread_self"); |
| 489 |
|
| 490 |
-------------------------- |
| 491 |
-- POSIX.1c Section 17 -- |
| 492 |
-------------------------- |
| 493 |
|
| 494 |
function pthread_setspecific |
| 495 |
(key : pthread_key_t; |
| 496 |
value : System.Address) return int; |
| 497 |
pragma Import (C, pthread_setspecific, "pthread_setspecific"); |
| 498 |
|
| 499 |
function pthread_getspecific (key : pthread_key_t) return System.Address; |
| 500 |
pragma Import (C, pthread_getspecific, "pthread_getspecific"); |
| 501 |
|
| 502 |
type destructor_pointer is access procedure (arg : System.Address); |
| 503 |
pragma Convention (C, destructor_pointer); |
| 504 |
|
| 505 |
function pthread_key_create |
| 506 |
(key : access pthread_key_t; |
| 507 |
destructor : destructor_pointer) return int; |
| 508 |
pragma Import (C, pthread_key_create, "pthread_key_create"); |
| 509 |
|
| 510 |
private |
| 511 |
|
| 512 |
type unsigned_int_array_8 is array (0 .. 7) of unsigned; |
| 513 |
type sigset_t is record |
| 514 |
sigset : unsigned_int_array_8; |
| 515 |
end record; |
| 516 |
pragma Convention (C_Pass_By_Copy, sigset_t); |
| 517 |
|
| 518 |
type pid_t is new int; |
| 519 |
|
| 520 |
type time_t is range -2 ** (System.Parameters.time_t_bits - 1) |
| 521 |
.. 2 ** (System.Parameters.time_t_bits - 1) - 1; |
| 522 |
|
| 523 |
type timespec is record |
| 524 |
tv_sec : time_t; |
| 525 |
tv_nsec : long; |
| 526 |
end record; |
| 527 |
pragma Convention (C, timespec); |
| 528 |
|
| 529 |
type pthread_attr_t is new int; |
| 530 |
type pthread_condattr_t is new int; |
| 531 |
type pthread_mutexattr_t is new int; |
| 532 |
type pthread_t is new int; |
| 533 |
|
| 534 |
type short_array is array (Natural range <>) of short; |
| 535 |
type int_array is array (Natural range <>) of int; |
| 536 |
|
| 537 |
type pthread_cond_t is record |
| 538 |
c_short : short_array (0 .. 1); |
| 539 |
c_int : int; |
| 540 |
c_int1 : int_array (0 .. 3); |
| 541 |
m_pad : int; |
| 542 |
m_ptr : int; -- see comment in pthread_mutex_t |
| 543 |
c_int2 : int_array (0 .. 1); |
| 544 |
c_int3 : int_array (0 .. 1); |
| 545 |
c_int4 : int_array (0 .. 1); |
| 546 |
end record; |
| 547 |
for pthread_cond_t'Alignment use System.Address'Alignment; |
| 548 |
pragma Convention (C, pthread_cond_t); |
| 549 |
|
| 550 |
type pthread_key_t is new int; |
| 551 |
|
| 552 |
end System.OS_Interface; |