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