make byteswap more portable

This commit is contained in:
Duncan Laurie 2004-01-27 15:54:45 +00:00
parent 3012023e7e
commit a76f069b0a

View File

@ -37,19 +37,20 @@
#ifndef IPMI_BSWAP_H #ifndef IPMI_BSWAP_H
#define IPMI_BSWAP_H #define IPMI_BSWAP_H
#if defined(__sun) #if HAVE_CONFIG_H
# include <config.h>
#define BSWAP_16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8)) #endif
#define BSWAP_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |\
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#if HAVE_BYTESWAP_H
# include <byteswap.h>
# define BSWAP_16(x) bswap_16(x)
# define BSWAP_32(x) bswap_32(x)
#elif HAVE_SYS_BYTEORDER_H
# include <sys/byteorder.h>
#else #else
# define BSWAP_16(x) ((((x) & 0xff00) >> 8) | (((x) & 0x00ff) << 8))
#include <byteswap.h> # define BSWAP_32(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) |\
(((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
#define BSWAP_16(x) bswap_16(x)
#define BSWAP_32(x) bswap_32(x)
#endif #endif
#endif /* IPMI_BSWAP_H */ #endif /* IPMI_BSWAP_H */