Skip to content

Commit

Permalink
Merge #182: cmake: Port PR29774 from the master branch
Browse files Browse the repository at this point in the history
fc91bfe fixup! cmake: Add fuzzing options (Hennadii Stepanov)
5927338 fixup! cmake: Add platform-specific definitions and properties (Hennadii Stepanov)
dcf2e66 refactor: Make 64-bit shift explicit (Hennadii Stepanov)
a7edea8 refactor: Fix "error C2248: cannot access private member" on MSVC (Hennadii Stepanov)

Pull request description:

  This PR ports bitcoin#29774 after the recent sync/rebase [PR](#179).

  Also included changes from bitcoin#29983.

Top commit has no ACKs.

Tree-SHA512: 562919ec9b89401d193c6d59a8634f5086a1a063b6ee075c465c5dbc9bf59da4bb1eb7b826deac91f470e22fe9bf049b43b7106bdc66c5d26c715d68a1008f4d
  • Loading branch information
hebasto committed May 3, 2024
2 parents 6e4f2e0 + fc91bfe commit 30b681f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Expand Up @@ -135,7 +135,7 @@ endif()
option(BUILD_TESTS "Build test_bitcoin executable." ON)
cmake_dependent_option(BUILD_GUI_TESTS "Build test_bitcoin-qt executable." ON "BUILD_TESTS" OFF)
option(BUILD_BENCH "Build bench_bitcoin executable." ON)
cmake_dependent_option(BUILD_FUZZ_BINARY "Build fuzz binary." ON "NOT MSVC" OFF)
option(BUILD_FUZZ_BINARY "Build fuzz binary." ON)
cmake_dependent_option(FUZZ "Build for fuzzing. Enabling this will disable all other targets and override BUILD_FUZZ_BINARY." OFF "NOT MSVC" OFF)

option(INSTALL_MAN "Install man pages." ON)
Expand Down Expand Up @@ -234,6 +234,7 @@ if(WIN32)
)
target_compile_options(core_interface INTERFACE
/utf-8
/Zc:preprocessor
/Zc:__cplusplus
)
# Improve parallelism in MSBuild.
Expand Down
3 changes: 2 additions & 1 deletion src/test/fuzz/CMakeLists.txt
Expand Up @@ -56,7 +56,8 @@ add_executable(fuzz
locale.cpp
merkleblock.cpp
message.cpp
miniscript.cpp
# TODO: Fix the code and enable miniscript.cpp for MSVC.
$<$<NOT:$<CXX_COMPILER_ID:MSVC>>:miniscript.cpp>
minisketch.cpp
mini_miner.cpp
muhash.cpp
Expand Down
4 changes: 2 additions & 2 deletions src/test/fuzz/poolresource.cpp
Expand Up @@ -63,9 +63,9 @@ class PoolResourceFuzzer
{
if (m_total_allocated > 0x1000000) return;
size_t alignment_bits = m_provider.ConsumeIntegralInRange<size_t>(0, 7);
size_t alignment = 1 << alignment_bits;
size_t alignment = size_t{1} << alignment_bits;
size_t size_bits = m_provider.ConsumeIntegralInRange<size_t>(0, 16 - alignment_bits);
size_t size = m_provider.ConsumeIntegralInRange<size_t>(1U << size_bits, (1U << (size_bits + 1)) - 1U) << alignment_bits;
size_t size = m_provider.ConsumeIntegralInRange<size_t>(size_t{1} << size_bits, (size_t{1} << (size_bits + 1)) - 1U) << alignment_bits;
Allocate(size, alignment);
}

Expand Down
9 changes: 4 additions & 5 deletions src/util/bitdeque.h
Expand Up @@ -14,18 +14,17 @@

/** Class that mimics std::deque<bool>, but with std::vector<bool>'s bit packing.
*
* BlobSize selects the (minimum) number of bits that are allocated at once.
* BITS_PER_WORD selects the (minimum) number of bits that are allocated at once.
* Larger values reduce the asymptotic memory usage overhead, at the cost of
* needing larger up-front allocations. The default is 4096 bytes.
*/
template<int BlobSize = 4096 * 8>
template<int BITS_PER_WORD = 4096 * 8>
class bitdeque
{
// Internal definitions
using word_type = std::bitset<BlobSize>;
using word_type = std::bitset<BITS_PER_WORD>;
using deque_type = std::deque<word_type>;
static_assert(BlobSize > 0);
static constexpr int BITS_PER_WORD = BlobSize;
static_assert(BITS_PER_WORD > 0);

// Forward and friend declarations of iterator types.
template<bool Const> class Iterator;
Expand Down

0 comments on commit 30b681f

Please sign in to comment.