reorganize pthread data structures and move the definitions to alltypes.h
authorRich Felker <dalias@aerifal.cx>
Thu, 17 Feb 2011 22:16:20 +0000 (17:16 -0500)
committerRich Felker <dalias@aerifal.cx>
Thu, 17 Feb 2011 22:16:20 +0000 (17:16 -0500)
this allows sys/types.h to provide the pthread types, as required by
POSIX. this design also facilitates forcing ABI-compatible sizes in
the arch-specific alltypes.h, while eliminating the need for
developers changing the internals of the pthread types to poke around
with arch-specific headers they may not be able to test.

28 files changed:
arch/i386/bits/alltypes.h.sh
arch/x86_64/bits/alltypes.h.sh
include/pthread.h
include/sys/types.h
src/internal/pthread_impl.h
src/thread/pthread_attr_getdetachstate.c
src/thread/pthread_attr_getguardsize.c
src/thread/pthread_attr_getstacksize.c
src/thread/pthread_attr_setdetachstate.c
src/thread/pthread_attr_setguardsize.c
src/thread/pthread_attr_setstacksize.c
src/thread/pthread_barrier_init.c
src/thread/pthread_barrier_wait.c
src/thread/pthread_cond_broadcast.c
src/thread/pthread_cond_signal.c
src/thread/pthread_cond_timedwait.c
src/thread/pthread_create.c
src/thread/pthread_mutex_lock.c
src/thread/pthread_mutex_timedlock.c
src/thread/pthread_mutex_trylock.c
src/thread/pthread_mutex_unlock.c
src/thread/pthread_rwlock_rdlock.c
src/thread/pthread_rwlock_timedrdlock.c
src/thread/pthread_rwlock_timedwrlock.c
src/thread/pthread_rwlock_tryrdlock.c
src/thread/pthread_rwlock_trywrlock.c
src/thread/pthread_rwlock_unlock.c
src/thread/pthread_rwlock_wrlock.c

index a5ba060e03f7cfbdfa3cb903848c8272a8a1532a..27289ea0fdfef599b4df182e85defc06fa11dd4e 100755 (executable)
@@ -78,7 +78,22 @@ TYPEDEF int id_t;
 TYPEDEF int uid_t;
 TYPEDEF int gid_t;
 TYPEDEF int key_t;
+
 TYPEDEF struct __pthread * pthread_t;
+TYPEDEF int pthread_once_t;
+TYPEDEF int pthread_key_t;
+TYPEDEF int pthread_spinlock_t;
+
+TYPEDEF struct { union { int __i[9]; size_t __s[2]; } __u; } pthread_attr_t;
+TYPEDEF unsigned pthread_mutexattr_t;
+TYPEDEF unsigned pthread_condattr_t;
+TYPEDEF unsigned pthread_barrierattr_t;
+TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
+
+TYPEDEF struct { union { int __i[6]; void *__p[1]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[12]; void *__p[1]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[8]; void *__p[1]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[5]; void *__p[1]; } __u; } pthread_barrier_t;
 
 TYPEDEF long long off_t;
 
index dffb13a0c24ccab778481635435aa5442a8cedae..05c0b7dce36f0b55faf43a55668d77566edc66cc 100755 (executable)
@@ -78,7 +78,22 @@ TYPEDEF int id_t;
 TYPEDEF unsigned int uid_t;
 TYPEDEF unsigned int gid_t;
 TYPEDEF int key_t;
+
 TYPEDEF struct __pthread * pthread_t;
+TYPEDEF int pthread_once_t;
+TYPEDEF int pthread_key_t;
+TYPEDEF int pthread_spinlock_t;
+
+TYPEDEF struct { union { int __i[14]; size_t __s[2]; } __u; } pthread_attr_t;
+TYPEDEF unsigned pthread_mutexattr_t;
+TYPEDEF unsigned pthread_condattr_t;
+TYPEDEF unsigned pthread_barrierattr_t;
+TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
+
+TYPEDEF struct { union { int __i[10]; void *__p[1]; } __u; } pthread_mutex_t;
+TYPEDEF struct { union { int __i[12]; void *__p[1]; } __u; } pthread_cond_t;
+TYPEDEF struct { union { int __i[14]; void *__p[1]; } __u; } pthread_rwlock_t;
+TYPEDEF struct { union { int __i[8]; void *__p[1]; } __u; } pthread_barrier_t;
 
 TYPEDEF long off_t;
 
