Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 2 additions & 12 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -61,18 +61,8 @@ case $host in
;;
esac

AC_ARG_ENABLE([c++17],
[AS_HELP_STRING([--enable-c++17],
[enable compilation in c++17 mode (disabled by default)])],
[use_cxx17=$enableval],
[use_cxx17=no])

dnl Require C++14 or C++17 compiler (no GNU extensions)
if test "x$use_cxx17" = xyes; then
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])
else
AX_CXX_COMPILE_STDCXX([14], [noext], [mandatory])
fi
dnl Require C++17 compiler (no GNU extensions)
AX_CXX_COMPILE_STDCXX([17], [noext], [mandatory])

dnl Check if -latomic is required for <std::atomic>
CHECK_ATOMIC
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/bdb.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ $(package)_config_opts_mingw32=--enable-mingw
$(package)_config_opts_linux=--with-pic
$(package)_config_opts_android=--with-pic
$(package)_cflags+=-Wno-error=implicit-function-declaration
$(package)_cxxflags=-std=c++11
$(package)_cxxflags=-std=c++17
$(package)_cppflags_mingw32=-DUNICODE -D_UNICODE
endef

Expand Down
2 changes: 1 addition & 1 deletion depends/packages/boost.mk
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ else
$(package)_toolset_$(host_os)=gcc
endif
$(package)_config_libraries=chrono,filesystem,system,thread,test
$(package)_cxxflags=-std=c++11 -fvisibility=hidden
$(package)_cxxflags=-std=c++17 -fvisibility=hidden
$(package)_cxxflags_linux=-fPIC
endef

Expand Down
2 changes: 1 addition & 1 deletion depends/packages/protobuf.mk
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ $(package)_download_path=$(native_$(package)_download_path)
$(package)_file_name=$(native_$(package)_file_name)
$(package)_sha256_hash=$(native_$(package)_sha256_hash)
$(package)_dependencies=native_$(package)
$(package)_cxxflags=-std=c++11
$(package)_cxxflags=-std=c++17

define $(package)_set_vars
$(package)_config_opts=--disable-shared --with-protoc=$(build_prefix)/bin/protoc
Expand Down
4 changes: 2 additions & 2 deletions depends/packages/qt.mk
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ $(package)_extra_sources += $($(package)_qttools_file_name)

define $(package)_set_vars
$(package)_config_opts_release = -release
$(package)_config_opts_release += -silent
$(package)_config_opts_debug = -debug
$(package)_config_opts += -bindir $(build_prefix)/bin
$(package)_config_opts += -c++std c++11
$(package)_config_opts += -c++std c++1z
$(package)_config_opts += -confirm-license
$(package)_config_opts += -dbus-runtime
$(package)_config_opts += -hostprefix $(build_prefix)
Expand Down Expand Up @@ -72,7 +73,6 @@ $(package)_config_opts += -qt-pcre
$(package)_config_opts += -qt-harfbuzz
$(package)_config_opts += -system-zlib
$(package)_config_opts += -static
$(package)_config_opts += -silent
$(package)_config_opts += -v
$(package)_config_opts += -no-feature-dial
$(package)_config_opts += -no-feature-ftp
Expand Down
2 changes: 1 addition & 1 deletion depends/packages/zeromq.mk
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ define $(package)_set_vars
$(package)_config_opts += --without-libsodium --without-libgssapi_krb5 --without-pgm --without-norm --without-vmci
$(package)_config_opts += --disable-libunwind --disable-radix-tree --without-gcov
$(package)_config_opts_linux=--with-pic
$(package)_cxxflags=-std=c++11
$(package)_cxxflags=-std=c++17
endef

define $(package)_preprocess_cmds
Expand Down
12 changes: 8 additions & 4 deletions src/script/sigcache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@
#include <util/system.h>

#include <cuckoocache.h>
#include <boost/thread.hpp>

#include <algorithm>
#include <mutex>
#include <shared_mutex>
#include <vector>

