diff options
Diffstat (limited to 'src/libstrongswan/threading/rwlock.h')
-rw-r--r-- | src/libstrongswan/threading/rwlock.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/libstrongswan/threading/rwlock.h b/src/libstrongswan/threading/rwlock.h index 2f681b781..2f4330ffb 100644 --- a/src/libstrongswan/threading/rwlock.h +++ b/src/libstrongswan/threading/rwlock.h @@ -31,11 +31,47 @@ struct private_rwlock_t { */ rwlock_t public; +#ifdef HAVE_PTHREAD_RWLOCK_INIT + /** * wrapped pthread rwlock */ pthread_rwlock_t rwlock; +#else + + /** + * mutex to emulate a native rwlock + */ + mutex_t *mutex; + + /** + * condvar to handle writers + */ + condvar_t *writers; + + /** + * condvar to handle readers + */ + condvar_t *readers; + + /** + * number of waiting writers + */ + u_int waiting_writers; + + /** + * number of readers holding the lock + */ + u_int reader_count; + + /** + * current writer thread, if any + */ + pthread_t writer; + +#endif /* HAVE_PTHREAD_RWLOCK_INIT */ + /** * profiling info, if enabled */ |