Remove code duplication for pthread_cond_timeout_np : use __pthread_cond_timedwait_relative helper
This commit is contained in:
parent
76ec6891e2
commit
a4e67f4512
@ -1215,22 +1215,12 @@ int pthread_cond_timeout_np(pthread_cond_t *cond,
|
|||||||
pthread_mutex_t * mutex,
|
pthread_mutex_t * mutex,
|
||||||
unsigned msecs)
|
unsigned msecs)
|
||||||
{
|
{
|
||||||
int oldvalue;
|
|
||||||
struct timespec ts;
|
struct timespec ts;
|
||||||
int status;
|
|
||||||
|
|
||||||
ts.tv_sec = msecs / 1000;
|
ts.tv_sec = msecs / 1000;
|
||||||
ts.tv_nsec = (msecs % 1000) * 1000000;
|
ts.tv_nsec = (msecs % 1000) * 1000000;
|
||||||
|
|
||||||
oldvalue = cond->value;
|
return __pthread_cond_timedwait_relative(cond, mutex, &ts);
|
||||||
|
|
||||||
pthread_mutex_unlock(mutex);
|
|
||||||
status = __futex_wait(&cond->value, oldvalue, &ts);
|
|
||||||
pthread_mutex_lock(mutex);
|
|
||||||
|
|
||||||
if(status == (-ETIMEDOUT)) return ETIMEDOUT;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user