mirror of
https://sourceware.org/git/glibc.git
synced 2025-08-08 17:42:12 +03:00
htl: Add type sizes in bits/pthreadtypes-arch.h and check them
This commit is contained in:
@@ -22,6 +22,8 @@
|
||||
int
|
||||
__pthread_attr_init (pthread_attr_t *attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_attr_t, __SIZEOF_PTHREAD_ATTR_T);
|
||||
|
||||
*attr = __pthread_default_attr;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -26,6 +26,8 @@ int
|
||||
pthread_barrier_init (pthread_barrier_t *barrier,
|
||||
const pthread_barrierattr_t *attr, unsigned count)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_barrier_t, __SIZEOF_PTHREAD_BARRIER_T);
|
||||
|
||||
if (count == 0)
|
||||
return EINVAL;
|
||||
|
||||
|
@@ -22,6 +22,8 @@
|
||||
int
|
||||
pthread_barrierattr_init (pthread_barrierattr_t *attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_barrierattr_t, __SIZEOF_PTHREAD_BARRIERATTR_T);
|
||||
|
||||
*attr = __pthread_default_barrierattr;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -25,6 +25,8 @@
|
||||
int
|
||||
__pthread_cond_init (pthread_cond_t *cond, const pthread_condattr_t * attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_cond_t, __SIZEOF_PTHREAD_COND_T);
|
||||
|
||||
*cond = (pthread_cond_t) __PTHREAD_COND_INITIALIZER;
|
||||
|
||||
if (attr == NULL
|
||||
|
@@ -22,6 +22,8 @@
|
||||
int
|
||||
__pthread_condattr_init (pthread_condattr_t *attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_condattr_t, __SIZEOF_PTHREAD_CONDATTR_T);
|
||||
|
||||
*attr = __pthread_default_condattr;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@ _pthread_mutex_init (pthread_mutex_t *mutex, const pthread_mutexattr_t *attr)
|
||||
{
|
||||
*mutex = (pthread_mutex_t) __PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T);
|
||||
|
||||
if (attr == NULL
|
||||
|| memcmp (attr, &__pthread_default_mutexattr, sizeof (*attr)) == 0)
|
||||
/* The default attributes. */
|
||||
|
@@ -22,6 +22,8 @@
|
||||
int
|
||||
__pthread_mutexattr_init (pthread_mutexattr_t *attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T);
|
||||
|
||||
*attr = __pthread_default_mutexattr;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -24,6 +24,8 @@
|
||||
int
|
||||
__pthread_once (pthread_once_t *once_control, void (*init_routine) (void))
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_once_t, __SIZEOF_PTHREAD_ONCE_T);
|
||||
|
||||
atomic_full_barrier ();
|
||||
if (once_control->__run == 0)
|
||||
{
|
||||
|
@@ -24,6 +24,8 @@ int
|
||||
_pthread_rwlock_init (pthread_rwlock_t *rwlock,
|
||||
const pthread_rwlockattr_t *attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_rwlock_t, __SIZEOF_PTHREAD_RWLOCK_T);
|
||||
|
||||
*rwlock = (pthread_rwlock_t) __PTHREAD_RWLOCK_INITIALIZER;
|
||||
|
||||
if (attr == NULL
|
||||
|
@@ -22,6 +22,8 @@
|
||||
int
|
||||
pthread_rwlockattr_init (pthread_rwlockattr_t *attr)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_rwlockattr_t, __SIZEOF_PTHREAD_RWLOCKATTR_T);
|
||||
|
||||
*attr = __pthread_default_rwlockattr;
|
||||
return 0;
|
||||
}
|
||||
|
@@ -74,4 +74,8 @@ hidden_proto (__pthread_setspecific)
|
||||
hidden_proto (_pthread_mutex_init)
|
||||
#endif
|
||||
|
||||
#define ASSERT_TYPE_SIZE(type, size) \
|
||||
_Static_assert (sizeof (type) == size, \
|
||||
"sizeof (" #type ") != " #size)
|
||||
|
||||
#endif /* pthreadP.h */
|
||||
|
@@ -19,4 +19,18 @@
|
||||
#ifndef _BITS_PTHREADTYPES_ARCH_H
|
||||
#define _BITS_PTHREADTYPES_ARCH_H 1
|
||||
|
||||
#define __SIZEOF_PTHREAD_MUTEX_T 32
|
||||
#define __SIZEOF_PTHREAD_ATTR_T 32
|
||||
#define __SIZEOF_PTHREAD_RWLOCK_T 28
|
||||
#define __SIZEOF_PTHREAD_BARRIER_T 24
|
||||
#define __SIZEOF_PTHREAD_MUTEXATTR_T 16
|
||||
#define __SIZEOF_PTHREAD_COND_T 20
|
||||
#define __SIZEOF_PTHREAD_CONDATTR_T 8
|
||||
#define __SIZEOF_PTHREAD_RWLOCKATTR_T 4
|
||||
#define __SIZEOF_PTHREAD_BARRIERATTR_T 4
|
||||
#define __SIZEOF_PTHREAD_ONCE_T 8
|
||||
|
||||
#define __LOCK_ALIGNMENT
|
||||
#define __ONCE_ALIGNMENT
|
||||
|
||||
#endif /* bits/pthreadtypes.h */
|
||||
|
@@ -34,6 +34,8 @@ static const pthread_mutexattr_t dfl_attr = {
|
||||
int
|
||||
_pthread_mutex_init (pthread_mutex_t *mtxp, const pthread_mutexattr_t *attrp)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_mutex_t, __SIZEOF_PTHREAD_MUTEX_T);
|
||||
|
||||
if (attrp == NULL)
|
||||
attrp = &dfl_attr;
|
||||
|
||||
|
@@ -33,6 +33,8 @@ static const pthread_mutexattr_t dfl_attr = {
|
||||
int
|
||||
__pthread_mutexattr_init (pthread_mutexattr_t *attrp)
|
||||
{
|
||||
ASSERT_TYPE_SIZE (pthread_mutexattr_t, __SIZEOF_PTHREAD_MUTEXATTR_T);
|
||||
|
||||
*attrp = dfl_attr;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user