fix for FreeBSD and other BSD's where endian.h becomes sys/endian.h

This commit is contained in:
fduncanh
2021-11-15 03:30:46 -05:00
parent 1fcc45aeb7
commit 785743ff1b
2 changed files with 11 additions and 0 deletions

View File

@@ -1,6 +1,13 @@
cmake_minimum_required(VERSION 3.4.1)
include_directories( playfair llhttp )
INCLUDE (CheckIncludeFiles)
# for BSD Unix (e.g. FreeBSD)
CHECK_INCLUDE_FILES ("sys/endian.h" HAVE_SYS_ENDIAN_H )
if (HAVE_SYS_ENDIAN_H)
add_definitions( -DSYS_ENDIAN_H )
endif (HAVE_SYS_ENDIAN_H)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Ofast -march=native -DSTANDALONE -D__STDC_CONSTANT_MACROS -D__STDC_LIMIT_MACROS -DTARGET_POSIX -D_LINUX -fPIC -DPIC -D_REENTRANT -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -U_FORTIFY_SOURCE -Wall -g")
if( APPLE )

View File

@@ -17,7 +17,11 @@
#include "byteutils.h"
#ifndef htonll
#ifdef SYS_ENDIAN_H
#include <sys/endian.h>
#else
#include <endian.h>
#endif
#define htonll(x) htobe64(x)
#define ntohll(x) be64toh(x)
#endif