[openib-general] fixup to use timex.h

Grant Grundler iod00d at hp.com
Tue May 10 14:00:21 PDT 2005


Michael,
userspace/perftests patch to add use of asm/timex.h to get_clock.h
Andi Kleen agrees this the best way to pick up get_cycles().

PPC64 has a clean timex.h. PPC does not.

thanks,
grant

Signed-off-by: Grant Grundler <iod00d at hp.com>


Index: get_clock.h
===================================================================
--- get_clock.h	(revision 2296)
+++ get_clock.h	(working copy)
@@ -31,8 +31,10 @@
  *
  * $Id$
  */
+
 #include <unistd.h>
 #include <stdio.h>
+
 #if defined (__x86_64__) || defined(__i386__)
 typedef unsigned long long cycles_t;
 static inline cycles_t get_clock()
@@ -44,7 +46,12 @@ static inline cycles_t get_clock()
 	val = (val << 32) | low;
 	return val;
 }
-#elif defined(__PPC64__)
+
+#elif defined(__PPC__)
+/* PPC (32-bit) only provides a kernel version of get_cycles().
+ * Which implies some PPC (32-bit) do not support mftb.
+ * Use at your own risk.
+ */
 typedef unsigned long long cycles_t;
 static inline cycles_t get_cycles()
 {
@@ -53,17 +60,12 @@ static inline cycles_t get_cycles()
 	asm volatile ("mftb %0" : "=r" (ret) : );
 	return ret;
 }
-#elif defined(__ia64__)
-typedef unsigned long long cycles_t;
-static inline cycles_t get_cycles()
-{
-	cycles_t ret;
 
-	asm volatile ("mov %0=ar.itc" : "=r"(ret));
-	return ret;
-}
 #else
-#warning get_clock not implemented for this architecture
+
+/* Everyone else has nice timex.h */
+#include <asm/timex.h>
+
 #endif
 
 double get_cpu_mhz()



More information about the general mailing list