From b29b3dfc10e14204962566ed34d89337c55e99e2 Mon Sep 17 00:00:00 2001 From: Peter Dimov Date: Mon, 29 Apr 2019 00:36:21 +0300 Subject: [PATCH] Move all deprecated names to endian.hpp; add deprecated_test.cpp to test/Jamfile --- include/boost/endian/arithmetic.hpp | 91 ------------------ include/boost/endian/buffers.hpp | 12 +-- include/boost/endian/detail/endian_load.hpp | 18 ++-- include/boost/endian/detail/endian_store.hpp | 18 ++-- include/boost/endian/endian.hpp | 99 ++++++++++++++++++++ test/Jamfile.v2 | 2 + test/deprecated_test.cpp | 3 +- 7 files changed, 127 insertions(+), 116 deletions(-) diff --git a/include/boost/endian/arithmetic.hpp b/include/boost/endian/arithmetic.hpp index 1f231b0..5e77c99 100644 --- a/include/boost/endian/arithmetic.hpp +++ b/include/boost/endian/arithmetic.hpp @@ -182,97 +182,6 @@ namespace endian typedef little_uint64_t native_uint64_t; # endif -# ifdef BOOST_ENDIAN_DEPRECATED_NAMES - - typedef order endianness; - typedef align alignment; - -# ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES - template - using endian = endian_arithmetic; -# endif - - // unaligned big endian signed integer types - typedef endian_arithmetic< order::big, int_least8_t, 8 > big8_t; - typedef endian_arithmetic< order::big, int_least16_t, 16 > big16_t; - typedef endian_arithmetic< order::big, int_least32_t, 24 > big24_t; - typedef endian_arithmetic< order::big, int_least32_t, 32 > big32_t; - typedef endian_arithmetic< order::big, int_least64_t, 40 > big40_t; - typedef endian_arithmetic< order::big, int_least64_t, 48 > big48_t; - typedef endian_arithmetic< order::big, int_least64_t, 56 > big56_t; - typedef endian_arithmetic< order::big, int_least64_t, 64 > big64_t; - - // unaligned big endian_arithmetic unsigned integer types - typedef endian_arithmetic< order::big, uint_least8_t, 8 > ubig8_t; - typedef endian_arithmetic< order::big, uint_least16_t, 16 > ubig16_t; - typedef endian_arithmetic< order::big, uint_least32_t, 24 > ubig24_t; - typedef endian_arithmetic< order::big, uint_least32_t, 32 > ubig32_t; - typedef endian_arithmetic< order::big, uint_least64_t, 40 > ubig40_t; - typedef endian_arithmetic< order::big, uint_least64_t, 48 > ubig48_t; - typedef endian_arithmetic< order::big, uint_least64_t, 56 > ubig56_t; - typedef endian_arithmetic< order::big, uint_least64_t, 64 > ubig64_t; - - // unaligned little endian_arithmetic signed integer types - typedef endian_arithmetic< order::little, int_least8_t, 8 > little8_t; - typedef endian_arithmetic< order::little, int_least16_t, 16 > little16_t; - typedef endian_arithmetic< order::little, int_least32_t, 24 > little24_t; - typedef endian_arithmetic< order::little, int_least32_t, 32 > little32_t; - typedef endian_arithmetic< order::little, int_least64_t, 40 > little40_t; - typedef endian_arithmetic< order::little, int_least64_t, 48 > little48_t; - typedef endian_arithmetic< order::little, int_least64_t, 56 > little56_t; - typedef endian_arithmetic< order::little, int_least64_t, 64 > little64_t; - - // unaligned little endian_arithmetic unsigned integer types - typedef endian_arithmetic< order::little, uint_least8_t, 8 > ulittle8_t; - typedef endian_arithmetic< order::little, uint_least16_t, 16 > ulittle16_t; - typedef endian_arithmetic< order::little, uint_least32_t, 24 > ulittle24_t; - typedef endian_arithmetic< order::little, uint_least32_t, 32 > ulittle32_t; - typedef endian_arithmetic< order::little, uint_least64_t, 40 > ulittle40_t; - typedef endian_arithmetic< order::little, uint_least64_t, 48 > ulittle48_t; - typedef endian_arithmetic< order::little, uint_least64_t, 56 > ulittle56_t; - typedef endian_arithmetic< order::little, uint_least64_t, 64 > ulittle64_t; - - // unaligned native endian_arithmetic signed integer types - typedef endian_arithmetic< order::native, int_least8_t, 8 > native8_t; - typedef endian_arithmetic< order::native, int_least16_t, 16 > native16_t; - typedef endian_arithmetic< order::native, int_least32_t, 24 > native24_t; - typedef endian_arithmetic< order::native, int_least32_t, 32 > native32_t; - typedef endian_arithmetic< order::native, int_least64_t, 40 > native40_t; - typedef endian_arithmetic< order::native, int_least64_t, 48 > native48_t; - typedef endian_arithmetic< order::native, int_least64_t, 56 > native56_t; - typedef endian_arithmetic< order::native, int_least64_t, 64 > native64_t; - - // unaligned native endian_arithmetic unsigned integer types - typedef endian_arithmetic< order::native, uint_least8_t, 8 > unative8_t; - typedef endian_arithmetic< order::native, uint_least16_t, 16 > unative16_t; - typedef endian_arithmetic< order::native, uint_least32_t, 24 > unative24_t; - typedef endian_arithmetic< order::native, uint_least32_t, 32 > unative32_t; - typedef endian_arithmetic< order::native, uint_least64_t, 40 > unative40_t; - typedef endian_arithmetic< order::native, uint_least64_t, 48 > unative48_t; - typedef endian_arithmetic< order::native, uint_least64_t, 56 > unative56_t; - typedef endian_arithmetic< order::native, uint_least64_t, 64 > unative64_t; - - // aligned native endian_arithmetic typedefs are not provided because - // types are superior for this use case - - typedef endian_arithmetic< order::big, int16_t, 16, align::yes > aligned_big16_t; - typedef endian_arithmetic< order::big, uint16_t, 16, align::yes > aligned_ubig16_t; - typedef endian_arithmetic< order::little, int16_t, 16, align::yes > aligned_little16_t; - typedef endian_arithmetic< order::little, uint16_t, 16, align::yes > aligned_ulittle16_t; - - typedef endian_arithmetic< order::big, int32_t, 32, align::yes > aligned_big32_t; - typedef endian_arithmetic< order::big, uint32_t, 32, align::yes > aligned_ubig32_t; - typedef endian_arithmetic< order::little, int32_t, 32, align::yes > aligned_little32_t; - typedef endian_arithmetic< order::little, uint32_t, 32, align::yes > aligned_ulittle32_t; - - typedef endian_arithmetic< order::big, int64_t, 64, align::yes > aligned_big64_t; - typedef endian_arithmetic< order::big, uint64_t, 64, align::yes > aligned_ubig64_t; - typedef endian_arithmetic< order::little, int64_t, 64, align::yes > aligned_little64_t; - typedef endian_arithmetic< order::little, uint64_t, 64, align::yes > aligned_ulittle64_t; - -# endif - //---------------------------------- end synopsis ------------------------------------// template ( val, value_ ); + boost::endian::endian_store( val, value_ ); } #endif endian_buffer& operator=( T val ) BOOST_NOEXCEPT { - endian::endian_store( val, value_ ); + boost::endian::endian_store( val, value_ ); return *this; } value_type value() const BOOST_NOEXCEPT { - return endian::endian_load( value_ ); + return boost::endian::endian_load( value_ ); } char const * data() const BOOST_NOEXCEPT @@ -293,20 +293,20 @@ public: explicit endian_buffer( T val ) BOOST_NOEXCEPT { - endian::endian_store( val, value_ ); + boost::endian::endian_store( val, value_ ); } #endif endian_buffer& operator=( T val ) BOOST_NOEXCEPT { - endian::endian_store( val, value_ ); + boost::endian::endian_store( val, value_ ); return *this; } value_type value() const BOOST_NOEXCEPT { - return endian::endian_load( value_ ); + return boost::endian::endian_load( value_ ); } char const * data() const BOOST_NOEXCEPT diff --git a/include/boost/endian/detail/endian_load.hpp b/include/boost/endian/detail/endian_load.hpp index 589e623..069e0ef 100644 --- a/include/boost/endian/detail/endian_load.hpp +++ b/include/boost/endian/detail/endian_load.hpp @@ -40,7 +40,7 @@ template inline T endian_load( unsigned char const * p ) BOOST_NOEXCEPT { - return detail::endian_load_impl()( p ); + return detail::endian_load_impl()( p ); } namespace detail @@ -94,7 +94,7 @@ template struct endian_load_impl::value && ( p[2] & 0x80 )? 0xFF: 0x00; - return endian::endian_load( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -111,7 +111,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -137,7 +137,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -161,7 +161,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -187,7 +187,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -211,7 +211,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -237,7 +237,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; @@ -261,7 +261,7 @@ template struct endian_load_impl( tmp ); + return boost::endian::endian_load( tmp ); } }; diff --git a/include/boost/endian/detail/endian_store.hpp b/include/boost/endian/detail/endian_store.hpp index 5e758d1..42c4550 100644 --- a/include/boost/endian/detail/endian_store.hpp +++ b/include/boost/endian/detail/endian_store.hpp @@ -39,7 +39,7 @@ template inline void endian_store( T const & v, unsigned char * p ) BOOST_NOEXCEPT { - return detail::endian_store_impl()( v, p ); + return detail::endian_store_impl()( v, p ); } namespace detail @@ -83,7 +83,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 4 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[0]; p[1] = tmp[1]; @@ -98,7 +98,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 4 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[1]; p[1] = tmp[2]; @@ -115,7 +115,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 8 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[0]; p[1] = tmp[1]; @@ -132,7 +132,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 8 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[3]; p[1] = tmp[4]; @@ -151,7 +151,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 8 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[0]; p[1] = tmp[1]; @@ -169,7 +169,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 8 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[2]; p[1] = tmp[3]; @@ -189,7 +189,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 8 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[0]; p[1] = tmp[1]; @@ -208,7 +208,7 @@ template struct endian_store_impl::value || is_enum::value ); unsigned char tmp[ 8 ]; - endian::endian_store( v, tmp ); + boost::endian::endian_store( v, tmp ); p[0] = tmp[1]; p[1] = tmp[2]; diff --git a/include/boost/endian/endian.hpp b/include/boost/endian/endian.hpp index 6c610c4..06b607b 100644 --- a/include/boost/endian/endian.hpp +++ b/include/boost/endian/endian.hpp @@ -14,6 +14,105 @@ # error " is deprecated. Define BOOST_ENDIAN_DEPRECATED_NAMES to use." #endif +#include + +BOOST_HEADER_DEPRECATED( "" ) + #include +#include + +namespace boost +{ +namespace endian +{ + typedef order endianness; + typedef align alignment; + +# ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES + template + using endian = endian_arithmetic; +# endif + + // unaligned big endian signed integer types + typedef endian_arithmetic< order::big, int_least8_t, 8 > big8_t; + typedef endian_arithmetic< order::big, int_least16_t, 16 > big16_t; + typedef endian_arithmetic< order::big, int_least32_t, 24 > big24_t; + typedef endian_arithmetic< order::big, int_least32_t, 32 > big32_t; + typedef endian_arithmetic< order::big, int_least64_t, 40 > big40_t; + typedef endian_arithmetic< order::big, int_least64_t, 48 > big48_t; + typedef endian_arithmetic< order::big, int_least64_t, 56 > big56_t; + typedef endian_arithmetic< order::big, int_least64_t, 64 > big64_t; + + // unaligned big endian_arithmetic unsigned integer types + typedef endian_arithmetic< order::big, uint_least8_t, 8 > ubig8_t; + typedef endian_arithmetic< order::big, uint_least16_t, 16 > ubig16_t; + typedef endian_arithmetic< order::big, uint_least32_t, 24 > ubig24_t; + typedef endian_arithmetic< order::big, uint_least32_t, 32 > ubig32_t; + typedef endian_arithmetic< order::big, uint_least64_t, 40 > ubig40_t; + typedef endian_arithmetic< order::big, uint_least64_t, 48 > ubig48_t; + typedef endian_arithmetic< order::big, uint_least64_t, 56 > ubig56_t; + typedef endian_arithmetic< order::big, uint_least64_t, 64 > ubig64_t; + + // unaligned little endian_arithmetic signed integer types + typedef endian_arithmetic< order::little, int_least8_t, 8 > little8_t; + typedef endian_arithmetic< order::little, int_least16_t, 16 > little16_t; + typedef endian_arithmetic< order::little, int_least32_t, 24 > little24_t; + typedef endian_arithmetic< order::little, int_least32_t, 32 > little32_t; + typedef endian_arithmetic< order::little, int_least64_t, 40 > little40_t; + typedef endian_arithmetic< order::little, int_least64_t, 48 > little48_t; + typedef endian_arithmetic< order::little, int_least64_t, 56 > little56_t; + typedef endian_arithmetic< order::little, int_least64_t, 64 > little64_t; + + // unaligned little endian_arithmetic unsigned integer types + typedef endian_arithmetic< order::little, uint_least8_t, 8 > ulittle8_t; + typedef endian_arithmetic< order::little, uint_least16_t, 16 > ulittle16_t; + typedef endian_arithmetic< order::little, uint_least32_t, 24 > ulittle24_t; + typedef endian_arithmetic< order::little, uint_least32_t, 32 > ulittle32_t; + typedef endian_arithmetic< order::little, uint_least64_t, 40 > ulittle40_t; + typedef endian_arithmetic< order::little, uint_least64_t, 48 > ulittle48_t; + typedef endian_arithmetic< order::little, uint_least64_t, 56 > ulittle56_t; + typedef endian_arithmetic< order::little, uint_least64_t, 64 > ulittle64_t; + + // unaligned native endian_arithmetic signed integer types + typedef endian_arithmetic< order::native, int_least8_t, 8 > native8_t; + typedef endian_arithmetic< order::native, int_least16_t, 16 > native16_t; + typedef endian_arithmetic< order::native, int_least32_t, 24 > native24_t; + typedef endian_arithmetic< order::native, int_least32_t, 32 > native32_t; + typedef endian_arithmetic< order::native, int_least64_t, 40 > native40_t; + typedef endian_arithmetic< order::native, int_least64_t, 48 > native48_t; + typedef endian_arithmetic< order::native, int_least64_t, 56 > native56_t; + typedef endian_arithmetic< order::native, int_least64_t, 64 > native64_t; + + // unaligned native endian_arithmetic unsigned integer types + typedef endian_arithmetic< order::native, uint_least8_t, 8 > unative8_t; + typedef endian_arithmetic< order::native, uint_least16_t, 16 > unative16_t; + typedef endian_arithmetic< order::native, uint_least32_t, 24 > unative24_t; + typedef endian_arithmetic< order::native, uint_least32_t, 32 > unative32_t; + typedef endian_arithmetic< order::native, uint_least64_t, 40 > unative40_t; + typedef endian_arithmetic< order::native, uint_least64_t, 48 > unative48_t; + typedef endian_arithmetic< order::native, uint_least64_t, 56 > unative56_t; + typedef endian_arithmetic< order::native, uint_least64_t, 64 > unative64_t; + + // aligned native endian_arithmetic typedefs are not provided because + // types are superior for this use case + + typedef endian_arithmetic< order::big, int16_t, 16, align::yes > aligned_big16_t; + typedef endian_arithmetic< order::big, uint16_t, 16, align::yes > aligned_ubig16_t; + typedef endian_arithmetic< order::little, int16_t, 16, align::yes > aligned_little16_t; + typedef endian_arithmetic< order::little, uint16_t, 16, align::yes > aligned_ulittle16_t; + + typedef endian_arithmetic< order::big, int32_t, 32, align::yes > aligned_big32_t; + typedef endian_arithmetic< order::big, uint32_t, 32, align::yes > aligned_ubig32_t; + typedef endian_arithmetic< order::little, int32_t, 32, align::yes > aligned_little32_t; + typedef endian_arithmetic< order::little, uint32_t, 32, align::yes > aligned_ulittle32_t; + + typedef endian_arithmetic< order::big, int64_t, 64, align::yes > aligned_big64_t; + typedef endian_arithmetic< order::big, uint64_t, 64, align::yes > aligned_ubig64_t; + typedef endian_arithmetic< order::little, int64_t, 64, align::yes > aligned_little64_t; + typedef endian_arithmetic< order::little, uint64_t, 64, align::yes > aligned_ulittle64_t; + +} // namespace endian +} // namespace boost #endif //BOOST_ENDIAN_ENDIAN_HPP diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index f1eea02..3000c28 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -68,3 +68,5 @@ run endian_ld_st_roundtrip_test.cpp : : : BOOST_ENDIAN_NO_INTRINSICS : e run endian_arithmetic_test.cpp ; run endian_arithmetic_test.cpp : : : BOOST_ENDIAN_NO_INTRINSICS : endian_arithmetic_test_ni ; + +run deprecated_test.cpp ; diff --git a/test/deprecated_test.cpp b/test/deprecated_test.cpp index e4417f6..3fc0a62 100644 --- a/test/deprecated_test.cpp +++ b/test/deprecated_test.cpp @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -115,7 +116,7 @@ namespace ubig64_t bu64(0x010203040506070ULL); ulittle64_t lu64(0x010203040506070ULL); - uint64_t x; + boost::uint64_t x; std::stringstream ss;