Skip to content

Commit

Permalink
fix for FreeBSD and other BSD's where endian.h becomes sys/endian.h
Browse files Browse the repository at this point in the history
  • Loading branch information
fduncanh committed Nov 15, 2021
1 parent 1fcc45a commit 785743f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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 )
Expand Down
4 changes: 4 additions & 0 deletions lib/byteutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 785743f

Please sign in to comment.