pthread_rwlock: use a mutex for process-private locks.

* instead of a benaphore.
* define PTHREAD_RWLOCK_INITIALIZER.
* adjust Init(), Destroy(), StructureLock() and StructureUnlock().
This commit is contained in:
Jérôme Duval
2017-07-27 18:33:53 +02:00
parent b34aa933ed
commit 6c9e01265b
3 changed files with 34 additions and 18 deletions
+2
View File
@@ -80,6 +80,8 @@ extern "C" {
{ PTHREAD_MUTEX_RECURSIVE, 0, -42, -1, 0 }
#define PTHREAD_COND_INITIALIZER \
{ 0, -42, NULL, 0, 0 }
#define PTHREAD_RWLOCK_INITIALIZER \
{ 0, -1, {{0}} }
/* mutex functions */
extern int pthread_mutex_destroy(pthread_mutex_t *mutex);
+5 -5
View File
@@ -105,15 +105,15 @@ struct _pthread_rwlock {
__haiku_std_int32 owner;
union {
struct {
__haiku_std_int32 sem;
} shared;
struct {
__haiku_std_int32 lock_sem;
__haiku_std_int32 lock_count;
__haiku_std_int32 mutex;
__haiku_std_int32 unused;
__haiku_std_int32 reader_count;
__haiku_std_int32 writer_count;
void* waiters[2];
} local;
struct {
__haiku_std_int32 sem;
} shared;
} u;
};