diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index 89f3e188ee..25a5217345 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -116,8 +116,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ BITCOIN_QT_CHECK([ TEMP_CPPFLAGS=$CPPFLAGS TEMP_CXXFLAGS=$CXXFLAGS - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" - CXXFLAGS="$PIC_FLAGS $CXXFLAGS" + CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS" + CXXFLAGS="$PIC_FLAGS $CORE_CXXFLAGS $CXXFLAGS" _BITCOIN_QT_IS_STATIC if test "x$bitcoin_cv_static_qt" = xyes; then _BITCOIN_QT_CHECK_STATIC_LIBS @@ -177,8 +177,8 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ AC_MSG_CHECKING(whether -fPIE can be used with this Qt config) TEMP_CPPFLAGS=$CPPFLAGS TEMP_CXXFLAGS=$CXXFLAGS - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" - CXXFLAGS="$PIE_FLAGS $CXXFLAGS" + CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS" + CXXFLAGS="$PIE_FLAGS $CORE_CXXFLAGS $CXXFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifndef QT_VERSION @@ -200,7 +200,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ BITCOIN_QT_CHECK([ AC_MSG_CHECKING(whether -fPIC is needed with this Qt config) TEMP_CPPFLAGS=$CPPFLAGS - CPPFLAGS="$QT_INCLUDES $CPPFLAGS" + CPPFLAGS="$QT_INCLUDES $CORE_CPPFLAGS $CPPFLAGS" AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ #include #ifndef QT_VERSION diff --git a/configure.ac b/configure.ac index 499f539ceb..af682ac9c1 100644 --- a/configure.ac +++ b/configure.ac @@ -372,7 +372,9 @@ case $host in esac if test "x$enable_debug" = xyes; then - dnl Clear default -g -O2 flags + dnl If debugging is enabled, and the user hasn't overriden CXXFLAGS, clear + dnl them, to prevent autoconfs "-g -O2" being added. Otherwise we'd end up + dnl with "-O0 -g3 -g -O2". if test "x$CXXFLAGS_overridden" = xno; then CXXFLAGS="" fi @@ -397,11 +399,11 @@ else # Stacktraces will be suboptimal due to optimization, but better than nothing. Also, -fno-omit-frame-pointer # mitigates this a little bit if test "x$GCC" = xyes; then - CFLAGS="$CFLAGS -g1 -fno-omit-frame-pointer" + DEBUG_CFLAGS="$DEBUG_CFLAGS -g1 -fno-omit-frame-pointer" fi if test "x$GXX" = xyes; then - CXXFLAGS="$CXXFLAGS -g1 -fno-omit-frame-pointer" + DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -g1 -fno-omit-frame-pointer" fi fi @@ -429,7 +431,7 @@ if test x$LINK_WRAP_SUPPORTED = "xyes"; then fi # Needed for MinGW targets when debug symbols are enabled as compiled objects get very large -AX_CHECK_COMPILE_FLAG([-Wa,-mbig-obj], [CXXFLAGS="$CXXFLAGS -Wa,-mbig-obj"],,,) +AX_CHECK_COMPILE_FLAG([-Wa,-mbig-obj], [DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -Wa,-mbig-obj"],,,) if test x$use_sanitizers != x; then dnl First check if the compiler accepts flags. If an incompatible pair like @@ -532,7 +534,7 @@ if test "x$CXXFLAGS_overridden" = "xno"; then fi dnl Don't allow extended (non-ASCII) symbols in identifiers. This is easier for code review. -AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CXXFLAGS="$CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]]) +AX_CHECK_COMPILE_FLAG([-fno-extended-identifiers],[[CORE_CXXFLAGS="$CORE_CXXFLAGS -fno-extended-identifiers"]],,[[$CXXFLAG_WERROR]]) enable_arm_crc=no enable_arm_shani=no @@ -683,7 +685,7 @@ CXXFLAGS="$TEMP_CXXFLAGS" fi -CPPFLAGS="$CPPFLAGS -DHAVE_BUILD_INFO -DGSL_NO_IOSTREAMS" +CORE_CPPFLAGS="$CORE_CPPFLAGS -DHAVE_BUILD_INFO -DGSL_NO_IOSTREAMS" AC_ARG_WITH([utils], [AS_HELP_STRING([--with-utils], @@ -755,7 +757,10 @@ case $host in AC_MSG_ERROR("windres not found") fi - CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" + CORE_CPPFLAGS="$CORE_CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -D_WIN32_WINNT=0x0601 -D_WIN32_IE=0x0501 -DWIN32_LEAN_AND_MEAN" + dnl Prevent the definition of min/max macros. + dnl We always want to use the standard library. + CORE_CPPFLAGS="$CORE_CPPFLAGS -DNOMINMAX" dnl libtool insists upon adding -nostdlib and a list of objects/libs to link against. dnl That breaks our ability to build dll's with static libgcc/libstdc++/libssp. Override @@ -766,14 +771,14 @@ case $host in postdeps_CXX= dnl We require Windows 7 (NT 6.1) or later - AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[LDFLAGS="$LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[CORE_LDFLAGS="$CORE_LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]]) ;; *darwin*) TARGET_OS=darwin if test x$cross_compiling != xyes; then BUILD_OS=darwin - AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [LDFLAGS="$LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-headerpad_max_install_names]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-headerpad_max_install_names"],, [[$LDFLAG_WERROR]]) AC_CHECK_PROG([BREW],brew, brew) if test x$BREW = xbrew; then @@ -800,8 +805,8 @@ case $host in gmp_prefix=$($BREW --prefix gmp 2>/dev/null) if test x$gmp_prefix != x; then - CPPFLAGS="$CPPFLAGS -I$gmp_prefix/include" - LDFLAGS="$LDFLAGS -L$gmp_prefix/lib" + CORE_CPPFLAGS="$CORE_CPPFLAGS -I$gmp_prefix/include" + CORE_LDFLAGS="$CORE_LDFLAGS -L$gmp_prefix/lib" fi case $host in @@ -813,20 +818,20 @@ case $host in if test "x$use_upnp" != xno && $BREW list --versions miniupnpc >/dev/null; then miniupnpc_prefix=$($BREW --prefix miniupnpc 2>/dev/null) if test "x$suppress_external_warnings" != xno; then - CPPFLAGS="$CPPFLAGS -isystem $miniupnpc_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -isystem $miniupnpc_prefix/include" else - CPPFLAGS="$CPPFLAGS -I$miniupnpc_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -I$miniupnpc_prefix/include" fi - LDFLAGS="$LDFLAGS -L$miniupnpc_prefix/lib" + CORE_LDFLAGS="$CORE_LDFLAGS -L$miniupnpc_prefix/lib" fi if test "x$use_natpmp" != xno && $BREW list --versions libnatpmp >/dev/null; then libnatpmp_prefix=$($BREW --prefix libnatpmp 2>/dev/null) if test "x$suppress_external_warnings" != xno; then - CPPFLAGS="$CPPFLAGS -isystem $libnatpmp_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -isystem $libnatpmp_prefix/include" else - CPPFLAGS="$CPPFLAGS -I$libnatpmp_prefix/include" + CORE_CPPFLAGS="$CORE_CPPFLAGS -I$libnatpmp_prefix/include" fi - LDFLAGS="$LDFLAGS -L$libnatpmp_prefix/lib" + CORE_LDFLAGS="$CORE_LDFLAGS -L$libnatpmp_prefix/lib" fi ;; esac @@ -849,7 +854,7 @@ case $host in esac fi - CPPFLAGS="$CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" + CORE_CPPFLAGS="$CORE_CPPFLAGS -DMAC_OSX -DOBJC_OLD_DISPATCH_PROTOTYPES=0" OBJCXXFLAGS="$CXXFLAGS" ;; *android*) @@ -912,11 +917,17 @@ if test x$use_lcov = xyes; then AC_SUBST(COV_TOOL_WRAPPER, "cov_tool_wrapper.sh") LCOV="$LCOV --gcov-tool $(pwd)/$COV_TOOL_WRAPPER" - AX_CHECK_LINK_FLAG([[--coverage]], [LDFLAGS="$LDFLAGS --coverage"], + AX_CHECK_LINK_FLAG([[--coverage]], [CORE_LDFLAGS="$CORE_LDFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage linker flag does not work")]) - AX_CHECK_COMPILE_FLAG([--coverage],[CXXFLAGS="$CXXFLAGS --coverage"], + AX_CHECK_COMPILE_FLAG([--coverage],[CORE_CXXFLAGS="$CORE_CXXFLAGS --coverage"], [AC_MSG_ERROR("lcov testing requested but --coverage flag does not work")]) - CXXFLAGS="$CXXFLAGS -Og" + dnl If coverage is enabled, and the user hasn't overriden CXXFLAGS, clear + dnl them, to prevent autoconfs "-g -O2" being added. Otherwise we'd end up + dnl with "--coverage -Og -O0 -g -O2". + if test "$CXXFLAGS_overridden" = "no"; then + CXXFLAGS="" + fi + CORE_CXXFLAGS="$CORE_CXXFLAGS -Og -O0" fi if test x$use_lcov_branch != xno; then @@ -942,13 +953,13 @@ AC_FUNC_STRERROR_R if test x$ac_cv_sys_file_offset_bits != x && test x$ac_cv_sys_file_offset_bits != xno && test x$ac_cv_sys_file_offset_bits != xunknown; then - CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" + CORE_CPPFLAGS="$CORE_CPPFLAGS -D_FILE_OFFSET_BITS=$ac_cv_sys_file_offset_bits" fi if test x$ac_cv_sys_large_files != x && test x$ac_cv_sys_large_files != xno && test x$ac_cv_sys_large_files != xunknown; then - CPPFLAGS="$CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" + CORE_CPPFLAGS="$CORE_CPPFLAGS -D_LARGE_FILES=$ac_cv_sys_large_files" fi if test "x$enable_gprof" = xyes; then @@ -1037,8 +1048,8 @@ dnl These flags are specific to ld64, and may cause issues with other linkers. dnl For example: GNU ld will interpret -dead_strip as -de and then try and use dnl "ad_strip" as the symbol for the entry point. if test x$TARGET_OS = xdarwin; then - AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]]) - AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [LDFLAGS="$LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip"],, [[$LDFLAG_WERROR]]) + AX_CHECK_LINK_FLAG([[-Wl,-dead_strip_dylibs]], [CORE_LDFLAGS="$CORE_LDFLAGS -Wl,-dead_strip_dylibs"],, [[$LDFLAG_WERROR]]) AX_CHECK_LINK_FLAG([[-Wl,-fixup_chains]], [HARDENED_LDFLAGS="$HARDENED_LDFLAGS -Wl,-fixup_chains"], [], [[$LDFLAG_WERROR]]) fi @@ -1048,7 +1059,6 @@ AC_CHECK_DECLS([getifaddrs, freeifaddrs],[CHECK_SOCKET],, [#include #include ] ) -AC_CHECK_DECLS([strnlen]) dnl These are used for daemonization in dashd AC_CHECK_DECLS([fork]) @@ -1361,7 +1371,7 @@ if test "x$enable_fuzz" = "xyes"; then [[-fsanitize=$use_sanitizers]], [AC_MSG_RESULT([no])], [AC_MSG_RESULT([yes]) - CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"], + CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION"], [], [AC_LANG_PROGRAM([[ #include @@ -1385,7 +1395,7 @@ else QT_TEST_INCLUDES=SUPPRESS_WARNINGS($QT_TEST_INCLUDES) fi - CPPFLAGS="$CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION" + CORE_CPPFLAGS="$CORE_CPPFLAGS -DPROVIDE_FUZZ_MAIN_FUNCTION" fi if test x$enable_wallet != xno; then @@ -1518,7 +1528,7 @@ fi dnl Check for reduced exports if test x$use_reduce_exports = xyes; then - AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CXXFLAGS="$CXXFLAGS -fvisibility=hidden"], + AX_CHECK_COMPILE_FLAG([-fvisibility=hidden],[CORE_CXXFLAGS="$CORE_CXXFLAGS -fvisibility=hidden"], [AC_MSG_ERROR([Cannot set hidden symbol visibility. Use --disable-reduce-exports.])],[[$CXXFLAG_WERROR]]) AX_CHECK_LINK_FLAG([[-Wl,--exclude-libs,ALL]],[RELDFLAGS="-Wl,--exclude-libs,ALL"],,[[$LDFLAG_WERROR]]) AX_CHECK_LINK_FLAG([-Wl,-no_exported_symbols], [LIBTOOL_APP_LDFLAGS="$LIBTOOL_APP_LDFLAGS -Wl,-no_exported_symbols"], [], [$LDFLAG_WERROR]) @@ -1870,10 +1880,14 @@ AC_SUBST(BITCOIN_MP_NODE_NAME) AC_SUBST(BITCOIN_MP_GUI_NAME) AC_SUBST(RELDFLAGS) +AC_SUBST(CORE_LDFLAGS) +AC_SUBST(CORE_CPPFLAGS) +AC_SUBST(CORE_CXXFLAGS) +AC_SUBST(DEBUG_CFLAGS) AC_SUBST(DEBUG_CPPFLAGS) +AC_SUBST(DEBUG_CXXFLAGS) AC_SUBST(WARN_CXXFLAGS) AC_SUBST(NOWARN_CXXFLAGS) -AC_SUBST(DEBUG_CXXFLAGS) AC_SUBST(ERROR_CXXFLAGS) AC_SUBST(GPROF_CXXFLAGS) AC_SUBST(GPROF_LDFLAGS) @@ -1995,10 +2009,10 @@ echo " target os = $host_os" echo " build os = $build_os" echo echo " CC = $CC" -echo " CFLAGS = $PTHREAD_CFLAGS $CFLAGS" -echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CPPFLAGS" +echo " CFLAGS = $DEBUG_CFLAGS $PTHREAD_CFLAGS $CFLAGS" +echo " CPPFLAGS = $DEBUG_CPPFLAGS $HARDENED_CPPFLAGS $CORE_CPPFLAGS $CPPFLAGS" echo " CXX = $CXX" -echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CXXFLAGS" -echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $LDFLAGS" +echo " CXXFLAGS = $DEBUG_CXXFLAGS $HARDENED_CXXFLAGS $WARN_CXXFLAGS $NOWARN_CXXFLAGS $ERROR_CXXFLAGS $GPROF_CXXFLAGS $CORE_CXXFLAGS $CXXFLAGS" +echo " LDFLAGS = $PTHREAD_LIBS $HARDENED_LDFLAGS $GPROF_LDFLAGS $CORE_LDFLAGS $LDFLAGS" echo " ARFLAGS = $ARFLAGS" echo diff --git a/src/Makefile.am b/src/Makefile.am index 55ffd7a6c6..3b714b247c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -9,9 +9,10 @@ print-%: FORCE DIST_SUBDIRS = secp256k1 -AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) -AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) -AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) +AM_LDFLAGS = $(LIBTOOL_LDFLAGS) $(HARDENED_LDFLAGS) $(GPROF_LDFLAGS) $(SANITIZER_LDFLAGS) $(CORE_LDFLAGS) +AM_CFLAGS = $(DEBUG_CFLAGS) +AM_CXXFLAGS = $(DEBUG_CXXFLAGS) $(HARDENED_CXXFLAGS) $(WARN_CXXFLAGS) $(NOWARN_CXXFLAGS) $(ERROR_CXXFLAGS) $(GPROF_CXXFLAGS) $(SANITIZER_CXXFLAGS) $(CORE_CXXFLAGS) +AM_CPPFLAGS = $(DEBUG_CPPFLAGS) $(HARDENED_CPPFLAGS) $(CORE_CPPFLAGS) AM_LIBTOOLFLAGS = --preserve-dup-deps PTHREAD_FLAGS = $(PTHREAD_CFLAGS) $(PTHREAD_LIBS) EXTRA_LIBRARIES = @@ -162,9 +163,9 @@ BITCOIN_CORE_H = \ coinjoin/util.h \ coins.h \ common/bloom.h \ - compat.h \ compat/assumptions.h \ compat/byteswap.h \ + compat/compat.h \ compat/cpuid.h \ compat/endian.h \ compressor.h \ @@ -279,7 +280,7 @@ BITCOIN_CORE_H = \ node/psbt.h \ node/transaction.h \ node/txreconciliation.h \ - node/ui_interface.h \ + node/interface_ui.h \ node/utxo_snapshot.h \ noui.h \ outputtype.h \ @@ -512,7 +513,7 @@ libbitcoin_server_a_SOURCES = \ node/psbt.cpp \ node/transaction.cpp \ node/txreconciliation.cpp \ - node/ui_interface.cpp \ + node/interface_ui.cpp \ noui.cpp \ policy/fees.cpp \ policy/packages.cpp \ @@ -792,7 +793,6 @@ libbitcoin_util_a_SOURCES = \ support/lockedpool.cpp \ chainparamsbase.cpp \ clientversion.cpp \ - compat/strnlen.cpp \ fs.cpp \ interfaces/echo.cpp \ interfaces/handler.cpp \ diff --git a/src/banman.cpp b/src/banman.cpp index c162eb08fd..d319a2a996 100644 --- a/src/banman.cpp +++ b/src/banman.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/bitcoin-cli.cpp b/src/bitcoin-cli.cpp index 045cf0ae76..43790e9ac4 100644 --- a/src/bitcoin-cli.cpp +++ b/src/bitcoin-cli.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/bitcoin-tx.cpp b/src/bitcoin-tx.cpp index 0eb122f086..cb40879f8e 100644 --- a/src/bitcoin-tx.cpp +++ b/src/bitcoin-tx.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/bitcoin-wallet.cpp b/src/bitcoin-wallet.cpp index 8e7c1490fd..4dfb973042 100644 --- a/src/bitcoin-wallet.cpp +++ b/src/bitcoin-wallet.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index d026c7c1f3..a3b9910e2d 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -10,12 +10,12 @@ #include #include -#include +#include #include #include #include #include -#include +#include #include #include #include diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index 487ab9aa9e..0298f78b96 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -8,6 +8,7 @@ #ifndef BITCOIN_COMPAT_ASSUMPTIONS_H #define BITCOIN_COMPAT_ASSUMPTIONS_H +#include #include // Assumption: We assume that the macro NDEBUG is not defined. diff --git a/src/compat.h b/src/compat/compat.h similarity index 74% rename from src/compat.h rename to src/compat/compat.h index 41f2cd7398..5dd73eb717 100644 --- a/src/compat.h +++ b/src/compat/compat.h @@ -3,24 +3,24 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_COMPAT_H -#define BITCOIN_COMPAT_H +#ifndef BITCOIN_COMPAT_COMPAT_H +#define BITCOIN_COMPAT_COMPAT_H #if defined(HAVE_CONFIG_H) #include #endif +// Windows defines FD_SETSIZE to 64 (see _fd_types.h in mingw-w64), +// which is too small for our usage, but allows us to redefine it safely. +// We redefine it to be 1024, to match glibc, see typesizes.h. #ifdef WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #ifdef FD_SETSIZE -#undef FD_SETSIZE // prevent redefinition compiler warning +#undef FD_SETSIZE #endif -#define FD_SETSIZE 1024 // max number of fds in fd_set +#define FD_SETSIZE 1024 #include #include -#include +#include #else #include #include @@ -37,54 +37,46 @@ #include #endif +// We map Linux / BSD error functions and codes, to the equivalent +// Windows definitions, and use the WSA* names throughout our code. +// Note that glibc defines EWOULDBLOCK as EAGAIN (see errno.h). #ifndef WIN32 typedef unsigned int SOCKET; -#include +#include #define WSAGetLastError() errno #define WSAEINVAL EINVAL -#define WSAEALREADY EALREADY #define WSAEWOULDBLOCK EWOULDBLOCK #define WSAEAGAIN EAGAIN #define WSAEMSGSIZE EMSGSIZE #define WSAEINTR EINTR #define WSAEINPROGRESS EINPROGRESS #define WSAEADDRINUSE EADDRINUSE -#define WSAENOTSOCK EBADF #define INVALID_SOCKET (SOCKET)(~0) #define SOCKET_ERROR -1 #define SD_SEND SHUT_WR #else -#ifndef WSAEAGAIN +// WSAEAGAIN doesn't exist on Windows #ifdef EAGAIN #define WSAEAGAIN EAGAIN #else #define WSAEAGAIN WSAEWOULDBLOCK #endif #endif -#endif -#ifdef WIN32 -#ifndef S_IRUSR -#define S_IRUSR 0400 -#define S_IWUSR 0200 -#endif -#else +// Windows defines MAX_PATH as it's maximum path length. +// We define MAX_PATH for use on non-Windows systems. +#ifndef WIN32 #define MAX_PATH 1024 #endif + +// ssize_t is POSIX, and not present when using MSVC. #ifdef _MSC_VER -#if !defined(ssize_t) -#ifdef _WIN64 -typedef int64_t ssize_t; -#else -typedef int32_t ssize_t; -#endif -#endif +#include +typedef SSIZE_T ssize_t; #endif -#if HAVE_DECL_STRNLEN == 0 -size_t strnlen( const char *start, size_t max_len); -#endif // HAVE_DECL_STRNLEN - +// The type of the option value passed to getsockopt & setsockopt +// differs between Windows and non-Windows. #ifndef WIN32 typedef void* sockopt_arg_type; #else @@ -135,4 +127,4 @@ bool static inline IsSelectableSocket(const SOCKET& s) { #define MSG_DONTWAIT 0 #endif -#endif // BITCOIN_COMPAT_H +#endif // BITCOIN_COMPAT_COMPAT_H diff --git a/src/compat/strnlen.cpp b/src/compat/strnlen.cpp deleted file mode 100644 index 72b69953d0..0000000000 --- a/src/compat/strnlen.cpp +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) 2009-2014 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#if defined(HAVE_CONFIG_H) -#include -#endif - -#include - -#if HAVE_DECL_STRNLEN == 0 -size_t strnlen( const char *start, size_t max_len) -{ - const char *end = (const char *)memchr(start, '\0', max_len); - - return end ? (size_t)(end - start) : max_len; -} -#endif // HAVE_DECL_STRNLEN \ No newline at end of file diff --git a/src/fs.cpp b/src/fs.cpp index 7e216099ad..03afb11ba4 100644 --- a/src/fs.cpp +++ b/src/fs.cpp @@ -11,9 +11,6 @@ #include #include #else -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #include #include diff --git a/src/httpserver.cpp b/src/httpserver.cpp index 504f3cf642..b4b263eb50 100644 --- a/src/httpserver.cpp +++ b/src/httpserver.cpp @@ -10,7 +10,7 @@ #include #include -#include +#include #include // For HTTP status codes #include #include diff --git a/src/i2p.cpp b/src/i2p.cpp index 507bdeab55..8ecb50645f 100644 --- a/src/i2p.cpp +++ b/src/i2p.cpp @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include +#include #include #include #include diff --git a/src/i2p.h b/src/i2p.h index f9619de9c5..fc9256160b 100644 --- a/src/i2p.h +++ b/src/i2p.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_I2P_H #define BITCOIN_I2P_H -#include +#include #include #include #include diff --git a/src/index/base.cpp b/src/index/base.cpp index cae1cc75fd..9cc326b9e9 100644 --- a/src/index/base.cpp +++ b/src/index/base.cpp @@ -5,7 +5,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/init.cpp b/src/init.cpp index 147f845859..e85721ce74 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -1441,11 +1441,6 @@ bool AppInitLockDataDirectory() bool AppInitInterfaces(NodeContext& node) { node.chain = interfaces::MakeChain(node); - // Create client interfaces for wallets that are supposed to be loaded - // according to -wallet and -disablewallet options. This only constructs - // the interfaces, it doesn't load wallet data. Wallets actually get loaded - // when load() and start() interface methods are called below. - g_wallet_init_interface.Construct(node); return true; } @@ -1515,11 +1510,17 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info) GetMainSignals().RegisterBackgroundSignalScheduler(*node.scheduler); - tableRPC.InitPlatformRestrictions(); + // Create client interfaces for wallets that are supposed to be loaded + // according to -wallet and -disablewallet options. This only constructs + // the interfaces, it doesn't load wallet data. Wallets actually get loaded + // when load() and start() interface methods are called below. + g_wallet_init_interface.Construct(node); + uiInterface.InitWallet(); /* Register RPC commands regardless of -server setting so they will be * available in the GUI RPC console even if external calls are disabled. */ + tableRPC.InitPlatformRestrictions(); RegisterAllCoreRPCCommands(tableRPC); for (const auto& client : node.chain_clients) { client->registerRpcs(); diff --git a/src/init/common.cpp b/src/init/common.cpp index 2a83ae16b7..f775810a72 100644 --- a/src/init/common.cpp +++ b/src/init/common.cpp @@ -11,7 +11,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/interfaces/node.h b/src/interfaces/node.h index 0b9abd07b7..9950762afd 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -309,6 +309,10 @@ public: using ShowProgressFn = std::function; virtual std::unique_ptr handleShowProgress(ShowProgressFn fn) = 0; + //! Register handler for wallet client constructed messages. + using InitWalletFn = std::function; + virtual std::unique_ptr handleInitWallet(InitWalletFn fn) = 0; + //! Register handler for number of connections changed messages. using NotifyNumConnectionsChangedFn = std::function; virtual std::unique_ptr handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) = 0; diff --git a/src/llmq/chainlocks.cpp b/src/llmq/chainlocks.cpp index 1ef7d22b91..1b6f56f5c8 100644 --- a/src/llmq/chainlocks.cpp +++ b/src/llmq/chainlocks.cpp @@ -12,7 +12,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/mapport.cpp b/src/mapport.cpp index ecdbcdff12..5a38353070 100644 --- a/src/mapport.cpp +++ b/src/mapport.cpp @@ -18,7 +18,7 @@ #include #ifdef USE_NATPMP -#include +#include #include #endif // USE_NATPMP diff --git a/src/masternode/sync.cpp b/src/masternode/sync.cpp index dc8cc60f76..09d89d9f0e 100644 --- a/src/masternode/sync.cpp +++ b/src/masternode/sync.cpp @@ -8,11 +8,11 @@ #include #include #include -#include +#include #include -#include #include #include +#include class CMasternodeSync; diff --git a/src/net.cpp b/src/net.cpp index db234f4876..9bfb813178 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/net.h b/src/net.h index 446e687048..524f0a244b 100644 --- a/src/net.h +++ b/src/net.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/netaddress.h b/src/netaddress.h index 102de00225..4d53ed9694 100644 --- a/src/netaddress.h +++ b/src/netaddress.h @@ -10,7 +10,7 @@ #endif #include -#include +#include #include #include #include diff --git a/src/netbase.cpp b/src/netbase.cpp index cf1ba19e65..adaf3fa629 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -5,7 +5,7 @@ #include -#include +#include #include #include #include diff --git a/src/netbase.h b/src/netbase.h index 9478555d59..51233967b3 100644 --- a/src/netbase.h +++ b/src/netbase.h @@ -9,7 +9,7 @@ #include #endif -#include +#include #include #include #include diff --git a/src/node/ui_interface.cpp b/src/node/interface_ui.cpp similarity index 95% rename from src/node/ui_interface.cpp rename to src/node/interface_ui.cpp index b87ae85ee7..b01d20bb3e 100644 --- a/src/node/ui_interface.cpp +++ b/src/node/interface_ui.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include @@ -15,6 +15,7 @@ struct UISignals { boost::signals2::signal> ThreadSafeMessageBox; boost::signals2::signal> ThreadSafeQuestion; boost::signals2::signal InitMessage; + boost::signals2::signal InitWallet; boost::signals2::signal NotifyNumConnectionsChanged; boost::signals2::signal NotifyNetworkActiveChanged; boost::signals2::signal NotifyAlertChanged; @@ -37,6 +38,7 @@ static UISignals g_ui_signals; ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeMessageBox); ADD_SIGNALS_IMPL_WRAPPER(ThreadSafeQuestion); ADD_SIGNALS_IMPL_WRAPPER(InitMessage); +ADD_SIGNALS_IMPL_WRAPPER(InitWallet); ADD_SIGNALS_IMPL_WRAPPER(NotifyNumConnectionsChanged); ADD_SIGNALS_IMPL_WRAPPER(NotifyNetworkActiveChanged); ADD_SIGNALS_IMPL_WRAPPER(NotifyAlertChanged); @@ -51,6 +53,7 @@ ADD_SIGNALS_IMPL_WRAPPER(BannedListChanged); bool CClientUIInterface::ThreadSafeMessageBox(const bilingual_str& message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeMessageBox(message, caption, style).value_or(false);} bool CClientUIInterface::ThreadSafeQuestion(const bilingual_str& message, const std::string& non_interactive_message, const std::string& caption, unsigned int style) { return g_ui_signals.ThreadSafeQuestion(message, non_interactive_message, caption, style).value_or(false);} void CClientUIInterface::InitMessage(const std::string& message) { return g_ui_signals.InitMessage(message); } +void CClientUIInterface::InitWallet() { return g_ui_signals.InitWallet(); } void CClientUIInterface::NotifyNumConnectionsChanged(int newNumConnections) { return g_ui_signals.NotifyNumConnectionsChanged(newNumConnections); } void CClientUIInterface::NotifyNetworkActiveChanged(bool networkActive) { return g_ui_signals.NotifyNetworkActiveChanged(networkActive); } void CClientUIInterface::NotifyAlertChanged() { return g_ui_signals.NotifyAlertChanged(); } diff --git a/src/node/ui_interface.h b/src/node/interface_ui.h similarity index 96% rename from src/node/ui_interface.h rename to src/node/interface_ui.h index a3934341be..3f8b683de2 100644 --- a/src/node/ui_interface.h +++ b/src/node/interface_ui.h @@ -3,8 +3,8 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#ifndef BITCOIN_NODE_UI_INTERFACE_H -#define BITCOIN_NODE_UI_INTERFACE_H +#ifndef BITCOIN_NODE_INTERFACE_UI_H +#define BITCOIN_NODE_INTERFACE_UI_H #include #include @@ -83,6 +83,9 @@ public: /** Progress message during initialization. */ ADD_SIGNALS_DECL_WRAPPER(InitMessage, void, const std::string& message); + /** Wallet client created. */ + ADD_SIGNALS_DECL_WRAPPER(InitWallet, void, ); + /** Number of network connections changed. */ ADD_SIGNALS_DECL_WRAPPER(NotifyNumConnectionsChanged, void, int newNumConnections); @@ -128,4 +131,4 @@ constexpr auto AbortError = InitError; extern CClientUIInterface uiInterface; -#endif // BITCOIN_NODE_UI_INTERFACE_H +#endif // BITCOIN_NODE_INTERFACE_UI_H diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index ea4bce94d6..90a4c51d7e 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -527,6 +527,10 @@ public: { return MakeHandler(::uiInterface.ShowProgress_connect(fn)); } + std::unique_ptr handleInitWallet(InitWalletFn fn) override + { + return MakeHandler(::uiInterface.InitWallet_connect(fn)); + } std::unique_ptr handleNotifyNumConnectionsChanged(NotifyNumConnectionsChangedFn fn) override { return MakeHandler(::uiInterface.NotifyNumConnectionsChanged_connect(fn)); diff --git a/src/noui.cpp b/src/noui.cpp index 57bbe39c90..11bfdbc80b 100644 --- a/src/noui.cpp +++ b/src/noui.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include diff --git a/src/qt/bitcoin.cpp b/src/qt/bitcoin.cpp index debab9e2a2..79a1db9002 100644 --- a/src/qt/bitcoin.cpp +++ b/src/qt/bitcoin.cpp @@ -16,7 +16,7 @@ #include #include #include -#include +#include #include #include #include @@ -262,7 +262,6 @@ void BitcoinApplication::createSplashScreen(const NetworkStyle *networkStyle) // We don't hold a direct pointer to the splash screen after creation, but the splash // screen will take care of deleting itself when finish() happens. m_splash->show(); - connect(this, &BitcoinApplication::requestedInitialize, m_splash, &SplashScreen::handleLoadWallet); connect(this, &BitcoinApplication::splashFinished, m_splash, &SplashScreen::finish); connect(this, &BitcoinApplication::requestedShutdown, m_splash, &QWidget::close); } diff --git a/src/qt/bitcoingui.cpp b/src/qt/bitcoingui.cpp index 734360d53f..4e2d32b031 100644 --- a/src/qt/bitcoingui.cpp +++ b/src/qt/bitcoingui.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/qt/guiutil.cpp b/src/qt/guiutil.cpp index 84afe40bba..2574adee48 100644 --- a/src/qt/guiutil.cpp +++ b/src/qt/guiutil.cpp @@ -29,9 +29,6 @@ #include #ifdef WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #include #include diff --git a/src/qt/main.cpp b/src/qt/main.cpp index a1220b9a59..eca9e9d88f 100644 --- a/src/qt/main.cpp +++ b/src/qt/main.cpp @@ -4,7 +4,7 @@ #include -#include +#include #include #include diff --git a/src/qt/paymentserver.cpp b/src/qt/paymentserver.cpp index 72553e81bb..2eb28aca35 100644 --- a/src/qt/paymentserver.cpp +++ b/src/qt/paymentserver.cpp @@ -17,7 +17,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/qt/sendcoinsdialog.cpp b/src/qt/sendcoinsdialog.cpp index 1319d1d836..5012e9342c 100644 --- a/src/qt/sendcoinsdialog.cpp +++ b/src/qt/sendcoinsdialog.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/qt/splashscreen.cpp b/src/qt/splashscreen.cpp index 005c3bcdb4..56bb8c2f89 100644 --- a/src/qt/splashscreen.cpp +++ b/src/qt/splashscreen.cpp @@ -199,6 +199,7 @@ void SplashScreen::subscribeToCoreSignals() // Connect signals to client m_handler_init_message = m_node->handleInitMessage(std::bind(InitMessage, this, std::placeholders::_1)); m_handler_show_progress = m_node->handleShowProgress(std::bind(ShowProgress, this, std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); + m_handler_init_wallet = m_node->handleInitWallet([this]() { handleLoadWallet(); }); } void SplashScreen::handleLoadWallet() diff --git a/src/qt/splashscreen.h b/src/qt/splashscreen.h index bcb5f99b36..7c38490793 100644 --- a/src/qt/splashscreen.h +++ b/src/qt/splashscreen.h @@ -66,6 +66,7 @@ private: bool m_shutdown = false; std::unique_ptr m_handler_init_message; std::unique_ptr m_handler_show_progress; + std::unique_ptr m_handler_init_wallet; std::unique_ptr m_handler_load_wallet; std::list> m_connected_wallets; std::list> m_connected_wallet_handlers; diff --git a/src/qt/transactionview.cpp b/src/qt/transactionview.cpp index 55760147c5..8102c53de6 100644 --- a/src/qt/transactionview.cpp +++ b/src/qt/transactionview.cpp @@ -18,7 +18,7 @@ #include #include -#include +#include #include diff --git a/src/qt/walletframe.cpp b/src/qt/walletframe.cpp index d97b1d7553..9e177c673e 100644 --- a/src/qt/walletframe.cpp +++ b/src/qt/walletframe.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index f0ed7ef0fe..d4a88de83b 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -22,7 +22,7 @@ #include #include #include -#include +#include #include #include // for GetBoolArg #include diff --git a/src/qt/walletview.cpp b/src/qt/walletview.cpp index 1a99436660..390df73576 100644 --- a/src/qt/walletview.cpp +++ b/src/qt/walletview.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include diff --git a/src/random.cpp b/src/random.cpp index 7d3b20bd65..e98b068d3c 100644 --- a/src/random.cpp +++ b/src/random.cpp @@ -9,24 +9,23 @@ #include #include #include -#include -#ifdef WIN32 -#include // for Windows API -#include -#endif #include #include -#include #include -#include // for Mutex -#include // for GetTimeMicros() +#include +#include +#include +#include #include #include #include #include -#ifndef WIN32 +#ifdef WIN32 +#include +#include +#else #include #endif @@ -729,7 +728,7 @@ bool Random_SanityCheck() * GetOSRand() overwrites all 32 bytes of the output given a maximum * number of tries. */ - static const ssize_t MAX_TRIES = 1024; + static constexpr int MAX_TRIES{1024}; uint8_t data[NUM_OS_RANDOM_BYTES]; bool overwritten[NUM_OS_RANDOM_BYTES] = {}; /* Tracks which bytes have been overwritten at least once */ int num_overwritten; diff --git a/src/randomenv.cpp b/src/randomenv.cpp index 06ac6d8f93..4cfe94acac 100644 --- a/src/randomenv.cpp +++ b/src/randomenv.cpp @@ -14,22 +14,23 @@ #include #include #include -#include // for GetTime() -#ifdef WIN32 -#include // for Windows API -#endif +#include #include #include +#include +#include #include #include #include #include -#include -#include -#ifndef WIN32 #include // must go before a number of other headers + +#ifdef WIN32 +#include +#include +#else #include #include #include diff --git a/src/shutdown.cpp b/src/shutdown.cpp index f500fa529e..fe88b3aa46 100644 --- a/src/shutdown.cpp +++ b/src/shutdown.cpp @@ -12,7 +12,7 @@ #include #include -#include +#include #include #include diff --git a/src/stats/rawsender.h b/src/stats/rawsender.h index d91f6c0def..fc0b0d6795 100644 --- a/src/stats/rawsender.h +++ b/src/stats/rawsender.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_STATS_RAWSENDER_H #define BITCOIN_STATS_RAWSENDER_H -#include +#include #include #include diff --git a/src/support/lockedpool.cpp b/src/support/lockedpool.cpp index 14ad4782d7..766e817a8a 100644 --- a/src/support/lockedpool.cpp +++ b/src/support/lockedpool.cpp @@ -10,9 +10,6 @@ #endif #ifdef WIN32 -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #else #include // for mmap diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index 43864a5453..ebf741651b 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/test/fuzz/util/net.cpp b/src/test/fuzz/util/net.cpp index a1494f8d3b..f8e996cfa5 100644 --- a/src/test/fuzz/util/net.cpp +++ b/src/test/fuzz/util/net.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include #include diff --git a/src/test/net_peer_connection_tests.cpp b/src/test/net_peer_connection_tests.cpp index 2a09791daf..c232baa93d 100644 --- a/src/test/net_peer_connection_tests.cpp +++ b/src/test/net_peer_connection_tests.cpp @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#include +#include #include #include #include diff --git a/src/test/net_tests.cpp b/src/test/net_tests.cpp index 02a958185f..1ff098cd1f 100644 --- a/src/test/net_tests.cpp +++ b/src/test/net_tests.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/test/sock_tests.cpp b/src/test/sock_tests.cpp index 9e98f4f0b1..fa95fc0ba5 100644 --- a/src/test/sock_tests.cpp +++ b/src/test/sock_tests.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include #include diff --git a/src/test/util/net.h b/src/test/util/net.h index 4c2be00e49..7ca37616e5 100644 --- a/src/test/util/net.h +++ b/src/test/util/net.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_TEST_UTIL_NET_H #define BITCOIN_TEST_UTIL_NET_H -#include +#include #include #include #include diff --git a/src/test/util_tests.cpp b/src/test/util_tests.cpp index 1a53f5cb16..fbdb851ae1 100644 --- a/src/test/util_tests.cpp +++ b/src/test/util_tests.cpp @@ -37,9 +37,11 @@ #include #include #include + +#include + #ifndef WIN32 #include -#include #include #endif diff --git a/src/timedata.cpp b/src/timedata.cpp index a0b8c33e7a..54378a5cf1 100644 --- a/src/timedata.cpp +++ b/src/timedata.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/torcontrol.cpp b/src/torcontrol.cpp index 26154a9939..a89099ecfd 100644 --- a/src/torcontrol.cpp +++ b/src/torcontrol.cpp @@ -7,7 +7,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/txdb.cpp b/src/txdb.cpp index 23e2480c4c..f780b56b44 100644 --- a/src/txdb.cpp +++ b/src/txdb.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include #include #include diff --git a/src/util/edge.h b/src/util/edge.h index 8e3ec357a1..7ac354c8bf 100644 --- a/src/util/edge.h +++ b/src/util/edge.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_UTIL_EDGE_H #define BITCOIN_UTIL_EDGE_H -#include +#include #include #include diff --git a/src/util/sock.cpp b/src/util/sock.cpp index 1d12669652..87e63b70c3 100644 --- a/src/util/sock.cpp +++ b/src/util/sock.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include #include diff --git a/src/util/sock.h b/src/util/sock.h index 4c18e71e0c..4d32d50e5e 100644 --- a/src/util/sock.h +++ b/src/util/sock.h @@ -5,7 +5,7 @@ #ifndef BITCOIN_UTIL_SOCK_H #define BITCOIN_UTIL_SOCK_H -#include +#include #include #include diff --git a/src/util/system.cpp b/src/util/system.cpp index 84d633db09..563a7bf4b0 100644 --- a/src/util/system.cpp +++ b/src/util/system.cpp @@ -60,9 +60,6 @@ #pragma warning(disable:4717) #endif -#ifndef NOMINMAX -#define NOMINMAX -#endif #include #include /* for _commit */ diff --git a/src/util/system.h b/src/util/system.h index 5779beb065..2983107c22 100644 --- a/src/util/system.h +++ b/src/util/system.h @@ -16,8 +16,8 @@ #endif #include -#include #include +#include #include #include #include diff --git a/src/util/time.cpp b/src/util/time.cpp index 2b9a469d9a..80f6891328 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -7,7 +7,7 @@ #include #endif -#include +#include #include #include diff --git a/src/util/time.h b/src/util/time.h index 306a1ae3f2..32bdebb205 100644 --- a/src/util/time.h +++ b/src/util/time.h @@ -6,7 +6,7 @@ #ifndef BITCOIN_UTIL_TIME_H #define BITCOIN_UTIL_TIME_H -#include +#include #include #include diff --git a/src/validation.cpp b/src/validation.cpp index 5f093aa1b2..d1681a265b 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/wallet/bdb.cpp b/src/wallet/bdb.cpp index 1509f9c177..ef6947a25f 100644 --- a/src/wallet/bdb.cpp +++ b/src/wallet/bdb.cpp @@ -3,6 +3,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. +#include #include #include #include @@ -12,8 +13,15 @@ #include -#ifndef WIN32 #include + +// Windows may not define S_IRUSR or S_IWUSR. We define both +// here, with the same values as glibc (see stat.h). +#ifdef WIN32 +#ifndef S_IRUSR +#define S_IRUSR 0400 +#define S_IWUSR 0200 +#endif #endif namespace { diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 15b3306f82..8f7a416939 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -9,7 +9,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/test/functional/test_framework/authproxy.py b/test/functional/test_framework/authproxy.py index da9f6f2979..5673f47826 100644 --- a/test/functional/test_framework/authproxy.py +++ b/test/functional/test_framework/authproxy.py @@ -39,7 +39,6 @@ from http import HTTPStatus import http.client import json import logging -import os import socket import time import urllib.parse @@ -101,11 +100,6 @@ class AuthServiceProxy(): 'User-Agent': USER_AGENT, 'Authorization': self.__auth_header, 'Content-type': 'application/json'} - if os.name == 'nt': - # Windows somehow does not like to re-use connections - # TODO: Find out why the connection would disconnect occasionally and make it reusable on Windows - # Avoid "ConnectionAbortedError: [WinError 10053] An established connection was aborted by the software in your host machine" - self._set_conn() try: self.__conn.request(method, path, postdata, headers) return self._get_response() @@ -116,10 +110,8 @@ class AuthServiceProxy(): self.__conn.request(method, path, postdata, headers) return self._get_response() except OSError as e: - retry = ( - '[WinError 10053] An established connection was aborted by the software in your host machine' in str(e)) # Workaround for a bug on macOS. See https://bugs.python.org/issue33450 - retry = retry or ('[Errno 41] Protocol wrong type for socket' in str(e)) + retry = '[Errno 41] Protocol wrong type for socket' in str(e) if retry: self.__conn.close() self.__conn.request(method, path, postdata, headers)