namespace {
/**
Expand All @@ -27,7 +31,7 @@ class CSignatureCache
uint256 nonce;
typedef CuckooCache::cache<uint256, SignatureCacheHasher> map_type;
map_type setValid;
boost::shared_mutex cs_sigcache;
std::shared_mutex cs_sigcache;

public:
CSignatureCache()
Expand All @@ -44,13 +48,13 @@ class CSignatureCache
bool
Get(const uint256& entry, const bool erase)
{
boost::shared_lock<boost::shared_mutex> lock(cs_sigcache);
std::shared_lock<std::shared_mutex> lock(cs_sigcache);
return setValid.contains(entry, erase);
}

void Set(uint256& entry)
{
boost::unique_lock<boost::shared_mutex> lock(cs_sigcache);
std::unique_lock<std::shared_mutex> lock(cs_sigcache);
setValid.insert(entry);
}
uint32_t setup_bytes(size_t n)
Expand Down
31 changes: 11 additions & 20 deletions src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,38 +202,29 @@ bool ExtractDestinations(const CScript& scriptPubKey, txnouttype& typeRet, std::

namespace
{
class CScriptVisitor : public boost::static_visitor<bool>
class CScriptVisitor : public boost::static_visitor<CScript>
{
private:
CScript *script;
public:
explicit CScriptVisitor(CScript *scriptin) { script = scriptin; }

bool operator()(const CNoDestination &dest) const {
script->clear();
return false;
CScript operator()(const CNoDestination& dest) const
{
return CScript();
}

bool operator()(const CKeyID &keyID) const {
script->clear();
*script << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
return true;
CScript operator()(const CKeyID& keyID) const
{
return CScript() << OP_DUP << OP_HASH160 << ToByteVector(keyID) << OP_EQUALVERIFY << OP_CHECKSIG;
}

bool operator()(const CScriptID &scriptID) const {
script->clear();
*script << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
return true;
CScript operator()(const CScriptID& scriptID) const
{
return CScript() << OP_HASH160 << ToByteVector(scriptID) << OP_EQUAL;
}
};
} // namespace

CScript GetScriptForDestination(const CTxDestination& dest)
{
CScript script;

boost::apply_visitor(CScriptVisitor(&script), dest);
return script;
return boost::apply_visitor(CScriptVisitor(), dest);
}

CScript GetScriptForRawPubKey(const CPubKey& pubKey)
Expand Down
17 changes: 11 additions & 6 deletions src/test/cuckoocache_tests.cpp
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
// Copyright (c) 2012-2016 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <boost/test/unit_test.hpp>
#include <cuckoocache.h>
#include <script/sigcache.h>
#include <test/test_dash.h>
#include <random.h>
#include <thread>

#include <boost/test/unit_test.hpp>

#include <deque>
#include <mutex>
#include <shared_mutex>
#include <thread>
#include <vector>

/** Test Suite for CuckooCache
*
Expand Down Expand Up @@ -199,11 +204,11 @@ static void test_cache_erase_parallel(size_t megabytes)
* "future proofed".
*/
std::vector<uint256> hashes_insert_copy = hashes;
boost::shared_mutex mtx;
std::shared_mutex mtx;

{
/** Grab lock to make sure we release inserts */
boost::unique_lock<boost::shared_mutex> l(mtx);
std::unique_lock<std::shared_mutex> l(mtx);
/** Insert the first half */
for (uint32_t i = 0; i < (n_insert / 2); ++i)
set.insert(hashes_insert_copy[i]);
Expand All @@ -217,7 +222,7 @@ static void test_cache_erase_parallel(size_t megabytes)
/** Each thread is emplaced with x copy-by-value
*/
threads.emplace_back([&, x] {
boost::shared_lock<boost::shared_mutex> l(mtx);
std::shared_lock<std::shared_mutex> l(mtx);
size_t ntodo = (n_insert/4)/3;
size_t start = ntodo*x;
size_t end = ntodo*(x+1);
Expand All @@ -230,7 +235,7 @@ static void test_cache_erase_parallel(size_t megabytes)
for (std::thread& t : threads)
t.join();
/** Grab lock to make sure we observe erases */
boost::unique_lock<boost::shared_mutex> l(mtx);
std::unique_lock<std::shared_mutex> l(mtx);
/** Insert the second half */
for (uint32_t i = (n_insert / 2); i < n_insert; ++i)
set.insert(hashes_insert_copy[i]);
Expand Down
3 changes: 2 additions & 1 deletion src/util/memory.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
#include <utility>

//! Substitute for C++14 std::make_unique.
//! DEPRECATED use std::make_unique in new code.
template <typename T, typename... Args>
std::unique_ptr<T> MakeUnique(Args&&... args)
{
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
return std::make_unique<T>(std::forward<Args>(args)...);
}

#endif