diff --git a/CMakeLists.txt b/CMakeLists.txt index c832d701d..b47cdc672 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -208,6 +208,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 b72b2f8d5..b03308c1e 100644 --- a/config.h.cmake +++ b/config.h.cmake @@ -43,6 +43,7 @@ #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 1c8f115f6..8c34d1fb7 100644 --- a/src/core/core-crypto.c +++ b/src/core/core-crypto.c @@ -34,10 +34,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" @@ -47,10 +55,6 @@ #include "core-string.h" #include "../plugins/plugin.h" -#ifdef htonll -#define htobe64 htonll -#endif - char *weecrypto_hash_algo_string[] = { "crc32", "md5", @@ -533,7 +537,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,