Cygwin: implement pthread_cond_clockwait
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
edf48054e9
commit
123454f9d0
|
@ -1092,6 +1092,7 @@ pthread_barrierattr_init SIGFE
|
|||
pthread_barrierattr_setpshared SIGFE
|
||||
pthread_cancel SIGFE
|
||||
pthread_cond_broadcast SIGFE
|
||||
pthread_cond_clockwait SIGFE
|
||||
pthread_cond_destroy SIGFE
|
||||
pthread_cond_init SIGFE
|
||||
pthread_cond_signal SIGFE
|
||||
|
|
|
@ -120,6 +120,10 @@ int pthread_cond_broadcast (pthread_cond_t *);
|
|||
int pthread_cond_destroy (pthread_cond_t *);
|
||||
int pthread_cond_init (pthread_cond_t *, const pthread_condattr_t *);
|
||||
int pthread_cond_signal (pthread_cond_t *);
|
||||
#if __GNU_VISIBLE
|
||||
int pthread_cond_clockwait (pthread_cond_t *, pthread_mutex_t *,
|
||||
clockid_t, const struct timespec *);
|
||||
#endif
|
||||
int pthread_cond_timedwait (pthread_cond_t *,
|
||||
pthread_mutex_t *, const struct timespec *);
|
||||
int pthread_cond_wait (pthread_cond_t *, pthread_mutex_t *);
|
||||
|
|
|
@ -2965,13 +2965,31 @@ __pthread_cond_wait_init (pthread_cond_t *cond, pthread_mutex_t *mutex)
|
|||
return 0;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
const struct timespec *abstime)
|
||||
static int
|
||||
__pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
clockid_t clock_id, const struct timespec *abstime)
|
||||
{
|
||||
int err = 0;
|
||||
LARGE_INTEGER timeout;
|
||||
|
||||
do
|
||||
{
|
||||
err = pthread_convert_abstime (clock_id, abstime, &timeout);
|
||||
if (err)
|
||||
break;
|
||||
|
||||
err = (*cond)->wait (*mutex, &timeout);
|
||||
}
|
||||
while (err == ETIMEDOUT);
|
||||
return err;
|
||||
}
|
||||
|
||||
extern "C" int
|
||||
pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
clockid_t clock_id, const struct timespec *abstime)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
pthread_testcancel ();
|
||||
|
||||
__try
|
||||
|
@ -2979,16 +2997,30 @@ pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
|||
err = __pthread_cond_wait_init (cond, mutex);
|
||||
if (err)
|
||||
__leave;
|
||||
err = __pthread_cond_clockwait (cond, mutex, clock_id, abstime);
|
||||
}
|
||||
__except (NO_ERROR)
|
||||
{
|
||||
return EINVAL;
|
||||
}
|
||||
__endtry
|
||||
return err;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
err = pthread_convert_abstime ((*cond)->clock_id, abstime, &timeout);
|
||||
if (err)
|
||||
__leave;
|
||||
extern "C" int
|
||||
pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex,
|
||||
const struct timespec *abstime)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
err = (*cond)->wait (*mutex, &timeout);
|
||||
}
|
||||
while (err == ETIMEDOUT);
|
||||
pthread_testcancel ();
|
||||
|
||||
__try
|
||||
{
|
||||
err = __pthread_cond_wait_init (cond, mutex);
|
||||
if (err)
|
||||
__leave;
|
||||
err = __pthread_cond_clockwait (cond, mutex, (*cond)->clock_id, abstime);
|
||||
}
|
||||
__except (NO_ERROR)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue