mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-05-17 23:56:39 +00:00
Merge #15146: Solve SmartOS FD_ZERO build issue
b4fd0ca9be14c81023db759c405c0f67cfa78166 Include cstring for sanity_test_fdelt if required (Ben Woosley) 7fb886b1b1110de4c79478ac094e64cdcb81f3c8 [moveonly] Split glibc sanity_test_fdelt out (Ben Woosley) Pull request description: SmartOS FD_ZERO is implemented in a way that requires an external declaration of memcpy. We can not simply include cstring in the existing file because sanity_test_memcpy is attempting to replace memcpy. Instead split glibc_sanity into fdelt and memcpy files, and include <cstring> in glibc_sanity/fdelt.cpp. Fixes #13581, see also #13619 ACKs for top commit: laanwj: Code review an lightly tested (but not on SmartOS) ACK b4fd0ca9be14c81023db759c405c0f67cfa78166 Tree-SHA512: 231306da291ad9eca8ba91bea1e9c27b6c2e96e484d1602e1c2cf27761202f9287ce0bc19fefd000943d2b449d0e5929cd39e2f7e09cf930d89fa520228ccbec
This commit is contained in:
commit
dd8cf82e96
33
configure.ac
33
configure.ac
@ -777,6 +777,39 @@ fi
|
|||||||
|
|
||||||
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
|
AC_CHECK_HEADERS([endian.h sys/endian.h byteswap.h stdio.h stdlib.h unistd.h strings.h sys/types.h sys/stat.h sys/select.h sys/prctl.h])
|
||||||
|
|
||||||
|
# FD_ZERO may be dependent on a declaration of memcpy, e.g. in SmartOS
|
||||||
|
# check that it fails to build without memcpy, then that it builds with
|
||||||
|
AC_MSG_CHECKING(FD_ZERO memcpy dependence)
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||||
|
#include <cstddef>
|
||||||
|
#if HAVE_SYS_SELECT_H
|
||||||
|
#include <sys/select.h>
|
||||||
|
#endif
|
||||||
|
]],[[
|
||||||
|
#if HAVE_SYS_SELECT_H
|
||||||
|
fd_set fds;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
#endif
|
||||||
|
]])],
|
||||||
|
[ AC_MSG_RESULT(no) ],
|
||||||
|
[
|
||||||
|
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
|
||||||
|
#include <cstring>
|
||||||
|
#if HAVE_SYS_SELECT_H
|
||||||
|
#include <sys/select.h>
|
||||||
|
#endif
|
||||||
|
]], [[
|
||||||
|
#if HAVE_SYS_SELECT_H
|
||||||
|
fd_set fds;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
#endif
|
||||||
|
]])],
|
||||||
|
[ AC_MSG_RESULT(yes); AC_DEFINE(HAVE_CSTRING_DEPENDENT_FD_ZERO, 1, [Define this symbol if FD_ZERO is dependent of a memcpy declaration being available]) ],
|
||||||
|
[ AC_MSG_ERROR(failed with cstring include) ]
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
AC_CHECK_DECLS([getifaddrs, freeifaddrs],,,
|
AC_CHECK_DECLS([getifaddrs, freeifaddrs],,,
|
||||||
[#include <sys/types.h>
|
[#include <sys/types.h>
|
||||||
#include <ifaddrs.h>]
|
#include <ifaddrs.h>]
|
||||||
|
@ -484,6 +484,7 @@ libbitcoin_util_a_SOURCES = \
|
|||||||
support/lockedpool.cpp \
|
support/lockedpool.cpp \
|
||||||
chainparamsbase.cpp \
|
chainparamsbase.cpp \
|
||||||
clientversion.cpp \
|
clientversion.cpp \
|
||||||
|
compat/glibc_sanity_fdelt.cpp \
|
||||||
compat/glibc_sanity.cpp \
|
compat/glibc_sanity.cpp \
|
||||||
compat/glibcxx_sanity.cpp \
|
compat/glibcxx_sanity.cpp \
|
||||||
compat/strnlen.cpp \
|
compat/strnlen.cpp \
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Copyright (c) 2009-2018 The Bitcoin Core developers
|
// Copyright (c) 2009-2019 The Bitcoin Core developers
|
||||||
// Distributed under the MIT software license, see the accompanying
|
// Distributed under the MIT software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
@ -9,7 +9,7 @@
|
|||||||
#include <cstddef>
|
#include <cstddef>
|
||||||
|
|
||||||
#if defined(HAVE_SYS_SELECT_H)
|
#if defined(HAVE_SYS_SELECT_H)
|
||||||
#include <sys/select.h>
|
bool sanity_test_fdelt();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
extern "C" void* memcpy(void* a, const void* b, size_t c);
|
extern "C" void* memcpy(void* a, const void* b, size_t c);
|
||||||
@ -41,21 +41,6 @@ bool sanity_test_memcpy()
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(HAVE_SYS_SELECT_H)
|
|
||||||
// trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined
|
|
||||||
// as >0 and optimizations must be set to at least -O2.
|
|
||||||
// test: Add a file descriptor to an empty fd_set. Verify that it has been
|
|
||||||
// correctly added.
|
|
||||||
bool sanity_test_fdelt()
|
|
||||||
{
|
|
||||||
fd_set fds;
|
|
||||||
FD_ZERO(&fds);
|
|
||||||
FD_SET(0, &fds);
|
|
||||||
return FD_ISSET(0, &fds);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
bool glibc_sanity_test()
|
bool glibc_sanity_test()
|
||||||
|
26
src/compat/glibc_sanity_fdelt.cpp
Normal file
26
src/compat/glibc_sanity_fdelt.cpp
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (c) 2009-2019 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 <config/bitcoin-config.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if defined(HAVE_SYS_SELECT_H)
|
||||||
|
#ifdef HAVE_CSTRING_DEPENDENT_FD_ZERO
|
||||||
|
#include <cstring>
|
||||||
|
#endif
|
||||||
|
#include <sys/select.h>
|
||||||
|
|
||||||
|
// trigger: Call FD_SET to trigger __fdelt_chk. FORTIFY_SOURCE must be defined
|
||||||
|
// as >0 and optimizations must be set to at least -O2.
|
||||||
|
// test: Add a file descriptor to an empty fd_set. Verify that it has been
|
||||||
|
// correctly added.
|
||||||
|
bool sanity_test_fdelt()
|
||||||
|
{
|
||||||
|
fd_set fds;
|
||||||
|
FD_ZERO(&fds);
|
||||||
|
FD_SET(0, &fds);
|
||||||
|
return FD_ISSET(0, &fds);
|
||||||
|
}
|
||||||
|
#endif
|
Loading…
x
Reference in New Issue
Block a user