From 0e7cde465cc456dd5a35ce7aba5b2e00631bca62 Mon Sep 17 00:00:00 2001 From: vkalintiris Date: Mon, 26 Feb 2024 15:48:26 +0200 Subject: Assorted build-related changes. (#16906) * Rename endian.h to byte_order.h The underlying issue is that non-relative header search paths would pick up our own endian.h. This should be fixed in a follow-up PR. * Do not include top-level source dir * Move h2o dep from libnetdata to netdata binary. * Update #endif comment. --- CMakeLists.txt | 8 +++----- src/libnetdata/byteorder.h | 32 ++++++++++++++++++++++++++++++++ src/libnetdata/endian.h | 32 -------------------------------- src/libnetdata/os.h | 2 +- 4 files changed, 36 insertions(+), 38 deletions(-) create mode 100644 src/libnetdata/byteorder.h delete mode 100644 src/libnetdata/endian.h diff --git a/CMakeLists.txt b/CMakeLists.txt index d6e9536bbc..c703309513 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -598,7 +598,7 @@ set(LIBNETDATA_FILES src/libnetdata/os.c src/libnetdata/os.h src/libnetdata/simple_hashtable.h - src/libnetdata/endian.h + src/libnetdata/byteorder.h src/libnetdata/onewayalloc/onewayalloc.c src/libnetdata/onewayalloc/onewayalloc.h src/libnetdata/popen/popen.c @@ -1464,7 +1464,7 @@ detect_systemd() add_library(libnetdata STATIC ${LIBNETDATA_FILES}) -target_include_directories(libnetdata BEFORE PUBLIC ${CONFIG_H_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/src) +target_include_directories(libnetdata BEFORE PUBLIC ${CONFIG_H_DIR} ${CMAKE_SOURCE_DIR}/src) # pthread (FIXME: use find_package for this) @@ -1592,9 +1592,6 @@ target_include_directories(libnetdata BEFORE PUBLIC ${OPENSSL_INCLUDE_DIRS}) target_compile_options(libnetdata PUBLIC ${OPENSSL_CFLAGS_OTHER}) target_link_libraries(libnetdata PUBLIC ${OPENSSL_LDFLAGS}) -# h2o -target_link_libraries(libnetdata PUBLIC "$<$:h2o>") - # mnl pkg_check_modules(MNL libmnl) if(MNL_FOUND) @@ -2056,6 +2053,7 @@ target_link_libraries(netdata PRIVATE "$<$:${IOKIT};${FOUNDATION}>" "$<$:sentry>" "$<$:LibDataChannel::LibDataChannelStatic>" + "$<$:h2o>" ) # diff --git a/src/libnetdata/byteorder.h b/src/libnetdata/byteorder.h new file mode 100644 index 0000000000..28fc9e663e --- /dev/null +++ b/src/libnetdata/byteorder.h @@ -0,0 +1,32 @@ +#ifndef LIBNETDATA_BYTE_ORDER_H +#define LIBNETDATA_BYTE_ORDER_H + +/** compatibility header for endian.h + * This is a simple compatibility shim to convert + * BSD/Linux endian macros to the Mac OS X equivalents. + * It is public domain. + * */ + +#ifndef __APPLE__ +#error "This header file (endian.h) is MacOS X specific.\n" +#endif /* __APPLE__ */ + + +#include + +#define htobe16(x) OSSwapHostToBigInt16(x) +#define htole16(x) OSSwapHostToLittleInt16(x) +#define be16toh(x) OSSwapBigToHostInt16(x) +#define le16toh(x) OSSwapLittleToHostInt16(x) + +#define htobe32(x) OSSwapHostToBigInt32(x) +#define htole32(x) OSSwapHostToLittleInt32(x) +#define be32toh(x) OSSwapBigToHostInt32(x) +#define le32toh(x) OSSwapLittleToHostInt32(x) + +#define htobe64(x) OSSwapHostToBigInt64(x) +#define htole64(x) OSSwapHostToLittleInt64(x) +#define be64toh(x) OSSwapBigToHostInt64(x) +#define le64toh(x) OSSwapLittleToHostInt64(x) + +#endif /* LIBNETDATA_BYTE_ORDER_H */ diff --git a/src/libnetdata/endian.h b/src/libnetdata/endian.h deleted file mode 100644 index 66f75cb1ad..0000000000 --- a/src/libnetdata/endian.h +++ /dev/null @@ -1,32 +0,0 @@ -#ifndef LIBNETDATA_ENDIAN_H -#define LIBNETDATA_ENDIAN_H - -/** compatibility header for endian.h - * This is a simple compatibility shim to convert - * BSD/Linux endian macros to the Mac OS X equivalents. - * It is public domain. - * */ - -#ifndef __APPLE__ -#error "This header file (endian.h) is MacOS X specific.\n" -#endif /* __APPLE__ */ - - -#include - -#define htobe16(x) OSSwapHostToBigInt16(x) -#define htole16(x) OSSwapHostToLittleInt16(x) -#define be16toh(x) OSSwapBigToHostInt16(x) -#define le16toh(x) OSSwapLittleToHostInt16(x) - -#define htobe32(x) OSSwapHostToBigInt32(x) -#define htole32(x) OSSwapHostToLittleInt32(x) -#define be32toh(x) OSSwapBigToHostInt32(x) -#define le32toh(x) OSSwapLittleToHostInt32(x) - -#define htobe64(x) OSSwapHostToBigInt64(x) -#define htole64(x) OSSwapHostToLittleInt64(x) -#define be64toh(x) OSSwapBigToHostInt64(x) -#define le64toh(x) OSSwapLittleToHostInt64(x) - -#endif /* LIBNETDATA_ENDIAN_H */ diff --git a/src/libnetdata/os.h b/src/libnetdata/os.h index 197548b0da..0e4a369635 100644 --- a/src/libnetdata/os.h +++ b/src/libnetdata/os.h @@ -37,7 +37,7 @@ int getsysctl(const char *name, int *mib, size_t miblen, void *ptr, size_t *len) #if __APPLE__ #include -#include "endian.h" +#include "byteorder.h" #define GETSYSCTL_BY_NAME(name, var) getsysctl_by_name(name, &(var), sizeof(var)) int getsysctl_by_name(const char *name, void *ptr, size_t len); -- cgit v1.2.3