diff options
Diffstat (limited to 'nptl')
-rw-r--r-- | nptl/lll_timedlock_wait.c | 3 | ||||
-rw-r--r-- | nptl/pthread_cond_wait.c | 4 | ||||
-rw-r--r-- | nptl/pthread_join_common.c | 3 | ||||
-rw-r--r-- | nptl/pthread_mutex_timedlock.c | 4 | ||||
-rw-r--r-- | nptl/pthread_rwlock_common.c | 7 | ||||
-rw-r--r-- | nptl/sem_clockwait.c | 3 | ||||
-rw-r--r-- | nptl/sem_timedwait.c | 3 |
7 files changed, 15 insertions, 12 deletions
diff --git a/nptl/lll_timedlock_wait.c b/nptl/lll_timedlock_wait.c index 03060e874b..cd3cc3d371 100644 --- a/nptl/lll_timedlock_wait.c +++ b/nptl/lll_timedlock_wait.c @@ -21,6 +21,7 @@ #include <errno.h> #include <lowlevellock.h> #include <sys/time.h> +#include <time.h> int @@ -28,7 +29,7 @@ __lll_clocklock_wait (int *futex, clockid_t clockid, const struct timespec *abstime, int private) { /* Reject invalid timeouts. */ - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) return EINVAL; /* Try locking. */ diff --git a/nptl/pthread_cond_wait.c b/nptl/pthread_cond_wait.c index bacae09c02..cf372bc017 100644 --- a/nptl/pthread_cond_wait.c +++ b/nptl/pthread_cond_wait.c @@ -645,7 +645,7 @@ __pthread_cond_timedwait (pthread_cond_t *cond, pthread_mutex_t *mutex, { /* Check parameter validity. This should also tell the compiler that it can assume that abstime is not NULL. */ - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) return EINVAL; /* Relaxed MO is suffice because clock ID bit is only modified @@ -668,7 +668,7 @@ __pthread_cond_clockwait (pthread_cond_t *cond, pthread_mutex_t *mutex, { /* Check parameter validity. This should also tell the compiler that it can assume that abstime is not NULL. */ - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) return EINVAL; if (!futex_abstimed_supported_clockid (clockid)) diff --git a/nptl/pthread_join_common.c b/nptl/pthread_join_common.c index 9545ae4bd3..8b55c380e9 100644 --- a/nptl/pthread_join_common.c +++ b/nptl/pthread_join_common.c @@ -19,6 +19,7 @@ #include "pthreadP.h" #include <atomic.h> #include <stap-probe.h> +#include <time.h> static void cleanup (void *arg) @@ -40,7 +41,7 @@ timedwait_tid (pid_t *tidp, const struct timespec *abstime) { pid_t tid; - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) return EINVAL; /* Repeat until thread terminated. */ diff --git a/nptl/pthread_mutex_timedlock.c b/nptl/pthread_mutex_timedlock.c index a0ce044dd4..c9bb3b9176 100644 --- a/nptl/pthread_mutex_timedlock.c +++ b/nptl/pthread_mutex_timedlock.c @@ -235,7 +235,7 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, } /* We are about to block; check whether the timeout is invalid. */ - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) return EINVAL; /* Work around the fact that the kernel rejects negative timeout values despite them being valid. */ @@ -561,7 +561,7 @@ __pthread_mutex_clocklock_common (pthread_mutex_t *mutex, if (oldval != ceilval) { /* Reject invalid timeouts. */ - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) { result = EINVAL; goto failpp; diff --git a/nptl/pthread_rwlock_common.c b/nptl/pthread_rwlock_common.c index 7070b9c2c8..9c05e03a09 100644 --- a/nptl/pthread_rwlock_common.c +++ b/nptl/pthread_rwlock_common.c @@ -24,6 +24,7 @@ #include <stap-probe.h> #include <atomic.h> #include <futex-internal.h> +#include <time.h> /* A reader--writer lock that fulfills the POSIX requirements (but operations @@ -290,8 +291,7 @@ __pthread_rwlock_rdlock_full (pthread_rwlock_t *rwlock, if the lock can be immediately acquired" (i.e., we need not but may check it). */ if (abstime && __glibc_unlikely (!futex_abstimed_supported_clockid (clockid) - || abstime->tv_nsec >= 1000000000 - || abstime->tv_nsec < 0)) + || ! valid_nanoseconds (abstime->tv_nsec))) return EINVAL; /* Make sure we are not holding the rwlock as a writer. This is a deadlock @@ -596,8 +596,7 @@ __pthread_rwlock_wrlock_full (pthread_rwlock_t *rwlock, if the lock can be immediately acquired" (i.e., we need not but may check it). */ if (abstime && __glibc_unlikely (!futex_abstimed_supported_clockid (clockid) - || abstime->tv_nsec >= 1000000000 - || abstime->tv_nsec < 0)) + || ! valid_nanoseconds (abstime->tv_nsec))) return EINVAL; /* Make sure we are not holding the rwlock as a writer. This is a deadlock diff --git a/nptl/sem_clockwait.c b/nptl/sem_clockwait.c index 9ed98c4cce..21628df524 100644 --- a/nptl/sem_clockwait.c +++ b/nptl/sem_clockwait.c @@ -18,6 +18,7 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <time.h> #include "sem_waitcommon.c" int @@ -32,7 +33,7 @@ sem_clockwait (sem_t *sem, clockid_t clockid, return -1; } - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) { __set_errno (EINVAL); return -1; diff --git a/nptl/sem_timedwait.c b/nptl/sem_timedwait.c index fbb50a5fc8..a3fbe8998b 100644 --- a/nptl/sem_timedwait.c +++ b/nptl/sem_timedwait.c @@ -17,6 +17,7 @@ License along with the GNU C Library; if not, see <https://www.gnu.org/licenses/>. */ +#include <time.h> #include "sem_waitcommon.c" /* This is in a separate file because because sem_timedwait is only provided @@ -24,7 +25,7 @@ int sem_timedwait (sem_t *sem, const struct timespec *abstime) { - if (abstime->tv_nsec < 0 || abstime->tv_nsec >= 1000000000) + if (! valid_nanoseconds (abstime->tv_nsec)) { __set_errno (EINVAL); return -1; |