SILC_SWAB_16

NAME

    #define SILC_SWAB_16(integer)

DESCRIPTION

Swabs 16-bit unsigned integer byte order. Returns the new value.

SOURCE

#if (defined(SILC_I386) || defined(SILC_X86_64)) && defined(__GNUC__)
#define SILC_SWAB_16(l)                         \
({                                              \
  SilcUInt16 _result_;                          \
  asm volatile ("movw %w1, %w0; rolw $8, %w0"   \
                : "=q" (_result_) : "q" (l));   \
  _result_;                                     \
})
#else
#define SILC_SWAB_16(l)                                         \
  ((SilcUInt16)(((SilcUInt16)(l) & (SilcUInt16)0x00FFU) << 8) | \
               (((SilcUInt16)(l) & (SilcUInt16)0xFF00U) >> 8))
#endif /* (SILC_I386 || SILC_X86_64) && __GNUC__ */