From owner-svn-src-all@FreeBSD.ORG Thu Apr 14 16:53:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6E992106566B; Thu, 14 Apr 2011 16:53:32 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5CF278FC13; Thu, 14 Apr 2011 16:53:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p3EGrWM3041067; Thu, 14 Apr 2011 16:53:32 GMT (envelope-from jkim@svn.freebsd.org) Received: (from jkim@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p3EGrWmv041064; Thu, 14 Apr 2011 16:53:32 GMT (envelope-from jkim@svn.freebsd.org) Message-Id: <201104141653.p3EGrWmv041064@svn.freebsd.org> From: Jung-uk Kim Date: Thu, 14 Apr 2011 16:53:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220631 - in head/sys: amd64/include i386/include X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2011 16:53:32 -0000 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) {