aboutsummaryrefslogtreecommitdiff
path: root/nptl
diff options
context:
space:
mode:
Diffstat (limited to 'nptl')
-rw-r--r--nptl/pthreadP.h6
-rw-r--r--nptl/pthread_mutex_init.c13
2 files changed, 19 insertions, 0 deletions
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h
index dbf46b0..ae1b881 100644
--- a/nptl/pthreadP.h
+++ b/nptl/pthreadP.h
@@ -639,4 +639,10 @@ check_stacksize_attr (size_t st)
return EINVAL;
}
+#define ASSERT_PTHREAD_STRING(x) __STRING (x)
+#define ASSERT_PTHREAD_INTERNAL_OFFSET(type, member, offset) \
+ _Static_assert (offsetof (type, member) == offset, \
+ "offset of " #member " field of " #type " != " \
+ ASSERT_PTHREAD_STRING (offset))
+
#endif /* pthreadP.h */
diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c
index 6f2fc80..e1f911b 100644
--- a/nptl/pthread_mutex_init.c
+++ b/nptl/pthread_mutex_init.c
@@ -23,6 +23,7 @@
#include <kernel-features.h>
#include "pthreadP.h"
#include <atomic.h>
+#include <pthread-offsets.h>
#include <stap-probe.h>
@@ -58,6 +59,18 @@ __pthread_mutex_init (pthread_mutex_t *mutex,
const struct pthread_mutexattr *imutexattr;
assert (sizeof (pthread_mutex_t) <= __SIZEOF_PTHREAD_MUTEX_T);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__nusers,
+ __PTHREAD_MUTEX_NUSERS_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__kind,
+ __PTHREAD_MUTEX_KIND_OFFSET);
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__spins,
+ __PTHREAD_MUTEX_SPINS_OFFSET);
+#if __PTHREAD_MUTEX_LOCK_ELISION
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__elision,
+ __PTHREAD_MUTEX_ELISION_OFFSET);
+#endif
+ ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__list,
+ __PTHREAD_MUTEX_LIST_OFFSET);
imutexattr = ((const struct pthread_mutexattr *) mutexattr
?: &default_mutexattr);