Whamcloud - gitweb
LU-9118 o2iblnd: handle MOFED libcfs time api collision
[fs/lustre-release.git] / libcfs / include / libcfs / linux / linux-time.h
index 44caab3..6c1004d 100644 (file)
  *
  * You should have received a copy of the GNU General Public License
  * version 2 along with this program; If not, see
- * http://www.sun.com/software/products/lustre/docs/GPLv2.pdf
- *
- * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
- * CA 95054 USA or visit www.sun.com if you need additional information or
- * have any questions.
+ * http://www.gnu.org/licenses/gpl-2.0.html
  *
  * GPL HEADER END
  */
 #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
  */
 
 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_TS64
+void ktime_get_ts64(struct timespec64 *ts);
+#endif /* HAVE_KTIME_GET_TS */
+
+#ifndef HAVE_KTIME_GET_REAL_TS64
+void ktime_get_real_ts64(struct timespec64 *ts);
+#endif /* HAVE_KTIME_GET_REAL_TS */
+
+#ifndef HAVE_KTIME_GET_REAL_SECONDS
+time64_t ktime_get_real_seconds(void);
+#endif /* HAVE_KTIME_GET_REAL_SECONDS */
+
+#ifndef HAVE_KTIME_GET_SECONDS
+time64_t ktime_get_seconds(void);
+#endif /* HAVE_KTIME_GET_SECONDS */
+
+#ifdef NEED_KTIME_GET_REAL_NS
+static inline u64 ktime_get_real_ns(void)
+{
+       return ktime_to_ns(ktime_get_real());
+}
+#endif /* NEED_KTIME_GET_REAL_NS */
 
 static inline int cfs_time_before(cfs_time_t t1, cfs_time_t t2)
 {
@@ -209,8 +251,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"