Auto merge of #2764 - syd0:remove-old-boost-defines, r=str4d
Remove Boost conditional compilation. Boost is currently at version 106200 in the depends subsystem so it is safe to remove code the refers to earlier versions. This closes #2445
This commit is contained in:
commit
213ac8d1fe
76
configure.ac
76
configure.ac
|
@ -554,33 +554,14 @@ fi
|
||||||
if test x$use_boost = xyes; then
|
if test x$use_boost = xyes; then
|
||||||
|
|
||||||
dnl Check for boost libs
|
dnl Check for boost libs
|
||||||
AX_BOOST_BASE
|
dnl We need Boost >= 1.62 to fix a potential security bug (https://github.com/zcash/zcash/issues/1241)
|
||||||
|
AX_BOOST_BASE([1.62])
|
||||||
AX_BOOST_SYSTEM
|
AX_BOOST_SYSTEM
|
||||||
AX_BOOST_FILESYSTEM
|
AX_BOOST_FILESYSTEM
|
||||||
AX_BOOST_PROGRAM_OPTIONS
|
AX_BOOST_PROGRAM_OPTIONS
|
||||||
AX_BOOST_THREAD
|
AX_BOOST_THREAD
|
||||||
AX_BOOST_CHRONO
|
AX_BOOST_CHRONO
|
||||||
|
|
||||||
|
|
||||||
if test x$use_reduce_exports = xyes; then
|
|
||||||
AC_MSG_CHECKING([for working boost reduced exports])
|
|
||||||
TEMP_CPPFLAGS="$CPPFLAGS"
|
|
||||||
CPPFLAGS="$BOOST_CPPFLAGS $CPPFLAGS"
|
|
||||||
AC_PREPROC_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
@%:@include <boost/version.hpp>
|
|
||||||
]], [[
|
|
||||||
#if BOOST_VERSION >= 104900
|
|
||||||
// Everything is okay
|
|
||||||
#else
|
|
||||||
# error Boost version is too old
|
|
||||||
#endif
|
|
||||||
]])],[
|
|
||||||
AC_MSG_RESULT(yes)
|
|
||||||
],[
|
|
||||||
AC_MSG_ERROR([boost versions < 1.49 are known to be broken with reduced exports. Use --disable-reduce-exports.])
|
|
||||||
])
|
|
||||||
CPPFLAGS="$TEMP_CPPFLAGS"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$use_reduce_exports = xyes; then
|
if test x$use_reduce_exports = xyes; then
|
||||||
|
@ -621,60 +602,7 @@ if test x$use_tests = xyes; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$use_boost = xyes; then
|
if test x$use_boost = xyes; then
|
||||||
|
|
||||||
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
|
BOOST_LIBS="$BOOST_LDFLAGS $BOOST_SYSTEM_LIB $BOOST_FILESYSTEM_LIB $BOOST_PROGRAM_OPTIONS_LIB $BOOST_THREAD_LIB $BOOST_CHRONO_LIB"
|
||||||
|
|
||||||
dnl Boost >= 1.50 uses sleep_for rather than the now-deprecated sleep, however
|
|
||||||
dnl it was broken from 1.50 to 1.52 when backed by nanosleep. Use sleep_for if
|
|
||||||
dnl a working version is available, else fall back to sleep. sleep was removed
|
|
||||||
dnl after 1.56.
|
|
||||||
dnl If neither is available, abort.
|
|
||||||
TEMP_LIBS="$LIBS"
|
|
||||||
LIBS="$BOOST_LIBS $LIBS"
|
|
||||||
TEMP_CPPFLAGS="$CPPFLAGS"
|
|
||||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <boost/thread/thread.hpp>
|
|
||||||
#include <boost/version.hpp>
|
|
||||||
]],[[
|
|
||||||
#if BOOST_VERSION >= 105000 && (!defined(BOOST_HAS_NANOSLEEP) || BOOST_VERSION >= 105200)
|
|
||||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(0));
|
|
||||||
#else
|
|
||||||
choke me
|
|
||||||
#endif
|
|
||||||
]])],
|
|
||||||
[boost_sleep=yes;
|
|
||||||
AC_DEFINE(HAVE_WORKING_BOOST_SLEEP_FOR, 1, [Define this symbol if boost sleep_for works])],
|
|
||||||
[boost_sleep=no])
|
|
||||||
LIBS="$TEMP_LIBS"
|
|
||||||
CPPFLAGS="$TEMP_CPPFLAGS"
|
|
||||||
|
|
||||||
if test x$boost_sleep != xyes; then
|
|
||||||
TEMP_LIBS="$LIBS"
|
|
||||||
LIBS="$BOOST_LIBS $LIBS"
|
|
||||||
TEMP_CPPFLAGS="$CPPFLAGS"
|
|
||||||
CPPFLAGS="$CPPFLAGS $BOOST_CPPFLAGS"
|
|
||||||
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
|
|
||||||
#include <boost/version.hpp>
|
|
||||||
#include <boost/thread.hpp>
|
|
||||||
#include <boost/date_time/posix_time/posix_time_types.hpp>
|
|
||||||
]],[[
|
|
||||||
#if BOOST_VERSION <= 105600
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(0));
|
|
||||||
#else
|
|
||||||
choke me
|
|
||||||
#endif
|
|
||||||
]])],
|
|
||||||
[boost_sleep=yes; AC_DEFINE(HAVE_WORKING_BOOST_SLEEP, 1, [Define this symbol if boost sleep works])],
|
|
||||||
[boost_sleep=no])
|
|
||||||
LIBS="$TEMP_LIBS"
|
|
||||||
CPPFLAGS="$TEMP_CPPFLAGS"
|
|
||||||
fi
|
|
||||||
|
|
||||||
if test x$boost_sleep != xyes; then
|
|
||||||
AC_MSG_ERROR(No working boost sleep implementation found.)
|
|
||||||
fi
|
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test x$use_pkgconfig = xyes; then
|
if test x$use_pkgconfig = xyes; then
|
||||||
|
|
|
@ -20,13 +20,6 @@ CScheduler::~CScheduler()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#if BOOST_VERSION < 105000
|
|
||||||
static boost::system_time toPosixTime(const boost::chrono::system_clock::time_point& t)
|
|
||||||
{
|
|
||||||
return boost::posix_time::from_time_t(boost::chrono::system_clock::to_time_t(t));
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
void CScheduler::serviceQueue()
|
void CScheduler::serviceQueue()
|
||||||
{
|
{
|
||||||
boost::unique_lock<boost::mutex> lock(newTaskMutex);
|
boost::unique_lock<boost::mutex> lock(newTaskMutex);
|
||||||
|
@ -45,20 +38,13 @@ void CScheduler::serviceQueue()
|
||||||
// Wait until either there is a new task, or until
|
// Wait until either there is a new task, or until
|
||||||
// the time of the first item on the queue:
|
// the time of the first item on the queue:
|
||||||
|
|
||||||
// wait_until needs boost 1.50 or later; older versions have timed_wait:
|
|
||||||
#if BOOST_VERSION < 105000
|
|
||||||
while (!shouldStop() && !taskQueue.empty() &&
|
|
||||||
newTaskScheduled.timed_wait(lock, toPosixTime(taskQueue.begin()->first))) {
|
|
||||||
// Keep waiting until timeout
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
// Some boost versions have a conflicting overload of wait_until that returns void.
|
// Some boost versions have a conflicting overload of wait_until that returns void.
|
||||||
// Explicitly use a template here to avoid hitting that overload.
|
// Explicitly use a template here to avoid hitting that overload.
|
||||||
while (!shouldStop() && !taskQueue.empty() &&
|
while (!shouldStop() && !taskQueue.empty() &&
|
||||||
newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) {
|
newTaskScheduled.wait_until<>(lock, taskQueue.begin()->first) != boost::cv_status::timeout) {
|
||||||
// Keep waiting until timeout
|
// Keep waiting until timeout
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
// If there are multiple threads, the queue can empty while we're waiting (another
|
// If there are multiple threads, the queue can empty while we're waiting (another
|
||||||
// thread may service the task we were waiting on).
|
// thread may service the task we were waiting on).
|
||||||
if (shouldStop() || taskQueue.empty())
|
if (shouldStop() || taskQueue.empty())
|
||||||
|
|
|
@ -30,14 +30,7 @@ static void microTask(CScheduler& s, boost::mutex& mutex, int& counter, int delt
|
||||||
|
|
||||||
static void MicroSleep(uint64_t n)
|
static void MicroSleep(uint64_t n)
|
||||||
{
|
{
|
||||||
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
|
|
||||||
boost::this_thread::sleep_for(boost::chrono::microseconds(n));
|
boost::this_thread::sleep_for(boost::chrono::microseconds(n));
|
||||||
#elif defined(HAVE_WORKING_BOOST_SLEEP)
|
|
||||||
boost::this_thread::sleep(boost::posix_time::microseconds(n));
|
|
||||||
#else
|
|
||||||
//should never get here
|
|
||||||
#error missing boost sleep implementation
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_CASE(manythreads)
|
BOOST_AUTO_TEST_CASE(manythreads)
|
||||||
|
|
|
@ -911,10 +911,6 @@ std::string LicenseInfo()
|
||||||
|
|
||||||
int GetNumCores()
|
int GetNumCores()
|
||||||
{
|
{
|
||||||
#if BOOST_VERSION >= 105600
|
|
||||||
return boost::thread::physical_concurrency();
|
return boost::thread::physical_concurrency();
|
||||||
#else // Must fall back to hardware_concurrency, which unfortunately counts virtual cores
|
|
||||||
return boost::thread::hardware_concurrency();
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,20 +43,7 @@ int64_t GetTimeMicros()
|
||||||
|
|
||||||
void MilliSleep(int64_t n)
|
void MilliSleep(int64_t n)
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* Boost's sleep_for was uninterruptable when backed by nanosleep from 1.50
|
|
||||||
* until fixed in 1.52. Use the deprecated sleep method for the broken case.
|
|
||||||
* See: https://svn.boost.org/trac/boost/ticket/7238
|
|
||||||
*/
|
|
||||||
#if defined(HAVE_WORKING_BOOST_SLEEP_FOR)
|
|
||||||
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
|
boost::this_thread::sleep_for(boost::chrono::milliseconds(n));
|
||||||
#elif defined(HAVE_WORKING_BOOST_SLEEP)
|
|
||||||
boost::this_thread::sleep(boost::posix_time::milliseconds(n));
|
|
||||||
#else
|
|
||||||
//should never get here
|
|
||||||
#error missing boost sleep implementation
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
|
std::string DateTimeStrFormat(const char* pszFormat, int64_t nTime)
|
||||||
|
|
|
@ -968,11 +968,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
|
||||||
pathDest /= wallet.strWalletFile;
|
pathDest /= wallet.strWalletFile;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
#if BOOST_VERSION >= 104000
|
|
||||||
boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists);
|
boost::filesystem::copy_file(pathSrc, pathDest, boost::filesystem::copy_option::overwrite_if_exists);
|
||||||
#else
|
|
||||||
boost::filesystem::copy_file(pathSrc, pathDest);
|
|
||||||
#endif
|
|
||||||
LogPrintf("copied wallet.dat to %s\n", pathDest.string());
|
LogPrintf("copied wallet.dat to %s\n", pathDest.string());
|
||||||
return true;
|
return true;
|
||||||
} catch (const boost::filesystem::filesystem_error& e) {
|
} catch (const boost::filesystem::filesystem_error& e) {
|
||||||
|
|
Loading…
Reference in New Issue