New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FreeBSD support in endian.h #476

Merged
merged 7 commits into from Nov 2, 2018
File filter...
Filter file types
Jump to file or symbol
Failed to load files and symbols.
+25 −4
Diff settings

Always

Just for now

Copy path View file
@@ -96,6 +96,15 @@ endif()

check_symbol_exists(nanosleep time.h DMLC_NANOSLEEP_PRESENT)

# Check endianness
include(TestBigEndian)
test_big_endian(BIG_ENDIAN)
if(BIG_ENDIAN)
set(DMLC_CMAKE_LITTLE_ENDIAN 0)
else()
set(DMLC_CMAKE_LITTLE_ENDIAN 1)
endif()

message(STATUS "${CMAKE_LOCAL}/build_config.h.in -> ${INCLUDE_DMLC_DIR}/build_config.h")
configure_file("${CMAKE_LOCAL}/build_config.h.in" "${INCLUDE_DMLC_DIR}/build_config.h")

Copy path View file
@@ -25,4 +25,6 @@

#cmakedefine DMLC_NANOSLEEP_PRESENT

#cmakedefine DMLC_CMAKE_LITTLE_ENDIAN ${DMLC_CMAKE_LITTLE_ENDIAN}

#endif // DMLC_BUILD_CONFIG_H_
Copy path View file
@@ -8,11 +8,21 @@

#include "./base.h"

#if defined(__APPLE__) || defined(_WIN32)
#define DMLC_LITTLE_ENDIAN 1
#ifdef DMLC_CMAKE_LITTLE_ENDIAN
// If compiled with CMake, use CMake's endian detection logic
#define DMLC_LITTLE_ENDIAN DMLC_CMAKE_LITTLE_ENDIAN
#else
#include <endian.h>
#define DMLC_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
#if defined(__APPLE__) || defined(_WIN32)
#define DMLC_LITTLE_ENDIAN 1
#elif defined(__GLIBC__)
#include <endian.h>
#define DMLC_LITTLE_ENDIAN (__BYTE_ORDER == __LITTLE_ENDIAN)
#elif defined(__FreeBSD__)
#include <sys/endian.h>
#define DMLC_LITTLE_ENDIAN (_BYTE_ORDER == _LITTLE_ENDIAN)
#else
#error "Unable to determine endianness of your machine; use CMake to compile"
#endif
#endif

/*! \brief whether serialize using little endian */
ProTip! Use n and p to navigate between commits in a pull request.