From owner-svn-src-projects@FreeBSD.ORG Fri Aug 13 22:39:11 2010 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A6E6C1065697; Fri, 13 Aug 2010 22:39:11 +0000 (UTC) (envelope-from jeff@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 961288FC15; Fri, 13 Aug 2010 22:39:11 +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 o7DMdB2E009260; Fri, 13 Aug 2010 22:39:11 GMT (envelope-from jeff@svn.freebsd.org) Received: (from jeff@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o7DMdB7i009258; Fri, 13 Aug 2010 22:39:11 GMT (envelope-from jeff@svn.freebsd.org) Message-Id: <201008132239.o7DMdB7i009258@svn.freebsd.org> From: Jeff Roberson Date: Fri, 13 Aug 2010 22:39:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r211293 - projects/ofed/head/sys/amd64/include X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Aug 2010 22:39:11 -0000 Author: jeff Date: Fri Aug 13 22:39:11 2010 New Revision: 211293 URL: http://svn.freebsd.org/changeset/base/211293 Log: - Provide a const testing wrapper for bswap16. - Use __inline to avoid compile problems with stricter compiler settings. Modified: projects/ofed/head/sys/amd64/include/endian.h Modified: projects/ofed/head/sys/amd64/include/endian.h ============================================================================== --- projects/ofed/head/sys/amd64/include/endian.h Fri Aug 13 22:08:42 2010 (r211292) +++ projects/ofed/head/sys/amd64/include/endian.h Fri Aug 13 22:39:11 2010 (r211293) @@ -69,7 +69,7 @@ extern "C" { #if defined(__GNUCLIKE_ASM) && defined(__GNUCLIKE_BUILTIN_CONSTANT_P) -static inline __uint32_t +static __inline __uint32_t __byte_swap_int_var(__uint32_t x) { register __uint32_t _x; @@ -96,7 +96,7 @@ __byte_swap_int_var(__uint32_t x) #endif /* __OPTIMIZE__ */ -static inline __uint64_t +static __inline __uint64_t __byte_swap_long_var(__uint64_t x) { register __uint64_t _x; @@ -127,7 +127,16 @@ __byte_swap_long_var(__uint64_t x) #endif /* __OPTIMIZE__ */ -#define __bswap16(_x) (__uint16_t)((_x) << 8 | (_x) >> 8) +#define __byte_swap_short_const(_x) (__uint16_t)((_x) << 8 | (_x) >> 8) + +static __inline __uint16_t +__byte_swap_short_var(__uint16_t x) +{ + return __byte_swap_short_const(x); +} + +#define __bswap16(x) (__builtin_constant_p(x) ? \ + __byte_swap_short_const(x) : __byte_swap_short_var(x)) #define __htonl(x) __bswap32(x) #define __htons(x) __bswap16(x)