mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 03:07:44 +00:00
LibPthread: Hookup abstime argument to pthread_cond_timedwait
Now that the futex implementation actually supports timeouts, we can fix the LibPthread implementation of pthread_cond_timedwait to support the timeout argument.
This commit is contained in:
parent
25a620a573
commit
6116739b38
1 changed files with 10 additions and 7 deletions
|
@ -485,14 +485,20 @@ int pthread_cond_destroy(pthread_cond_t*)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
|
static int cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime)
|
||||||
{
|
{
|
||||||
i32 value = cond->value;
|
i32 value = cond->value;
|
||||||
cond->previous = value;
|
cond->previous = value;
|
||||||
pthread_mutex_unlock(mutex);
|
pthread_mutex_unlock(mutex);
|
||||||
int rc = futex(&cond->value, FUTEX_WAIT, value, nullptr);
|
int rc = futex(&cond->value, FUTEX_WAIT, value, abstime);
|
||||||
ASSERT(rc == 0);
|
|
||||||
pthread_mutex_lock(mutex);
|
pthread_mutex_lock(mutex);
|
||||||
|
return rc;
|
||||||
|
}
|
||||||
|
|
||||||
|
int pthread_cond_wait(pthread_cond_t* cond, pthread_mutex_t* mutex)
|
||||||
|
{
|
||||||
|
int rc = cond_wait(cond, mutex, nullptr);
|
||||||
|
ASSERT(rc == 0);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -515,10 +521,7 @@ int pthread_condattr_setclock(pthread_condattr_t* attr, clockid_t clock)
|
||||||
|
|
||||||
int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime)
|
int pthread_cond_timedwait(pthread_cond_t* cond, pthread_mutex_t* mutex, const struct timespec* abstime)
|
||||||
{
|
{
|
||||||
// FIXME: Implement timeout.
|
return cond_wait(cond, mutex, abstime);
|
||||||
(void)abstime;
|
|
||||||
pthread_cond_wait(cond, mutex);
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int pthread_cond_signal(pthread_cond_t* cond)
|
int pthread_cond_signal(pthread_cond_t* cond)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue