mirror of
git://git.musl-libc.org/musl
synced 2025-04-01 22:48:38 +00:00
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:
parent
c4dd0c98ba
commit
0109d950e6
@ -48,9 +48,9 @@ TYPEDEF struct __pthread * pthread_t;
|
||||
TYPEDEF int pthread_once_t;
|
||||
TYPEDEF int pthread_key_t;
|
||||
TYPEDEF int pthread_spinlock_t;
|
||||
TYPEDEF unsigned pthread_mutexattr_t;
|
||||
TYPEDEF unsigned pthread_condattr_t;
|
||||
TYPEDEF unsigned pthread_barrierattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_mutexattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_condattr_t;
|
||||
TYPEDEF struct { unsigned __attr; } pthread_barrierattr_t;
|
||||
TYPEDEF struct { unsigned __attr[2]; } pthread_rwlockattr_t;
|
||||
|
||||
TYPEDEF struct _IO_FILE 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)
|
||||
{
|
||||
*pshared = !!*a;
|
||||
*pshared = !!a->__attr;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_getclock(const pthread_condattr_t *restrict a, clockid_t *restrict clk)
|
||||
{
|
||||
*clk = *a & 0x7fffffff;
|
||||
*clk = a->__attr & 0x7fffffff;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_condattr_getpshared(const pthread_condattr_t *restrict a, int *restrict pshared)
|
||||
{
|
||||
*pshared = *a>>31;
|
||||
*pshared = a->__attr>>31;
|
||||
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)
|
||||
{
|
||||
*pshared = *a>>31;
|
||||
*pshared = a->__attr>>31;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_getrobust(const pthread_mutexattr_t *restrict a, int *restrict robust)
|
||||
{
|
||||
*robust = *a / 4U % 2;
|
||||
*robust = a->__attr / 4U % 2;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_mutexattr_gettype(const pthread_mutexattr_t *restrict a, int *restrict type)
|
||||
{
|
||||
*type = *a & 3;
|
||||
*type = a->__attr & 3;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pthread_rwlockattr_getpshared(const pthread_rwlockattr_t *restrict a, int *restrict pshared)
|
||||
{
|
||||
*pshared = *(int *)a;
|
||||
*pshared = a->__attr[0];
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
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;
|
||||
*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;
|
||||
}
|
||||
|
@ -2,6 +2,6 @@
|
||||
|
||||
int pthread_barrierattr_setpshared(pthread_barrierattr_t *a, int pshared)
|
||||
{
|
||||
*a = pshared ? INT_MIN : 0;
|
||||
a->__attr = pshared ? INT_MIN : 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -4,8 +4,8 @@ int pthread_cond_init(pthread_cond_t *restrict c, const pthread_condattr_t *rest
|
||||
{
|
||||
*c = (pthread_cond_t){0};
|
||||
if (a) {
|
||||
c->_c_clock = *a & 0x7fffffff;
|
||||
if (*a>>31) c->_c_mutex = (void *)-1;
|
||||
c->_c_clock = a->__attr & 0x7fffffff;
|
||||
if (a->__attr>>31) c->_c_mutex = (void *)-1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
int pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clk)
|
||||
{
|
||||
if (clk < 0 || clk-2U < 2) return EINVAL;
|
||||
*a &= 0x80000000;
|
||||
*a |= clk;
|
||||
a->__attr &= 0x80000000;
|
||||
a->__attr |= clk;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
int pthread_condattr_setpshared(pthread_condattr_t *a, int pshared)
|
||||
{
|
||||
if (pshared > 1U) return EINVAL;
|
||||
*a &= 0x7fffffff;
|
||||
*a |= pshared<<31;
|
||||
a->__attr &= 0x7fffffff;
|
||||
a->__attr |= pshared<<31;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
int pthread_mutex_init(pthread_mutex_t *restrict m, const pthread_mutexattr_t *restrict a)
|
||||
{
|
||||
*m = (pthread_mutex_t){0};
|
||||
if (a) m->_m_type = *a & 7;
|
||||
if (a) m->_m_type = a->__attr & 7;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
int pthread_mutexattr_setpshared(pthread_mutexattr_t *a, int pshared)
|
||||
{
|
||||
if (pshared > 1U) return EINVAL;
|
||||
*a &= 0x7fffffff;
|
||||
*a |= pshared<<31;
|
||||
a->__attr &= 0x7fffffff;
|
||||
a->__attr |= pshared<<31;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,7 +3,7 @@
|
||||
int pthread_mutexattr_setrobust(pthread_mutexattr_t *a, int robust)
|
||||
{
|
||||
if (robust > 1U) return EINVAL;
|
||||
*a &= ~4;
|
||||
*a |= robust*4;
|
||||
a->__attr &= ~4;
|
||||
a->__attr |= robust*4;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
int pthread_mutexattr_settype(pthread_mutexattr_t *a, int type)
|
||||
{
|
||||
if ((unsigned)type > 2) return EINVAL;
|
||||
*a = (*a & ~3) | type;
|
||||
a->__attr = (a->__attr & ~3) | type;
|
||||
return 0;
|
||||
}
|
||||
|
@ -3,6 +3,6 @@
|
||||
int pthread_rwlockattr_setpshared(pthread_rwlockattr_t *a, int pshared)
|
||||
{
|
||||
if (pshared > 1U) return EINVAL;
|
||||
*(int *)a = pshared;
|
||||
a->__attr[0] = pshared;
|
||||
return 0;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user