Cleaned up pthread rwlocks implementation.

- used underscore_style_for_vars
- extracted time related functionality into a function
- cleaned up style
- removed unused fields from pthread_rwlock_t on LP64
- changed reservation in pthread_rwlock_t so that the size of the
structure equals glibc version

Bug: 8133149

Change-Id: I84ad3918678dc7f5e6b3db9b7e9b0899d3abe9cd
This commit is contained in:
Calin Juravle
2014-05-22 19:21:22 +01:00
parent 4f6ed4a109
commit 92687e41bc
3 changed files with 83 additions and 81 deletions

View File

@@ -94,17 +94,28 @@ typedef long pthread_condattr_t;
typedef long pthread_rwlockattr_t;
typedef struct {
#if !defined(__LP64__)
pthread_mutex_t __unused_lock;
pthread_cond_t __unused_cond;
#endif
volatile int32_t state; // 0=unlock, -1=writer lock, +n=reader lock
volatile int32_t writerThreadId;
volatile int32_t pendingReaders;
volatile int32_t pendingWriters;
volatile int32_t writer_thread_id;
volatile int32_t pending_readers;
volatile int32_t pending_writers;
int32_t attr;
void* __reserved[3];
#ifdef __LP64__
char __reserved[36];
#else
char __reserved[12];
#endif
} pthread_rwlock_t;
#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, 0, { NULL, NULL, NULL } }
#ifdef __LP64__
#define PTHREAD_RWLOCK_INITIALIZER { 0, 0, 0, 0, 0, { 0 } }
#else
#define PTHREAD_RWLOCK_INITIALIZER { PTHREAD_MUTEX_INITIALIZER, PTHREAD_COND_INITIALIZER, 0, 0, 0, 0, 0, { 0 } }
#endif
typedef int pthread_key_t;
typedef long pthread_t;