Add SWAP_LE?? and SWAP_BE?? macros, and make things use them. Converts values
to/from little endian or big endian, which is a NOP if that's what the current platform already is.
This commit is contained in:
@ -48,11 +48,6 @@
|
||||
# define __const const
|
||||
#endif
|
||||
|
||||
#ifndef __THROW
|
||||
# define __THROW
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef ATTRIBUTE_UNUSED
|
||||
# define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
|
||||
#endif /* ATTRIBUTE_UNUSED */
|
||||
@ -118,6 +113,22 @@
|
||||
# define BB_LITTLE_ENDIAN 1
|
||||
#endif
|
||||
|
||||
#if BB_BIG_ENDIAN
|
||||
#define SWAP_BE16(x) x
|
||||
#define SWAP_BE32(x) x
|
||||
#define SWAP_BE64(x) x
|
||||
#define SWAP_LE16(x) bswap_16(x)
|
||||
#define SWAP_LE32(x) bswap_32(x)
|
||||
#define SWAP_LE64(x) bswap_64(x)
|
||||
#else
|
||||
#define SWAP_BE16(x) bswap_16(x)
|
||||
#define SWAP_BE32(x) bswap_32(x)
|
||||
#define SWAP_BE64(x) bswap_64(x)
|
||||
#define SWAP_LE16(x) x
|
||||
#define SWAP_LE32(x) x
|
||||
#define SWAP_LE64(x) x
|
||||
#endif
|
||||
|
||||
/* ---- Networking ------------------------------------------ */
|
||||
#ifndef __APPLE__
|
||||
# include <arpa/inet.h>
|
||||
|
Reference in New Issue
Block a user