summaryrefslogtreecommitdiffstats
path: root/sys/amd64/include
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/amd64/include
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/amd64/include')
-rw-r--r--sys/amd64/include/cpufunc.h9
1 files changed, 9 insertions, 0 deletions
diff --git a/sys/amd64/include/cpufunc.h b/sys/amd64/include/cpufunc.h
index b06e490..9b61d37 100644
--- a/sys/amd64/include/cpufunc.h
+++ b/sys/amd64/include/cpufunc.h
@@ -322,6 +322,15 @@ rdtsc(void)
return (low | ((uint64_t)high << 32));
}
+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