File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change 2424 * builtins for GCC. MSVC has similar ones. 
2525 */  
2626
27+ //  Some GCC versions do not include __builtin_bswap16
28+ //  The compiler optimizes the code below into a single ROL instruction so the intrinsic is not really needed
29+ #define  BYTESWAP16 (v ) (((v) >> 8 ) | ((v) << 8 ))
30+ 
2731#if  defined(WIN32) || defined(_WIN32)
2832 #define  BSWAP16 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : _byteswap_ushort((::uint16_t )v))
2933 #define  BSWAP32 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : _byteswap_ulong((::uint32_t )v))
3034 #define  BSWAP64 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : _byteswap_uint64((::uint64_t )v))
3135#elif  __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
32-  #define  BSWAP16 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : __builtin_bswap16 ((::uint16_t )v))
36+  #define  BSWAP16 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : BYTESWAP16 ((::uint16_t )v))
3337 #define  BSWAP32 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : __builtin_bswap32((::uint32_t )v))
3438 #define  BSWAP64 (b,v ) ((b == Ir::SBE_LITTLE_ENDIAN) ? (v) : __builtin_bswap64((::uint64_t )v))
3539#elif  __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
36-  #define  BSWAP16 (b,v ) ((b == Ir::SBE_BIG_ENDIAN) ? (v) : __builtin_bswap16 ((::uint16_t )v))
40+  #define  BSWAP16 (b,v ) ((b == Ir::SBE_BIG_ENDIAN) ? (v) : BYTESWAP16 ((::uint16_t )v))
3741 #define  BSWAP32 (b,v ) ((b == Ir::SBE_BIG_ENDIAN) ? (v) : __builtin_bswap32((::uint32_t )v))
3842 #define  BSWAP64 (b,v ) ((b == Ir::SBE_BIG_ENDIAN) ? (v) : __builtin_bswap64((::uint64_t )v))
3943#else 
                         You can’t perform that action at this time. 
           
                  
0 commit comments