Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Apr 2011 16:53:32 +0000 (UTC)
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r220631 - in head/sys: amd64/include i386/include
Message-ID:  <201104141653.p3EGrWmv041064@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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)
 {



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201104141653.p3EGrWmv041064>