index e820ae55f8d05f89b464200097025fad25b2c23e..749a0e8c01f62eb8d8d7a59a290f7d344f9729b8 100644 (file)
@@ -8,6 +8,18 @@ extern "C" {
 #define __NEED_struct_timespec
 #define __NEED_sigset_t
 #define __NEED_pthread_t
+#define __NEED_pthread_attr_t
+#define __NEED_pthread_mutexattr_t
+#define __NEED_pthread_condattr_t
+#define __NEED_pthread_rwlockattr_t
+#define __NEED_pthread_barrierattr_t
+#define __NEED_pthread_mutex_t
+#define __NEED_pthread_cond_t
+#define __NEED_pthread_rwlock_t
+#define __NEED_pthread_barrier_t
+#define __NEED_pthread_spinlock_t
+#define __NEED_pthread_key_t
+#define __NEED_pthread_once_t
 #define __NEED_size_t
 
 #include <bits/alltypes.h>
@@ -15,51 +27,6 @@ extern "C" {
 #include <sched.h>
 #include <time.h>
 
-typedef int pthread_once_t, pthread_key_t, pthread_spinlock_t;
-typedef int pthread_mutexattr_t, pthread_condattr_t, pthread_barrierattr_t;
-
-typedef struct {
-       size_t __guardsize;
-       size_t __stacksize;
-       unsigned __detach : 1;
-       unsigned __pad : 31;
-       int __attr[6];
-} pthread_attr_t;
-
-typedef struct {
-       int __attr[2];
-} pthread_rwlockattr_t;
-
-typedef struct {
-       int __type;
-       int __lock;
-       pthread_t __owner;
-       int __pad2;
-       int __waiters;
-       int __pad;
-} pthread_mutex_t;
-
-typedef struct {
-       int __block;
-       int __pad[11];
-} pthread_cond_t;
-
-typedef struct {
-       int __wrlock;
-       int __readers;
-       int __waiters;
-       int __owner;
-       int __pad[4];
-} pthread_rwlock_t;
-
-typedef struct {
-       int __count;
-       int __limit;
-       int __left;
-       int __waiters;
-       int __barrier[1];
-} pthread_barrier_t;
-
 #define PTHREAD_CREATE_JOINABLE 0
 #define PTHREAD_CREATE_DETACHED 1
 
index 8be19e6b2ca83300595708f23b52ace43d4ee807..7a126b077a3f0111eb7ecb46b883ef9fd1a3f0b9 100644 (file)
@@ -42,6 +42,20 @@ extern "C" {
 #define __NEED_suseconds_t
 #define __NEED_blksize_t
 
+#define __NEED_pthread_t
+#define __NEED_pthread_attr_t
+#define __NEED_pthread_mutexattr_t
+#define __NEED_pthread_condattr_t
+#define __NEED_pthread_rwlockattr_t
+#define __NEED_pthread_barrierattr_t
+#define __NEED_pthread_mutex_t
+#define __NEED_pthread_cond_t
+#define __NEED_pthread_rwlock_t
+#define __NEED_pthread_barrier_t
+#define __NEED_pthread_spinlock_t
+#define __NEED_pthread_key_t
+#define __NEED_pthread_once_t
+
 #include <bits/alltypes.h>
 
 #ifdef _GNU_SOURCE
index e481ab5aa928d74abbe6f84f4c74aeabecb47da6..615af7083325f57f2ab16762fc9d474dc12385ce 100644 (file)
@@ -38,6 +38,25 @@ struct pthread {
        pthread_attr_t attr;
 };
 
+#define __SU (sizeof(size_t)/sizeof(int))
+
+#define _a_stacksize __u.__s[0]
+#define _a_guardsize __u.__s[1]
+#define _a_detach __u.__i[2*__SU+0]
+#define _m_type __u.__i[0]
+#define _m_lock __u.__i[1]
+#define _m_waiters __u.__i[2]
+#define _m_owner __u.__i[3]
+#define _c_block __u.__i[0]
+#define _rw_wrlock __u.__i[0]
+#define _rw_readers __u.__i[1]
+#define _rw_waiters __u.__i[2]
+#define _rw_owner __u.__i[3]
+#define _b_count __u.__i[0]
+#define _b_limit __u.__i[1]
+#define _b_left __u.__i[2]
+#define _b_waiters __u.__i[3]
+
 #include "pthread_arch.h"
 
 #define SIGCANCEL 32
index 9cd49536f7cc770a78731d3883f0a0c34ca67241..de65c25fc7410897e49971231d86e2f547c8eb8b 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_attr_getdetachstate(pthread_attr_t *a, int *state)
 {
-       *state = a->__detach;
+       *state = a->_a_detach;
        return 0;
 }
index 3f089c8cbd44c90aa3246a8b8cbfd9eb576fc788..e6b9ee2ae06e417ddcb358b6540bd5372bc948bf 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_attr_getguardsize(pthread_attr_t *a, size_t *size)
 {
-       *size = a->__guardsize + DEFAULT_GUARD_SIZE;
+       *size = a->_a_guardsize + DEFAULT_GUARD_SIZE;
        return 0;
 }
index 40bbf1868ca1293bcdd5e9167aa286bec8cc5706..900dc9f53839bd112adcc78a1e9b6b210a8cf4fe 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_attr_getstacksize(pthread_attr_t *a, size_t *size)
 {
-       *size = a->__stacksize + DEFAULT_STACK_SIZE;
+       *size = a->_a_stacksize + DEFAULT_STACK_SIZE;
        return 0;
 }
index d23b477869514a8928f4baa0cb85f738737f3cfa..bfffba8c0c4b126c91a4587d40fb18413713b9be 100644 (file)
@@ -2,6 +2,6 @@
 
 int pthread_attr_setdetachstate(pthread_attr_t *a, int state)
 {
-       a->__detach = state;
+       a->_a_detach = state;
        return 0;
 }
index e0e8d3fb1033df951264bbd560c0b7559425b896..9f21d24702fbf3874c26e196943653166bb3f818 100644 (file)
@@ -3,6 +3,6 @@
 int pthread_attr_setguardsize(pthread_attr_t *a, size_t size)
 {
        if (size > SIZE_MAX/8) return EINVAL;
-       a->__guardsize = size - DEFAULT_GUARD_SIZE;
+       a->_a_guardsize = size - DEFAULT_GUARD_SIZE;
        return 0;
 }
index 58f4bb180a47e0bc9fb3076d052a875d23e233b2..df16b980886e54c2581c4004e811fcc45c17df19 100644 (file)
@@ -3,6 +3,6 @@
 int pthread_attr_setstacksize(pthread_attr_t *a, size_t size)
 {
        if (size-PAGE_SIZE > SIZE_MAX/4) return EINVAL;
-       a->__stacksize = size - DEFAULT_STACK_SIZE;
+       a->_a_stacksize = size - DEFAULT_STACK_SIZE;
        return 0;
 }
index 2cc67ed5afd41883fe9375cc0f016e244a454c89..736d10146faf86cc432be85593482ddada09fb85 100644 (file)
@@ -3,6 +3,6 @@
 int pthread_barrier_init(pthread_barrier_t *b, const pthread_barrierattr_t *a, unsigned count)
 {
        if (!count) return EINVAL;
-       *b = (pthread_barrier_t){ .__limit = count-1 };
+       *b = (pthread_barrier_t){ ._b_limit = count-1 };
        return 0;
 }
index 02c252ad38d3c11d89ad497c43dc072998c3a930..7bfadb9532195bfad63561032e5e3f2fde376f12 100644 (file)
@@ -5,27 +5,27 @@ int pthread_barrier_wait(pthread_barrier_t *b)
        int cur;
 
        /* Trivial case: count was set at 1 */
-       if (!b->__limit) return PTHREAD_BARRIER_SERIAL_THREAD;
+       if (!b->_b_limit) return PTHREAD_BARRIER_SERIAL_THREAD;
 
        /* Wait for anyone still suspended at previous use of barrier */
-       while ((cur=b->__left))
-               __wait(&b->__left, &b->__waiters, cur, 0);
+       while ((cur=b->_b_left))
+               __wait(&b->_b_left, &b->_b_waiters, cur, 0);
 
        /* If we are the last to reach barrier, reset it and wake others */
-       if (a_fetch_add(&b->__count, 1) == b->__limit) {
-               b->__left = b->__limit;
-               b->__count = 0;
-               __wake(&b->__count, -1, 0);
+       if (a_fetch_add(&b->_b_count, 1) == b->_b_limit) {
+               b->_b_left = b->_b_limit;
+               b->_b_count = 0;
+               __wake(&b->_b_count, -1, 0);
                return PTHREAD_BARRIER_SERIAL_THREAD;
        }
 
        /* Wait for our peers to reach the barrier */
-       while ((cur=b->__count))
-               __wait(&b->__count, 0, cur, 0);
+       while ((cur=b->_b_count))
+               __wait(&b->_b_count, 0, cur, 0);
 
        /* If we're the last to wake up and barrier is awaiting reuse */
-       if (a_fetch_add(&b->__left, -1) == 1 && b->__waiters)
-               __wake(&b->__left, -1, 0);
+       if (a_fetch_add(&b->_b_left, -1) == 1 && b->_b_waiters)
+               __wake(&b->_b_left, -1, 0);
 
        return 0;
 }
index 7a023b850bab8c8627ab5d543c5ddc46947d439d..1d378c0b271b0420044a5dc842eba04f6c3887e0 100644 (file)
@@ -2,7 +2,7 @@
 
 int pthread_cond_broadcast(pthread_cond_t *c)
 {
-       c->__block = 0;
-       __wake(&c->__block, -1, 0);
+       c->_c_block = 0;
+       __wake(&c->_c_block, -1, 0);
        return 0;
 }
index 0dd9416bff4ac1b8db8ac43f48052fcd2d7773d8..574f5c79bab9a6e04a3078a1748a2a45f2901d39 100644 (file)
@@ -2,7 +2,7 @@
 
 int pthread_cond_signal(pthread_cond_t *c)
 {
-       c->__block = 0;
-       __wake(&c->__block, 1, 0);
+       c->_c_block = 0;
+       __wake(&c->_c_block, 1, 0);
        return 0;
 }
index b67dded44bcb4d0cb8b3eecdfccc91b1435ef7ad..b0214b40a88068375d4011ebe6d604e2d81985a0 100644 (file)
@@ -11,11 +11,11 @@ int pthread_cond_timedwait(pthread_cond_t *c, pthread_mutex_t *m, const struct t
        CANCELPT(0);
 
        pthread_cleanup_push(relock, m);
-       c->__block = 1;
+       c->_c_block = 1;
        if ((r=pthread_mutex_unlock(m))) return r;
 
        CANCELPT(1);
-       e = __timedwait(&c->__block, 1, CLOCK_REALTIME, ts, 0);
+       e = __timedwait(&c->_c_block, 1, CLOCK_REALTIME, ts, 0);
        CANCELPT(0);
 
        pthread_cleanup_pop(0);
index af6ccf0760769ea6709b447227c705e07506a71f..b6c475d0ad7349c45acba92d8886f15b5ac22f45 100644 (file)
@@ -173,8 +173,8 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo
        if (!init && ++init) init_threads();
 
        if (!attr) attr = &default_attr;
-       guard = ROUND(attr->__guardsize + DEFAULT_GUARD_SIZE);
-       size = guard + ROUND(attr->__stacksize + DEFAULT_STACK_SIZE);
+       guard = ROUND(attr->_a_guardsize + DEFAULT_GUARD_SIZE);
+       size = guard + ROUND(attr->_a_stacksize + DEFAULT_STACK_SIZE);
        size += __pthread_tsd_size;
        map = mmap(0, size, PROT_READ|PROT_WRITE|PROT_EXEC, MAP_PRIVATE|MAP_ANON, -1, 0);
        if (!map) return EAGAIN;
@@ -190,7 +190,7 @@ int pthread_create(pthread_t *res, const pthread_attr_t *attr, void *(*entry)(vo
        new->start_arg = arg;
        new->self = new;
        new->tsd = (void *)tsd;
-       new->detached = attr->__detach;
+       new->detached = attr->_a_detach;
        new->attr = *attr;
        memcpy(new->tlsdesc, self->tlsdesc, sizeof new->tlsdesc);
        new->tlsdesc[1] = (uintptr_t)new;
index 6696f17a234b7e571ed8ae5210fc273c2b0ad8db..15ede3f5abdbe75edac86fdfd6ae8da7688bf472 100644 (file)
@@ -4,6 +4,6 @@ int pthread_mutex_lock(pthread_mutex_t *m)
 {
        int r;
        while ((r=pthread_mutex_trylock(m)) == EBUSY)
-               __wait(&m->__lock, &m->__waiters, 1, 0);
+               __wait(&m->_m_lock, &m->_m_waiters, 1, 0);
        return r;
 }
index 5dfad94ff1b7c56b1ebb1d70cf2187ffcad9284b..20ce01283816fcd108662c424ae3f88d91ea3e53 100644 (file)
@@ -4,12 +4,12 @@ int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *at)
 {
        int r, w=0;
        while ((r=pthread_mutex_trylock(m)) == EBUSY) {
-               if (!w) a_inc(&m->__waiters), w++;
-               if (__timedwait(&m->__lock, 1, CLOCK_REALTIME, at, 0) == ETIMEDOUT) {
-                       if (w) a_dec(&m->__waiters);
+               if (!w) a_inc(&m->_m_waiters), w++;
+               if (__timedwait(&m->_m_lock, 1, CLOCK_REALTIME, at, 0) == ETIMEDOUT) {
+                       if (w) a_dec(&m->_m_waiters);
                        return ETIMEDOUT;
                }
        }
-       if (w) a_dec(&m->__waiters);
+       if (w) a_dec(&m->_m_waiters);
        return r;
 }
index 1e3817bbf8960fc53f36bba70c8f9c6171985e0a..29268fdb0fa772f02e06dddf51bf00c851bebe88 100644 (file)
@@ -2,27 +2,27 @@
 
 int pthread_mutex_trylock(pthread_mutex_t *m)
 {
-       if (m->__type == PTHREAD_MUTEX_RECURSIVE) {
+       if (m->_m_type == PTHREAD_MUTEX_RECURSIVE) {
                pthread_t self = pthread_self();
-               if (m->__owner == self) {
-                       if ((unsigned)m->__lock >= INT_MAX) return EAGAIN;
-                       a_inc(&m->__lock);
+               if (m->_m_owner == self->tid) {
+                       if ((unsigned)m->_m_lock >= INT_MAX) return EAGAIN;
+                       a_inc(&m->_m_lock);
                        return 0;
                }
-               if (a_fetch_add(&m->__lock, 1)) {
-                       if (a_fetch_add(&m->__lock, -1)==1 && m->__waiters)
-                               __wake(&m->__lock, 1, 0);
+               if (a_fetch_add(&m->_m_lock, 1)) {
+                       if (a_fetch_add(&m->_m_lock, -1)==1 && m->_m_waiters)
+                               __wake(&m->_m_lock, 1, 0);
                        return EBUSY;
                }
-               m->__owner = self;
+               m->_m_owner = self->tid;
                return 0;
        }
 
-       if (a_xchg(&m->__lock, 1))
-               if (m->__type == PTHREAD_MUTEX_ERRORCHECK
-                && m->__owner == pthread_self()) return EDEADLK;
+       if (a_xchg(&m->_m_lock, 1))
+               if (m->_m_type == PTHREAD_MUTEX_ERRORCHECK
+                && m->_m_owner == pthread_self()->tid) return EDEADLK;
                else return EBUSY;
-       if (m->__type == PTHREAD_MUTEX_ERRORCHECK)
-               m->__owner = pthread_self();
+       if (m->_m_type == PTHREAD_MUTEX_ERRORCHECK)
+               m->_m_owner = pthread_self()->tid;
        return 0;
 }
index 23e64ac8d24fc25f3b15bd898523fa0c5e4f1a6e..0275eb52e6e6a5e93f34a2037e601dbbaaccdfac 100644 (file)
@@ -2,18 +2,18 @@
 
 int pthread_mutex_unlock(pthread_mutex_t *m)
 {
-       if (m->__type == PTHREAD_MUTEX_RECURSIVE) {
-               if (a_fetch_add(&m->__lock, -1)==1 && m->__waiters)
-                       __wake(&m->__lock, 1, 0);
+       if (m->_m_type == PTHREAD_MUTEX_RECURSIVE) {
+               if (a_fetch_add(&m->_m_lock, -1)==1 && m->_m_waiters)
+                       __wake(&m->_m_lock, 1, 0);
                return 0;
        }
 
-       if (m->__type == PTHREAD_MUTEX_ERRORCHECK
-        && m->__owner != pthread_self())
+       if (m->_m_type == PTHREAD_MUTEX_ERRORCHECK
+        && m->_m_owner != pthread_self()->tid)
                return EPERM;
 
-       m->__owner = 0;
-       m->__lock = 0;
-       if (m->__waiters) __wake(&m->__lock, 1, 0);
+       m->_m_owner = 0;
+       m->_m_lock = 0;
+       if (m->_m_waiters) __wake(&m->_m_lock, 1, 0);
        return 0;
 }
index 6bcdb81544d19667f498a4f3fbfef37c3c393ea4..29863507c07453336e4513f6250d9991d2037f9c 100644 (file)
@@ -3,6 +3,6 @@
 int pthread_rwlock_rdlock(pthread_rwlock_t *rw)
 {
        while (pthread_rwlock_tryrdlock(rw))
-               __wait(&rw->__wrlock, &rw->__waiters, 1, 0);
+               __wait(&rw->_rw_wrlock, &rw->_rw_waiters, 1, 0);
        return 0;
 }
index 290327deb811a88b619bcb8d7aeb0bc6905519c8..1e76a8e10b1dd42a29ffadee13c00b32888a1d9d 100644 (file)
@@ -4,12 +4,12 @@ int pthread_rwlock_timedrdlock(pthread_rwlock_t *rw, const struct timespec *at)
 {
        int w=0;
        while (pthread_rwlock_tryrdlock(rw)) {
-               if (!w) a_inc(&rw->__waiters), w++;
-               if (__timedwait(&rw->__wrlock, 1, CLOCK_REALTIME, at, 0)==ETIMEDOUT) {
-                       if (w) a_dec(&rw->__waiters);
+               if (!w) a_inc(&rw->_rw_waiters), w++;
+               if (__timedwait(&rw->_rw_wrlock, 1, CLOCK_REALTIME, at, 0)==ETIMEDOUT) {
+                       if (w) a_dec(&rw->_rw_waiters);
                        return ETIMEDOUT;
                }
        }
-       if (w) a_dec(&rw->__waiters);
+       if (w) a_dec(&rw->_rw_waiters);
        return 0;
 }
index 9f7496485fa939f788b0b212e13224af6ad63762..9682774938d8f2dc122c9913c6a616590c667fde 100644 (file)
@@ -4,14 +4,14 @@ int pthread_rwlock_timedwrlock(pthread_rwlock_t *rw, const struct timespec *at)
 {
        int nr, *p, w=0;
        while (pthread_rwlock_trywrlock(rw)==EAGAIN) {
-               if (!w) a_inc(&rw->__waiters), w++;
-               if ((nr=rw->__readers)) p = &rw->__readers;
-               else nr=1, p = &rw->__wrlock;
+               if (!w) a_inc(&rw->_rw_waiters), w++;
+               if ((nr=rw->_rw_readers)) p = &rw->_rw_readers;
+               else nr=1, p = &rw->_rw_wrlock;
                if (__timedwait(p, nr, CLOCK_REALTIME, at, 0)==ETIMEDOUT) {
-                       if (w) a_dec(&rw->__waiters);
+                       if (w) a_dec(&rw->_rw_waiters);
                        return ETIMEDOUT;
                }
        }
-       if (w) a_dec(&rw->__waiters);
+       if (w) a_dec(&rw->_rw_waiters);
        return 0;
 }
index f59fbbdd04a3bfe39ee94d6dbd80f2ab558f9bff..fc1d5328a787dc6df63db2cc265227c795e9b394 100644 (file)
@@ -2,11 +2,11 @@
 
 int pthread_rwlock_tryrdlock(pthread_rwlock_t *rw)
 {
-       a_inc(&rw->__readers);
-       if (rw->__wrlock) {
-               a_dec(&rw->__readers);
-               if (rw->__waiters && !rw->__readers)
-                       __wake(&rw->__readers, 1, 0);
+       a_inc(&rw->_rw_readers);
+       if (rw->_rw_wrlock) {
+               a_dec(&rw->_rw_readers);
+               if (rw->_rw_waiters && !rw->_rw_readers)
+                       __wake(&rw->_rw_readers, 1, 0);
                return EAGAIN;
        }
        return 0;
index c029b87408081b30c9ddcc39ed637e3b5e47d8ae..1bcf7c998f3a113773b60e8c76ed8f1b8c841db7 100644 (file)
@@ -2,12 +2,12 @@
 
 int pthread_rwlock_trywrlock(pthread_rwlock_t *rw)
 {
-       if (a_xchg(&rw->__wrlock, 1))
+       if (a_xchg(&rw->_rw_wrlock, 1))
                return EAGAIN;
-       if (rw->__readers) {
-               a_store(&rw->__wrlock, 0);
+       if (rw->_rw_readers) {
+               a_store(&rw->_rw_wrlock, 0);
                return EAGAIN;
        }
-       rw->__owner = pthread_self()->tid;
+       rw->_rw_owner = pthread_self()->tid;
        return 0;
 }
index f39117e743ee75c20a420f8ecfec1d336adb8d42..060e3fe10ada2c330c51cf73cf8f9a6fdfab8361 100644 (file)
@@ -3,15 +3,15 @@
 int pthread_rwlock_unlock(pthread_rwlock_t *rw)
 {
        struct pthread *self = pthread_self();
-       if (rw->__owner == self->tid) {
-               rw->__owner = 0;
-               a_store(&rw->__wrlock, 0);
-               if (rw->__waiters)
-                       __wake(&rw->__wrlock, -1, 0);
+       if (rw->_rw_owner == self->tid) {
+               rw->_rw_owner = 0;
+               a_store(&rw->_rw_wrlock, 0);
+               if (rw->_rw_waiters)
+                       __wake(&rw->_rw_wrlock, -1, 0);
                return 0;
        }
-       a_dec(&rw->__readers);
-       if (rw->__waiters && !rw->__readers)
-               __wake(&rw->__readers, 1, 0);
+       a_dec(&rw->_rw_readers);
+       if (rw->_rw_waiters && !rw->_rw_readers)
+               __wake(&rw->_rw_readers, 1, 0);
        return 0;
 }
index 219e924a5bbd14920f7323692c08933835d38ff9..8fd9ad1de1cbc0aa406c983eef12ba3cf2fc6380 100644 (file)
@@ -4,10 +4,10 @@ int pthread_rwlock_wrlock(pthread_rwlock_t *rw)
 {
        int nr;
        while (pthread_rwlock_trywrlock(rw)==EAGAIN) {
-               if ((nr=rw->__readers))
-                       __wait(&rw->__readers, &rw->__waiters, nr, 0);
+               if ((nr=rw->_rw_readers))
+                       __wait(&rw->_rw_readers, &rw->_rw_waiters, nr, 0);
                else
-                       __wait(&rw->__wrlock, &rw->__waiters, 1, 0);
+                       __wait(&rw->_rw_wrlock, &rw->_rw_waiters, 1, 0);
        }
        return 0;
 }