summaryrefslogtreecommitdiffstats
path: root/sys/i386/include/cpufunc.h
diff options
context:
space:
mode:
authorjkim <jkim@FreeBSD.org>2011-04-14 16:53:32 +0000
committerjkim <jkim@FreeBSD.org>2011-04-14 16:53:32 +0000
commit7d94642dc23686950f47b7e3a616efae4a14e819 (patch)
treed733579d318c88789438b5f4908d2d64a6052216 /sys/i386/include/cpufunc.h
parent89ffb7531942ac0a6cf7fc42157ea50d958b95e3 (diff)
downloadFreeBSD-src-7d94642dc23686950f47b7e3a616efae4a14e819.zip
FreeBSD-src-7d94642dc23686950f47b7e3a616efae4a14e819.tar.gz
Add a function rdtsc32() to read lower 32 bits from TSC and discard upper
32 bits. Some times compiler inserts unnecessary instructions to preserve unused upper 32 bits even when it is casted to a 32-bit value. It reduces such compiler mistakes where every cycle counts.
Diffstat (limited to 'sys/i386/include/cpufunc.h')
-rw-r--r--sys/i386/include/cpufunc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/i386/include/cpufunc.h b/sys/i386/include/cpufunc.h
index 9285499..d6ec534 100644
--- a/sys/i386/include/cpufunc.h
+++ b/sys/i386/include/cpufunc.h
@@ -332,6 +332,15 @@ rdtsc(void)
return (rv);
}
+static __inline uint32_t
+rdtsc32(void)
+{
+ uint32_t rv;
+
+ __asm __volatile("rdtsc" : "=a" (rv) : : "edx");
+ return (rv);
+}
+
static __inline void
wbinvd(void)
{
OpenPOWER on IntegriCloud