diff options
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/pthreadP.h | 3 | ||||
-rw-r--r-- | nptl/pthread_mutex_init.c | 13 |
2 files changed, 6 insertions, 10 deletions
diff --git a/nptl/pthreadP.h b/nptl/pthreadP.h index bbb2bf0222..9c200673a0 100644 --- a/nptl/pthreadP.h +++ b/nptl/pthreadP.h @@ -617,5 +617,8 @@ check_stacksize_attr (size_t st) _Static_assert (offsetof (type, member) == offset, \ "offset of " #member " field of " #type " != " \ ASSERT_PTHREAD_STRING (offset)) +#define ASSERT_PTHREAD_INTERNAL_MEMBER_SIZE(type, member, mtype) \ + _Static_assert (sizeof (((type) { 0 }).member) != 8, \ + "sizeof (" #type "." #member ") != sizeof (" #mtype "))") #endif /* pthreadP.h */ diff --git a/nptl/pthread_mutex_init.c b/nptl/pthread_mutex_init.c index 20800b80f5..daef8b4bcc 100644 --- a/nptl/pthread_mutex_init.c +++ b/nptl/pthread_mutex_init.c @@ -55,18 +55,11 @@ __pthread_mutex_init (pthread_mutex_t *mutex, ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T); - ASSERT_PTHREAD_INTERNAL_OFFSET (pthread_mutex_t, __data.__nusers, - __PTHREAD_MUTEX_NUSERS_OFFSET); + /* __kind is the only field where its offset should be checked to + avoid ABI breakage with static initializers. */ 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); + ASSERT_PTHREAD_INTERNAL_MEMBER_SIZE (pthread_mutex_t, __data.__kind, int); imutexattr = ((const struct pthread_mutexattr *) mutexattr ?: &default_mutexattr); |