Skip to content
Snippets Groups Projects
Commit 695d8cea authored by Tatsuhiro Tsujikawa's avatar Tatsuhiro Tsujikawa
Browse files

Define ngtcp2_ntohl64 and ngtcp2_htonl64 as noop for bigendian system

parent c0235d3c
No related merge requests found
......@@ -142,6 +142,7 @@ check_include_file("string.h" HAVE_STRING_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
check_include_file("sys/endian.h" HAVE_SYS_ENDIAN_H)
check_include_file("endian.h" HAVE_ENDIAN_H)
check_include_file("byteswap.h" HAVE_BYTESWAP_H)
include(CheckTypeSize)
# Checks for typedefs, structures, and compiler characteristics.
......@@ -161,6 +162,8 @@ if(HAVE_SYS_ENDIAN_H)
check_symbol_exists(be64toh "sys/endian.h" HAVE_BE64TOH)
endif()
check_symbol_exists(bswap_64 "byteswap.h" HAVE_BSWAP_64)
include(ExtractValidFlags)
set(WARNCFLAGS)
set(WARNCXXFLAGS)
......
......@@ -294,6 +294,7 @@ AC_CHECK_HEADERS([ \
unistd.h \
sys/endian.h \
endian.h \
byteswap.h \
])
# Checks for typedefs, structures, and compiler characteristics.
......@@ -331,6 +332,10 @@ AC_CHECK_DECLS([be64toh], [], [], [[
#endif
]])
AC_CHECK_DECLS([bswap_64], [], [], [[
#include <byteswap.h>
]])
# More compiler flags from nghttp2.
save_CFLAGS=$CFLAGS
save_CXXFLAGS=$CXXFLAGS
......
......@@ -37,6 +37,10 @@
# include <netinet/in.h>
#endif /* HAVE_NETINET_IN_H */
#ifdef HAVE_BYTESWAP_H
# include <byteswap.h>
#endif /* HAVE_BYTESWAP_H */
#ifdef HAVE_ENDIAN_H
# include <endian.h>
#endif /* HAVE_ENDIAN_H */
......@@ -47,16 +51,25 @@
#include <ngtcp2/ngtcp2.h>
#if defined HAVE_BSWAP_64 || HAVE_DECL_BSWAP_64
# define ngtcp2_bswap64 bswap_64
#else /* !HAVE_BSWAP_64 */
# define ngtcp2_bswap64(N) \
((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
#endif /* !HAVE_BSWAP_64 */
#if defined HAVE_BE64TOH || HAVE_DECL_BE64TOH
# define ngtcp2_ntohl64(N) be64toh(N)
# define ngtcp2_htonl64(N) htobe64(N)
#else /* !HAVE_BE64TOH */
# define ngtcp2_bswap64(N) \
((uint64_t)(ntohl((uint32_t)(N))) << 32 | ntohl((uint32_t)((N) >> 32)))
# define ngtcp2_ntohl64(N) ngtcp2_bswap64(N)
# define ngtcp2_htonl64(N) ngtcp2_bswap64(N)
#endif /* !HAVE_BE64TOH */
# if defined WORDS_BIGENDIAN
# define ngtcp2_ntohl64(N) (N)
# define ngtcp2_htonl64(N) (N)
# else /* !WORDS_BIGENDIAN */
# define ngtcp2_ntohl64(N) ngtcp2_bswap64(N)
# define ngtcp2_htonl64(N) ngtcp2_bswap64(N)
# endif /* !WORDS_BIGENDIAN */
#endif /* !HAVE_BE64TOH */
#if defined(WIN32)
/* Windows requires ws2_32 library for ntonl family functions. We
define inline functions for those function so that we don't have
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment