Whamcloud - gitweb
Land b_smallfix onto HEAD (20040423_1603)
[fs/lustre-release.git] / lustre / portals / include / linux / libcfs.h
index 99d3877..5b1b8a5 100644 (file)
@@ -6,6 +6,8 @@
 
 #define PORTAL_DEBUG
 
+/* I think this beast is just trying to get cycles_t and get_cycles().
+ * this should be in its own header. */
 #ifdef __linux__
 # include <asm/types.h>
 # if defined(__powerpc__) && !defined(__KERNEL__)
 #  include <asm/timex.h>
 #  undef __KERNEL__
 # else
-#  include <asm/timex.h>
+#  if defined(__KERNEL__)
+#   include <asm/timex.h>
+#  else
+#   include <sys/time.h>
+#   define cycles_t unsigned long
+static inline cycles_t get_cycles(void) 
+{
+        struct timeval tv;
+        gettimeofday(&tv, NULL);
+        return (tv.tv_sec * 100000) + tv.tv_usec;
+}
+#  endif
 # endif
 #else
 # include <sys/types.h>
@@ -29,7 +42,7 @@ typedef u_int64_t __u64;
 #endif
 
 #ifndef offsetof
-# define offsetof(typ,memb)     ((int)((char *)&(((typ *)0)->memb)))
+# define offsetof(typ,memb)     ((unsigned long)((char *)&(((typ *)0)->memb)))
 #endif
 
 #define LOWEST_BIT_SET(x)       ((x) & ~((x) - 1))