diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2006-01-09 23:52:29 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@g5.osdl.org> | 2006-01-10 11:01:36 -0500 |
commit | 5f82b2b77e66d452c3037cc47f436d2d76fd5f06 (patch) | |
tree | c3c5f11d7160fa4651ca1acf5d927a7546c3d725 | |
parent | 2a698971941bf5e6ebe96275f7d5318b2cf91ccf (diff) |
[PATCH] hrtimer: create and use timespec_valid macro
add timespec_valid(ts) [returns false if the timespec is denorm]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r-- | include/linux/time.h | 6 | ||||
-rw-r--r-- | kernel/posix-timers.c | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index 4d49cabb9b47..64e797464589 100644 --- a/include/linux/time.h +++ b/include/linux/time.h | |||
@@ -44,6 +44,12 @@ extern unsigned long mktime(const unsigned int year, const unsigned int mon, | |||
44 | 44 | ||
45 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); | 45 | extern void set_normalized_timespec(struct timespec *ts, time_t sec, long nsec); |
46 | 46 | ||
47 | /* | ||
48 | * Returns true if the timespec is norm, false if denorm: | ||
49 | */ | ||
50 | #define timespec_valid(ts) \ | ||
51 | (((ts)->tv_sec >= 0) && (((unsigned) (ts)->tv_nsec) < NSEC_PER_SEC)) | ||
52 | |||
47 | extern struct timespec xtime; | 53 | extern struct timespec xtime; |
48 | extern struct timespec wall_to_monotonic; | 54 | extern struct timespec wall_to_monotonic; |
49 | extern seqlock_t xtime_lock; | 55 | extern seqlock_t xtime_lock; |
diff --git a/kernel/posix-timers.c b/kernel/posix-timers.c index 69d5a4b5395b..6b851a1bf4b0 100644 --- a/kernel/posix-timers.c +++ b/kernel/posix-timers.c | |||
@@ -712,8 +712,7 @@ out: | |||
712 | */ | 712 | */ |
713 | static int good_timespec(const struct timespec *ts) | 713 | static int good_timespec(const struct timespec *ts) |
714 | { | 714 | { |
715 | if ((!ts) || (ts->tv_sec < 0) || | 715 | if ((!ts) || !timespec_valid(ts)) |
716 | ((unsigned) ts->tv_nsec >= NSEC_PER_SEC)) | ||
717 | return 0; | 716 | return 0; |
718 | return 1; | 717 | return 1; |
719 | } | 718 | } |
@@ -1406,7 +1405,7 @@ sys_clock_nanosleep(const clockid_t which_clock, int flags, | |||
1406 | if (copy_from_user(&t, rqtp, sizeof (struct timespec))) | 1405 | if (copy_from_user(&t, rqtp, sizeof (struct timespec))) |
1407 | return -EFAULT; | 1406 | return -EFAULT; |
1408 | 1407 | ||
1409 | if ((unsigned) t.tv_nsec >= NSEC_PER_SEC || t.tv_sec < 0) | 1408 | if (!timespec_valid(&t)) |
1410 | return -EINVAL; | 1409 | return -EINVAL; |
1411 | 1410 | ||
1412 | /* | 1411 | /* |