Module Name: src
Committed By: joerg
Date: Wed Dec 3 18:33:02 UTC 2014
Modified Files:
src/sys/sys: bswap.h
Log Message:
Add explicit cast to ensure no intermediate integer promotion happens.
To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/sys/bswap.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/sys/bswap.h
diff -u src/sys/sys/bswap.h:1.16 src/sys/sys/bswap.h:1.17
--- src/sys/sys/bswap.h:1.16 Sat Aug 8 21:23:15 2009
+++ src/sys/sys/bswap.h Wed Dec 3 18:33:02 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: bswap.h,v 1.16 2009/08/08 21:23:15 christos Exp $ */
+/* $NetBSD: bswap.h,v 1.17 2014/12/03 18:33:02 joerg Exp $ */
/* Written by Manuel Bouyer. Public domain */
@@ -62,15 +62,15 @@ __END_DECLS
(((x) & 0x00ff) << 8))))
#define bswap64(x) \
- (__builtin_constant_p((x)) ? \
+ __CAST(uint64_t, __builtin_constant_p((x)) ? \
__byte_swap_u64_constant(x) : __BYTE_SWAP_U64_VARIABLE(x))
#define bswap32(x) \
- (__builtin_constant_p((x)) ? \
+ __CAST(uint32_t, __builtin_constant_p((x)) ? \
__byte_swap_u32_constant(x) : __BYTE_SWAP_U32_VARIABLE(x))
#define bswap16(x) \
- (__builtin_constant_p((x)) ? \
+ __CAST(uint16_t, __builtin_constant_p((x)) ? \
__byte_swap_u16_constant(x) : __BYTE_SWAP_U16_VARIABLE(x))
#endif /* __GNUC__ && __OPTIMIZE__ */