aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/time.h
diff options
context:
space:
mode:
Diffstat (limited to 'include/linux/time.h')
-rw-r--r--include/linux/time.h25
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 {
33#define NSEC_PER_SEC 1000000000L 33#define NSEC_PER_SEC 1000000000L
34#define NSEC_PER_USEC 1000L 34#define NSEC_PER_USEC 1000L
35 35
36static __inline__ int timespec_equal(struct timespec *a, struct timespec *b) 36static inline int timespec_equal(struct timespec *a, struct timespec *b)
37{ 37{
38 return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec); 38 return (a->tv_sec == b->tv_sec) && (a->tv_nsec == b->tv_nsec);
39} 39}
40 40
41/*
42 * lhs < rhs: return <0
43 * lhs == rhs: return 0
44 * lhs > rhs: return >0
45 */
46static inline int timespec_compare(struct timespec *lhs, struct timespec *rhs)
47{
48 if (lhs->tv_sec < rhs->tv_sec)
49 return -1;
50 if (lhs->tv_sec > rhs->tv_sec)
51 return 1;
52 return lhs->tv_nsec - rhs->tv_nsec;
53}
54
55static inline int timeval_compare(struct timeval *lhs, struct timeval *rhs)
56{
57 if (lhs->tv_sec < rhs->tv_sec)
58 return -1;
59 if (lhs->tv_sec > rhs->tv_sec)
60 return 1;
61 return lhs->tv_usec - rhs->tv_usec;
62}
63
41extern unsigned long mktime(const unsigned int year, const unsigned int mon, 64extern unsigned long mktime(const unsigned int year, const unsigned int mon,
42 const unsigned int day, const unsigned int hour, 65 const unsigned int day, const unsigned int hour,
43 const unsigned int min, const unsigned int sec); 66 const unsigned int min, const unsigned int sec);