@@ -18,6 +18,7 @@
#include "pthreadP.h"
#include <string.h>
+#include <pthread-offsets.h>
static const struct pthread_rwlockattr default_rwlockattr =
@@ -34,6 +35,21 @@ __pthread_rwlock_init (pthread_rwlock_t *rwlock,
{
ASSERT_TYPE_SIZE (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__readers,
+ __PTHREAD_RWLOCK_READERS_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__writers,
+ __PTHREAD_RWLOCK_WRITERS_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__wrphase_futex,
+ __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__writers_futex,
+ __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__cur_writer,
+ __PTHREAD_RWLOCK_CUR_WRITER_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__shared,
+ __PTHREAD_RWLOCK_SHARED_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_rwlock_t, __data.__flags,
+ __PTHREAD_RWLOCK_FLAGS_OFFSET);
+
const struct pthread_rwlockattr *iattr;
iattr = ((const struct pthread_rwlockattr *) attr) ?: &default_rwlockattr;
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 24
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 24
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
@@ -3,3 +3,16 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#else
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
+#endif
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 36
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 36
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 16
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 20
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 24
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 28
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 40
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 50
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 51
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 24
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
@@ -3,3 +3,16 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#else
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
+#endif
@@ -11,3 +11,26 @@
# define __PTHREAD_MUTEX_ELISION_OFFSET 22
# define __PTHREAD_MUTEX_LIST_OFFSET 20
#endif
+
+#if _MIPS_SIM == _ABI64
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#else
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+# if __BYTE_ORDER == __BIG_ENDIAN
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+# else
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
+# endif
+#endif
@@ -3,3 +3,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
@@ -13,3 +13,21 @@
# define __PTHREAD_MUTEX_ELISION_OFFSET 22
# define __PTHREAD_MUTEX_LIST_OFFSET 20
#endif
+
+#if __WORDSIZE == 64
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#else
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#endif
@@ -22,3 +22,11 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 24
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+#define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
@@ -13,3 +13,21 @@
# define __PTHREAD_MUTEX_ELISION_OFFSET 22
# define __PTHREAD_MUTEX_LIST_OFFSET 20
#endif
+
+#if __WORDSIZE == 64
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#else
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#endif
@@ -3,3 +3,16 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 20
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+#if __BYTE_ORDER == __BIG_ENDIAN
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#else
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 25
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 24
+#endif
@@ -13,3 +13,21 @@
# define __PTHREAD_MUTEX_ELISION_OFFSET 22
# define __PTHREAD_MUTEX_LIST_OFFSET 20
#endif
+
+#if __WORDSIZE == 64
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#else
+# define __PTHREAD_RWLOCK_READERS_OFFSET 0
+# define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+# define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+# define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+# define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 28
+# define __PTHREAD_RWLOCK_SHARED_OFFSET 26
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 27
+#endif
@@ -3,3 +3,15 @@
#define __PTHREAD_MUTEX_SPINS_OFFSET 20
#define __PTHREAD_MUTEX_ELISION_OFFSET 22
#define __PTHREAD_MUTEX_LIST_OFFSET 24
+
+#define __PTHREAD_RWLOCK_READERS_OFFSET 0
+#define __PTHREAD_RWLOCK_WRITERS_OFFSET 4
+#define __PTHREAD_RWLOCK_WRPHASE_FUTEX_OFFSET 8
+#define __PTHREAD_RWLOCK_WRITERS_FUTEX_OFFSET 12
+#define __PTHREAD_RWLOCK_CUR_WRITER_OFFSET 24
+#define __PTHREAD_RWLOCK_SHARED_OFFSET 28
+#ifdef __ILP32__
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 40
+#else
+# define __PTHREAD_RWLOCK_FLAGS_OFFSET 48
+#endif