#include <stdint.h>
-#if defined(__FreeBSD__)
-#include <sys/endian.h>
-#else
-#include <endian.h>
-#endif
+#include "include/byteorder.h"
#ifndef SCTP_USE_ADLER32
crc = sctp_crc_tableil8_o32[(crc ^ *p_buf++) & 0x000000FF] ^
(crc >> 8);
for (li = 0; li < running_length / 8; li++) {
-#if BYTE_ORDER == BIG_ENDIAN
+#ifdef CEPH_BIG_ENDIAN
crc ^= *p_buf++;
crc ^= (*p_buf++) << 8;
crc ^= (*p_buf++) << 16;
sctp_crc_tableil8_o72[term2 & 0x000000FF] ^
sctp_crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
-#if BYTE_ORDER == BIG_ENDIAN
+#ifdef CEPH_BIG_ENDIAN
crc ^= sctp_crc_tableil8_o56[*p_buf++];
crc ^= sctp_crc_tableil8_o48[*p_buf++];
crc ^= sctp_crc_tableil8_o40[*p_buf++];
sctp_crc_tableil8_o72[term2 & 0x000000FF] ^
sctp_crc_tableil8_o64[(term2 >> 8) & 0x000000FF];
-#if BYTE_ORDER == BIG_ENDIAN
+#ifdef CEPH_BIG_ENDIAN
crc ^= sctp_crc_tableil8_o56[0];
crc ^= sctp_crc_tableil8_o48[0];
crc ^= sctp_crc_tableil8_o40[0];
#ifndef CEPH_BYTEORDER_H
#define CEPH_BYTEORDER_H
-#if defined(__linux__)
-#include <endian.h>
-#elif defined(__FreeBSD__)
-#include <sys/endian.h>
-#else
-#error "Your platform is not yet supported."
+#include <sys/param.h>
+#include "int_types.h"
+
+#if defined(__APPLE__)
+# if __DARWIN_BYTE_ORDER == __DARWIN_LITTLE_ENDIAN
+# define CEPH_LITTLE_ENDIAN
+# elif __DARWIN_BYTE_ORDER == __DARWIN_BIG_ENDIAN
+# define CEPH_BIG_ENDIAN
+# endif
#endif
#if defined(__FreeBSD__)
-#define __BYTE_ORDER _BYTE_ORDER
-#define __BIG_ENDIAN _BIG_ENDIAN
-#define __LITTLE_ENDIAN _LITTLE_ENDIAN
+# if _BYTE_ORDER == _LITTLE_ENDIAN
+# define CEPH_LITTLE_ENDIAN
+# elif _BYTE_ORDER == _BIG_ENDIAN
+# define CEPH_BIG_ENDIAN
+# endif
+#endif
+
+#if defined(__linux__)
+# if BYTE_ORDER == LITTLE_ENDIAN
+# define CEPH_LITTLE_ENDIAN
+# elif BYTE_ORDER == BIG_ENDIAN
+# define CEPH_BIG_ENDIAN
+# endif
#endif
static __inline__ __u16 swab16(__u16 val)
((val << 56)));
}
-#if !defined(__BYTE_ORDER) || !defined(__BIG_ENDIAN) || !defined(__LITTLE_ENDIAN)
-#error "Endianess is unknown!"
-#endif
-
// mswab == maybe swab (if not LE)
-#if __BYTE_ORDER == __BIG_ENDIAN
+#ifdef CEPH_BIG_ENDIAN
# define mswab64(a) swab64(a)
# define mswab32(a) swab32(a)
# define mswab16(a) swab16(a)
-#else
-# if __BYTE_ORDER != __LITTLE_ENDIAN
-# warning __BYTE_ORDER is not defined, assuming little endian
-# endif
+#elif defined(CEPH_LITTLE_ENDIAN)
# define mswab64(a) (a)
# define mswab32(a) (a)
# define mswab16(a) (a)
+#else
+# error "Could not determine endianess"
#endif
+#ifdef __cplusplus
#define MAKE_LE_CLASS(bits) \
struct ceph_le##bits { \
MAKE_LE_CLASS(16)
#undef MAKE_LE_CLASS
+#endif /* __cplusplus */
+
#define init_le64(x) { (__u64)mswab64(x) }
#define init_le32(x) { (__u32)mswab32(x) }
#define init_le16(x) { (__u16)mswab16(x) }