updated boost on windows
This commit is contained in:
@@ -21,8 +21,8 @@
|
||||
#ifndef BOOST_ENDIAN_ARITHMETIC_HPP
|
||||
#define BOOST_ENDIAN_ARITHMETIC_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||
#endif
|
||||
|
||||
@@ -35,7 +35,8 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef/detail/endian_compat.h>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/predef/other/endian.h>
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <boost/endian/buffers.hpp>
|
||||
#define BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
||||
@@ -58,7 +59,8 @@
|
||||
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
|
||||
# endif
|
||||
|
||||
# if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS)
|
||||
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
|
||||
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
|
||||
# define BOOST_ENDIAN_NO_CTORS
|
||||
# endif
|
||||
|
||||
@@ -146,7 +148,7 @@ namespace endian
|
||||
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_t;
|
||||
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_t;
|
||||
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
// native endian signed integer unaligned types
|
||||
typedef big_int8_t native_int8_t;
|
||||
typedef big_int16_t native_int16_t;
|
||||
@@ -300,7 +302,7 @@ namespace endian
|
||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_LOG
|
||||
if ( endian_log )
|
||||
std::cout << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
||||
@@ -325,7 +327,7 @@ namespace endian
|
||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_LOG
|
||||
if ( endian_log )
|
||||
std::cout << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
||||
@@ -361,7 +363,7 @@ namespace endian
|
||||
this->m_value = ::boost::endian::native_to_big(val);
|
||||
}
|
||||
|
||||
# endif
|
||||
# endif
|
||||
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
this->m_value = ::boost::endian::native_to_big(val);
|
||||
@@ -390,7 +392,7 @@ namespace endian
|
||||
# endif
|
||||
this->m_value = ::boost::endian::native_to_little(val);
|
||||
}
|
||||
# endif
|
||||
# endif
|
||||
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
this->m_value = ::boost::endian::native_to_little(val);
|
||||
@@ -406,8 +408,8 @@ namespace endian
|
||||
# pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ENDIAN_ARITHMETIC_HPP
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
#ifndef BOOST_ENDIAN_BUFFERS_HPP
|
||||
#define BOOST_ENDIAN_BUFFERS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable: 4127) // conditional expression is constant
|
||||
#endif
|
||||
|
||||
#ifdef BOOST_ENDIAN_LOG
|
||||
@@ -35,14 +35,20 @@
|
||||
#endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef/detail/endian_compat.h>
|
||||
#include <boost/config/workaround.hpp>
|
||||
#include <boost/predef/other/endian.h>
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/type_traits/make_unsigned.hpp>
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/type_identity.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
#include <iosfwd>
|
||||
#include <climits>
|
||||
#include <cstring>
|
||||
|
||||
# if CHAR_BIT != 8
|
||||
# error Platforms with CHAR_BIT != 8 are not supported
|
||||
@@ -54,7 +60,8 @@
|
||||
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
|
||||
# endif
|
||||
|
||||
# if defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) && defined(BOOST_ENDIAN_FORCE_PODNESS)
|
||||
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
|
||||
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
|
||||
# define BOOST_ENDIAN_NO_CTORS
|
||||
# endif
|
||||
|
||||
@@ -143,7 +150,7 @@ namespace endian
|
||||
typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t;
|
||||
typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t;
|
||||
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
// unaligned native endian signed integer buffers
|
||||
typedef big_int8_buf_t native_int8_buf_t;
|
||||
typedef big_int16_buf_t native_int16_buf_t;
|
||||
@@ -195,7 +202,7 @@ namespace endian
|
||||
return os << x.value();
|
||||
}
|
||||
|
||||
// Stream extractor
|
||||
// Stream extractor
|
||||
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
|
||||
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
|
||||
std::basic_istream<charT, traits>&
|
||||
@@ -221,20 +228,27 @@ namespace endian
|
||||
{
|
||||
typedef unrolled_byte_loops<T, n_bytes - 1, sign> next;
|
||||
|
||||
static T load_big(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return static_cast<T>(*(bytes - 1) | (next::load_big(bytes - 1) << 8)); }
|
||||
static T load_little(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return static_cast<T>(*bytes | (next::load_little(bytes + 1) << 8)); }
|
||||
// shifting a negative number is flagged by -fsanitize=undefined
|
||||
// so use the corresponding unsigned type for the shifts
|
||||
|
||||
static void store_big(char* bytes, T value) BOOST_NOEXCEPT
|
||||
typedef typename boost::conditional<
|
||||
boost::is_integral<T>::value,
|
||||
boost::make_unsigned<T>, boost::type_identity<T> >::type::type U;
|
||||
|
||||
static T load_big(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return static_cast<T>(*(bytes - 1) | (static_cast<U>(next::load_big(bytes - 1)) << 8)); }
|
||||
static T load_little(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return static_cast<T>(*bytes | (static_cast<U>(next::load_little(bytes + 1)) << 8)); }
|
||||
|
||||
static void store_big(unsigned char* bytes, T value) BOOST_NOEXCEPT
|
||||
{
|
||||
*(bytes - 1) = static_cast<char>(value);
|
||||
next::store_big(bytes - 1, static_cast<T>(value >> 8));
|
||||
*(bytes - 1) = static_cast<unsigned char>(value);
|
||||
next::store_big(bytes - 1, static_cast<T>(static_cast<U>(value) >> 8));
|
||||
}
|
||||
static void store_little(char* bytes, T value) BOOST_NOEXCEPT
|
||||
static void store_little(unsigned char* bytes, T value) BOOST_NOEXCEPT
|
||||
{
|
||||
*bytes = static_cast<char>(value);
|
||||
next::store_little(bytes + 1, static_cast<T>(value >> 8));
|
||||
*bytes = static_cast<unsigned char>(value);
|
||||
next::store_little(bytes + 1, static_cast<T>(static_cast<U>(value) >> 8));
|
||||
}
|
||||
};
|
||||
|
||||
@@ -245,10 +259,10 @@ namespace endian
|
||||
{ return *(bytes - 1); }
|
||||
static T load_little(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return *bytes; }
|
||||
static void store_big(char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *(bytes - 1) = static_cast<char>(value); }
|
||||
static void store_little(char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *bytes = static_cast<char>(value); }
|
||||
static void store_big(unsigned char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *(bytes - 1) = static_cast<unsigned char>(value); }
|
||||
static void store_little(unsigned char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *bytes = static_cast<unsigned char>(value); }
|
||||
|
||||
};
|
||||
|
||||
@@ -259,16 +273,26 @@ namespace endian
|
||||
{ return *reinterpret_cast<const signed char*>(bytes - 1); }
|
||||
static T load_little(const unsigned char* bytes) BOOST_NOEXCEPT
|
||||
{ return *reinterpret_cast<const signed char*>(bytes); }
|
||||
static void store_big(char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *(bytes - 1) = static_cast<char>(value); }
|
||||
static void store_little(char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *bytes = static_cast<char>(value); }
|
||||
static void store_big(unsigned char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *(bytes - 1) = static_cast<unsigned char>(value); }
|
||||
static void store_little(unsigned char* bytes, T value) BOOST_NOEXCEPT
|
||||
{ *bytes = static_cast<unsigned char>(value); }
|
||||
};
|
||||
|
||||
template <typename T, std::size_t n_bytes>
|
||||
inline
|
||||
T load_big_endian(const void* bytes) BOOST_NOEXCEPT
|
||||
{
|
||||
# if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
|
||||
// All major x86 compilers elide this test and optimize out memcpy
|
||||
// (the x86 architecture allows unaligned loads, but -fsanitize=undefined does not)
|
||||
if (sizeof(T) == n_bytes)
|
||||
{
|
||||
T t;
|
||||
std::memcpy( &t, bytes, sizeof(T) );
|
||||
return boost::endian::big_to_native(t);
|
||||
}
|
||||
# endif
|
||||
return unrolled_byte_loops<T, n_bytes>::load_big
|
||||
(static_cast<const unsigned char*>(bytes) + n_bytes);
|
||||
}
|
||||
@@ -278,13 +302,13 @@ namespace endian
|
||||
T load_little_endian(const void* bytes) BOOST_NOEXCEPT
|
||||
{
|
||||
# if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
|
||||
// On x86 (which is little endian), unaligned loads are permitted
|
||||
if (sizeof(T) == n_bytes) // GCC 4.9, VC++ 14.0, and probably others, elide this
|
||||
// test and generate code only for the applicable return
|
||||
// case since sizeof(T) and n_bytes are known at compile
|
||||
// time.
|
||||
// All major x86 compilers elide this test and optimize out memcpy
|
||||
// (the x86 architecture allows unaligned loads, but -fsanitize=undefined does not)
|
||||
if (sizeof(T) == n_bytes)
|
||||
{
|
||||
return *reinterpret_cast<T const *>(bytes);
|
||||
T t;
|
||||
std::memcpy( &t, bytes, sizeof(T) );
|
||||
return t; // or endian::little_to_native(t) if we ever extend the #ifdef to non-x86
|
||||
}
|
||||
# endif
|
||||
return unrolled_byte_loops<T, n_bytes>::load_little
|
||||
@@ -295,8 +319,18 @@ namespace endian
|
||||
inline
|
||||
void store_big_endian(void* bytes, T value) BOOST_NOEXCEPT
|
||||
{
|
||||
# if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
|
||||
// All major x86 compilers elide this test and optimize out memcpy
|
||||
// (the x86 architecture allows unaligned loads, but -fsanitize=undefined does not)
|
||||
if (sizeof(T) == n_bytes)
|
||||
{
|
||||
boost::endian::native_to_big_inplace(value);
|
||||
std::memcpy( bytes, &value, sizeof(T) );
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
unrolled_byte_loops<T, n_bytes>::store_big
|
||||
(static_cast<char*>(bytes) + n_bytes, value);
|
||||
(static_cast<unsigned char*>(bytes) + n_bytes, value);
|
||||
}
|
||||
|
||||
template <typename T, std::size_t n_bytes>
|
||||
@@ -304,18 +338,18 @@ namespace endian
|
||||
void store_little_endian(void* bytes, T value) BOOST_NOEXCEPT
|
||||
{
|
||||
# if defined(__x86_64__) || defined(_M_X64) || defined(__i386) || defined(_M_IX86)
|
||||
// On x86 (which is little endian), unaligned stores are permitted
|
||||
if (sizeof(T) == n_bytes) // GCC 4.9, VC++ 14.0, and probably others, elide this
|
||||
// test and generate code only for the applicable return
|
||||
// case since sizeof(T) and n_bytes are known at compile
|
||||
// time.
|
||||
// All major x86 compilers elide this test and optimize out memcpy
|
||||
// (the x86 architecture allows unaligned loads, but -fsanitize=undefined does not)
|
||||
if (sizeof(T) == n_bytes)
|
||||
{
|
||||
*reinterpret_cast<T *>(bytes) = value;
|
||||
// if we ever extend the #ifdef to non-x86:
|
||||
// endian::native_to_little_inplace(value);
|
||||
std::memcpy( bytes, &value, sizeof(T) );
|
||||
return;
|
||||
}
|
||||
# endif
|
||||
unrolled_byte_loops<T, n_bytes>::store_little
|
||||
(static_cast<char*>(bytes), value);
|
||||
(static_cast<unsigned char*>(bytes), value);
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
@@ -346,7 +380,7 @@ namespace endian
|
||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
explicit endian_buffer(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_LOG
|
||||
if ( endian_log )
|
||||
std::cout << "big, unaligned, "
|
||||
@@ -365,7 +399,7 @@ namespace endian
|
||||
return *this;
|
||||
}
|
||||
value_type value() const BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_LOG
|
||||
if ( endian_log )
|
||||
std::cout << "big, unaligned, " << n_bits << "-bits, convert("
|
||||
@@ -388,7 +422,7 @@ namespace endian
|
||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||
explicit endian_buffer(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_LOG
|
||||
if ( endian_log )
|
||||
std::cout << "little, unaligned, " << n_bits << "-bits, construct("
|
||||
@@ -400,7 +434,7 @@ namespace endian
|
||||
endian_buffer & operator=(T val) BOOST_NOEXCEPT
|
||||
{ detail::store_little_endian<T, n_bits/8>(m_value, val); return *this; }
|
||||
value_type value() const BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_LOG
|
||||
if ( endian_log )
|
||||
std::cout << "little, unaligned, " << n_bits << "-bits, convert("
|
||||
@@ -435,14 +469,14 @@ namespace endian
|
||||
m_value = ::boost::endian::native_to_big(val);
|
||||
}
|
||||
|
||||
# endif
|
||||
# endif
|
||||
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
m_value = ::boost::endian::native_to_big(val);
|
||||
return *this;
|
||||
}
|
||||
//operator value_type() const BOOST_NOEXCEPT
|
||||
//{
|
||||
//{
|
||||
// return ::boost::endian::big_to_native(m_value);
|
||||
//}
|
||||
value_type value() const BOOST_NOEXCEPT
|
||||
@@ -480,7 +514,7 @@ namespace endian
|
||||
m_value = ::boost::endian::native_to_little(val);
|
||||
}
|
||||
|
||||
# endif
|
||||
# endif
|
||||
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
||||
{
|
||||
m_value = ::boost::endian::native_to_little(val);
|
||||
@@ -508,8 +542,8 @@ namespace endian
|
||||
# pragma pack(pop)
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ENDIAN_BUFFERS_HPP
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#define BOOST_ENDIAN_CONVERSION_HPP
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/predef/detail/endian_compat.h>
|
||||
#include <boost/predef/other/endian.h>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/endian/detail/intrinsic.hpp>
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
@@ -26,7 +26,7 @@ namespace endian
|
||||
BOOST_SCOPED_ENUM_START(order)
|
||||
{
|
||||
big, little,
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
native = big
|
||||
# else
|
||||
native = little
|
||||
@@ -48,12 +48,12 @@ namespace endian
|
||||
// by argument dependent lookup (ADL). //
|
||||
// //
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
|
||||
// customization for exact-length arithmetic types. See doc/conversion.html/#FAQ.
|
||||
// Note: The omission of a overloads for the arithmetic type (typically long, or
|
||||
// long long) not assigned to one of the exact length typedefs is a deliberate
|
||||
// design decision. Such overloads would be non-portable and thus error prone.
|
||||
|
||||
|
||||
inline int8_t endian_reverse(int8_t x) BOOST_NOEXCEPT;
|
||||
inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT;
|
||||
inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT;
|
||||
@@ -112,7 +112,7 @@ namespace endian
|
||||
// //
|
||||
// user-defined types (UDTs) //
|
||||
// //
|
||||
// All reverse in place function templates are required to be implemented in terms //
|
||||
// All reverse in place function templates are required to be implemented in terms //
|
||||
// of an unqualified call to "endian_reverse_inplace(x)", a function reversing //
|
||||
// the endianness of x, which is a non-const reference. This provides a //
|
||||
// customization point for any UDT that provides a "reverse_inplace" free-function //
|
||||
@@ -146,7 +146,7 @@ namespace endian
|
||||
// generic conditional reverse in place
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||
class EndianReversibleInplace>
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||
|
||||
// runtime reverse in place
|
||||
template <class EndianReversibleInplace>
|
||||
@@ -199,33 +199,35 @@ namespace endian
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
return (static_cast<uint16_t>(x) << 8)
|
||||
| (static_cast<uint16_t>(x) >> 8);
|
||||
# else
|
||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(static_cast<uint16_t>(x));
|
||||
return static_cast<int16_t>(
|
||||
BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(static_cast<uint16_t>(x)));
|
||||
# endif
|
||||
}
|
||||
|
||||
inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
uint32_t step16;
|
||||
step16 = static_cast<uint32_t>(x) << 16 | static_cast<uint32_t>(x) >> 16;
|
||||
return
|
||||
((static_cast<uint32_t>(step16) << 8) & 0xff00ff00)
|
||||
| ((static_cast<uint32_t>(step16) >> 8) & 0x00ff00ff);
|
||||
# else
|
||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(static_cast<uint32_t>(x));
|
||||
return static_cast<int32_t>(
|
||||
BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(static_cast<uint32_t>(x)));
|
||||
# endif
|
||||
}
|
||||
|
||||
inline int64_t endian_reverse(int64_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
uint64_t step32, step16;
|
||||
step32 = static_cast<uint64_t>(x) << 32 | static_cast<uint64_t>(x) >> 32;
|
||||
step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16
|
||||
@@ -233,10 +235,11 @@ namespace endian
|
||||
return static_cast<int64_t>((step16 & 0x00FF00FF00FF00FFULL) << 8
|
||||
| (step16 & 0xFF00FF00FF00FF00ULL) >> 8);
|
||||
# else
|
||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(static_cast<uint64_t>(x));
|
||||
return static_cast<int64_t>(
|
||||
BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(static_cast<uint64_t>(x)));
|
||||
# endif
|
||||
}
|
||||
|
||||
|
||||
inline uint8_t endian_reverse(uint8_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
return x;
|
||||
@@ -244,7 +247,7 @@ namespace endian
|
||||
|
||||
inline uint16_t endian_reverse(uint16_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
return (x << 8)
|
||||
| (x >> 8);
|
||||
# else
|
||||
@@ -252,9 +255,9 @@ namespace endian
|
||||
# endif
|
||||
}
|
||||
|
||||
inline uint32_t endian_reverse(uint32_t x) BOOST_NOEXCEPT
|
||||
inline uint32_t endian_reverse(uint32_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
uint32_t step16;
|
||||
step16 = x << 16 | x >> 16;
|
||||
return
|
||||
@@ -267,7 +270,7 @@ namespace endian
|
||||
|
||||
inline uint64_t endian_reverse(uint64_t x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
uint64_t step32, step16;
|
||||
step32 = x << 32 | x >> 32;
|
||||
step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16
|
||||
@@ -282,7 +285,7 @@ namespace endian
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
return x;
|
||||
# else
|
||||
return endian_reverse(x);
|
||||
@@ -292,7 +295,7 @@ namespace endian
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
return x;
|
||||
# else
|
||||
return endian_reverse(x);
|
||||
@@ -302,7 +305,7 @@ namespace endian
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
# if BOOST_ENDIAN_LITTLE_BYTE
|
||||
return x;
|
||||
# else
|
||||
return endian_reverse(x);
|
||||
@@ -312,7 +315,7 @@ namespace endian
|
||||
template <class EndianReversible >
|
||||
inline EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
# if BOOST_ENDIAN_LITTLE_BYTE
|
||||
return x;
|
||||
# else
|
||||
return endian_reverse(x);
|
||||
@@ -367,14 +370,14 @@ namespace endian
|
||||
}
|
||||
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
inline void big_to_native_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{ endian_reverse_inplace(x); }
|
||||
# endif
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
inline void native_to_big_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
@@ -384,14 +387,14 @@ namespace endian
|
||||
# endif
|
||||
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
# if BOOST_ENDIAN_LITTLE_BYTE
|
||||
inline void little_to_native_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
{ endian_reverse_inplace(x); }
|
||||
# endif
|
||||
template <class EndianReversibleInplace>
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
# if BOOST_ENDIAN_LITTLE_BYTE
|
||||
inline void native_to_little_inplace(EndianReversibleInplace&) BOOST_NOEXCEPT {}
|
||||
# else
|
||||
inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT
|
||||
@@ -402,7 +405,7 @@ namespace endian
|
||||
|
||||
namespace detail
|
||||
{
|
||||
// Primary template and specializations support generic
|
||||
// Primary template and specializations support generic
|
||||
// endian_reverse_inplace().
|
||||
// See rationale in endian_reverse_inplace() below.
|
||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||
@@ -446,7 +449,7 @@ namespace endian
|
||||
template <class T>
|
||||
inline void big_reverse_copy(T from, char* to) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
std::memcpy(to, reinterpret_cast<const char*>(&from), sizeof(T));
|
||||
# else
|
||||
std::reverse_copy(reinterpret_cast<const char*>(&from),
|
||||
@@ -456,7 +459,7 @@ namespace endian
|
||||
template <class T>
|
||||
inline void big_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
# if BOOST_ENDIAN_BIG_BYTE
|
||||
std::memcpy(reinterpret_cast<char*>(&to), from, sizeof(T));
|
||||
# else
|
||||
std::reverse_copy(from, from + sizeof(T), reinterpret_cast<char*>(&to));
|
||||
@@ -465,7 +468,7 @@ namespace endian
|
||||
template <class T>
|
||||
inline void little_reverse_copy(T from, char* to) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
# if BOOST_ENDIAN_LITTLE_BYTE
|
||||
std::memcpy(to, reinterpret_cast<const char*>(&from), sizeof(T));
|
||||
# else
|
||||
std::reverse_copy(reinterpret_cast<const char*>(&from),
|
||||
@@ -475,7 +478,7 @@ namespace endian
|
||||
template <class T>
|
||||
inline void little_reverse_copy(const char* from, T& to) BOOST_NOEXCEPT
|
||||
{
|
||||
# ifdef BOOST_LITTLE_ENDIAN
|
||||
# if BOOST_ENDIAN_LITTLE_BYTE
|
||||
std::memcpy(reinterpret_cast<char*>(&to), from, sizeof(T));
|
||||
# else
|
||||
std::reverse_copy(from, from + sizeof(T), reinterpret_cast<char*>(&to));
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
// boost/endian/detail/config.hpp ----------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2003, 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifndef BOOST_ENDIAN_CONFIG_HPP
|
||||
#define BOOST_ENDIAN_CONFIG_HPP
|
||||
|
||||
// This header implements separate compilation features as described in
|
||||
// http://www.boost.org/more/separate_compilation.html
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/system/api_config.hpp> // for BOOST_POSIX_API or BOOST_WINDOWS_API
|
||||
|
||||
// throw an exception ----------------------------------------------------------------//
|
||||
//
|
||||
// Exceptions were originally thrown via boost::throw_exception().
|
||||
// As throw_exception() became more complex, it caused user error reporting
|
||||
// to be harder to interpret, since the exception reported became much more complex.
|
||||
// The immediate fix was to throw directly, wrapped in a macro to make any later change
|
||||
// easier.
|
||||
|
||||
#define BOOST_ENDIAN_THROW(EX) throw EX
|
||||
|
||||
// enable dynamic linking -------------------------------------------------------------//
|
||||
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ENDIAN_DYN_LINK)
|
||||
# if defined(BOOST_ENDIAN_SOURCE)
|
||||
# define BOOST_ENDIAN_DECL BOOST_SYMBOL_EXPORT
|
||||
# else
|
||||
# define BOOST_ENDIAN_DECL BOOST_SYMBOL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define BOOST_ENDIAN_DECL
|
||||
#endif
|
||||
|
||||
// enable automatic library variant selection ----------------------------------------//
|
||||
|
||||
#if !defined(BOOST_ENDIAN_SOURCE) && !defined(BOOST_ALL_NO_LIB) \
|
||||
&& !defined(BOOST_ENDIAN_NO_LIB)
|
||||
//
|
||||
// Set the name of our library, this will get undef'ed by auto_link.hpp
|
||||
// once it's done with it:
|
||||
//
|
||||
#define BOOST_LIB_NAME boost_endian
|
||||
//
|
||||
// If we're importing code from a dll, then tell auto_link.hpp about it:
|
||||
//
|
||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ENDIAN_DYN_LINK)
|
||||
# define BOOST_DYN_LINK
|
||||
#endif
|
||||
//
|
||||
// And include the header that does the work:
|
||||
//
|
||||
#include <boost/config/auto_link.hpp>
|
||||
#endif // auto-linking disabled
|
||||
|
||||
#endif // BOOST_ENDIAN_CONFIG_HPP
|
||||
@@ -9,8 +9,8 @@
|
||||
#ifndef BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||
#define BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||
#endif
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace boost
|
||||
friend bool operator==(const D& x, ArithmeticT y) BOOST_NOEXCEPT { return +x == y; }
|
||||
friend bool operator<(const D& x, ArithmeticT y) BOOST_NOEXCEPT { return +x < y; }
|
||||
# endif
|
||||
|
||||
|
||||
// The basic arithmetic operations.
|
||||
friend D& operator+=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x + y); }
|
||||
@@ -83,13 +83,13 @@ namespace boost
|
||||
{ return x = static_cast<ArithmeticT>(+x << y); }
|
||||
friend D& operator>>=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x >> y); }
|
||||
|
||||
|
||||
// A few binary arithmetic operations not covered by operators base class.
|
||||
friend ArithmeticT operator<<(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return static_cast<ArithmeticT>(+x << y); }
|
||||
friend ArithmeticT operator>>(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return static_cast<ArithmeticT>(+x >> y); }
|
||||
|
||||
|
||||
// Auto-increment and auto-decrement can be defined in terms of the
|
||||
// arithmetic operations.
|
||||
friend D& operator++(D& x) BOOST_NOEXCEPT { return x += 1; }
|
||||
@@ -97,13 +97,13 @@ namespace boost
|
||||
|
||||
# ifdef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
||||
friend D operator++(D& x, int) BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
D tmp(x);
|
||||
x += 1;
|
||||
return tmp;
|
||||
}
|
||||
friend D operator--(D& x, int) BOOST_NOEXCEPT
|
||||
{
|
||||
{
|
||||
D tmp(x);
|
||||
x -= 1;
|
||||
return tmp;
|
||||
@@ -117,10 +117,10 @@ namespace boost
|
||||
friend std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os, const D& x)
|
||||
{
|
||||
return os << +x;
|
||||
return os << +x;
|
||||
}
|
||||
|
||||
// Stream extractor
|
||||
// Stream extractor
|
||||
template <class charT, class traits>
|
||||
friend std::basic_istream<charT, traits>&
|
||||
operator>>(std::basic_istream<charT, traits>& is, D& x)
|
||||
@@ -135,8 +135,8 @@ namespace boost
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||
|
||||
@@ -8,5 +8,5 @@
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#ifdef _MSC_VER
|
||||
# pragma warning(push)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
|
||||
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) __builtin_bswap64(x)
|
||||
|
||||
// Linux systems provide the byteswap.h header, with
|
||||
// Linux systems provide the byteswap.h header, with
|
||||
#elif defined(__linux__)
|
||||
// don't check for obsolete forms defined(linux) and defined(__linux) on the theory that
|
||||
// compilers that predefine only these are so old that byteswap.h probably isn't present.
|
||||
|
||||
@@ -45,7 +45,7 @@ struct report_errors_reminder
|
||||
|
||||
~report_errors_reminder()
|
||||
{
|
||||
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
|
||||
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user