1
0
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:
Samuel Thibault
2020-01-13 01:17:07 +01:00
parent e404be33fe
commit 196e62cbe4
14 changed files with 42 additions and 0 deletions

View File

@@ -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;
}

View File

@@ -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;

View File

@@ -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;
}

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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. */

View File

@@ -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;
}

View File

@@ -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)
{

View File

@@ -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

View File

@@ -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;
}

View File

@@ -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 */

View File

@@ -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 */

View File

@@ -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;

View File

@@ -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;
}