summaryrefslogtreecommitdiff
path: root/include/linux/time.h
diff options
context:
space:
mode:
authorJames Simmons <jsimmons@heisenberg.transvirtual.com>2002-07-02 20:37:20 -0700
committerJames Simmons <jsimmons@heisenberg.transvirtual.com>2002-07-02 20:37:20 -0700
commit28a6a4d12b4fbe5eca55079c87f5573ea435b922 (patch)
tree0195e0a31c8d430d39636a3b69195fd7d2f75c4a /include/linux/time.h
parent8ccb8c608e9f870cd4fdbc7ebf47adef48529067 (diff)
parent55eebc460dcad11fcfbe10be5da3374240914582 (diff)
Merge http://fbdev.bkbits.net/fbdev-2.5
into heisenberg.transvirtual.com:/tmp/fbdev-2.5
Diffstat (limited to 'include/linux/time.h')
-rw-r--r--include/linux/time.h42
1 files changed, 31 insertions, 11 deletions
diff --git a/include/linux/time.h b/include/linux/time.h
index e7447958ece1..d9f9c6a340d8 100644
--- a/include/linux/time.h
+++ b/include/linux/time.h
@@ -12,6 +12,16 @@ struct timespec {
};
#endif /* _STRUCT_TIMESPEC */
+struct timeval {
+ time_t tv_sec; /* seconds */
+ suseconds_t tv_usec; /* microseconds */
+};
+
+struct timezone {
+ int tz_minuteswest; /* minutes west of Greenwich */
+ int tz_dsttime; /* type of dst correction */
+};
+
#ifdef __KERNEL__
/*
@@ -48,6 +58,27 @@ jiffies_to_timespec(unsigned long jiffies, struct timespec *value)
value->tv_sec = jiffies / HZ;
}
+/* Same for "timeval" */
+static __inline__ unsigned long
+timeval_to_jiffies(struct timeval *value)
+{
+ unsigned long sec = value->tv_sec;
+ long usec = value->tv_usec;
+
+ if (sec >= (MAX_JIFFY_OFFSET / HZ))
+ return MAX_JIFFY_OFFSET;
+ usec += 1000000L / HZ - 1;
+ usec /= 1000000L / HZ;
+ return HZ * sec + usec;
+}
+
+static __inline__ void
+jiffies_to_timeval(unsigned long jiffies, struct timeval *value)
+{
+ value->tv_usec = (jiffies % HZ) * (1000000L / HZ);
+ value->tv_sec = jiffies / HZ;
+}
+
/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
* Assumes input in normal date format, i.e. 1980-12-31 23:59:59
@@ -88,17 +119,6 @@ extern struct timeval xtime;
#endif /* __KERNEL__ */
-
-struct timeval {
- time_t tv_sec; /* seconds */
- suseconds_t tv_usec; /* microseconds */
-};
-
-struct timezone {
- int tz_minuteswest; /* minutes west of Greenwich */
- int tz_dsttime; /* type of dst correction */
-};
-
#define NFDBITS __NFDBITS
#ifdef __KERNEL__