Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 13 Aug 2010 22:39:11 +0000 (UTC)
From:      Jeff Roberson <jeff@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-projects@freebsd.org
Subject:   svn commit: r211293 - projects/ofed/head/sys/amd64/include
Message-ID:  <201008132239.o7DMdB7i009258@svn.freebsd.org>

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



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