diff options
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/compat/assumptions.h | 5 | ||||
-rw-r--r-- | src/serialize.h | 19 | ||||
-rw-r--r-- | src/test/fuzz/float.cpp | 3 | ||||
-rw-r--r-- | src/test/fuzz/util.h | 2 | ||||
-rw-r--r-- | src/test/serialize_tests.cpp | 2 | ||||
-rw-r--r-- | src/util/types.h | 11 |
7 files changed, 0 insertions, 43 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index f3f58b41b7..2c25f04d08 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -265,7 +265,6 @@ BITCOIN_CORE_H = \ util/tokenpipe.h \ util/trace.h \ util/translation.h \ - util/types.h \ util/ui_change_type.h \ util/url.h \ util/vector.h \ diff --git a/src/compat/assumptions.h b/src/compat/assumptions.h index 5f50cde3ff..7a254c3b67 100644 --- a/src/compat/assumptions.h +++ b/src/compat/assumptions.h @@ -36,11 +36,6 @@ static_assert(std::numeric_limits<double>::is_iec559, "IEEE 754 double assumed") // Example(s): Everywhere :-) static_assert(std::numeric_limits<unsigned char>::digits == 8, "8-bit byte assumed"); -// Assumption: We assume floating-point widths. -// Example(s): Type punning in serialization code (ser_{float,double}_to_uint{32,64}). -static_assert(sizeof(float) == 4, "32-bit float assumed"); -static_assert(sizeof(double) == 8, "64-bit double assumed"); - // Assumption: We assume integer widths. // Example(s): GetSizeOfCompactSize and WriteCompactSize in the serialization // code. diff --git a/src/serialize.h b/src/serialize.h index 276f643c7f..5ef846b9e9 100644 --- a/src/serialize.h +++ b/src/serialize.h @@ -23,7 +23,6 @@ #include <prevector.h> #include <span.h> -#include <util/types.h> /** * The maximum size of a serialized object in bytes or number of elements @@ -123,20 +122,6 @@ template<typename Stream> inline uint64_t ser_readdata64(Stream &s) s.read((char*)&obj, 8); return le64toh(obj); } -inline uint64_t ser_double_to_uint64(double x) -{ - uint64_t tmp; - std::memcpy(&tmp, &x, sizeof(x)); - static_assert(sizeof(tmp) == sizeof(x), "double and uint64_t assumed to have the same size"); - return tmp; -} -inline double ser_uint64_to_double(uint64_t y) -{ - double tmp; - std::memcpy(&tmp, &y, sizeof(y)); - static_assert(sizeof(tmp) == sizeof(y), "double and uint64_t assumed to have the same size"); - return tmp; -} ///////////////////////////////////////////////////////////////// @@ -221,8 +206,6 @@ template<typename Stream> inline void Serialize(Stream& s, int32_t a ) { ser_wri template<typename Stream> inline void Serialize(Stream& s, uint32_t a) { ser_writedata32(s, a); } template<typename Stream> inline void Serialize(Stream& s, int64_t a ) { ser_writedata64(s, a); } template<typename Stream> inline void Serialize(Stream& s, uint64_t a) { ser_writedata64(s, a); } -template<typename Stream> inline void Serialize(Stream& s, float a ) { static_assert(ALWAYS_FALSE<Stream>, "Not implemented"); } -template<typename Stream> inline void Serialize(Stream& s, double a ) { ser_writedata64(s, ser_double_to_uint64(a)); } template<typename Stream, int N> inline void Serialize(Stream& s, const char (&a)[N]) { s.write(a, N); } template<typename Stream, int N> inline void Serialize(Stream& s, const unsigned char (&a)[N]) { s.write(CharCast(a), N); } template<typename Stream> inline void Serialize(Stream& s, const Span<const unsigned char>& span) { s.write(CharCast(span.data()), span.size()); } @@ -239,8 +222,6 @@ template<typename Stream> inline void Unserialize(Stream& s, int32_t& a ) { a = template<typename Stream> inline void Unserialize(Stream& s, uint32_t& a) { a = ser_readdata32(s); } template<typename Stream> inline void Unserialize(Stream& s, int64_t& a ) { a = ser_readdata64(s); } template<typename Stream> inline void Unserialize(Stream& s, uint64_t& a) { a = ser_readdata64(s); } -template<typename Stream> inline void Unserialize(Stream& s, float& a ) { static_assert(ALWAYS_FALSE<Stream>, "Not implemented"); } -template<typename Stream> inline void Unserialize(Stream& s, double& a ) { a = ser_uint64_to_double(ser_readdata64(s)); } template<typename Stream, int N> inline void Unserialize(Stream& s, char (&a)[N]) { s.read(a, N); } template<typename Stream, int N> inline void Unserialize(Stream& s, unsigned char (&a)[N]) { s.read(CharCast(a), N); } template<typename Stream> inline void Unserialize(Stream& s, Span<unsigned char>& span) { s.read(CharCast(span.data()), span.size()); } diff --git a/src/test/fuzz/float.cpp b/src/test/fuzz/float.cpp index e95d593b22..adef66a3ee 100644 --- a/src/test/fuzz/float.cpp +++ b/src/test/fuzz/float.cpp @@ -3,15 +3,12 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include <memusage.h> -#include <serialize.h> -#include <streams.h> #include <test/fuzz/FuzzedDataProvider.h> #include <test/fuzz/fuzz.h> #include <util/serfloat.h> #include <version.h> #include <cassert> -#include <cstdint> #include <cmath> #include <limits> diff --git a/src/test/fuzz/util.h b/src/test/fuzz/util.h index ac8df782be..cf7796e4ae 100644 --- a/src/test/fuzz/util.h +++ b/src/test/fuzz/util.h @@ -513,7 +513,6 @@ void WriteToStream(FuzzedDataProvider& fuzzed_data_provider, Stream& stream) noe WRITE_TO_STREAM_CASE(uint32_t, fuzzed_data_provider.ConsumeIntegral<uint32_t>()), WRITE_TO_STREAM_CASE(int64_t, fuzzed_data_provider.ConsumeIntegral<int64_t>()), WRITE_TO_STREAM_CASE(uint64_t, fuzzed_data_provider.ConsumeIntegral<uint64_t>()), - WRITE_TO_STREAM_CASE(double, fuzzed_data_provider.ConsumeFloatingPoint<double>()), WRITE_TO_STREAM_CASE(std::string, fuzzed_data_provider.ConsumeRandomLengthString(32)), WRITE_TO_STREAM_CASE(std::vector<char>, ConsumeRandomLengthIntegralVector<char>(fuzzed_data_provider))); } catch (const std::ios_base::failure&) { @@ -544,7 +543,6 @@ void ReadFromStream(FuzzedDataProvider& fuzzed_data_provider, Stream& stream) no READ_FROM_STREAM_CASE(uint32_t), READ_FROM_STREAM_CASE(int64_t), READ_FROM_STREAM_CASE(uint64_t), - READ_FROM_STREAM_CASE(double), READ_FROM_STREAM_CASE(std::string), READ_FROM_STREAM_CASE(std::vector<char>)); } catch (const std::ios_base::failure&) { diff --git a/src/test/serialize_tests.cpp b/src/test/serialize_tests.cpp index 0812ef643e..58709178a4 100644 --- a/src/test/serialize_tests.cpp +++ b/src/test/serialize_tests.cpp @@ -70,7 +70,6 @@ BOOST_AUTO_TEST_CASE(sizes) BOOST_CHECK_EQUAL(sizeof(uint32_t), GetSerializeSize(uint32_t(0), 0)); BOOST_CHECK_EQUAL(sizeof(int64_t), GetSerializeSize(int64_t(0), 0)); BOOST_CHECK_EQUAL(sizeof(uint64_t), GetSerializeSize(uint64_t(0), 0)); - BOOST_CHECK_EQUAL(sizeof(double), GetSerializeSize(double(0), 0)); // Bool is serialized as char BOOST_CHECK_EQUAL(sizeof(char), GetSerializeSize(bool(0), 0)); @@ -84,7 +83,6 @@ BOOST_AUTO_TEST_CASE(sizes) BOOST_CHECK_EQUAL(GetSerializeSize(uint32_t(0), 0), 4U); BOOST_CHECK_EQUAL(GetSerializeSize(int64_t(0), 0), 8U); BOOST_CHECK_EQUAL(GetSerializeSize(uint64_t(0), 0), 8U); - BOOST_CHECK_EQUAL(GetSerializeSize(double(0), 0), 8U); BOOST_CHECK_EQUAL(GetSerializeSize(bool(0), 0), 1U); } diff --git a/src/util/types.h b/src/util/types.h deleted file mode 100644 index 0047b00026..0000000000 --- a/src/util/types.h +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright (c) 2021 The Bitcoin Core developers -// Distributed under the MIT software license, see the accompanying -// file COPYING or http://www.opensource.org/licenses/mit-license.php. - -#ifndef BITCOIN_UTIL_TYPES_H -#define BITCOIN_UTIL_TYPES_H - -template <class> -inline constexpr bool ALWAYS_FALSE{false}; - -#endif // BITCOIN_UTIL_TYPES_H |