* commit '5362e8d232005056b21b65e5e0abaf58b7a2687c': Remove harmful attempts to be helpful in pthread_mutex functions.
This commit is contained in:
commit
7105f40649
@ -282,21 +282,16 @@ int pthread_mutexattr_getpshared(const pthread_mutexattr_t* attr, int* pshared)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pthread_mutex_init(pthread_mutex_t *mutex,
|
int pthread_mutex_init(pthread_mutex_t* mutex, const pthread_mutexattr_t* attr) {
|
||||||
const pthread_mutexattr_t *attr)
|
|
||||||
{
|
|
||||||
int value = 0;
|
|
||||||
|
|
||||||
if (mutex == NULL)
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
if (__predict_true(attr == NULL)) {
|
if (__predict_true(attr == NULL)) {
|
||||||
mutex->value = MUTEX_TYPE_BITS_NORMAL;
|
mutex->value = MUTEX_TYPE_BITS_NORMAL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((*attr & MUTEXATTR_SHARED_MASK) != 0)
|
int value = 0;
|
||||||
|
if ((*attr & MUTEXATTR_SHARED_MASK) != 0) {
|
||||||
value |= MUTEX_SHARED_MASK;
|
value |= MUTEX_SHARED_MASK;
|
||||||
|
}
|
||||||
|
|
||||||
switch (*attr & MUTEXATTR_TYPE_MASK) {
|
switch (*attr & MUTEXATTR_TYPE_MASK) {
|
||||||
case PTHREAD_MUTEX_NORMAL:
|
case PTHREAD_MUTEX_NORMAL:
|
||||||
@ -473,9 +468,6 @@ int pthread_mutex_lock_impl(pthread_mutex_t *mutex)
|
|||||||
{
|
{
|
||||||
int mvalue, mtype, tid, shared;
|
int mvalue, mtype, tid, shared;
|
||||||
|
|
||||||
if (__predict_false(mutex == NULL))
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
mvalue = mutex->value;
|
mvalue = mutex->value;
|
||||||
mtype = (mvalue & MUTEX_TYPE_MASK);
|
mtype = (mvalue & MUTEX_TYPE_MASK);
|
||||||
shared = (mvalue & MUTEX_SHARED_MASK);
|
shared = (mvalue & MUTEX_SHARED_MASK);
|
||||||
@ -565,9 +557,6 @@ int pthread_mutex_unlock_impl(pthread_mutex_t *mutex)
|
|||||||
{
|
{
|
||||||
int mvalue, mtype, tid, shared;
|
int mvalue, mtype, tid, shared;
|
||||||
|
|
||||||
if (__predict_false(mutex == NULL))
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
mvalue = mutex->value;
|
mvalue = mutex->value;
|
||||||
mtype = (mvalue & MUTEX_TYPE_MASK);
|
mtype = (mvalue & MUTEX_TYPE_MASK);
|
||||||
shared = (mvalue & MUTEX_SHARED_MASK);
|
shared = (mvalue & MUTEX_SHARED_MASK);
|
||||||
@ -630,9 +619,6 @@ int pthread_mutex_trylock_impl(pthread_mutex_t *mutex)
|
|||||||
{
|
{
|
||||||
int mvalue, mtype, tid, shared;
|
int mvalue, mtype, tid, shared;
|
||||||
|
|
||||||
if (__predict_false(mutex == NULL))
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
mvalue = mutex->value;
|
mvalue = mutex->value;
|
||||||
mtype = (mvalue & MUTEX_TYPE_MASK);
|
mtype = (mvalue & MUTEX_TYPE_MASK);
|
||||||
shared = (mvalue & MUTEX_SHARED_MASK);
|
shared = (mvalue & MUTEX_SHARED_MASK);
|
||||||
@ -705,9 +691,6 @@ int pthread_mutex_lock_timeout_np_impl(pthread_mutex_t *mutex, unsigned msecs)
|
|||||||
/* compute absolute expiration time */
|
/* compute absolute expiration time */
|
||||||
__timespec_to_relative_msec(&abstime, msecs, clock);
|
__timespec_to_relative_msec(&abstime, msecs, clock);
|
||||||
|
|
||||||
if (__predict_false(mutex == NULL))
|
|
||||||
return EINVAL;
|
|
||||||
|
|
||||||
mvalue = mutex->value;
|
mvalue = mutex->value;
|
||||||
mtype = (mvalue & MUTEX_TYPE_MASK);
|
mtype = (mvalue & MUTEX_TYPE_MASK);
|
||||||
shared = (mvalue & MUTEX_SHARED_MASK);
|
shared = (mvalue & MUTEX_SHARED_MASK);
|
||||||
|
Loading…
Reference in New Issue
Block a user