Skip to content

Commit

Permalink
deps: ntlmclient: provide platform-independent htonll implementation
Browse files Browse the repository at this point in the history
With the introduction of ntlmclient, we've started playing whac-a-mole
with platforms to support the non-standard htonll function. Let's end
this game once and for all by providing a generic implementation that's
implemented via htonl(3P) and a endianness-check in CMake.
  • Loading branch information
pks-t committed Aug 24, 2020
1 parent c71321a commit 03fb6a7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 25 deletions.
7 changes: 7 additions & 0 deletions deps/ntlmclient/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
INCLUDE(TestBigEndian)

FILE(GLOB SRC_NTLMCLIENT "ntlm.c" "unicode_builtin.c" "util.c")
LIST(SORT SRC_NTLMCLIENT)

ADD_DEFINITIONS(-DNTLM_STATIC=1)

DISABLE_WARNINGS(implicit-fallthrough)

TEST_BIG_ENDIAN(BIG_ENDIAN)
IF(BIG_ENDIAN)
ADD_DEFINITIONS(-DBIG_ENDIAN)
ENDIF()

IF(USE_HTTPS STREQUAL "SecureTransport")
ADD_DEFINITIONS(-DCRYPT_COMMONCRYPTO)
SET(SRC_NTLMCLIENT_CRYPTO "crypt_commoncrypto.c")
Expand Down
29 changes: 4 additions & 25 deletions deps/ntlmclient/compat.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,10 @@
# include <stdbool.h>
#endif

#ifdef __linux__
/* See man page endian(3) */
# include <endian.h>
# define htonll htobe64
#elif defined(__NetBSD__) || defined(__OpenBSD__)
/* See man page htobe64(3) */
# include <endian.h>
# define htonll htobe64
#elif defined(__FreeBSD__)
/* See man page bwaps64(9) */
# include <sys/endian.h>
# define htonll htobe64
#elif defined(sun) || defined(__sun)
/* See man page byteorder(3SOCKET) */
# include <sys/types.h>
# include <netinet/in.h>
# include <inttypes.h>

# if !defined(htonll)
# if defined(_BIG_ENDIAN)
# define htonll(x) (x)
# else
# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32))
# endif
# endif
#if defined(BIG_ENDIAN)
# define htonll(x) (x)
#else
# define htonll(x) ((((uint64_t)htonl(x)) << 32) + htonl((uint64_t)(x) >> 32))
#endif

#ifndef MIN
Expand Down

0 comments on commit 03fb6a7

Please sign in to comment.