der. This is because reader locks are specified to be recursive, but for efficiency reasons we do not keep track of which threads already hold a reader lock. For this reason, we can not prefer some reader locks over others, and thus a recursive reader lock could be stalled by a pending writer, leading to a dead lock. */ #define NPTH_RWLOCK_PREFER_WRITER_NP PTHREAD_RWLOCK_PREFER_WRITER_NP /* The non-recursive choise is a promise by the application that it does not lock the rwlock for reading recursively. In this setting, writers are preferred, but note that recursive reader locking is prone to deadlocks in that case. */ #define NPTH_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP \ PTHREAD_RWLOCK_PREFER_WRITER_NONRECURSIVE_NP #define NPTH_RWLOCK_DEFAULT_NP PTHREAD_RWLOCK_DEFAULT_NP #define NPTH_RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER #define NPTH_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP \ PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP typedef pthread_rwlock_t npth_rwlock_t; #define npth_rwlock_init pthread_rwlock_init #define npth_rwlock_destroy pthread_rwlock_destroy #define npth_rwlock_tryrdlock pthread_rwlock_tryrdlock int npth_rwlock_rdlock (npth_rwlock_t *rwlock); int npth_rwlock_timedrdlock (npth_rwlock_t *rwlock, const struct timespec *abstime); #define npth_rwlock_trywrlock pthread_rwlock_trywrlock int npth_rwlock_wrlock (npth_rwlock_t *rwlock); int npth_rwlock_timedwrlock (npth_rwlock_t *rwlock, const struct timespec *abstime); #define npth_rwlock_unlock pthread_rwlock_unlock #endif /* !_NPTH_NO_RWLOCK */ #endif typedef pthread_cond_t npth_cond_t; #define NPTH_COND_INITIALIZER PTHREAD_COND_INITIALIZER /* For now, we don't support any cond attributes. */ #define npth_cond_init pthread_cond_init #define npth_cond_broadcast pthread_cond_broadcast #define npth_cond_signal pthread_cond_signal #define npth_cond_destroy pthread_cond_destroy int npth_cond_wait(npth_cond_t *cond, npth_mutex_t *mutex); int npth_cond_timedwait(npth_cond_t *cond, npth_mutex_t *mutex, const struct timespec *abstime); /* Not needed. */ /* pth_barrier_t, pth_barrier_init, pth_barrier_reach */