From owner-svn-src-all@FreeBSD.ORG Wed Apr 8 19:06:47 2009 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 9C053106566C; Wed, 8 Apr 2009 19:06:47 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 6FA278FC1E; Wed, 8 Apr 2009 19:06:47 +0000 (UTC) (envelope-from ed@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n38J6lR1071507; Wed, 8 Apr 2009 19:06:47 GMT (envelope-from ed@svn.freebsd.org) Received: (from ed@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n38J6ln1071504; Wed, 8 Apr 2009 19:06:47 GMT (envelope-from ed@svn.freebsd.org) Message-Id: <200904081906.n38J6ln1071504@svn.freebsd.org> From: Ed Schouten Date: Wed, 8 Apr 2009 19:06:47 +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: r190853 - 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: Wed, 08 Apr 2009 19:06:48 -0000 Author: ed Date: Wed Apr 8 19:06:47 2009 New Revision: 190853 URL: http://svn.freebsd.org/changeset/base/190853 Log: Implement __bswap16() without using inline assembly. Most compilers nowadays (including GCC) are smart enough to know what's going on and generate more efficient code anyway. Submitted by: Christoph Mallon Modified: head/sys/amd64/include/endian.h head/sys/i386/include/endian.h Modified: head/sys/amd64/include/endian.h ============================================================================== --- head/sys/amd64/include/endian.h Wed Apr 8 18:30:42 2009 (r190852) +++ head/sys/amd64/include/endian.h Wed Apr 8 19:06:47 2009 (r190853) @@ -135,26 +135,6 @@ __extension__ ({ register __uint64_t __X #endif /* __OPTIMIZE__ */ -#define __byte_swap_word_var(x) \ -__extension__ ({ register __uint16_t __X = (x); \ - __asm ("xchgb %h0, %b0" : "+Q" (__X)); \ - __X; }) - -#ifdef __OPTIMIZE__ - -#define __byte_swap_word_const(x) \ - ((((x) & 0xff00) >> 8) | \ - (((x) & 0x00ff) << 8)) - -#define __byte_swap_word(x) (__builtin_constant_p(x) ? \ - __byte_swap_word_const(x) : __byte_swap_word_var(x)) - -#else /* __OPTIMIZE__ */ - -#define __byte_swap_word(x) __byte_swap_word_var(x) - -#endif /* __OPTIMIZE__ */ - static __inline __uint64_t __bswap64(__uint64_t _x) { @@ -172,8 +152,7 @@ __bswap32(__uint32_t _x) static __inline __uint16_t __bswap16(__uint16_t _x) { - - return (__byte_swap_word(_x)); + return (_x << 8 | _x >> 8); } #define __htonl(x) __bswap32(x) Modified: head/sys/i386/include/endian.h ============================================================================== --- head/sys/i386/include/endian.h Wed Apr 8 18:30:42 2009 (r190852) +++ head/sys/i386/include/endian.h Wed Apr 8 19:06:47 2009 (r190853) @@ -109,26 +109,6 @@ __extension__ ({ register __uint32_t __X #endif /* __OPTIMIZE__ */ -#define __byte_swap_word_var(x) \ -__extension__ ({ register __uint16_t __X = (x); \ - __asm ("xchgb %h0, %b0" : "+q" (__X)); \ - __X; }) - -#ifdef __OPTIMIZE__ - -#define __byte_swap_word_const(x) \ - ((((x) & 0xff00) >> 8) | \ - (((x) & 0x00ff) << 8)) - -#define __byte_swap_word(x) (__builtin_constant_p(x) ? \ - __byte_swap_word_const(x) : __byte_swap_word_var(x)) - -#else /* __OPTIMIZE__ */ - -#define __byte_swap_word(x) __byte_swap_word_var(x) - -#endif /* __OPTIMIZE__ */ - static __inline __uint64_t __bswap64(__uint64_t _x) { @@ -149,8 +129,7 @@ __bswap32(__uint32_t _x) static __inline __uint16_t __bswap16(__uint16_t _x) { - - return (__byte_swap_word(_x)); + return (_x << 8 | _x >> 8); } #define __htonl(x) __bswap32(x)