diff --git a/Makefile.am b/Makefile.am
index ba22eb6817..6f107dc3ea 100755
--- a/Makefile.am
+++ b/Makefile.am
@@ -301,10 +301,6 @@ test_libbitcoin_system_test_SOURCES = \
test/hash/sha/sha256.cpp \
test/hash/sha/sha512.cpp \
test/hash/sha/vectorization.cpp \
- test/hash/sha/clone/algorithm.hpp \
- test/hash/sha/clone/algorithm.ipp \
- test/hash/sha/clone/algorithm_compression.ipp \
- test/hash/sha/clone/algorithm_vectorization.ipp \
test/intrinsics/haves.cpp \
test/intrinsics/intrinsics.cpp \
test/intrinsics/xcpu/cpuid.cpp \
@@ -343,9 +339,9 @@ test_libbitcoin_system_test_SOURCES = \
test/stream/devices/copy_source.cpp \
test/stream/devices/flip_sink.cpp \
test/stream/devices/push_sink.cpp \
- test/stream/simple/iostream.cpp \
- test/stream/simple/istream.cpp \
- test/stream/simple/ostream.cpp \
+ test/stream/iostream/iostream.cpp \
+ test/stream/iostream/istream.cpp \
+ test/stream/iostream/ostream.cpp \
test/stream/streamers/bit_flipper.cpp \
test/stream/streamers/bit_reader.cpp \
test/stream/streamers/bit_writer.cpp \
@@ -647,10 +643,11 @@ include_bitcoin_system_impl_streamdir = ${includedir}/bitcoin/system/impl/stream
include_bitcoin_system_impl_stream_HEADERS = \
include/bitcoin/system/impl/stream/device.ipp
-include_bitcoin_system_impl_stream_simpledir = ${includedir}/bitcoin/system/impl/stream/simple
-include_bitcoin_system_impl_stream_simple_HEADERS = \
- include/bitcoin/system/impl/stream/simple/istream.ipp \
- include/bitcoin/system/impl/stream/simple/ostream.ipp
+include_bitcoin_system_impl_stream_iostreamdir = ${includedir}/bitcoin/system/impl/stream/iostream
+include_bitcoin_system_impl_stream_iostream_HEADERS = \
+ include/bitcoin/system/impl/stream/iostream/iostream.ipp \
+ include/bitcoin/system/impl/stream/iostream/istream.ipp \
+ include/bitcoin/system/impl/stream/iostream/ostream.ipp
include_bitcoin_system_impl_stream_streamersdir = ${includedir}/bitcoin/system/impl/stream/streamers
include_bitcoin_system_impl_stream_streamers_HEADERS = \
@@ -741,6 +738,7 @@ include_bitcoin_system_streamdir = ${includedir}/bitcoin/system/stream
include_bitcoin_system_stream_HEADERS = \
include/bitcoin/system/stream/binary.hpp \
include/bitcoin/system/stream/device.hpp \
+ include/bitcoin/system/stream/iostream.hpp \
include/bitcoin/system/stream/make_stream.hpp \
include/bitcoin/system/stream/make_streamer.hpp \
include/bitcoin/system/stream/stream.hpp \
@@ -755,12 +753,6 @@ include_bitcoin_system_stream_devices_HEADERS = \
include/bitcoin/system/stream/devices/flip_sink.hpp \
include/bitcoin/system/stream/devices/push_sink.hpp
-include_bitcoin_system_stream_simpledir = ${includedir}/bitcoin/system/stream/simple
-include_bitcoin_system_stream_simple_HEADERS = \
- include/bitcoin/system/stream/simple/iostream.hpp \
- include/bitcoin/system/stream/simple/istream.hpp \
- include/bitcoin/system/stream/simple/ostream.hpp
-
include_bitcoin_system_stream_streamersdir = ${includedir}/bitcoin/system/stream/streamers
include_bitcoin_system_stream_streamers_HEADERS = \
include/bitcoin/system/stream/streamers/bit_flipper.hpp \
diff --git a/builds/cmake/CMakeLists.txt b/builds/cmake/CMakeLists.txt
index 9975fadc7b..5ef9672f14 100644
--- a/builds/cmake/CMakeLists.txt
+++ b/builds/cmake/CMakeLists.txt
@@ -775,10 +775,6 @@ if (with-tests)
"../../test/hash/sha/sha256.cpp"
"../../test/hash/sha/sha512.cpp"
"../../test/hash/sha/vectorization.cpp"
- "../../test/hash/sha/clone/algorithm.hpp"
- "../../test/hash/sha/clone/algorithm.ipp"
- "../../test/hash/sha/clone/algorithm_compression.ipp"
- "../../test/hash/sha/clone/algorithm_vectorization.ipp"
"../../test/intrinsics/haves.cpp"
"../../test/intrinsics/intrinsics.cpp"
"../../test/intrinsics/xcpu/cpuid.cpp"
@@ -817,9 +813,9 @@ if (with-tests)
"../../test/stream/devices/copy_source.cpp"
"../../test/stream/devices/flip_sink.cpp"
"../../test/stream/devices/push_sink.cpp"
- "../../test/stream/simple/iostream.cpp"
- "../../test/stream/simple/istream.cpp"
- "../../test/stream/simple/ostream.cpp"
+ "../../test/stream/iostream/iostream.cpp"
+ "../../test/stream/iostream/istream.cpp"
+ "../../test/stream/iostream/ostream.cpp"
"../../test/stream/streamers/bit_flipper.cpp"
"../../test/stream/streamers/bit_reader.cpp"
"../../test/stream/streamers/bit_writer.cpp"
diff --git a/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj b/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj
index d4870b6541..d1a77d673a 100644
--- a/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj
+++ b/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj
@@ -211,9 +211,9 @@
-
-
-
+
+
+
$(IntDir)test_stream_stream.obj
@@ -296,7 +296,6 @@
-
@@ -310,9 +309,6 @@
-
-
-
@@ -346,11 +342,6 @@
-
-
- "$(TargetPath)" --run_test=istream_tests --show_progress=no --build_info=yes
-
-
{39F60708-FF48-4C22-952D-43470866F684}
@@ -359,4 +350,4 @@
-
\ No newline at end of file
+
diff --git a/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj.filters
index ce8ee07768..0927a3985a 100644
--- a/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj.filters
+++ b/builds/msvc/vs2022/libbitcoin-system-test/libbitcoin-system-test.vcxproj.filters
@@ -46,14 +46,11 @@
{51A424A9-2C12-4211-0000-000000000005}
-
- {51A424A9-2C12-4211-0000-000000000007}
-
{51A424A9-2C12-4211-0000-000000000008}
- {51A424A9-2C12-4211-0000-000000000008}
+ {51A424A9-2C12-4211-0000-000000000007}
{51A424A9-2C12-4211-0000-000000000009}
@@ -71,37 +68,37 @@
{51A424A9-2C12-4211-0000-00000000000D}
- {51A424A9-2C12-4211-0000-000000000009}
+ {51A424A9-2C12-4211-0000-000000000008}
-
- {51A424A9-2C12-4211-0000-000000000010}
+
+ {51A424A9-2C12-4211-0000-000000000009}
- {51A424A9-2C12-4211-0000-0000000000A1}
+ {51A424A9-2C12-4211-0000-000000000010}
{51A424A9-2C12-4211-0000-00000000000E}
- {51A424A9-2C12-4211-0000-0000000000B1}
+ {51A424A9-2C12-4211-0000-0000000000A1}
{51A424A9-2C12-4211-0000-00000000000F}
- {51A424A9-2C12-4211-0000-0000000000C1}
+ {51A424A9-2C12-4211-0000-0000000000B1}
- {51A424A9-2C12-4211-0000-0000000000D1}
+ {51A424A9-2C12-4211-0000-0000000000C1}
- {51A424A9-2C12-4211-0000-0000000000E1}
+ {51A424A9-2C12-4211-0000-0000000000D1}
{51A424A9-2C12-4211-0000-000000000001}
- {51A424A9-2C12-4211-0000-0000000000F1}
+ {51A424A9-2C12-4211-0000-0000000000E1}
@@ -468,14 +465,14 @@
src\stream\devices
-
- src\stream\simple
+
+ src\stream\iostream
-
- src\stream\simple
+
+ src\stream\iostream
-
- src\stream\simple
+
+ src\stream\iostream
src\stream
@@ -671,9 +668,6 @@
src\hash\performance
-
- src\hash\sha\clone
-
src\hash
@@ -709,15 +703,6 @@
-
- src\hash\sha\clone
-
-
- src\hash\sha\clone
-
-
- src\hash\sha\clone
-
diff --git a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj
index 19af639a32..619323cece 100644
--- a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj
+++ b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj
@@ -407,11 +407,9 @@
+
-
-
-
@@ -559,8 +557,9 @@
-
-
+
+
+
diff --git a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters
index bfb5208f3c..8e504d94c8 100644
--- a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters
+++ b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters
@@ -82,7 +82,7 @@
{39F60708-FF48-4C22-0000-000000000010}
-
+
{39F60708-FF48-4C22-0000-0000000000C3}
@@ -124,41 +124,38 @@
{39F60708-FF48-4C22-0000-000000000005}
-
- {39F60708-FF48-4C22-0000-000000000006}
-
- {39F60708-FF48-4C22-0000-000000000007}
+ {39F60708-FF48-4C22-0000-000000000006}
- {39F60708-FF48-4C22-0000-000000000008}
+ {39F60708-FF48-4C22-0000-000000000007}
{39F60708-FF48-4C22-0000-000000000011}
- {39F60708-FF48-4C22-0000-000000000009}
+ {39F60708-FF48-4C22-0000-000000000008}
{39F60708-FF48-4C22-0000-0000000000A2}
- {39F60708-FF48-4C22-0000-000000000010}
+ {39F60708-FF48-4C22-0000-000000000009}
- {39F60708-FF48-4C22-0000-000000000011}
+ {39F60708-FF48-4C22-0000-000000000010}
- {39F60708-FF48-4C22-0000-000000000012}
+ {39F60708-FF48-4C22-0000-000000000011}
{39F60708-FF48-4C22-0000-0000000000B2}
- {39F60708-FF48-4C22-0000-000000000013}
+ {39F60708-FF48-4C22-0000-000000000012}
- {39F60708-FF48-4C22-0000-0000000000A4}
+ {39F60708-FF48-4C22-0000-000000000013}
{39F60708-FF48-4C22-0000-000000000000}
@@ -1100,21 +1097,15 @@
include\bitcoin\system\stream\devices
+
+ include\bitcoin\system\stream
+
include\bitcoin\system\stream
include\bitcoin\system\stream
-
- include\bitcoin\system\stream\simple
-
-
- include\bitcoin\system\stream\simple
-
-
- include\bitcoin\system\stream\simple
-
include\bitcoin\system\stream
@@ -1552,11 +1543,14 @@
include\bitcoin\system\impl\stream
-
- include\bitcoin\system\impl\stream\simple
+
+ include\bitcoin\system\impl\stream\iostream
+
+
+ include\bitcoin\system\impl\stream\iostream
-
- include\bitcoin\system\impl\stream\simple
+
+ include\bitcoin\system\impl\stream\iostream
include\bitcoin\system\impl\stream\streamers
diff --git a/include/bitcoin/system.hpp b/include/bitcoin/system.hpp
index ebc9b3020b..687f3f649b 100755
--- a/include/bitcoin/system.hpp
+++ b/include/bitcoin/system.hpp
@@ -177,6 +177,7 @@
#include
#include
#include
+#include
#include
#include
#include
@@ -187,9 +188,6 @@
#include
#include
#include
-#include
-#include
-#include
#include
#include
#include
diff --git a/include/bitcoin/system/hash/sha/algorithm.hpp b/include/bitcoin/system/hash/sha/algorithm.hpp
index e49b383b9b..bb04e495f8 100644
--- a/include/bitcoin/system/hash/sha/algorithm.hpp
+++ b/include/bitcoin/system/hash/sha/algorithm.hpp
@@ -269,10 +269,10 @@ class algorithm
const xstate_t& xstate) NOEXCEPT;
template = true>
- INLINE static void merkle_hash_v_(idigests_t& digests,
+ INLINE static void merkle_hash_invoke(idigests_t& digests,
iblocks_t& blocks) NOEXCEPT;
- INLINE static void merkle_hash_v(digests_t& digests) NOEXCEPT;
+ INLINE static void merkle_hash_dispatch(digests_t& digests) NOEXCEPT;
/// Message Schedule (block vectorization).
/// -----------------------------------------------------------------------
@@ -285,15 +285,17 @@ class algorithm
INLINE static Word extract(xWord a) NOEXCEPT;
template
- INLINE static void compress_v(state_t& state,
+ INLINE static void compress_dispatch(state_t& state,
const xbuffer_t& xbuffer) NOEXCEPT;
template = true>
- INLINE static void iterate_v_(state_t& state, iblocks_t& blocks) NOEXCEPT;
+ INLINE static void iterate_invoke(state_t& state, iblocks_t& blocks) NOEXCEPT;
template
- INLINE static void iterate_v(state_t& state, const ablocks_t& blocks) NOEXCEPT;
- INLINE static void iterate_v(state_t& state, iblocks_t& blocks) NOEXCEPT;
+ INLINE static void iterate_dispatch(state_t& state,
+ const ablocks_t& blocks) NOEXCEPT;
+ INLINE static void iterate_dispatch(state_t& state,
+ iblocks_t& blocks) NOEXCEPT;
/// Message Schedule (sigma vectorization).
/// -----------------------------------------------------------------------
@@ -303,17 +305,20 @@ class algorithm
auto x6, auto x7, auto x8) NOEXCEPT;
template
- INLINE static void prepare_v(buffer_t& buffer) NOEXCEPT;
- INLINE static void schedule_v(auto& buffer) NOEXCEPT;
+ INLINE static void prepare_dispatch(buffer_t& buffer) NOEXCEPT;
+ INLINE static void schedule_invoke(buffer_t& buffer) NOEXCEPT;
+ INLINE static void schedule_dispatch(auto& buffer) NOEXCEPT;
public:
static constexpr auto have_x128 = Vectorized && system::with_sse41;
static constexpr auto have_x256 = Vectorized && system::with_avx2;
static constexpr auto have_x512 = Vectorized && system::with_avx512;
- static constexpr auto min_lanes = (have_x128 ? 16 : (have_x256 ? 32 :
- (have_x128 ? 64 : 0))) / SHA::word_bytes;
- static constexpr auto vectorization = (have_x128 || have_x256 || have_x512) &&
- !(build_x32 && is_same_size);
+ static constexpr auto vectorization = (have_x128 || have_x256 || have_x512)
+ && !(build_x32 && is_same_size);
+ static constexpr auto min_lanes =
+ (have_x128 ? bytes<128> :
+ (have_x256 ? bytes<256> :
+ (have_x512 ? bytes<512> : 0))) / SHA::word_bytes;
};
} // namespace sha
diff --git a/include/bitcoin/system/impl/hash/sha/algorithm.ipp b/include/bitcoin/system/impl/hash/sha/algorithm.ipp
index 3673eb710a..3cd0429ed3 100644
--- a/include/bitcoin/system/impl/hash/sha/algorithm.ipp
+++ b/include/bitcoin/system/impl/hash/sha/algorithm.ipp
@@ -573,7 +573,7 @@ schedule(auto& buffer) NOEXCEPT
}
else if constexpr (vectorization)
{
- schedule_v(buffer);
+ schedule_dispatch(buffer);
}
else
{
@@ -1198,7 +1198,7 @@ iterate(state_t& state, const ablocks_t& blocks) NOEXCEPT
}
else if constexpr (vectorization)
{
- iterate_v(state, blocks);
+ iterate_dispatch(state, blocks);
}
else
{
@@ -1212,7 +1212,7 @@ iterate(state_t& state, iblocks_t& blocks) NOEXCEPT
{
if constexpr (vectorization)
{
- iterate_v(state, blocks);
+ iterate_dispatch(state, blocks);
}
else
{
@@ -1284,7 +1284,7 @@ merkle_hash(digests_t& digests) NOEXCEPT
}
else if constexpr (vectorization)
{
- merkle_hash_v(digests);
+ merkle_hash_dispatch(digests);
}
else
{
diff --git a/include/bitcoin/system/impl/hash/sha/algorithm_vectorization.ipp b/include/bitcoin/system/impl/hash/sha/algorithm_vectorization.ipp
index a8cc497ed7..a3435e2a98 100644
--- a/include/bitcoin/system/impl/hash/sha/algorithm_vectorization.ipp
+++ b/include/bitcoin/system/impl/hash/sha/algorithm_vectorization.ipp
@@ -404,15 +404,19 @@ output(idigests_t& digests, const xstate_t& xstate) NOEXCEPT
digests.template advance();
}
+// Merkle Hash.
+// ----------------------------------------------------------------------------
+
TEMPLATE
template >
INLINE void CLASS::
-merkle_hash_v_(idigests_t& digests, iblocks_t& blocks) NOEXCEPT
+merkle_hash_invoke(idigests_t& digests, iblocks_t& blocks) NOEXCEPT
{
BC_ASSERT(digests.size() == blocks.size());
constexpr auto lanes = capacity;
static_assert(is_valid_lanes);
+ // RUNTIME INTRINSIC CHECK
if (blocks.size() >= lanes && have())
{
static auto initial = pack(H::get);
@@ -447,7 +451,7 @@ merkle_hash_v_(idigests_t& digests, iblocks_t& blocks) NOEXCEPT
TEMPLATE
INLINE void CLASS::
-merkle_hash_v(digests_t& digests) NOEXCEPT
+merkle_hash_dispatch(digests_t& digests) NOEXCEPT
{
// Merkle vector dispatch.
static_assert(sizeof(digest_t) == to_half(sizeof(block_t)));
@@ -463,11 +467,11 @@ merkle_hash_v(digests_t& digests) NOEXCEPT
// Merkle hash vector dispatch.
if constexpr (have_x512)
- merkle_hash_v_(idigests, iblocks);
+ merkle_hash_invoke(idigests, iblocks);
if constexpr (have_x256)
- merkle_hash_v_(idigests, iblocks);
+ merkle_hash_invoke(idigests, iblocks);
if constexpr (have_x128)
- merkle_hash_v_(idigests, iblocks);
+ merkle_hash_invoke(idigests, iblocks);
// iblocks.size() is reduced by vectorization.
offset = blocks - iblocks.size();
@@ -484,7 +488,7 @@ merkle_hash_v(digests_t& digests) NOEXCEPT
TEMPLATE
template
INLINE void CLASS::
-compress_v(state_t& state, const xbuffer_t& xbuffer) NOEXCEPT
+compress_dispatch(state_t& state, const xbuffer_t& xbuffer) NOEXCEPT
{
constexpr auto lanes = capacity;
@@ -521,11 +525,12 @@ compress_v(state_t& state, const xbuffer_t& xbuffer) NOEXCEPT
TEMPLATE
template >
INLINE void CLASS::
-iterate_v_(state_t& state, iblocks_t& blocks) NOEXCEPT
+iterate_invoke(state_t& state, iblocks_t& blocks) NOEXCEPT
{
constexpr auto lanes = capacity;
static_assert(is_valid_lanes);
+ // RUNTIME INTRINSIC CHECK
if (blocks.size() >= lanes && have())
{
BC_PUSH_WARNING(NO_UNINITIALZIED_VARIABLE)
@@ -537,7 +542,7 @@ iterate_v_(state_t& state, iblocks_t& blocks) NOEXCEPT
// input() advances block iterator by lanes.
input(xbuffer, blocks);
schedule_(xbuffer);
- compress_v(state, xbuffer);
+ compress_dispatch(state, xbuffer);
}
while (blocks.size() >= lanes);
}
@@ -545,17 +550,17 @@ iterate_v_(state_t& state, iblocks_t& blocks) NOEXCEPT
TEMPLATE
INLINE void CLASS::
-iterate_v(state_t& state, iblocks_t& blocks) NOEXCEPT
+iterate_dispatch(state_t& state, iblocks_t& blocks) NOEXCEPT
{
if (blocks.size() >= min_lanes)
{
// Schedule iteration vector dispatch.
if constexpr (have_x512)
- iterate_v_(state, blocks);
+ iterate_invoke(state, blocks);
if constexpr (have_x256)
- iterate_v_(state, blocks);
+ iterate_invoke(state, blocks);
if constexpr (have_x128)
- iterate_v_(state, blocks);
+ iterate_invoke(state, blocks);
}
// Complete rounds using normal form.
@@ -566,12 +571,12 @@ iterate_v(state_t& state, iblocks_t& blocks) NOEXCEPT
TEMPLATE
template
INLINE void CLASS::
-iterate_v(state_t& state, const ablocks_t& blocks) NOEXCEPT
+iterate_dispatch(state_t& state, const ablocks_t& blocks) NOEXCEPT
{
if (blocks.size() >= min_lanes)
{
auto iblocks = iblocks_t{ array_cast(blocks) };
- iterate_v(state, iblocks);
+ iterate_dispatch(state, iblocks);
}
else
{
@@ -602,7 +607,7 @@ sigma0_8(auto x1, auto x2, auto x3, auto x4, auto x5, auto x6, auto x7,
TEMPLATE
template
INLINE void CLASS::
-prepare_v(buffer_t& buffer) NOEXCEPT
+prepare_dispatch(buffer_t& buffer) NOEXCEPT
{
// Requires avx512 for sha512 and avx2 for sha256.
// sigma0x8 message scheduling for single block iteration.
@@ -668,35 +673,50 @@ prepare_v(buffer_t& buffer) NOEXCEPT
TEMPLATE
INLINE void CLASS::
-schedule_v(auto& buffer) NOEXCEPT
+schedule_invoke(buffer_t& buffer) NOEXCEPT
{
- using word = decltype(buffer.front());
+ // RUNTIME INTRINSIC CHECK
+ if (have_lanes())
+ {
+ prepare_dispatch<16>(buffer);
+ prepare_dispatch<24>(buffer);
+ prepare_dispatch<32>(buffer);
+ prepare_dispatch<40>(buffer);
+ prepare_dispatch<48>(buffer);
+ prepare_dispatch<56>(buffer);
+
+ if constexpr (SHA::rounds == 80)
+ {
+ prepare_dispatch<64>(buffer);
+ prepare_dispatch<72>(buffer);
+ }
- if constexpr (SHA::strength == 160 || !is_same_type)
+ add_k(buffer);
+ }
+ else
{
schedule_(buffer);
}
- else if (!have_lanes())
+}
+
+TEMPLATE
+INLINE void CLASS::
+schedule_dispatch(auto& buffer) NOEXCEPT
+{
+ // buffer may be vectorized via merkle execution path.
+ using word = decltype(buffer.front());
+
+ // Schedule prepare vector dispatch.
+ if constexpr ((SHA::strength != 160) && is_same_type &&
+ ((have_x512 && (capacity == 8u)) ||
+ (have_x256 && (capacity == 8u)) ||
+ (have_x128 && (capacity == 8u))))
{
- schedule_(buffer);
+ schedule_invoke(buffer);
}
else
{
- // Schedule prepare vector dispatch.
- prepare_v<16>(buffer);
- prepare_v<24>(buffer);
- prepare_v<32>(buffer);
- prepare_v<40>(buffer);
- prepare_v<48>(buffer);
- prepare_v<56>(buffer);
-
- if constexpr (SHA::rounds == 80)
- {
- prepare_v<64>(buffer);
- prepare_v<72>(buffer);
- }
-
- add_k(buffer);
+ schedule_(buffer);
}
}
diff --git a/include/bitcoin/system/impl/stream/iostream/iostream.ipp b/include/bitcoin/system/impl/stream/iostream/iostream.ipp
new file mode 100644
index 0000000000..3d22521ed9
--- /dev/null
+++ b/include/bitcoin/system/impl/stream/iostream/iostream.ipp
@@ -0,0 +1,82 @@
+/**
+ * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
+ *
+ * This file is part of libbitcoin.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#ifndef LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_IOSTREAM_IPP
+#define LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_IOSTREAM_IPP
+
+#include
+
+namespace libbitcoin {
+namespace system {
+
+BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
+
+template
+INLINE iostream::iostream(Buffer& buffer) NOEXCEPT
+ : position_(buffer.data()),
+ begin_(position_),
+ end_(begin_ + buffer.size()),
+ state_(goodbit)
+{
+}
+
+template
+INLINE iostream::iostream(uint8_t* begin,
+ ptrdiff_t size) NOEXCEPT
+ : position_(begin),
+ begin_(position_),
+ end_(begin_ + size),
+ state_(goodbit)
+{
+}
+
+template
+INLINE typename iostream::iostate
+iostream::rdstate() const NOEXCEPT
+{
+ return state_;
+}
+
+template
+INLINE void
+iostream::setstate(iostate state) NOEXCEPT
+{
+ state_ |= state;
+}
+
+template
+INLINE void
+iostream::clear(iostate state) NOEXCEPT
+{
+ state_ = state;
+}
+
+// private
+template
+INLINE bool
+iostream::is_overflow(pos_type size) const NOEXCEPT
+{
+ return (state_ != goodbit) || (size > (end_ - position_));
+}
+
+BC_POP_WARNING()
+
+} // namespace system
+} // namespace libbitcoin
+
+#endif
diff --git a/include/bitcoin/system/impl/stream/simple/istream.ipp b/include/bitcoin/system/impl/stream/iostream/istream.ipp
similarity index 60%
rename from include/bitcoin/system/impl/stream/simple/istream.ipp
rename to include/bitcoin/system/impl/stream/iostream/istream.ipp
index c9345f74d3..e0bd6939d2 100644
--- a/include/bitcoin/system/impl/stream/simple/istream.ipp
+++ b/include/bitcoin/system/impl/stream/iostream/istream.ipp
@@ -16,8 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef LIBBITCOIN_SYSTEM_STREAM_SIMPLE_ISTREAM_IPP
-#define LIBBITCOIN_SYSTEM_STREAM_SIMPLE_ISTREAM_IPP
+#ifndef LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_ISTREAM_IPP
+#define LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_ISTREAM_IPP
#include
#include
@@ -26,25 +26,18 @@
namespace libbitcoin {
namespace system {
-template
-inline istream::istream(const Source& source) NOEXCEPT
- : position_(source.data()),
- begin_(position_),
- end_(begin_ + source.size()),
- state_(goodbit)
-{
-}
+BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
-template
-inline typename istream::pos_type
-istream::tellg() const NOEXCEPT
+template
+INLINE typename iostream::pos_type
+iostream::tellg() const NOEXCEPT
{
return static_cast(position_ - begin_);
}
-template
-inline istream&
-istream::seekg(off_type offset, seekdir direction) NOEXCEPT
+template
+INLINE iostream&
+iostream::seekg(off_type offset, seekdir direction) NOEXCEPT
{
if (state_ != goodbit)
return *this;
@@ -96,30 +89,25 @@ istream::seekg(off_type offset, seekdir direction) NOEXCEPT
return *this;
}
-template
-inline typename istream::iostate
-istream::rdstate() const NOEXCEPT
+template
+INLINE typename iostream::int_type
+iostream::peek() NOEXCEPT
{
- return state_;
-}
+ constexpr auto eof = std::char_traits::eof();
-template
-inline void
-istream::setstate(iostate state) NOEXCEPT
-{
- state_ |= state;
-}
+ if (is_overflow(1))
+ {
+ setstate(badbit);
+ return eof;
+ }
-template
-inline void
-istream::clear(iostate state) NOEXCEPT
-{
- state_ = state;
+ const uint8_t value = *position_;
+ return system::sign_cast(value);
}
-template
-inline void
-istream::read(char_type* data, pos_type size) NOEXCEPT
+template
+INLINE void
+iostream::read(char_type* data, pos_type size) NOEXCEPT
{
if (is_overflow(size))
{
@@ -134,37 +122,15 @@ istream::read(char_type* data, pos_type size) NOEXCEPT
position_ += size;
}
-template
-inline typename istream::int_type
-istream::peek() NOEXCEPT
-{
- constexpr auto eof = std::char_traits::eof();
-
- if (is_overflow(1))
- {
- setstate(badbit);
- return eof;
- }
-
- const uint8_t value = *position_;
- return system::sign_cast(value);
-}
-
// private
-template
+template
constexpr bool
-istream::is_positive(off_type value) NOEXCEPT
+iostream::is_positive(off_type value) NOEXCEPT
{
return !is_zero(value) && !system::is_negative(value);
}
-// private
-template
-inline bool
-istream::is_overflow(pos_type size) const NOEXCEPT
-{
- return (state_ != goodbit) || (size > (end_ - position_));
-}
+BC_POP_WARNING()
} // namespace system
} // namespace libbitcoin
diff --git a/include/bitcoin/system/impl/stream/iostream/ostream.ipp b/include/bitcoin/system/impl/stream/iostream/ostream.ipp
new file mode 100644
index 0000000000..3dce8ffa09
--- /dev/null
+++ b/include/bitcoin/system/impl/stream/iostream/ostream.ipp
@@ -0,0 +1,65 @@
+/**
+ * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
+ *
+ * This file is part of libbitcoin.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+#ifndef LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_OSTREAM_IPP
+#define LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_OSTREAM_IPP
+
+#include
+#include
+
+namespace libbitcoin {
+namespace system {
+
+BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
+
+template
+INLINE typename iostream::pos_type
+iostream::tellp() const NOEXCEPT
+{
+ return static_cast(position_ - begin_);
+}
+
+template
+INLINE void
+iostream::write(const char_type* data, pos_type size) NOEXCEPT
+{
+ if (is_overflow(size))
+ {
+ setstate(badbit);
+ return;
+ }
+
+ BC_PUSH_WARNING(NO_UNSAFE_COPY_N)
+ std::copy_n(data, size, position_);
+ BC_POP_WARNING()
+
+ position_ += size;
+}
+
+template
+INLINE void
+iostream::flush() NOEXCEPT
+{
+}
+
+BC_POP_WARNING()
+
+} // namespace system
+} // namespace libbitcoin
+
+#endif
diff --git a/include/bitcoin/system/impl/stream/simple/ostream.ipp b/include/bitcoin/system/impl/stream/simple/ostream.ipp
deleted file mode 100644
index 26c5361e95..0000000000
--- a/include/bitcoin/system/impl/stream/simple/ostream.ipp
+++ /dev/null
@@ -1,100 +0,0 @@
-/**
- * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
- *
- * This file is part of libbitcoin.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-#ifndef LIBBITCOIN_SYSTEM_STREAM_SIMPLE_OSTREAM_IPP
-#define LIBBITCOIN_SYSTEM_STREAM_SIMPLE_OSTREAM_IPP
-
-#include
-#include
-
-namespace libbitcoin {
-namespace system {
-
-template
-inline ostream::ostream(Sink& sink) NOEXCEPT
- : position_(sink.data()),
- begin_(position_),
- end_(begin_ + sink.size()),
- state_(goodbit)
-{
-}
-
-template
-inline typename ostream::pos_type
-ostream::tellp() const NOEXCEPT
-{
- return static_cast(position_ - begin_);
-}
-
-template
-inline typename ostream::iostate
-ostream::rdstate() const NOEXCEPT
-{
- return state_;
-}
-
-template
-inline void
-ostream::setstate(iostate state) NOEXCEPT
-{
- state_ |= state;
-}
-
-template
-inline void
-ostream::clear(iostate state) NOEXCEPT
-{
- state_ = state;
-}
-
-template
-inline void
-ostream::write(const char_type* data, pos_type size) NOEXCEPT
-{
- if (is_overflow(size))
- {
- setstate(badbit);
- return;
- }
-
- BC_PUSH_WARNING(NO_UNSAFE_COPY_N)
- std::copy_n(data, size, position_);
- BC_POP_WARNING()
-
- position_ += size;
-}
-
-template
-inline void
-ostream::flush() NOEXCEPT
-{
- // no-op.
-}
-
-// private
-template
-inline bool
-ostream::is_overflow(pos_type size) const NOEXCEPT
-{
- return (state_ != goodbit) || (size > (end_ - position_));
-}
-
-} // namespace system
-} // namespace libbitcoin
-
-#endif
diff --git a/include/bitcoin/system/intrinsics/haves.hpp b/include/bitcoin/system/intrinsics/haves.hpp
index d3df545c90..7305c146b3 100644
--- a/include/bitcoin/system/intrinsics/haves.hpp
+++ b/include/bitcoin/system/intrinsics/haves.hpp
@@ -98,7 +98,6 @@ namespace xcr0
constexpr auto avx_bit = 2;
}
-
// Local util because no dependency on /math.
template
constexpr bool get_bit(Value value) NOEXCEPT
@@ -267,20 +266,6 @@ using to_extended =
iif == one, xint256_t,
xint512_t>>>>>>;
-/// Compile time (constexpr) availability of extended integer intrinsics,
-/// as a template function of the extended integer type.
-template = true>
-CONSTEVAL bool with() NOEXCEPT
-{
- if constexpr (is_same_type)
- return with_avx512;
- else if constexpr (is_same_type)
- return with_avx2;
- else if constexpr (is_same_type)
- return with_sse41;
- else return false;
-}
-
/// Runtime time availability of extended integer intrinsics, as a template
/// function of the extended integer type.
template = true>
diff --git a/include/bitcoin/system/intrinsics/xcpu/defines.hpp b/include/bitcoin/system/intrinsics/xcpu/defines.hpp
index a2b5647026..d4cb1150bb 100644
--- a/include/bitcoin/system/intrinsics/xcpu/defines.hpp
+++ b/include/bitcoin/system/intrinsics/xcpu/defines.hpp
@@ -21,9 +21,6 @@
#include
-/// Base type for mock extended integer types, used for differentiation.
-struct xmock_t {};
-
#if defined(HAVE_XCPU)
#include
#if defined(HAVE_X64)
diff --git a/include/bitcoin/system/intrinsics/xcpu/functional_128.hpp b/include/bitcoin/system/intrinsics/xcpu/functional_128.hpp
index 6a3051ea97..106b47dbc1 100644
--- a/include/bitcoin/system/intrinsics/xcpu/functional_128.hpp
+++ b/include/bitcoin/system/intrinsics/xcpu/functional_128.hpp
@@ -274,8 +274,8 @@ INLINE xint128_t byteswap(xint128_t a) NOEXCEPT
#else
-// Symbol is defined but not usable.
-struct xint128_t : xmock_t {};
+// Symbol is defined but not usable as an integer.
+using xint128_t = std_array>;
#endif // HAVE_SSE4
diff --git a/include/bitcoin/system/intrinsics/xcpu/functional_256.hpp b/include/bitcoin/system/intrinsics/xcpu/functional_256.hpp
index 438f45300f..a6f83cd2cb 100644
--- a/include/bitcoin/system/intrinsics/xcpu/functional_256.hpp
+++ b/include/bitcoin/system/intrinsics/xcpu/functional_256.hpp
@@ -287,8 +287,8 @@ INLINE xint256_t byteswap(xint256_t a) NOEXCEPT
#else
-// Symbol is defined but not usable.
-struct xint256_t : xmock_t {};
+// Symbol is defined but not usable as an integer.
+using xint256_t = std_array>;
#endif // HAVE_AVX2
diff --git a/include/bitcoin/system/intrinsics/xcpu/functional_512.hpp b/include/bitcoin/system/intrinsics/xcpu/functional_512.hpp
index 90b114a725..29f3d30112 100644
--- a/include/bitcoin/system/intrinsics/xcpu/functional_512.hpp
+++ b/include/bitcoin/system/intrinsics/xcpu/functional_512.hpp
@@ -327,8 +327,8 @@ INLINE xint512_t byteswap(xint512_t a) NOEXCEPT
#else
-// Symbol is defined but not usable.
-struct xint512_t : xmock_t {};
+// Symbol is defined but not usable as an integer.
+using xint512_t = std_array>;
#endif // HAVE_AVX512
diff --git a/include/bitcoin/system/stream/simple/istream.hpp b/include/bitcoin/system/stream/iostream.hpp
similarity index 59%
rename from include/bitcoin/system/stream/simple/istream.hpp
rename to include/bitcoin/system/stream/iostream.hpp
index 198b33b6b3..7e5fc98c19 100644
--- a/include/bitcoin/system/stream/simple/istream.hpp
+++ b/include/bitcoin/system/stream/iostream.hpp
@@ -16,8 +16,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see .
*/
-#ifndef LIBBITCOIN_SYSTEM_STREAM_SIMPLE_ISTREAM_HPP
-#define LIBBITCOIN_SYSTEM_STREAM_SIMPLE_ISTREAM_HPP
+#ifndef LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_HPP
+#define LIBBITCOIN_SYSTEM_STREAM_IOSTREAM_HPP
#include
#include
@@ -25,14 +25,12 @@
namespace libbitcoin {
namespace system {
-BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
-
-/// Support for high level input operations on a byte buffer.
-template
-class istream
+/// Support for high level input/output operations on a byte buffer.
+template
+class iostream
{
public:
- DEFAULT_COPY_MOVE_DESTRUCT(istream);
+ DEFAULT_COPY_MOVE_DESTRUCT(iostream);
using char_type = Character;
using int_type = typename std::basic_ios::int_type;
@@ -52,44 +50,54 @@ class istream
static constexpr seekdir end = 2;
/// Construct the object.
- inline istream(const Source& source) NOEXCEPT;
-
- /// Return the relative input position indicator (zero-based).
- virtual inline pos_type tellg() const NOEXCEPT;
-
- /// Set the relative input position indicator (zero-based).
- virtual inline istream& seekg(off_type offset, seekdir direction) NOEXCEPT;
+ INLINE iostream(Buffer& buffer) NOEXCEPT;
+ INLINE iostream(uint8_t* begin, ptrdiff_t size) NOEXCEPT;
/// Return state flags.
- virtual inline iostate rdstate() const NOEXCEPT;
+ virtual INLINE iostate rdstate() const NOEXCEPT;
/// Set the stream error flags state in addition to currently set flags.
- virtual inline void setstate(iostate state) NOEXCEPT;
+ virtual INLINE void setstate(iostate state) NOEXCEPT;
/// Set the stream error state flags by assigning the state value.
- virtual inline void clear(iostate state = goodbit) NOEXCEPT;
+ virtual INLINE void clear(iostate state = goodbit) NOEXCEPT;
- /// Read a block of characters, sets badbit on underflow.
- virtual inline void read(char_type* data, pos_type size) NOEXCEPT;
+ /// Return the relative input position indicator (zero-based).
+ virtual INLINE pos_type tellg() const NOEXCEPT;
+
+ /// Return the relative output position indicator (zero-based).
+ virtual INLINE pos_type tellp() const NOEXCEPT;
+
+ /// Set the relative input position indicator (zero-based).
+ virtual INLINE iostream& seekg(off_type offset, seekdir direction) NOEXCEPT;
/// Read the next character without advancing, sets badbit on underflow.
- virtual inline int_type peek() NOEXCEPT;
+ virtual INLINE int_type peek() NOEXCEPT;
+
+ /// Read a block of characters, sets badbit on underflow.
+ virtual INLINE void read(char_type* data, pos_type size) NOEXCEPT;
+
+ /// Write a block of characters, sets badbit on overflow.
+ virtual INLINE void write(const char_type* data, pos_type size) NOEXCEPT;
+
+ /// Synchronize with the underlying storage device (no-op).
+ virtual INLINE void flush() NOEXCEPT;
private:
static constexpr bool is_positive(off_type value) NOEXCEPT;
- inline bool is_overflow(pos_type size) const NOEXCEPT;
+ INLINE bool is_overflow(pos_type size) const NOEXCEPT;
- const uint8_t* position_;
- const uint8_t* begin_;
- const uint8_t* end_;
+ uint8_t* position_;
+ uint8_t* begin_;
+ uint8_t* end_;
iostate state_;
};
-BC_POP_WARNING()
-
} // namespace system
} // namespace libbitcoin
-#include
+#include
+#include
+#include
#endif
diff --git a/include/bitcoin/system/stream/simple/iostream.hpp b/include/bitcoin/system/stream/simple/iostream.hpp
deleted file mode 100644
index 9e7f05ab9a..0000000000
--- a/include/bitcoin/system/stream/simple/iostream.hpp
+++ /dev/null
@@ -1,75 +0,0 @@
-/**
- * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
- *
- * This file is part of libbitcoin.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-#ifndef LIBBITCOIN_SYSTEM_STREAM_SIMPLE_IOSTREAM_HPP
-#define LIBBITCOIN_SYSTEM_STREAM_SIMPLE_IOSTREAM_HPP
-
-#include
-#include
-#include
-
-namespace libbitcoin {
-namespace system {
-
-// The only multiple inheritance conflicts are resolved below.
-BC_PUSH_WARNING(DIAMOND_INHERITANCE)
-
-/// Support for high level input and output operations on a byte buffer.
-template
-class iostream
- : public istream,
- public ostream
-{
- DEFAULT_COPY_MOVE(iostream);
-
- /// Common based for state methods, just pick one.
- using base = istream;
-
- /// Construct the object.
- iostream(Buffer& buffer) NOEXCEPT
- : istream(buffer),
- ostream(buffer)
- {
- }
-
- // Two base destructor calls order is unimportant.
- ~iostream() override = default;
-
- inline typename base::iostate rdstate() const NOEXCEPT override
- {
- return base::rdstate();
- }
-
- inline void setstate(typename base::iostate state) NOEXCEPT override
- {
- base::setstate(state);
- }
-
- inline void clear(
- typename base::iostate state=base::goodbit) NOEXCEPT override
- {
- base::clear(state);
- }
-};
-
-BC_POP_WARNING()
-
-} // namespace system
-} // namespace libbitcoin
-
-#endif
diff --git a/include/bitcoin/system/stream/simple/ostream.hpp b/include/bitcoin/system/stream/simple/ostream.hpp
deleted file mode 100644
index e50741823c..0000000000
--- a/include/bitcoin/system/stream/simple/ostream.hpp
+++ /dev/null
@@ -1,84 +0,0 @@
-/**
- * Copyright (c) 2011-2023 libbitcoin developers (see AUTHORS)
- *
- * This file is part of libbitcoin.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-#ifndef LIBBITCOIN_SYSTEM_STREAM_SIMPLE_OSTREAM_HPP
-#define LIBBITCOIN_SYSTEM_STREAM_SIMPLE_OSTREAM_HPP
-
-#include
-#include
-
-namespace libbitcoin {
-namespace system {
-
-BC_PUSH_WARNING(NO_POINTER_ARITHMETIC)
-
-/// Support for high level output operations on a byte buffer.
-template
-class ostream
-{
-public:
- DEFAULT_COPY_MOVE_DESTRUCT(ostream);
-
- using char_type = Character;
- using pos_type = typename std::basic_ios::pos_type;
- using failure = typename std::ios_base::failure;
-
- using iostate = uint8_t;
- static constexpr iostate goodbit = 0;
- static constexpr iostate eofbit = 1;
- static constexpr iostate failbit = 2;
- static constexpr iostate badbit = 4;
-
- /// Construct the object.
- inline ostream(Sink& sink) NOEXCEPT;
-
- /// Return the relative output position indicator (zero-based).
- virtual inline pos_type tellp() const NOEXCEPT;
-
- /// Return state flags.
- virtual inline iostate rdstate() const NOEXCEPT;
-
- /// Set the stream error flags state in addition to currently set flags.
- virtual inline void setstate(iostate state) NOEXCEPT;
-
- /// Set the stream error state flags by assigning the state value.
- virtual inline void clear(iostate state=goodbit) NOEXCEPT;
-
- /// Write a block of characters, sets badbit on overflow.
- virtual inline void write(const char_type* data, pos_type size) NOEXCEPT;
-
- /// Synchronize with the underlying storage device.
- virtual inline void flush() NOEXCEPT;
-
-private:
- inline bool is_overflow(pos_type size) const NOEXCEPT;
-
- uint8_t* position_;
- uint8_t* begin_;
- uint8_t* end_;
- iostate state_;
-};
-
-BC_POP_WARNING()
-
-} // namespace system
-} // namespace libbitcoin
-
-#include
-
-#endif
diff --git a/include/bitcoin/system/stream/stream.hpp b/include/bitcoin/system/stream/stream.hpp
index 08b6443a6d..494fa10353 100644
--- a/include/bitcoin/system/stream/stream.hpp
+++ b/include/bitcoin/system/stream/stream.hpp
@@ -27,9 +27,7 @@
#include
#include
#include
-#include
-#include
-#include
+#include
#include
#include
#include
diff --git a/include/bitcoin/system/stream/streamers/bit_flipper.hpp b/include/bitcoin/system/stream/streamers/bit_flipper.hpp
index fb35a2e16a..513f711fb9 100644
--- a/include/bitcoin/system/stream/streamers/bit_flipper.hpp
+++ b/include/bitcoin/system/stream/streamers/bit_flipper.hpp
@@ -28,12 +28,12 @@
#include
#include
-// The only multiple inheritance conflicts are resolved below.
-BC_PUSH_WARNING(DIAMOND_INHERITANCE)
-
namespace libbitcoin {
namespace system {
+// The only multiple inheritance conflicts are resolved below.
+BC_PUSH_WARNING(DIAMOND_INHERITANCE)
+
/// A bit reader/writer that accepts an iostream.
/// Bit actions may lead to unextected read behavior, as they are read and
/// flushed to the byte reader/writer on byte boundaries. Flushing a
@@ -79,9 +79,9 @@ class bit_flipper
}
};
+BC_POP_WARNING()
+
} // namespace system
} // namespace libbitcoin
-BC_POP_WARNING()
-
#endif
diff --git a/include/bitcoin/system/stream/streamers/bit_reader.hpp b/include/bitcoin/system/stream/streamers/bit_reader.hpp
index f4bfedb76c..1ab31d103f 100644
--- a/include/bitcoin/system/stream/streamers/bit_reader.hpp
+++ b/include/bitcoin/system/stream/streamers/bit_reader.hpp
@@ -27,13 +27,13 @@
#include
#include
+namespace libbitcoin {
+namespace system {
+
// The inheritance is virtual, so not actually multiple.
// But the boost type constraint 'is_virtual_base_of' triggers the warning.
BC_PUSH_WARNING(DIAMOND_INHERITANCE)
-namespace libbitcoin {
-namespace system {
-
/// A bit reader that accepts an istream.
template
class bit_reader
@@ -77,11 +77,11 @@ class bit_reader
uint8_t offset_;
};
+BC_POP_WARNING()
+
} // namespace system
} // namespace libbitcoin
-BC_POP_WARNING()
-
#include
#endif
diff --git a/include/bitcoin/system/stream/streams.hpp b/include/bitcoin/system/stream/streams.hpp
index 8ca0996a02..bde4d79781 100644
--- a/include/bitcoin/system/stream/streams.hpp
+++ b/include/bitcoin/system/stream/streams.hpp
@@ -27,9 +27,6 @@
#include
#include
#include
-#include
-#include
-#include
namespace libbitcoin {
namespace system {
@@ -46,7 +43,6 @@ namespace stream
{
/// An input stream that copies data from a data_reference.
using copy = make_stream>;
- using simple = istream;
}
namespace out
@@ -59,14 +55,12 @@ namespace stream
using push = make_stream>;
using text = push;
using data = push;
- using simple = ostream;
}
namespace flip
{
/// An input/output stream that copies data to a data_slab.
using copy = make_stream>;
- using simple = iostream;
}
}
diff --git a/test/hash/performance/performance.hpp b/test/hash/performance/performance.hpp
index bfce39842c..bc0225bc45 100644
--- a/test/hash/performance/performance.hpp
+++ b/test/hash/performance/performance.hpp
@@ -22,7 +22,6 @@
#include "../../test.hpp"
#include "baseline/rmd160.h"
#include "baseline/sha256.h"
-#include "../sha/clone/algorithm.hpp"
#include
namespace performance {
diff --git a/test/hash/sha/algorithm.cpp b/test/hash/sha/algorithm.cpp
index 99cea30d47..80853bb50d 100644
--- a/test/hash/sha/algorithm.cpp
+++ b/test/hash/sha/algorithm.cpp
@@ -18,7 +18,6 @@
*/
#include "../../test.hpp"
#include "../hash.hpp"
-#include "clone/algorithm.hpp"
BOOST_AUTO_TEST_SUITE(sha_algorithm_tests)
diff --git a/test/hash/sha/clone/algorithm.hpp b/test/hash/sha/clone/algorithm.hpp
deleted file mode 100644
index 78ff795e55..0000000000
--- a/test/hash/sha/clone/algorithm.hpp
+++ /dev/null
@@ -1,319 +0,0 @@
-/**
- * Copyright (c) 2011-2022 libbitcoin developers (see AUTHORS)
- *
- * This file is part of libbitcoin.
- *
- * This program is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU Affero General Public License for more details.
- *
- * You should have received a copy of the GNU Affero General Public License
- * along with this program. If not, see .
- */
-#ifndef LIBBITCOIN_SYSTEM_HASH_SHAX_ALGORITHM_HPP
-#define LIBBITCOIN_SYSTEM_HASH_SHAX_ALGORITHM_HPP
-
-#include "../../../test.hpp"
-
-namespace shax {
-
-/// SHA hashing algorithm.
-/// Compression not yet implemented.
-/// Vectorization of message schedules and merkle hashes.
-template = true>
-class algorithm : algorithm_t
-{
-public:
- /// Types.
- /// -----------------------------------------------------------------------
-
- /// Aliases.
- using H = SHA;
- using K = typename SHA::K;
- using word_t = typename SHA::word_t;
- using state_t = typename SHA::state_t;
-
- /// Word-based types.
- using chunk_t = std_array;
- using words_t = std_array;
- using buffer_t = std_array;
-
- /// Byte-based types.
- using byte_t = uint8_t;
- using half_t = std_array;
- using block_t = std_array;
- using digest_t = std_array>;
-
- /// Collection types.
- template
- using ablocks_t = std_array;
- using iblocks_t = iterable;
- using digests_t = std_vector;
-
- /// Constants (and count_t).
- /// -----------------------------------------------------------------------
- /// count_t is uint64_t (sha160/256) or uint128_t (sha512).
- /// All extended integer intrinsics currently have a "64 on 32" limit.
-
- static constexpr auto count_bits = SHA::block_words * SHA::word_bytes;
- static constexpr auto count_bytes = bytes;
- using count_t = unsigned_exact_type>;
-
- static constexpr auto caching = Cached;
- static constexpr auto limit_bits = maximum -count_bits;
- static constexpr auto limit_bytes = to_floored_bytes(limit_bits);
- static constexpr auto big_end_count = true;
-
- /// Single hashing.
- /// -----------------------------------------------------------------------
- template
- static constexpr digest_t hash(const ablocks_t& blocks) NOEXCEPT;
- static constexpr digest_t hash(const block_t& block) NOEXCEPT;
- static constexpr digest_t hash(const state_t& state) NOEXCEPT;
- static constexpr digest_t hash(const half_t& half) NOEXCEPT;
- static constexpr digest_t hash(const half_t& left, const half_t& right) NOEXCEPT;
- static digest_t hash(iblocks_t&& blocks) NOEXCEPT;
-
- /// Double hashing (sha256/512).
- /// -----------------------------------------------------------------------
- template
- static constexpr digest_t double_hash(const ablocks_t& blocks) NOEXCEPT;
- static constexpr digest_t double_hash(const block_t& block) NOEXCEPT;
- static constexpr digest_t double_hash(const half_t& half) NOEXCEPT;
- static constexpr digest_t double_hash(const half_t& left, const half_t& right) NOEXCEPT;
- static digest_t double_hash(iblocks_t&& blocks) NOEXCEPT;
-
- /// Merkle hashing (sha256/512).
- /// -----------------------------------------------------------------------
- static VCONSTEXPR digest_t merkle_root(digests_t&& digests) NOEXCEPT;
- static VCONSTEXPR digests_t& merkle_hash(digests_t& digests) NOEXCEPT;
-
- /// Streamed hashing (unfinalized).
- /// -----------------------------------------------------------------------
- static void accumulate(state_t& state, iblocks_t&& blocks) NOEXCEPT;
- static constexpr void accumulate(state_t& state, const block_t& block) NOEXCEPT;
- static constexpr digest_t finalize(state_t& state, size_t blocks) NOEXCEPT;
- static constexpr digest_t finalize_double(state_t& state, size_t blocks) NOEXCEPT;
- static constexpr digest_t normalize(const state_t& state) NOEXCEPT;
-
-protected:
- /// Functions
- /// -----------------------------------------------------------------------
- using uint = unsigned int;
-
- template
- INLINE static constexpr auto sigma(auto x) NOEXCEPT;
- template
- INLINE static constexpr auto Sigma(auto x) NOEXCEPT;
-
- INLINE static constexpr auto parity(auto x, auto y, auto z) NOEXCEPT;
- INLINE static constexpr auto choice(auto x, auto y, auto z) NOEXCEPT;
- INLINE static constexpr auto majority(auto x, auto y, auto z) NOEXCEPT;
-
- INLINE static constexpr auto Sigma0(auto x) NOEXCEPT;
- INLINE static constexpr auto Sigma1(auto x) NOEXCEPT;
- INLINE static constexpr auto sigma0(auto x) NOEXCEPT;
- INLINE static constexpr auto sigma1(auto x) NOEXCEPT;
-
- /// Rounds
- /// -----------------------------------------------------------------------
-
- template
- static CONSTEVAL auto functor() NOEXCEPT;
-
- template
- INLINE static constexpr void round(auto a, auto& b, auto c, auto d,
- auto& e, auto wk) NOEXCEPT;
-
- template