diff --git a/CMakeLists.txt b/CMakeLists.txt index 96e28a71b..75a05b0c7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,6 +218,8 @@ check_symbol_exists("malloc_trim" "malloc.h" HAVE_MALLOC_TRIM) check_function_exists(mallinfo HAVE_MALLINFO) check_function_exists(mallinfo2 HAVE_MALLINFO2) +check_symbol_exists("htonll" "sys/types.h;netinet/in.h;inttypes.h" HAVE_HTONLL) + check_symbol_exists("eat_newline_glitch" "term.h" HAVE_EAT_NEWLINE_GLITCH) # Check for Large File Support diff --git a/config.h.cmake b/config.h.cmake index 8de138062..eec9097bd 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -49,6 +49,7 @@ SPDX-License-Identifier: GPL-3.0-or-later #cmakedefine HAVE_MALLINFO2 #cmakedefine HAVE_MALLOC_H #cmakedefine HAVE_MALLOC_TRIM +#cmakedefine HAVE_HTONLL #cmakedefine HAVE_EAT_NEWLINE_GLITCH #cmakedefine HAVE_ASPELL_VERSION_STRING #cmakedefine HAVE_ENCHANT_GET_VERSION diff --git a/src/core/core-crypto.c b/src/core/core-crypto.c index ddf475e60..93d76d22f 100644 --- a/src/core/core-crypto.c +++ b/src/core/core-crypto.c @@ -36,10 +36,18 @@ /* Bring in htobe64 */ #ifdef __ANDROID__ #define _BSD_SOURCE +#define BE_INT64 htobe64 #include #elif defined(__APPLE__) #include -#define htobe64 OSSwapHostToBigInt64 +#define BE_INT64 OSSwapHostToBigInt64 +#elif defined(HAVE_HTONLL) +#include +#include +#include +#define BE_INT64 htonll +#else +#define BE_INT64 htobe64 #endif #include "weechat.h" @@ -49,10 +57,6 @@ #include "core-string.h" #include "../plugins/plugin.h" -#ifdef htonll -#define htobe64 htonll -#endif - char *weecrypto_hash_algo_string[] = { "crc32", "md5", @@ -536,7 +540,7 @@ weecrypto_totp_generate_internal (const char *secret, int length_secret, int rc, offset, length; unsigned long bin_code; - moving_factor_swapped = htobe64 (moving_factor); + moving_factor_swapped = BE_INT64 (moving_factor); rc = weecrypto_hmac (secret, length_secret, &moving_factor_swapped, sizeof (moving_factor_swapped), GCRY_MD_SHA1,