From 553ebddc5923af76bdcaef290219a903d914de43 Mon Sep 17 00:00:00 2001 From: Poul-Henning Kamp Date: Wed, 5 Feb 2003 08:55:10 +0000 Subject: [PATCH] Make get_cyclecount() use binuptime() when no tsc is available: it is cheaper. --- sys/amd64/include/cpu.h | 8 ++++---- sys/i386/include/cpu.h | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/sys/amd64/include/cpu.h b/sys/amd64/include/cpu.h index 06c191b402a..d4e72bb593e 100644 --- a/sys/amd64/include/cpu.h +++ b/sys/amd64/include/cpu.h @@ -94,17 +94,17 @@ void fork_trampoline(void); /* * Return contents of in-cpu fast counter as a sort of "bogo-time" - * for non-critical timing. + * for random-harvesting purposes. */ static __inline u_int64_t get_cyclecount(void) { #if defined(I386_CPU) || defined(I486_CPU) - struct timespec tv; + struct bintime bt; if (!tsc_present) { - nanotime(&tv); - return (tv.tv_sec * (u_int64_t)1000000000 + tv.tv_nsec); + binuptime(&bt); + return (bt.frac ^ bt.sec); } #endif return (rdtsc()); diff --git a/sys/i386/include/cpu.h b/sys/i386/include/cpu.h index 06c191b402a..d4e72bb593e 100644 --- a/sys/i386/include/cpu.h +++ b/sys/i386/include/cpu.h @@ -94,17 +94,17 @@ void fork_trampoline(void); /* * Return contents of in-cpu fast counter as a sort of "bogo-time" - * for non-critical timing. + * for random-harvesting purposes. */ static __inline u_int64_t get_cyclecount(void) { #if defined(I386_CPU) || defined(I486_CPU) - struct timespec tv; + struct bintime bt; if (!tsc_present) { - nanotime(&tv); - return (tv.tv_sec * (u_int64_t)1000000000 + tv.tv_nsec); + binuptime(&bt); + return (bt.frac ^ bt.sec); } #endif return (rdtsc());