Skip to content

Commit

Permalink
c++20 serialization endian changes POC
Browse files Browse the repository at this point in the history
- use of std::endian means that we no longer have to rely on configure checks
and compiler macros for compile-time endianness checks.
- countl_zero replaces the need for __builtin_clz*
- use macros to check for byteswap builtins
  • Loading branch information
theuni committed Jan 16, 2024
1 parent a3fb1f8 commit 6aa4e64
Show file tree
Hide file tree
Showing 8 changed files with 116 additions and 322 deletions.
14 changes: 1 addition & 13 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -977,7 +977,7 @@ if test "$TARGET_OS" = "darwin"; then
AX_CHECK_LINK_FLAG([-Wl,-fixup_chains], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"], [], [$LDFLAG_WERROR])
fi

AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h])
AC_CHECK_HEADERS([sys/select.h sys/prctl.h sys/sysctl.h vm/vm_param.h sys/vmmeter.h sys/resources.h])

AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],,
[#include <sys/types.h>
Expand All @@ -992,18 +992,6 @@ AC_CHECK_DECLS([pipe2])

AC_CHECK_FUNCS([timingsafe_bcmp])

AC_CHECK_DECLS([le16toh, le32toh, le64toh, htole16, htole32, htole64, be16toh, be32toh, be64toh, htobe16, htobe32, htobe64],,,
[#if HAVE_ENDIAN_H
#include <endian.h>
#elif HAVE_SYS_ENDIAN_H
#include <sys/endian.h>
#endif])

AC_CHECK_DECLS([bswap_16, bswap_32, bswap_64],,,
[#if HAVE_BYTESWAP_H
#include <byteswap.h>
#endif])

AC_MSG_CHECKING([for __builtin_clzl])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ ]], [[
(void) __builtin_clzl(0);
Expand Down
1 change: 0 additions & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ BITCOIN_CORE_H = \
common/run_command.h \
common/url.h \
compat/assumptions.h \
compat/byteswap.h \
compat/compat.h \
compat/cpuid.h \
compat/endian.h \
Expand Down
59 changes: 0 additions & 59 deletions src/compat/byteswap.h

This file was deleted.

Loading

0 comments on commit 6aa4e64

Please sign in to comment.