aboutsummaryrefslogtreecommitdiff
path: root/linuxthreads/condvar.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2000-01-31 08:11:53 +0000
committerUlrich Drepper <drepper@redhat.com>2000-01-31 08:11:53 +0000
commit8a94dfe44e23e89b366019c9b4cad1a3cc1d853b (patch)
treea6b4a42d962fa7a4904d293784f6531c77c1b552 /linuxthreads/condvar.c
parent4d76a0ec18ca374bbb5a2cf15b80515e246a135b (diff)
downloadglibc-8a94dfe44e23e89b366019c9b4cad1a3cc1d853b.tar
glibc-8a94dfe44e23e89b366019c9b4cad1a3cc1d853b.tar.gz
glibc-8a94dfe44e23e89b366019c9b4cad1a3cc1d853b.tar.bz2
glibc-8a94dfe44e23e89b366019c9b4cad1a3cc1d853b.zip
Update.
* sysdeps/alpha/fpu/feholdexcpt.c: Correct return value according to the standard. * sysdeps/alpha/fpu/fesetround.c: Likewise. * sysdeps/arm/fpu/feholdexcpt.c: Likewise. * sysdeps/arm/fpu/fesetround.c: Likewise. * sysdeps/generic/feholdexcpt.c: Likewise. * sysdeps/generic/fesetround.c: Likewise. * sysdeps/i386/fpu/feholdexcpt.c: Likewise. * sysdeps/i386/fpu/fesetround.c: Likewise. * sysdeps/m68k/fpu/feholdexcpt.c: Likewise. * sysdeps/m68k/fpu/fesetround.c: Likewise. * sysdeps/mips/fpu/fesetround.c: Likewise. * sysdeps/powerpc/fpu/feholdexcpt.c: Likewise. * sysdeps/powerpc/fpu/fesetround.c: Likewise. * sysdeps/sparc/fpu/feholdexcpt.c: Likewise. * sysdeps/sparc/fpu/fesetround.c: Likewise. Patch by Miloslav Trmac <mitr@volny.cz>.
Diffstat (limited to 'linuxthreads/condvar.c')
-rw-r--r--linuxthreads/condvar.c54
1 files changed, 34 insertions, 20 deletions
diff --git a/linuxthreads/condvar.c b/linuxthreads/condvar.c
index aab3ff257b..5f0e1939d3 100644
--- a/linuxthreads/condvar.c
+++ b/linuxthreads/condvar.c
@@ -26,13 +26,13 @@
#include "restart.h"
static int pthread_cond_timedwait_relative_old(pthread_cond_t *,
- pthread_mutex_t *, struct timespec *);
+ pthread_mutex_t *, const struct timespec *);
static int pthread_cond_timedwait_relative_new(pthread_cond_t *,
- pthread_mutex_t *, struct timespec *);
+ pthread_mutex_t *, const struct timespec *);
static int (*pthread_cond_tw_rel)(pthread_cond_t *, pthread_mutex_t *,
- struct timespec *) = pthread_cond_timedwait_relative_old;
+ const struct timespec *) = pthread_cond_timedwait_relative_old;
/* initialize this module */
void __pthread_init_condvar(int rt_sig_available)
@@ -130,16 +130,29 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
static int
pthread_cond_timedwait_relative_old(pthread_cond_t *cond,
pthread_mutex_t *mutex,
- struct timespec * reltime)
+ const struct timespec * abstime)
{
volatile pthread_descr self = thread_self();
sigset_t unblock, initial_mask;
int retsleep, already_canceled, was_signalled;
sigjmp_buf jmpbuf;
pthread_extricate_if extr;
+ struct timeval now;
+ struct timespec reltime;
requeue_and_wait_again:
+ /* Compute a time offset relative to now. */
+ __gettimeofday (&now, NULL);
+ reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
+ reltime.tv_sec = abstime->tv_sec - now.tv_sec;
+ if (reltime.tv_nsec < 0) {
+ reltime.tv_nsec += 1000000000;
+ reltime.tv_sec -= 1;
+ }
+ if (reltime.tv_sec < 0)
+ return ETIMEDOUT;
+
retsleep = 0;
already_canceled = 0;
was_signalled = 0;
@@ -179,7 +192,7 @@ requeue_and_wait_again:
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
/* Sleep for the required duration */
- retsleep = __libc_nanosleep(reltime, reltime);
+ retsleep = __libc_nanosleep(&reltime, NULL);
/* Block the restart signal again */
sigprocmask(SIG_SETMASK, &initial_mask, NULL);
was_signalled = 0;
@@ -250,16 +263,29 @@ requeue_and_wait_again:
static int
pthread_cond_timedwait_relative_new(pthread_cond_t *cond,
pthread_mutex_t *mutex,
- struct timespec * reltime)
+ const struct timespec * abstime)
{
volatile pthread_descr self = thread_self();
sigset_t unblock, initial_mask;
int retsleep, already_canceled, was_signalled;
sigjmp_buf jmpbuf;
pthread_extricate_if extr;
+ struct timeval now;
+ struct timespec reltime;
requeue_and_wait_again:
+ /* Compute a time offset relative to now. */
+ __gettimeofday (&now, NULL);
+ reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
+ reltime.tv_sec = abstime->tv_sec - now.tv_sec;
+ if (reltime.tv_nsec < 0) {
+ reltime.tv_nsec += 1000000000;
+ reltime.tv_sec -= 1;
+ }
+ if (reltime.tv_sec < 0)
+ return ETIMEDOUT;
+
retsleep = 0;
already_canceled = 0;
was_signalled = 0;
@@ -298,7 +324,7 @@ pthread_cond_timedwait_relative_new(pthread_cond_t *cond,
sigaddset(&unblock, __pthread_sig_restart);
sigprocmask(SIG_UNBLOCK, &unblock, &initial_mask);
/* Sleep for the required duration */
- retsleep = __libc_nanosleep(reltime, reltime);
+ retsleep = __libc_nanosleep(&reltime, NULL);
/* Block the restart signal again */
sigprocmask(SIG_SETMASK, &initial_mask, NULL);
was_signalled = 0;
@@ -363,20 +389,8 @@ pthread_cond_timedwait_relative_new(pthread_cond_t *cond,
int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
const struct timespec * abstime)
{
- struct timeval now;
- struct timespec reltime;
- /* Compute a time offset relative to now */
- __gettimeofday(&now, NULL);
- reltime.tv_sec = abstime->tv_sec - now.tv_sec;
- reltime.tv_nsec = abstime->tv_nsec - now.tv_usec * 1000;
- if (reltime.tv_nsec < 0) {
- reltime.tv_nsec += 1000000000;
- reltime.tv_sec -= 1;
- }
- if (reltime.tv_sec < 0) return ETIMEDOUT;
-
/* Indirect call through pointer! */
- return pthread_cond_tw_rel(cond, mutex, &reltime);
+ return pthread_cond_tw_rel(cond, mutex, abstime);
}
int pthread_cond_signal(pthread_cond_t *cond)