mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-03 11:12:27 +00:00
parent
95f54eeb40
commit
c1d99676c4
1421 changed files with 5556 additions and 2198 deletions
|
@ -1,5 +1,7 @@
|
|||
#ifndef COSMOPOLITAN_LIBC_RUNTIME_PTHREAD_H_
|
||||
#define COSMOPOLITAN_LIBC_RUNTIME_PTHREAD_H_
|
||||
#include "libc/calls/struct/timespec.h"
|
||||
#include "libc/dce.h"
|
||||
|
||||
#define PTHREAD_KEYS_MAX 64
|
||||
|
||||
|
@ -82,6 +84,7 @@ int pthread_mutex_init(pthread_mutex_t *, const pthread_mutexattr_t *);
|
|||
int pthread_mutex_lock(pthread_mutex_t *);
|
||||
int pthread_mutex_unlock(pthread_mutex_t *);
|
||||
int pthread_mutex_trylock(pthread_mutex_t *);
|
||||
int pthread_mutex_timedlock(pthread_mutex_t *, const struct timespec *);
|
||||
int pthread_mutex_destroy(pthread_mutex_t *);
|
||||
int pthread_mutex_consistent(pthread_mutex_t *);
|
||||
int pthread_mutexattr_init(pthread_mutexattr_t *);
|
||||
|
@ -91,6 +94,8 @@ int pthread_mutexattr_settype(pthread_mutexattr_t *, int);
|
|||
int pthread_cond_init(pthread_cond_t *, const pthread_condattr_t *);
|
||||
int pthread_cond_destroy(pthread_cond_t *);
|
||||
int pthread_cond_wait(pthread_cond_t *, pthread_mutex_t *);
|
||||
int pthread_cond_timedwait(pthread_cond_t *, pthread_mutex_t *,
|
||||
const struct timespec *);
|
||||
int pthread_cond_broadcast(pthread_cond_t *);
|
||||
int pthread_cancel(pthread_t);
|
||||
int pthread_cond_signal(pthread_cond_t *);
|
||||
|
@ -98,8 +103,10 @@ int pthread_rwlock_init(pthread_rwlock_t *, const pthread_rwlockattr_t *);
|
|||
int pthread_rwlock_destroy(pthread_rwlock_t *);
|
||||
int pthread_rwlock_rdlock(pthread_rwlock_t *);
|
||||
int pthread_rwlock_tryrdlock(pthread_rwlock_t *);
|
||||
int pthread_rwlock_timedrdlock(pthread_rwlock_t *, const struct timespec *);
|
||||
int pthread_rwlock_wrlock(pthread_rwlock_t *);
|
||||
int pthread_rwlock_trywrlock(pthread_rwlock_t *);
|
||||
int pthread_rwlock_timedwrlock(pthread_rwlock_t *, const struct timespec *);
|
||||
int pthread_rwlock_unlock(pthread_rwlock_t *);
|
||||
int pthread_key_create(pthread_key_t *, pthread_key_dtor);
|
||||
int pthread_key_delete(pthread_key_t);
|
||||
|
@ -132,8 +139,9 @@ void *pthread_getspecific(pthread_key_t);
|
|||
#define pthread_mutex_unlock(mutex) \
|
||||
((mutex)->attr == PTHREAD_MUTEX_NORMAL \
|
||||
? (__atomic_store_n(&(mutex)->lock, 0, __ATOMIC_RELAXED), \
|
||||
__atomic_load_n(&(mutex)->waits, __ATOMIC_RELAXED) && \
|
||||
_pthread_mutex_wake(mutex), \
|
||||
((IsLinux() || IsOpenbsd()) && \
|
||||
__atomic_load_n(&(mutex)->waits, __ATOMIC_RELAXED) && \
|
||||
_pthread_mutex_wake(mutex)), \
|
||||
0) \
|
||||
: pthread_mutex_unlock(mutex))
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue