2022-05-28 12:50:01 +00:00
|
|
|
#ifndef COSMOPOLITAN_LIBC_THREAD_THREAD_H_
|
|
|
|
#define COSMOPOLITAN_LIBC_THREAD_THREAD_H_
|
2022-09-10 09:56:25 +00:00
|
|
|
|
2022-09-13 21:57:38 +00:00
|
|
|
#define PTHREAD_KEYS_MAX 128
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
#define PTHREAD_STACK_MIN 65536
|
2022-09-10 09:56:25 +00:00
|
|
|
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
|
|
|
|
|
|
|
|
#define PTHREAD_BARRIER_SERIAL_THREAD 31337
|
|
|
|
|
|
|
|
#define PTHREAD_MUTEX_DEFAULT 0
|
|
|
|
#define PTHREAD_MUTEX_NORMAL 0
|
|
|
|
#define PTHREAD_MUTEX_RECURSIVE 1
|
|
|
|
#define PTHREAD_MUTEX_ERRORCHECK 2
|
|
|
|
#define PTHREAD_MUTEX_STALLED 0
|
|
|
|
#define PTHREAD_MUTEX_ROBUST 1
|
|
|
|
|
|
|
|
#define PTHREAD_PROCESS_PRIVATE 0
|
|
|
|
#define PTHREAD_PROCESS_SHARED 1
|
|
|
|
|
|
|
|
#define PTHREAD_CREATE_JOINABLE 0
|
|
|
|
#define PTHREAD_CREATE_DETACHED 1
|
|
|
|
|
|
|
|
#define PTHREAD_INHERIT_SCHED 0
|
|
|
|
#define PTHREAD_EXPLICIT_SCHED 1
|
|
|
|
|
2022-10-11 00:52:41 +00:00
|
|
|
#define PTHREAD_CANCELED ((void *)-1)
|
|
|
|
|
|
|
|
#define PTHREAD_CANCEL_ENABLE 0
|
|
|
|
#define PTHREAD_CANCEL_DISABLE 1
|
2022-11-04 08:04:43 +00:00
|
|
|
#define PTHREAD_CANCEL_MASKED 2
|
2022-10-11 00:52:41 +00:00
|
|
|
|
|
|
|
#define PTHREAD_CANCEL_DEFERRED 0
|
|
|
|
#define PTHREAD_CANCEL_ASYNCHRONOUS 1
|
|
|
|
|
2022-10-17 18:02:04 +00:00
|
|
|
#define PTHREAD_SCOPE_SYSTEM 0
|
|
|
|
#define PTHREAD_SCOPE_PROCESS 1
|
|
|
|
|
2022-11-11 05:52:47 +00:00
|
|
|
#define PTHREAD_ATTR_NO_SIGMASK_NP -1
|
|
|
|
|
2022-05-28 12:50:01 +00:00
|
|
|
#if !(__ASSEMBLER__ + __LINKER__ + 0)
|
|
|
|
COSMOPOLITAN_C_START_
|
|
|
|
|
2022-09-11 18:02:07 +00:00
|
|
|
#define PTHREAD_ONCE_INIT _PTHREAD_INIT
|
|
|
|
#define PTHREAD_COND_INITIALIZER _PTHREAD_INIT
|
|
|
|
#define PTHREAD_RWLOCK_INITIALIZER _PTHREAD_INIT
|
|
|
|
#define PTHREAD_MUTEX_INITIALIZER _PTHREAD_INIT
|
2024-05-27 09:12:27 +00:00
|
|
|
#define _PTHREAD_INIT \
|
|
|
|
{ 0 }
|
2022-09-10 09:56:25 +00:00
|
|
|
|
|
|
|
typedef uintptr_t pthread_t;
|
|
|
|
typedef int pthread_id_np_t;
|
|
|
|
typedef char pthread_condattr_t;
|
|
|
|
typedef char pthread_rwlockattr_t;
|
|
|
|
typedef char pthread_barrierattr_t;
|
|
|
|
typedef unsigned pthread_key_t;
|
|
|
|
typedef void (*pthread_key_dtor)(void *);
|
|
|
|
|
|
|
|
typedef struct pthread_once_s {
|
2022-09-11 18:02:07 +00:00
|
|
|
_Atomic(uint32_t) _lock;
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_once_t;
|
|
|
|
|
|
|
|
typedef struct pthread_spinlock_s {
|
2022-11-11 05:52:47 +00:00
|
|
|
_Atomic(int) _lock;
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_spinlock_t;
|
|
|
|
|
|
|
|
typedef struct pthread_mutex_s {
|
2022-09-13 06:10:38 +00:00
|
|
|
_Atomic(int32_t) _lock;
|
2022-09-13 21:57:38 +00:00
|
|
|
unsigned _type : 2;
|
|
|
|
unsigned _pshared : 1;
|
2023-01-03 13:01:00 +00:00
|
|
|
unsigned _depth : 6;
|
|
|
|
unsigned _owner : 23;
|
2022-10-16 19:05:08 +00:00
|
|
|
long _pid;
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_mutex_t;
|
|
|
|
|
|
|
|
typedef struct pthread_mutexattr_s {
|
2022-09-11 18:02:07 +00:00
|
|
|
char _type;
|
|
|
|
char _pshared;
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_mutexattr_t;
|
|
|
|
|
|
|
|
typedef struct pthread_cond_s {
|
2022-09-11 18:02:07 +00:00
|
|
|
void *_nsync[2];
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_cond_t;
|
|
|
|
|
|
|
|
typedef struct pthread_rwlock_s {
|
2022-09-11 18:02:07 +00:00
|
|
|
void *_nsync[2];
|
|
|
|
char _iswrite;
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_rwlock_t;
|
|
|
|
|
2022-09-11 18:02:07 +00:00
|
|
|
typedef struct pthread_barrier_s {
|
|
|
|
void *_nsync;
|
|
|
|
} pthread_barrier_t;
|
|
|
|
|
2022-09-10 09:56:25 +00:00
|
|
|
typedef struct pthread_attr_s {
|
2022-10-09 06:54:05 +00:00
|
|
|
char __detachstate;
|
|
|
|
char __inheritsched;
|
2022-11-11 05:52:47 +00:00
|
|
|
char __havesigmask;
|
2022-10-09 06:54:05 +00:00
|
|
|
int __schedparam;
|
|
|
|
int __schedpolicy;
|
2022-10-17 18:02:04 +00:00
|
|
|
int __contentionscope;
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
int __guardsize;
|
|
|
|
size_t __stacksize;
|
Make improvements
- We now serialize the file descriptor table when spawning / executing
processes on Windows. This means you can now inherit more stuff than
just standard i/o. It's needed by bash, which duplicates the console
to file descriptor #255. We also now do a better job serializing the
environment variables, so you're less likely to encounter E2BIG when
using your bash shell. We also no longer coerce environ to uppercase
- execve() on Windows now remotely controls its parent process to make
them spawn a replacement for itself. Then it'll be able to terminate
immediately once the spawn succeeds, without having to linger around
for the lifetime as a shell process for proxying the exit code. When
process worker thread running in the parent sees the child die, it's
given a handle to the new child, to replace it in the process table.
- execve() and posix_spawn() on Windows will now provide CreateProcess
an explicit handle list. This allows us to remove handle locks which
enables better fork/spawn concurrency, with seriously correct thread
safety. Other codebases like Go use the same technique. On the other
hand fork() still favors the conventional WIN32 inheritence approach
which can be a little bit messy, but is *controlled* by guaranteeing
perfectly clean slates at both the spawning and execution boundaries
- sigset_t is now 64 bits. Having it be 128 bits was a mistake because
there's no reason to use that and it's only supported by FreeBSD. By
using the system word size, signal mask manipulation on Windows goes
very fast. Furthermore @asyncsignalsafe funcs have been rewritten on
Windows to take advantage of signal masking, now that it's much more
pleasant to use.
- All the overlapped i/o code on Windows has been rewritten for pretty
good signal and cancelation safety. We're now able to ensure overlap
data structures are cleaned up so long as you don't longjmp() out of
out of a signal handler that interrupted an i/o operation. Latencies
are also improved thanks to the removal of lots of "busy wait" code.
Waits should be optimal for everything except poll(), which shall be
the last and final demon we slay in the win32 i/o horror show.
- getrusage() on Windows is now able to report RUSAGE_CHILDREN as well
as RUSAGE_SELF, thanks to aggregation in the process manager thread.
2023-10-08 12:36:18 +00:00
|
|
|
uint64_t __sigmask;
|
Make improvements
- Every unit test now passes on Apple Silicon. The final piece of this
puzzle was porting our POSIX threads cancelation support, since that
works differently on ARM64 XNU vs. AMD64. Our semaphore support on
Apple Silicon is also superior now compared to AMD64, thanks to the
grand central dispatch library which lets *NSYNC locks go faster.
- The Cosmopolitan runtime is now more stable, particularly on Windows.
To do this, thread local storage is mandatory at all runtime levels,
and the innermost packages of the C library is no longer being built
using ASAN. TLS is being bootstrapped with a 128-byte TIB during the
process startup phase, and then later on the runtime re-allocates it
either statically or dynamically to support code using _Thread_local.
fork() and execve() now do a better job cooperating with threads. We
can now check how much stack memory is left in the process or thread
when functions like kprintf() / execve() etc. call alloca(), so that
ENOMEM can be raised, reduce a buffer size, or just print a warning.
- POSIX signal emulation is now implemented the same way kernels do it
with pthread_kill() and raise(). Any thread can interrupt any other
thread, regardless of what it's doing. If it's blocked on read/write
then the killer thread will cancel its i/o operation so that EINTR can
be returned in the mark thread immediately. If it's doing a tight CPU
bound operation, then that's also interrupted by the signal delivery.
Signal delivery works now by suspending a thread and pushing context
data structures onto its stack, and redirecting its execution to a
trampoline function, which calls SetThreadContext(GetCurrentThread())
when it's done.
- We're now doing a better job managing locks and handles. On NetBSD we
now close semaphore file descriptors in forked children. Semaphores on
Windows can now be canceled immediately, which means mutexes/condition
variables will now go faster. Apple Silicon semaphores can be canceled
too. We're now using Apple's pthread_yield() funciton. Apple _nocancel
syscalls are now used on XNU when appropriate to ensure pthread_cancel
requests aren't lost. The MbedTLS library has been updated to support
POSIX thread cancelations. See tool/build/runitd.c for an example of
how it can be used for production multi-threaded tls servers. Handles
on Windows now leak less often across processes. All i/o operations on
Windows are now overlapped, which means file pointers can no longer be
inherited across dup() and fork() for the time being.
- We now spawn a thread on Windows to deliver SIGCHLD and wakeup wait4()
which means, for example, that posix_spawn() now goes 3x faster. POSIX
spawn is also now more correct. Like Musl, it's now able to report the
failure code of execve() via a pipe although our approach favors using
shared memory to do that on systems that have a true vfork() function.
- We now spawn a thread to deliver SIGALRM to threads when setitimer()
is used. This enables the most precise wakeups the OS makes possible.
- The Cosmopolitan runtime now uses less memory. On NetBSD for example,
it turned out the kernel would actually commit the PT_GNU_STACK size
which caused RSS to be 6mb for every process. Now it's down to ~4kb.
On Apple Silicon, we reduce the mandatory upstream thread size to the
smallest possible size to reduce the memory overhead of Cosmo threads.
The examples directory has a program called greenbean which can spawn
a web server on Linux with 10,000 worker threads and have the memory
usage of the process be ~77mb. The 1024 byte overhead of POSIX-style
thread-local storage is now optional; it won't be allocated until the
pthread_setspecific/getspecific functions are called. On Windows, the
threads that get spawned which are internal to the libc implementation
use reserve rather than commit memory, which shaves a few hundred kb.
- sigaltstack() is now supported on Windows, however it's currently not
able to be used to handle stack overflows, since crash signals are
still generated by WIN32. However the crash handler will still switch
to the alt stack, which is helpful in environments with tiny threads.
- Test binaries are now smaller. Many of the mandatory dependencies of
the test runner have been removed. This ensures many programs can do a
better job only linking the the thing they're testing. This caused the
test binaries for LIBC_FMT for example, to decrease from 200kb to 50kb
- long double is no longer used in the implementation details of libc,
except in the APIs that define it. The old code that used long double
for time (instead of struct timespec) has now been thoroughly removed.
- ShowCrashReports() is now much tinier in MODE=tiny. Instead of doing
backtraces itself, it'll just print a command you can run on the shell
using our new `cosmoaddr2line` program to view the backtrace.
- Crash report signal handling now works in a much better way. Instead
of terminating the process, it now relies on SA_RESETHAND so that the
default SIG_IGN behavior can terminate the process if necessary.
- Our pledge() functionality has now been fully ported to AARCH64 Linux.
2023-09-19 03:44:45 +00:00
|
|
|
void *__stackaddr;
|
2022-09-10 09:56:25 +00:00
|
|
|
} pthread_attr_t;
|
|
|
|
|
2022-10-09 06:54:05 +00:00
|
|
|
struct _pthread_cleanup_buffer {
|
|
|
|
void (*__routine)(void *);
|
|
|
|
void *__arg;
|
|
|
|
int __canceltype;
|
|
|
|
struct _pthread_cleanup_buffer *__prev;
|
|
|
|
};
|
|
|
|
|
2022-11-11 05:52:47 +00:00
|
|
|
/* clang-format off */
|
2022-09-13 06:10:38 +00:00
|
|
|
|
2024-01-09 09:26:03 +00:00
|
|
|
int pthread_atfork(void (*)(void), void (*)(void), void (*)(void)) dontthrow;
|
|
|
|
int pthread_attr_destroy(pthread_attr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getdetachstate(const pthread_attr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getguardsize(const pthread_attr_t *, size_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getinheritsched(const pthread_attr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getschedpolicy(const pthread_attr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getscope(const pthread_attr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getstack(const pthread_attr_t *, void **, size_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_getstacksize(const pthread_attr_t *, size_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_init(pthread_attr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_setdetachstate(pthread_attr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_setguardsize(pthread_attr_t *, size_t) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_setinheritsched(pthread_attr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_setschedpolicy(pthread_attr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_setscope(pthread_attr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_attr_setstack(pthread_attr_t *, void *, size_t) libcesque paramsnonnull((1));
|
|
|
|
int pthread_attr_setstacksize(pthread_attr_t *, size_t) libcesque paramsnonnull();
|
|
|
|
int pthread_barrier_destroy(pthread_barrier_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_barrier_init(pthread_barrier_t *, const pthread_barrierattr_t *, unsigned) libcesque paramsnonnull((1));
|
|
|
|
int pthread_barrier_wait(pthread_barrier_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_barrierattr_destroy(pthread_barrierattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_barrierattr_getpshared(const pthread_barrierattr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_barrierattr_init(pthread_barrierattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_barrierattr_setpshared(pthread_barrierattr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_cancel(pthread_t) libcesque;
|
|
|
|
int pthread_cond_broadcast(pthread_cond_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_cond_destroy(pthread_cond_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *) libcesque paramsnonnull((1));
|
|
|
|
int pthread_cond_signal(pthread_cond_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_condattr_destroy(pthread_condattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_condattr_getpshared(const pthread_condattr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_condattr_init(pthread_condattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_condattr_setpshared(pthread_condattr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_create(pthread_t *, const pthread_attr_t *, void *(*)(void *), void *) dontthrow paramsnonnull((1));
|
|
|
|
int pthread_detach(pthread_t) libcesque;
|
|
|
|
int pthread_equal(pthread_t, pthread_t) libcesque;
|
|
|
|
int pthread_getattr_np(pthread_t, pthread_attr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_getname_np(pthread_t, char *, size_t) libcesque paramsnonnull();
|
|
|
|
int pthread_getunique_np(pthread_t, pthread_id_np_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_join(pthread_t, void **) libcesque;
|
|
|
|
int pthread_key_create(pthread_key_t *, pthread_key_dtor) libcesque paramsnonnull((1));
|
|
|
|
int pthread_key_delete(pthread_key_t) libcesque;
|
|
|
|
int pthread_kill(pthread_t, int) libcesque;
|
|
|
|
int pthread_mutex_consistent(pthread_mutex_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutex_destroy(pthread_mutex_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *) libcesque paramsnonnull((1));
|
|
|
|
int pthread_mutex_lock(pthread_mutex_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutex_trylock(pthread_mutex_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutex_unlock(pthread_mutex_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutexattr_destroy(pthread_mutexattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutexattr_gettype(const pthread_mutexattr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutexattr_init(pthread_mutexattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_mutexattr_setpshared(pthread_mutexattr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_mutexattr_settype(pthread_mutexattr_t *, int) libcesque paramsnonnull();
|
2022-11-11 05:52:47 +00:00
|
|
|
int pthread_once(pthread_once_t *, void (*)(void)) paramsnonnull();
|
2024-01-09 09:26:03 +00:00
|
|
|
int pthread_orphan_np(void) libcesque;
|
|
|
|
int pthread_rwlock_destroy(pthread_rwlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *) libcesque paramsnonnull((1));
|
|
|
|
int pthread_rwlock_rdlock(pthread_rwlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlock_tryrdlock(pthread_rwlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlock_trywrlock(pthread_rwlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlock_unlock(pthread_rwlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlock_wrlock(pthread_rwlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlockattr_destroy(pthread_rwlockattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *, int *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlockattr_init(pthread_rwlockattr_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_setcancelstate(int, int *) libcesque;
|
|
|
|
int pthread_setcanceltype(int, int *) libcesque;
|
|
|
|
int pthread_setname_np(pthread_t, const char *) libcesque paramsnonnull();
|
|
|
|
int pthread_setschedprio(pthread_t, int) libcesque;
|
|
|
|
int pthread_setspecific(pthread_key_t, const void *) libcesque;
|
|
|
|
int pthread_spin_destroy(pthread_spinlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_spin_init(pthread_spinlock_t *, int) libcesque paramsnonnull();
|
|
|
|
int pthread_spin_lock(pthread_spinlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_spin_trylock(pthread_spinlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_spin_unlock(pthread_spinlock_t *) libcesque paramsnonnull();
|
|
|
|
int pthread_testcancel_np(void) libcesque;
|
|
|
|
int pthread_tryjoin_np(pthread_t, void **) libcesque;
|
|
|
|
int pthread_yield_np(void) libcesque;
|
|
|
|
int pthread_yield(void) libcesque;
|
|
|
|
pthread_id_np_t pthread_getthreadid_np(void) libcesque;
|
|
|
|
pthread_t pthread_self(void) libcesque pureconst;
|
|
|
|
void *pthread_getspecific(pthread_key_t) libcesque;
|
|
|
|
void pthread_cleanup_pop(struct _pthread_cleanup_buffer *, int) libcesque paramsnonnull();
|
|
|
|
void pthread_cleanup_push(struct _pthread_cleanup_buffer *, void (*)(void *), void *) libcesque paramsnonnull((1));
|
|
|
|
void pthread_exit(void *) libcesque wontreturn;
|
|
|
|
void pthread_testcancel(void) libcesque;
|
|
|
|
void pthread_pause_np(void) libcesque;
|
2022-11-11 05:52:47 +00:00
|
|
|
|
|
|
|
/* clang-format on */
|
2022-10-09 06:54:05 +00:00
|
|
|
|
|
|
|
#define pthread_cleanup_push(routine, arg) \
|
|
|
|
{ \
|
|
|
|
struct _pthread_cleanup_buffer _buffer; \
|
2022-11-11 05:52:47 +00:00
|
|
|
pthread_cleanup_push(&_buffer, (routine), (arg));
|
2022-10-09 06:54:05 +00:00
|
|
|
|
2022-11-11 05:52:47 +00:00
|
|
|
#define pthread_cleanup_pop(execute) \
|
|
|
|
pthread_cleanup_pop(&_buffer, (execute)); \
|
2022-10-09 06:54:05 +00:00
|
|
|
}
|
2022-09-10 09:56:25 +00:00
|
|
|
|
2022-05-28 12:50:01 +00:00
|
|
|
COSMOPOLITAN_C_END_
|
|
|
|
#endif /* !(__ASSEMBLER__ + __LINKER__ + 0) */
|
|
|
|
#endif /* COSMOPOLITAN_LIBC_THREAD_THREAD_H_ */
|