diff --git a/src/common.h b/src/common.h index ba951d6..ef5546d 100644 --- a/src/common.h +++ b/src/common.h @@ -69,6 +69,20 @@ char (&ArraySizeHelper(const T (&array)[N]))[N]; #define arraysize(array) (sizeof(ArraySizeHelper(array))) +#if defined(_FREEBSD) +#include +#endif +#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_FREEBSD) +#include +#if BYTE_ORDER == __BIG_ENDIAN +#define IS_BIG_ENDIAN +#endif +#endif + +#ifdef IS_BIG_ENDIAN +inline uint32 Swap32(uint32 x) { return __builtin_bswap32(x); } +#endif + namespace sentencepiece { #ifdef OS_WIN namespace win32 { diff --git a/src/util.h b/src/util.h index 01a561f..5110291 100644 --- a/src/util.h +++ b/src/util.h @@ -36,16 +36,6 @@ #include #endif -#if defined(_FREEBSD) -#include -#endif -#if !defined(__APPLE__) && !defined(_WIN32) && !defined(_FREEBSD) -#include -#if BYTE_ORDER == __BIG_ENDIAN -#define IS_BIG_ENDIAN -#endif -#endif - namespace sentencepiece { template std::ostream &operator<<(std::ostream &out, const std::vector &v) { @@ -411,10 +401,6 @@ class StatusBuilder { #define CHECK_GT_OR_RETURN(a, b) CHECK_OR_RETURN((a) > (b)) #define CHECK_LT_OR_RETURN(a, b) CHECK_OR_RETURN((a) < (b)) -#ifdef IS_BIG_ENDIAN -inline uint32 Swap32(uint32 x) { return __builtin_bswap32(x); } -#endif - } // namespace util namespace port {