svn commit: r220631 - in head/sys: amd64/include i386/include

Jung-uk Kim jkim at FreeBSD.org
Thu Apr 14 16:53:32 UTC 2011


Author: jkim
Date: Thu Apr 14 16:53:32 2011
New Revision: 220631
URL: http://svn.freebsd.org/changeset/base/220631

Log:
  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.

Modified:
  head/sys/amd64/include/cpufunc.h
  head/sys/i386/include/cpufunc.h

Modified: head/sys/amd64/include/cpufunc.h
==============================================================================
--- head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:45:16 2011	(r220630)
+++ head/sys/amd64/include/cpufunc.h	Thu Apr 14 16:53:32 2011	(r220631)
@@ -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)
 {

Modified: head/sys/i386/include/cpufunc.h
==============================================================================
--- head/sys/i386/include/cpufunc.h	Thu Apr 14 16:45:16 2011	(r220630)
+++ head/sys/i386/include/cpufunc.h	Thu Apr 14 16:53:32 2011	(r220631)
@@ -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)
 {


More information about the svn-src-head mailing list