Index: kernel/arch/amd64/include/cpuid.h
===================================================================
--- kernel/arch/amd64/include/cpuid.h	(revision 8cd140f26dd9503acc9c3b85b265d95ff017cea4)
+++ kernel/arch/amd64/include/cpuid.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -58,7 +58,4 @@
 extern void cpuid(uint32_t cmd, cpu_info_t *info);
 
-
-extern uint64_t rdtsc(void);
-
 #endif /* !def __ASM__ */
 #endif
Index: kernel/arch/amd64/include/cycle.h
===================================================================
--- kernel/arch/amd64/include/cycle.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
+++ kernel/arch/amd64/include/cycle.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2006 Martin Decky
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup amd64
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_amd64_CYCLE_H_
+#define KERN_amd64_CYCLE_H_
+
+extern uint64_t get_cycle(void);
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/amd64/src/asm_utils.S
===================================================================
--- kernel/arch/amd64/src/asm_utils.S	(revision 8cd140f26dd9503acc9c3b85b265d95ff017cea4)
+++ kernel/arch/amd64/src/asm_utils.S	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -63,5 +63,5 @@
 .global cpuid
 .global has_cpuid
-.global rdtsc
+.global get_cycle
 .global read_efer_flag
 .global set_efer_flag
@@ -147,5 +147,5 @@
 	ret
 
-rdtsc:
+get_cycle:
 	xorq %rax,%rax
 	rdtsc
Index: kernel/arch/ia32/include/asm.h
===================================================================
--- kernel/arch/ia32/include/asm.h	(revision 8cd140f26dd9503acc9c3b85b265d95ff017cea4)
+++ kernel/arch/ia32/include/asm.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -229,13 +229,4 @@
 }
 
-static inline uint64_t rdtsc(void)
-{
-	uint64_t v;
-	
-	__asm__ volatile("rdtsc\n" : "=A" (v));
-	
-	return v;
-}
-
 /** Return current IP address */
 static inline uintptr_t * get_ip() 
Index: kernel/arch/ia32/include/cycle.h
===================================================================
--- kernel/arch/ia32/include/cycle.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
+++ kernel/arch/ia32/include/cycle.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2001-2004 Jakub Jermar
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ *   notice, this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ *   notice, this list of conditions and the following disclaimer in the
+ *   documentation and/or other materials provided with the distribution.
+ * - The name of the author may not be used to endorse or promote products
+ *   derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
+ * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
+ * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+/** @addtogroup ia32	
+ * @{
+ */
+/** @file
+ */
+
+#ifndef KERN_ia32_CYCLE_H_
+#define KERN_ia32_CYCLE_H_
+
+static inline uint64_t get_cycle(void)
+{
+	uint64_t v;
+	
+	asm volatile(
+		"rdtsc\n"
+		: "=A" (v)
+	);
+	
+	return v;
+}
+
+#endif
+
+/** @}
+ */
Index: kernel/arch/ia32/src/drivers/i8254.c
===================================================================
--- kernel/arch/ia32/src/drivers/i8254.c	(revision 8cd140f26dd9503acc9c3b85b265d95ff017cea4)
+++ kernel/arch/ia32/src/drivers/i8254.c	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -40,4 +40,5 @@
 #include <time/clock.h>
 #include <time/delay.h>
+#include <arch/cycle.h>
 #include <arch/interrupt.h>
 #include <arch/drivers/i8259.h>
@@ -138,9 +139,9 @@
 	CPU->delay_loop_const = ((MAGIC_NUMBER*LOOPS)/1000) / ((t1-t2)-(o1-o2)) + (((MAGIC_NUMBER*LOOPS)/1000) % ((t1-t2)-(o1-o2)) ? 1 : 0);
 
-	clk1 = rdtsc();
-	delay(1<<SHIFT);
-	clk2 = rdtsc();
+	clk1 = get_cycle();
+	delay(1 << SHIFT);
+	clk2 = get_cycle();
 	
-	CPU->frequency_mhz = (clk2-clk1)>>SHIFT;
+	CPU->frequency_mhz = (clk2 - clk1) >> SHIFT;
 
 	return;
Index: kernel/arch/ia32xen/include/asm.h
===================================================================
--- kernel/arch/ia32xen/include/asm.h	(revision 8cd140f26dd9503acc9c3b85b265d95ff017cea4)
+++ kernel/arch/ia32xen/include/asm.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -219,13 +219,4 @@
 }
 
-static inline uint64_t rdtsc(void)
-{
-	uint64_t v;
-	
-	__asm__ volatile("rdtsc\n" : "=A" (v));
-	
-	return v;
-}
-
 /** Return current IP address */
 static inline uintptr_t * get_ip() 
Index: kernel/arch/ia32xen/include/cycle.h
===================================================================
--- kernel/arch/ia32xen/include/cycle.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
+++ kernel/arch/ia32xen/include/cycle.h	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -0,0 +1,1 @@
+../../ia32/include/cycle.h
Index: kernel/kernel.config
===================================================================
--- kernel/kernel.config	(revision 8cd140f26dd9503acc9c3b85b265d95ff017cea4)
+++ kernel/kernel.config	(revision 134877d64bac047ca117c283bd304140ea31a7b0)
@@ -147,3 +147,3 @@
 
 # Benchmark test
-! [CONFIG_TEST!=] CONFIG_BENCH (y/n)
+! [CONFIG_TEST!=] CONFIG_BENCH (n/y)
