svn commit: r213578 - head/sys/sparc64/include

Marius Strobl marius at FreeBSD.org
Fri Oct 8 14:59:46 UTC 2010


Author: marius
Date: Fri Oct  8 14:59:45 2010
New Revision: 213578
URL: http://svn.freebsd.org/changeset/base/213578

Log:
  In the replacement text of the __bswapN_const() macros cast the argument
  to the expected type so they work like the corresponding __bswapN_var()
  functions and the compiler doesn't complain when arguments of different
  width are passed.

Modified:
  head/sys/sparc64/include/endian.h

Modified: head/sys/sparc64/include/endian.h
==============================================================================
--- head/sys/sparc64/include/endian.h	Fri Oct  8 14:59:14 2010	(r213577)
+++ head/sys/sparc64/include/endian.h	Fri Oct  8 14:59:45 2010	(r213578)
@@ -69,18 +69,20 @@
 #define	__is_constant(x)	0
 #endif
 
-#define	__bswap16_const(x)	((((x) >> 8) & 0xff) |			\
-	(((x) << 8) & 0xff00))
-#define	__bswap32_const(x)	((((x) >> 24) & 0xff) |			\
-	(((x) >> 8) & 0xff00) | (((x) << 8) & 0xff0000) |		\
-	(((x) << 24) & 0xff000000))
-#define	__bswap64_const(x)	((((x) >> 56) & 0xff) |			\
-	(((x) >> 40) & 0xff00) | (((x) >> 24) & 0xff0000) |		\
-	(((x) >> 8) & 0xff000000) |					\
-	(((x) << 8) & ((__uint64_t)0xff << 32)) |			\
-	(((x) << 24) & ((__uint64_t)0xff << 40)) |			\
-	(((x) << 40) & ((__uint64_t)0xff << 48)) |			\
-	(((x) << 56) & ((__uint64_t)0xff << 56)))
+#define	__bswap16_const(x)	((((__uint16_t)(x) >> 8) & 0xff) |	\
+	(((__uint16_t)(x) << 8) & 0xff00))
+#define	__bswap32_const(x)	((((__uint32_t)(x) >> 24) & 0xff) |	\
+	(((__uint32_t)(x) >> 8) & 0xff00) |				\
+	(((__uint32_t)(x)<< 8) & 0xff0000) |				\
+	(((__uint32_t)(x) << 24) & 0xff000000))
+#define	__bswap64_const(x)	((((__uint64_t)(x) >> 56) & 0xff) |	\
+	(((__uint64_t)(x) >> 40) & 0xff00) |				\
+	(((__uint64_t)(x) >> 24) & 0xff0000) |				\
+	(((__uint64_t)(x) >> 8) & 0xff000000) |				\
+	(((__uint64_t)(x) << 8) & ((__uint64_t)0xff << 32)) |		\
+	(((__uint64_t)(x) << 24) & ((__uint64_t)0xff << 40)) |		\
+	(((__uint64_t)(x) << 40) & ((__uint64_t)0xff << 48)) |		\
+	(((__uint64_t)(x) << 56) & ((__uint64_t)0xff << 56)))
 
 static __inline __uint16_t
 __bswap16_var(__uint16_t _x)


More information about the svn-src-all mailing list