patch-2.1.68 linux/include/linux/time.h
Next file: linux/include/net/dst.h
Previous file: linux/include/linux/tcp.h
Back to the patch index
Back to the overall index
- Lines: 40
- Date:
Sun Nov 30 10:59:03 1997
- Orig file:
v2.1.67/linux/include/linux/time.h
- Orig date:
Fri Dec 27 02:04:48 1996
diff -u --recursive --new-file v2.1.67/linux/include/linux/time.h linux/include/linux/time.h
@@ -1,6 +1,8 @@
#ifndef _LINUX_TIME_H
#define _LINUX_TIME_H
+#include <asm/param.h>
+
#ifndef _STRUCT_TIMESPEC
#define _STRUCT_TIMESPEC
struct timespec {
@@ -9,6 +11,30 @@
};
#endif /* _STRUCT_TIMESPEC */
+/*
+ * change timeval to jiffies, trying to avoid the
+ * most obvious overflows..
+ */
+static inline unsigned long
+timespec_to_jiffies(struct timespec *value)
+{
+ unsigned long sec = value->tv_sec;
+ long nsec = value->tv_nsec;
+
+ if (sec > ((long)(~0UL >> 1) / HZ))
+ return ~0UL >> 1;
+ nsec += 1000000000L / HZ - 1;
+ nsec /= 1000000000L / HZ;
+ return HZ * sec + nsec;
+}
+
+static inline void
+jiffies_to_timespec(unsigned long jiffies, struct timespec *value)
+{
+ value->tv_nsec = (jiffies % HZ) * (1000000000L / HZ);
+ value->tv_sec = jiffies / HZ;
+}
+
struct timeval {
int tv_sec; /* seconds */
int tv_usec; /* microseconds */
FUNET's LINUX-ADM group, linux-adm@nic.funet.fi
TCL-scripts by Sam Shen, slshen@lbl.gov