BSD compat: use sys/endian.h if available

<byteswap.h> is a linuxism. On BSD-like systems this is <sys/endian.h>
This commit is contained in:
Melvyn Sopacua 2017-02-13 14:30:48 +01:00
parent e9decd2574
commit 6eb6f35f24
2 changed files with 13 additions and 1 deletions

View File

@ -1,4 +1,12 @@
add_executable(nominatim export.c geometry.cpp import.c index.c input.c nominatim.c postgresql.c sprompt.c)
include(CheckIncludeFile)
CHECK_INCLUDE_FILE(byteswap.h HAVE_BYTESWAP_H)
CHECK_INCLUDE_FILE(sys/endian.h HAVE_SYS_ENDIAN_H)
if(HAVE_BYTESWAP_H)
target_compile_definitions(nominatim PRIVATE HAVE_BYTESWAP_H)
endif(HAVE_BYTESWAP_H)
if(HAVE_SYS_ENDIAN_H)
target_compile_definitions(nominatim PRIVATE HAVE_SYS_ENDIAN_H)
endif(HAVE_SYS_ENDIAN_H)
target_link_libraries(nominatim ${LIBXML2_LIBRARIES} ${ZLIB_LIBRARIES} ${BZIP2_LIBRARIES} ${PostgreSQL_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})

View File

@ -7,7 +7,11 @@
#define PG_OID_INT8 20
#define PG_OID_INT4 23
#if defined(HAVE_BYTESWAP_H)
#include <byteswap.h>
#elif defined(HAVE_SYS_ENDIAN_H)
#include <sys/endian.h>
#endif
#if __BYTE_ORDER == __BIG_ENDIAN
#define PGint16(x) (x)