Whamcloud - gitweb
LU-6245 libcfs: remove cfs_fs_time handling
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-time.h
index 44caab3..7c41643 100644 (file)
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/version.h>
+#include <linux/jiffies.h>
+#include <linux/types.h>
 #include <linux/time.h>
 #include <asm/div64.h>
 
 /*
- * post 2.5 kernels.
- */
-
-#include <linux/jiffies.h>
-
-/*
  * Generic kernel stuff
  */
 
@@ -107,8 +103,40 @@ typedef unsigned long cfs_time_t;      /* jiffies */
 typedef long cfs_duration_t;
 typedef cycles_t cfs_cycles_t;
 
-#define timespec64             timespec
-#define ktime_get_real_ts64    ktime_get_real_ts
+#ifndef HAVE_TIMESPEC64
+
+typedef __s64 time64_t;
+
+#if __BITS_PER_LONG == 64
+
+# define timespec64 timespec
+
+static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
+{
+       return ts;
+}
+
+#else
+struct timespec64 {
+       time64_t        tv_sec;         /* seconds */
+       long            tv_nsec;        /* nanoseconds */
+};
+
+static inline struct timespec64 timespec_to_timespec64(const struct timespec ts)
+{
+       struct timespec64 ret;
+
+       ret.tv_sec = ts.tv_sec;
+       ret.tv_nsec = ts.tv_nsec;
+       return ret;
+}
+#endif /* __BITS_PER_LONG != 64 */
+
+#endif /* HAVE_TIMESPEC64 */
+
+#ifndef HAVE_KTIME_GET_REAL_TS64
+void ktime_get_real_ts64(struct timespec64 *ts);
+#endif /* HAVE_KTIME_GET_REAL_TS */
 
 static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
 {
@@ -209,8 +237,6 @@ static inline int cfs_time_beforeq_64(__u64 t1, __u64 t2)
 /*
  * One jiffy
  */
-#define CFS_TICK                (1)
-
 #define CFS_TIME_T              "%lu"
 #define CFS_DURATION_T          "%ld"