diff -Naru clockspeed-0.62.orig/Makefile clockspeed-0.62/Makefile
--- clockspeed-0.62.orig/Makefile	1998-10-14 02:37:49.000000000 +0900
+++ clockspeed-0.62/Makefile	2007-05-09 03:18:32.000000000 +0900
@@ -74,6 +74,7 @@
 
 clockspeed.o: \
 compile clockspeed.c readwrite.h exit.h select.h scan.h fmt.h str.h \
+hasmftb.h \
 fifo.h open.h error.h auto_home.h timing.h hasrdtsc.h hasgethr.h
 	./compile clockspeed.c
 
@@ -158,6 +159,13 @@
 	&& echo \#define HASRDTSC 1 || exit 0 ) > hasrdtsc.h
 	rm -f tryrdtsc.o tryrdtsc
 
+hasmftb.h: \
+trymftb.c compile load
+	( ( ./compile trymftb.c && ./load trymftb && ./trymftb \
+	) >/dev/null 2>&1 \
+	&& echo \#define HASMFTB 1 || exit 0 ) > hasmftb.h
+	rm -f trymftb.o trymftb
+
 hier.o: \
 compile hier.c auto_home.h
 	./compile hier.c
@@ -288,6 +296,7 @@
 tai_pack.3 tai.h tai_pack.c tai_unpack.c taia.3 taia_now.3 \
 taia_pack.3 taia.h taia_add.c taia_half.c taia_less.c taia_now.c \
 taia_pack.c taia_sub.c taia_unpack.c uint64.h1 uint64.h2 tryulong64.c \
+trymftb.c \
 timing.h tryrdtsc.c trygethr.c
 	shar -m `cat FILES` > shar
 	chmod 400 shar
diff -Naru clockspeed-0.62.orig/clockspeed.c clockspeed-0.62/clockspeed.c
--- clockspeed-0.62.orig/clockspeed.c	1998-10-14 02:37:49.000000000 +0900
+++ clockspeed-0.62/clockspeed.c	2007-05-09 03:21:17.000000000 +0900
@@ -14,11 +14,13 @@
 
 #ifndef HASRDTSC
 #ifndef HASGETHRTIME
+#ifndef HASMFTB
 
   Error! Need an unadjusted hardware clock.
 
 #endif
 #endif
+#endif
 
 struct point {
   timing lowlevel;
diff -Naru clockspeed-0.62.orig/timing.h clockspeed-0.62/timing.h
--- clockspeed-0.62.orig/timing.h	1998-10-14 02:37:49.000000000 +0900
+++ clockspeed-0.62/timing.h	2007-05-09 03:27:56.000000000 +0900
@@ -2,6 +2,7 @@
 #define TIMING_H
 
 #include "hasrdtsc.h"
+#include "hasmftb.h"
 #include "hasgethr.h"
 #include <sys/types.h>
 #include <sys/time.h>
@@ -17,13 +18,31 @@
 #define timing_now(x) asm volatile(".byte 15;.byte 49" : "=a"((x)->t[0]),"=d"((x)->t[1]))
 #define timing_diff(x,y) (((x)->t[0] - (double) (y)->t[0]) + 4294967296.0 * ((x)->t[1] - (double) (y)->t[1]))
 
-#else
-#ifdef HASGETHRTIME
+#elif defined(HASGETHRTIME)
 
 typedef struct { hrtime_t t; } timing;
 #define timing_now(x) ((x)->t = gethrtime())
 #define timing_diff(x,y) ((double) ((x)->t - (y)->t))
 
+#elif defined(HASMFTB)
+
+typedef struct { unsigned long t[2]; } timing;
+#define timing_now(x) do { \
+  unsigned int h1, l1; \
+  asm volatile("mftbu %0" : "=r"(h1)); \
+  asm volatile("mftb %0" : "=r"(l1)); \
+  while (1) { \
+    unsigned int h2; \
+    asm volatile("mftbu %0" : "=r"(h2)); \
+    if (h2 == h1) break; \
+    h1 = h2; \
+    asm volatile("mftb %0" : "=r"(l1)); \
+  } \
+  (x)->t[0] = l1; \
+  (x)->t[1] = h1; \
+} while (0)
+#define timing_diff(x,y) (((x)->t[0] - (double) (y)->t[0]) + 4294967296.0 * ((x)->t[1] - (double) (y)->t[1]))
+
 #else
 
 #define timing timing_basic
@@ -31,6 +50,5 @@
 #define timing_diff timing_basic_diff
 
 #endif
-#endif
 
 #endif
diff -Naru clockspeed-0.62.orig/trymftb.c clockspeed-0.62/trymftb.c
--- clockspeed-0.62.orig/trymftb.c	1970-01-01 09:00:00.000000000 +0900
+++ clockspeed-0.62/trymftb.c	2007-05-09 03:17:53.000000000 +0900
@@ -0,0 +1,31 @@
+main()
+{
+  unsigned int h1, l1, h2, l2;
+
+  h1 = 0;
+  l1 = 0;
+  h2 = 0;
+  l2 = 0;
+
+  asm volatile("mftbu %0" : "=r" (h1));
+  asm volatile("mftb %0" : "=r" (l1));
+  while (1) {
+    unsigned int t;
+    asm volatile("mftbu %0" : "=r" (t));
+    if (t == h1) break;
+    h1 = t;
+    asm volatile("mftb %0" : "=r" (l1));
+  }
+  asm volatile("mftbu %0" : "=r" (h2));
+  asm volatile("mftb %0" : "=r" (l2));
+  while (1) {
+    unsigned int t;
+    asm volatile("mftbu %0" : "=r" (t));
+    if (t == h2) break;
+    h2 = t;
+    asm volatile("mftb %0" : "=r" (l2));
+  }
+  if (l1 != l2) _exit(0);
+  if (h1 != h2) _exit(0);
+  _exit(1);
+}
