diff options
| author | Jeff Garzik <jgarzik@pobox.com> | 2006-02-18 00:20:30 +0300 |
|---|---|---|
| committer | Jeff Garzik <jgarzik@pobox.com> | 2006-02-18 00:20:30 +0300 |
| commit | b04a92e1601eb6df3a3b6599e7fb7ee021eef2cb (patch) | |
| tree | f190980d5bffae81a67c0cea0d913ed2444ceb0c /include/linux/time.h | |
| parent | 70c07e02625ec46d0ffbfce1acef42d660803528 (diff) | |
| parent | f5e2a7b22e7d7dfda8794906d0fddeaaa09bb944 (diff) | |
| download | linux-b04a92e1601eb6df3a3b6599e7fb7ee021eef2cb.tar.xz | |
Merge branch 'upstream-fixes'
Diffstat (limited to 'include/linux/time.h')
| -rw-r--r-- | include/linux/time.h | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index 7b4dc36532bb..d9cdba54b789 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -33,11 +33,34 @@ struct timezone { #define NSEC_PER_SEC 1000000000L #define NSEC_PER_USEC 1000L -static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) +static inline int timespec_equal(struct timespec *a, struct timespec *b) { return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec); } +/* + * lhs < rhs: return <0 + * lhs == rhs: return 0 + * lhs > rhs: return >0 + */ +static inline int timespec_compare(struct timespec *lhs, struct timespec *rhs) +{ + if (lhs->tv_sec < rhs->tv_sec) + return -1; + if (lhs->tv_sec > rhs->tv_sec) + return 1; + return lhs->tv_nsec - rhs->tv_nsec; +} + +static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs) +{ + if (lhs->tv_sec < rhs->tv_sec) + return -1; + if (lhs->tv_sec > rhs->tv_sec) + return 1; + return lhs->tv_usec - rhs->tv_usec; +} + extern unsigned long mktime(const unsigned int year, const unsigned int mon, const unsigned int day, const unsigned int hour, const unsigned int min, const unsigned int sec); |
