make pthread attribute types structs, even when they just have one field

this change is to get the right tags for C++ ABI matching. it should
have no other effects.
This commit is contained in:
Rich Felker 2013-07-22 13:57:02 -04:00
parent c4dd0c98ba
commit 0109d950e6
12 changed files with 25 additions and 25 deletions

View File

@ -48,9 +48,9 @@ TYPEDEF struct __pthread * pthread_t;
TYPEDEF int pthread_once_t; TYPEDEF int pthread_once_t;
TYPEDEF int pthread_key_t; TYPEDEF int pthread_key_t;
TYPEDEF int pthread_spinlock_t; TYPEDEF int pthread_spinlock_t;
TYPEDEF unsigned pthread_mutexattr_t; TYPEDEF struct { unsigned __attr; } pthread_mutexattr_t;
TYPEDEF unsigned pthread_condattr_t; TYPEDEF struct { unsigned __attr; } pthread_condattr_t;
TYPEDEF unsigned pthread_barrierattr_t; TYPEDEF struct { unsigned __attr; } pthread_barrierattr_t;
TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t; TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
TYPEDEF struct _IO_FILE FILE; TYPEDEF struct _IO_FILE FILE;

View File

@ -52,19 +52,19 @@ int pthread_attr_getstacksize(const pthread_attr_t *restrict a, size_t *restrict
int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared) int pthread_barrierattr_getpshared(const pthread_barrierattr_t *restrict a, int *restrict pshared)
{ {
*pshared = !!*a; *pshared = !!a->__attr;
return 0; return 0;
} }
int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk) int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
{ {
*clk = *a & 0x7fffffff; *clk = a->__attr & 0x7fffffff;
return 0; return 0;
} }
int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared) int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
{ {
*pshared = *a>>31; *pshared = a->__attr>>31;
return 0; return 0;
} }
@ -75,24 +75,24 @@ int pthread_mutexattr_getprotocol(const pthread_mutexattr_t *restrict a, int *re
} }
int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared) int pthread_mutexattr_getpshared(const pthread_mutexattr_t *restrict a, int *restrict pshared)
{ {
*pshared = *a>>31; *pshared = a->__attr>>31;
return 0; return 0;
} }
int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust) int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust)
{ {
*robust = *a / 4U % 2; *robust = a->__attr / 4U % 2;
return 0; return 0;
} }
int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type) int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type)
{ {
*type = *a & 3; *type = a->__attr & 3;
return 0; return 0;
} }
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared) int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared)
{ {
*pshared = *(int *)a; *pshared = a->__attr[0];
return 0; return 0;
} }

View File

@ -3,6 +3,6 @@
int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count) int pthread_barrier_init(pthread_barrier_t *restrict b, const pthread_barrierattr_t *restrict a, unsigned count)
{ {
if (count-1 > INT_MAX-1) return EINVAL; if (count-1 > INT_MAX-1) return EINVAL;
*b = (pthread_barrier_t){ ._b_limit = count-1 | (a?*a:0) }; *b = (pthread_barrier_t){ ._b_limit = count-1 | (a?a->__attr:0) };
return 0; return 0;
} }

View File

@ -2,6 +2,6 @@
int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared) int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared)
{ {
*a = pshared ? INT_MIN : 0; a->__attr = pshared ? INT_MIN : 0;
return 0; return 0;
} }

View File

@ -4,8 +4,8 @@ int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *rest
{ {
*c = (pthread_cond_t){0}; *c = (pthread_cond_t){0};
if (a) { if (a) {
c->_c_clock = *a & 0x7fffffff; c->_c_clock = a->__attr & 0x7fffffff;
if (*a>>31) c->_c_mutex = (void *)-1; if (a->__attr>>31) c->_c_mutex = (void *)-1;
} }
return 0; return 0;
} }

View File

@ -3,7 +3,7 @@
int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk) int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk)
{ {
if (clk < 0 || clk-2U < 2) return EINVAL; if (clk < 0 || clk-2U < 2) return EINVAL;
*a &= 0x80000000; a->__attr &= 0x80000000;
*a |= clk; a->__attr |= clk;
return 0; return 0;
} }

View File

@ -3,7 +3,7 @@
int pthread_condattr_setpshared(pthread_condattr_t *a, int pshared) int pthread_condattr_setpshared(pthread_condattr_t *a, int pshared)
{ {
if (pshared > 1U) return EINVAL; if (pshared > 1U) return EINVAL;
*a &= 0x7fffffff; a->__attr &= 0x7fffffff;
*a |= pshared<<31; a->__attr |= pshared<<31;
return 0; return 0;
} }

View File

@ -3,6 +3,6 @@
int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a) int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a)
{ {
*m = (pthread_mutex_t){0}; *m = (pthread_mutex_t){0};
if (a) m->_m_type = *a & 7; if (a) m->_m_type = a->__attr & 7;
return 0; return 0;
} }

View File

@ -3,7 +3,7 @@
int pthread_mutexattr_setpshared(pthread_mutexattr_t *a, int pshared) int pthread_mutexattr_setpshared(pthread_mutexattr_t *a, int pshared)
{ {
if (pshared > 1U) return EINVAL; if (pshared > 1U) return EINVAL;
*a &= 0x7fffffff; a->__attr &= 0x7fffffff;
*a |= pshared<<31; a->__attr |= pshared<<31;
return 0; return 0;
} }

View File

@ -3,7 +3,7 @@
int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust) int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust)
{ {
if (robust > 1U) return EINVAL; if (robust > 1U) return EINVAL;
*a &= ~4; a->__attr &= ~4;
*a |= robust*4; a->__attr |= robust*4;
return 0; return 0;
} }

View File

@ -3,6 +3,6 @@
int pthread_mutexattr_settype(pthread_mutexattr_t *a, int type) int pthread_mutexattr_settype(pthread_mutexattr_t *a, int type)
{ {
if ((unsigned)type > 2) return EINVAL; if ((unsigned)type > 2) return EINVAL;
*a = (*a & ~3) | type; a->__attr = (a->__attr & ~3) | type;
return 0; return 0;
} }

View File

@ -3,6 +3,6 @@
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int pshared) int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int pshared)
{ {
if (pshared > 1U) return EINVAL; if (pshared > 1U) return EINVAL;
*(int *)a = pshared; a->__attr[0] = pshared;
return 0; return 0;
} }