Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/sys Add explicit cast to ensure no intermediate integer ...



details:   https://anonhg.NetBSD.org/src/rev/21cb7280061e
branches:  trunk
changeset: 334726:21cb7280061e
user:      joerg <joerg%NetBSD.org@localhost>
date:      Wed Dec 03 18:33:02 2014 +0000

description:
Add explicit cast to ensure no intermediate integer promotion happens.

diffstat:

 sys/sys/bswap.h |  8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diffs (28 lines):

diff -r 5ebd0eb89648 -r 21cb7280061e sys/sys/bswap.h
--- a/sys/sys/bswap.h   Wed Dec 03 15:26:44 2014 +0000
+++ b/sys/sys/bswap.h   Wed Dec 03 18:33:02 2014 +0000
@@ -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 @@
         (((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__ */



Home | Main Index | Thread Index | Old Index