update boost
This commit is contained in:
@@ -1,142 +0,0 @@
|
||||
// boost/endian/detail/cover_operators.hpp ----------------------------------//
|
||||
|
||||
// Copyright Darin Adler 2000
|
||||
// Copyright Beman Dawes 2008
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
||||
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
||||
|
||||
#ifndef BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||
#define BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(push)
|
||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||
#endif
|
||||
|
||||
# ifndef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
||||
# include <boost/operators.hpp>
|
||||
# endif
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <iosfwd>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
// A class that adds arithmetic operators to an arithmetic cover class
|
||||
//
|
||||
// Uses the curiously recurring template pattern (CRTP).
|
||||
//
|
||||
// If the class being covered has a non-explicit conversion to an integer type
|
||||
// then a smaller number of cover operations are needed. Define the macro
|
||||
// BOOST_ENDIAN_MINIMAL_COVER_OPERATORS to indicate this.
|
||||
//
|
||||
// Define BOOST_NO_IO_COVER_OPERATORS if I/O cover operations are not desired.
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
template <class D, // D is the CRTP derived type, i.e. the cover class
|
||||
class ArithmeticT>
|
||||
class cover_operators
|
||||
# ifndef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
||||
: boost::operators<D>
|
||||
# endif
|
||||
{
|
||||
// The other operations take advantage of the type conversion that's
|
||||
// built into unary +.
|
||||
|
||||
// Unary operations.
|
||||
friend ArithmeticT operator+(const D& x) BOOST_NOEXCEPT { return x; }
|
||||
# ifndef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
||||
friend ArithmeticT operator-(const D& x) BOOST_NOEXCEPT { return -+x; }
|
||||
friend ArithmeticT operator~(const D& x) BOOST_NOEXCEPT { return ~+x; }
|
||||
friend ArithmeticT operator!(const D& x) BOOST_NOEXCEPT { return !+x; }
|
||||
|
||||
// The basic ordering operations.
|
||||
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); }
|
||||
friend D& operator-=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x - y); }
|
||||
friend D& operator*=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x * y); }
|
||||
friend D& operator/=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x / y); }
|
||||
friend D& operator%=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x % y); }
|
||||
friend D& operator&=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x & y); }
|
||||
friend D& operator|=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x | y); }
|
||||
friend D& operator^=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ return x = static_cast<ArithmeticT>(+x ^ y); }
|
||||
friend D& operator<<=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||
{ 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; }
|
||||
friend D& operator--(D& x) BOOST_NOEXCEPT { return x -= 1; }
|
||||
|
||||
# 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;
|
||||
}
|
||||
# endif
|
||||
|
||||
# ifndef BOOST_NO_IO_COVER_OPERATORS
|
||||
|
||||
// Stream inserter
|
||||
template <class charT, class traits>
|
||||
friend std::basic_ostream<charT, traits>&
|
||||
operator<<(std::basic_ostream<charT, traits>& os, const D& x)
|
||||
{
|
||||
return os << +x;
|
||||
}
|
||||
|
||||
// Stream extractor
|
||||
template <class charT, class traits>
|
||||
friend std::basic_istream<charT, traits>&
|
||||
operator>>(std::basic_istream<charT, traits>& is, D& x)
|
||||
{
|
||||
ArithmeticT i;
|
||||
if (is >> i)
|
||||
x = i;
|
||||
return is;
|
||||
}
|
||||
# endif
|
||||
};
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma warning(pop)
|
||||
#endif
|
||||
|
||||
#endif // BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||
589
linx64/include/boost/endian/detail/endian_load.hpp
Normal file
589
linx64/include/boost/endian/detail/endian_load.hpp
Normal file
@@ -0,0 +1,589 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_ENDIAN_LOAD_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_ENDIAN_LOAD_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/detail/endian_reverse.hpp>
|
||||
#include <boost/endian/detail/order.hpp>
|
||||
#include <boost/endian/detail/integral_by_size.hpp>
|
||||
#include <boost/endian/detail/is_trivially_copyable.hpp>
|
||||
#include <boost/type_traits/is_signed.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Requires:
|
||||
//
|
||||
// sizeof(T) must be 1, 2, 4, or 8
|
||||
// 1 <= N <= sizeof(T)
|
||||
// T is TriviallyCopyable
|
||||
// if N < sizeof(T), T is integral or enum
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
|
||||
inline T endian_load( unsigned char const * p ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
|
||||
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
|
||||
|
||||
return detail::endian_load_impl<T, sizeof(T), order::native, N, Order>()( p );
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// same endianness, same size
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_load_impl<T, N, O, N, O>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
T t;
|
||||
std::memcpy( &t, p, N );
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
// same size, reverse endianness
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl<T, N, O1, N, O2>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
typename integral_by_size<N>::type tmp;
|
||||
std::memcpy( &tmp, p, N );
|
||||
|
||||
endian_reverse_inplace( tmp );
|
||||
|
||||
T t;
|
||||
std::memcpy( &t, &tmp, N );
|
||||
return t;
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 1 -> 2
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
return boost::endian::endian_load<T, 2, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
|
||||
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[1] = p[0];
|
||||
|
||||
return boost::endian::endian_load<T, 2, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 1 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = p[0];
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 2 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = p[0];
|
||||
tmp[3] = p[1];
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 3 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
tmp[3] = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
|
||||
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
tmp[1] = p[0];
|
||||
tmp[2] = p[1];
|
||||
tmp[3] = p[2];
|
||||
|
||||
return boost::endian::endian_load<T, 4, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 1 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
tmp[4] = fill;
|
||||
tmp[5] = fill;
|
||||
tmp[6] = fill;
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
tmp[4] = fill;
|
||||
tmp[5] = fill;
|
||||
tmp[6] = fill;
|
||||
|
||||
tmp[7] = p[0];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 2 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
tmp[4] = fill;
|
||||
tmp[5] = fill;
|
||||
tmp[6] = fill;
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
tmp[4] = fill;
|
||||
tmp[5] = fill;
|
||||
|
||||
tmp[6] = p[0];
|
||||
tmp[7] = p[1];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 3 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
|
||||
tmp[3] = fill;
|
||||
tmp[4] = fill;
|
||||
tmp[5] = fill;
|
||||
tmp[6] = fill;
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
tmp[4] = fill;
|
||||
|
||||
tmp[5] = p[0];
|
||||
tmp[6] = p[1];
|
||||
tmp[7] = p[2];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 4 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[3] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
tmp[3] = p[3];
|
||||
|
||||
tmp[4] = fill;
|
||||
tmp[5] = fill;
|
||||
tmp[6] = fill;
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
tmp[3] = fill;
|
||||
|
||||
tmp[4] = p[0];
|
||||
tmp[5] = p[1];
|
||||
tmp[6] = p[2];
|
||||
tmp[7] = p[3];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 5 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[4] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
tmp[3] = p[3];
|
||||
tmp[4] = p[4];
|
||||
|
||||
tmp[5] = fill;
|
||||
tmp[6] = fill;
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
tmp[2] = fill;
|
||||
|
||||
tmp[3] = p[0];
|
||||
tmp[4] = p[1];
|
||||
tmp[5] = p[2];
|
||||
tmp[6] = p[3];
|
||||
tmp[7] = p[4];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 6 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[5] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
tmp[3] = p[3];
|
||||
tmp[4] = p[4];
|
||||
tmp[5] = p[5];
|
||||
|
||||
tmp[6] = fill;
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
tmp[1] = fill;
|
||||
|
||||
tmp[2] = p[0];
|
||||
tmp[3] = p[1];
|
||||
tmp[4] = p[2];
|
||||
tmp[5] = p[3];
|
||||
tmp[6] = p[4];
|
||||
tmp[7] = p[5];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
// expanding load 7 -> 8
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::little>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[6] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = p[0];
|
||||
tmp[1] = p[1];
|
||||
tmp[2] = p[2];
|
||||
tmp[3] = p[3];
|
||||
tmp[4] = p[4];
|
||||
tmp[5] = p[5];
|
||||
tmp[6] = p[6];
|
||||
|
||||
tmp[7] = fill;
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::little>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::big>
|
||||
{
|
||||
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
|
||||
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
|
||||
|
||||
tmp[0] = fill;
|
||||
|
||||
tmp[1] = p[0];
|
||||
tmp[2] = p[1];
|
||||
tmp[3] = p[2];
|
||||
tmp[4] = p[3];
|
||||
tmp[5] = p[4];
|
||||
tmp[6] = p[5];
|
||||
tmp[7] = p[6];
|
||||
|
||||
return boost::endian::endian_load<T, 8, order::big>( tmp );
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_ENDIAN_LOAD_HPP_INCLUDED
|
||||
178
linx64/include/boost/endian/detail/endian_reverse.hpp
Normal file
178
linx64/include/boost/endian/detail/endian_reverse.hpp
Normal file
@@ -0,0 +1,178 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_ENDIAN_REVERSE_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_ENDIAN_REVERSE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019, 2020 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/detail/integral_by_size.hpp>
|
||||
#include <boost/endian/detail/intrinsic.hpp>
|
||||
#include <boost/endian/detail/is_scoped_enum.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_same.hpp>
|
||||
#include <boost/type_traits/enable_if.hpp>
|
||||
#include <boost/type_traits/is_class.hpp>
|
||||
#include <boost/type_traits/integral_constant.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
#if defined(BOOST_ENDIAN_NO_INTRINSICS)
|
||||
# if defined(BOOST_NO_CXX14_CONSTEXPR)
|
||||
# define BOOST_ENDIAN_CONSTEXPR
|
||||
# else
|
||||
# define BOOST_ENDIAN_CONSTEXPR constexpr
|
||||
# endif
|
||||
#else
|
||||
# if defined(BOOST_ENDIAN_CONSTEXPR_INTRINSICS)
|
||||
# define BOOST_ENDIAN_CONSTEXPR BOOST_CONSTEXPR
|
||||
# else
|
||||
# define BOOST_ENDIAN_CONSTEXPR
|
||||
# endif
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// -- portable approach suggested by tymofey, with avoidance of undefined behavior
|
||||
// as suggested by Giovanni Piero Deretta, with a further refinement suggested
|
||||
// by Pyry Jahkola.
|
||||
// -- intrinsic approach suggested by reviewers, and by David Stone, who provided
|
||||
// his Boost licensed macro implementation (detail/intrinsic.hpp)
|
||||
|
||||
inline uint8_t BOOST_CONSTEXPR endian_reverse_impl( uint8_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return x;
|
||||
}
|
||||
|
||||
inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
|
||||
return (x << 8) | (x >> 8);
|
||||
|
||||
#else
|
||||
|
||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
|
||||
uint32_t step16 = x << 16 | x >> 16;
|
||||
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
|
||||
|
||||
#else
|
||||
|
||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x);
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_NOEXCEPT
|
||||
{
|
||||
#ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||
|
||||
uint64_t step32 = x << 32 | x >> 32;
|
||||
uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
|
||||
return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8;
|
||||
|
||||
#else
|
||||
|
||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x);
|
||||
|
||||
# endif
|
||||
}
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
|
||||
inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x ) BOOST_NOEXCEPT
|
||||
{
|
||||
return endian_reverse_impl( static_cast<uint64_t>( x >> 64 ) ) |
|
||||
static_cast<uint128_type>( endian_reverse_impl( static_cast<uint64_t>( x ) ) ) << 64;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
// is_endian_reversible
|
||||
|
||||
template<class T> struct is_endian_reversible: boost::integral_constant<bool,
|
||||
(boost::is_integral<T>::value && !boost::is_same<T, bool>::value) || is_scoped_enum<T>::value>
|
||||
{
|
||||
};
|
||||
|
||||
// is_endian_reversible_inplace
|
||||
|
||||
template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
|
||||
boost::is_integral<T>::value || boost::is_enum<T>::value || boost::is_same<T, float>::value || boost::is_same<T, double>::value>
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Requires:
|
||||
// T is non-bool integral or scoped enumeration type
|
||||
|
||||
template<class T> inline BOOST_CONSTEXPR
|
||||
typename enable_if_< !is_class<T>::value, T >::type
|
||||
endian_reverse( T x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
|
||||
|
||||
typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t;
|
||||
|
||||
return static_cast<T>( detail::endian_reverse_impl( static_cast<uintN_t>( x ) ) );
|
||||
}
|
||||
|
||||
// Requires:
|
||||
// T is integral, enumeration, float or double
|
||||
|
||||
template<class T> inline
|
||||
typename enable_if_< !is_class<T>::value >::type
|
||||
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<T>::value );
|
||||
|
||||
typename detail::integral_by_size< sizeof(T) >::type x2;
|
||||
|
||||
std::memcpy( &x2, &x, sizeof(T) );
|
||||
|
||||
x2 = detail::endian_reverse_impl( x2 );
|
||||
|
||||
std::memcpy( &x, &x2, sizeof(T) );
|
||||
}
|
||||
|
||||
// Default implementation for user-defined types
|
||||
|
||||
template<class T> inline
|
||||
typename enable_if_< is_class<T>::value >::type
|
||||
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
|
||||
{
|
||||
x = endian_reverse( x );
|
||||
}
|
||||
|
||||
// endian_reverse_inplace for arrays
|
||||
|
||||
template<class T, std::size_t N>
|
||||
inline void endian_reverse_inplace( T (&x)[ N ] ) BOOST_NOEXCEPT
|
||||
{
|
||||
for( std::size_t i = 0; i < N; ++i )
|
||||
{
|
||||
endian_reverse_inplace( x[i] );
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_ENDIAN_REVERSE_HPP_INCLUDED
|
||||
442
linx64/include/boost/endian/detail/endian_store.hpp
Normal file
442
linx64/include/boost/endian/detail/endian_store.hpp
Normal file
@@ -0,0 +1,442 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_ENDIAN_STORE_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_ENDIAN_STORE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/endian/detail/endian_reverse.hpp>
|
||||
#include <boost/endian/detail/order.hpp>
|
||||
#include <boost/endian/detail/integral_by_size.hpp>
|
||||
#include <boost/endian/detail/is_trivially_copyable.hpp>
|
||||
#include <boost/type_traits/is_integral.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/static_assert.hpp>
|
||||
#include <cstddef>
|
||||
#include <cstring>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
// Requires:
|
||||
//
|
||||
// sizeof(T) must be 1, 2, 4, or 8
|
||||
// 1 <= N <= sizeof(T)
|
||||
// T is TriviallyCopyable
|
||||
// if N < sizeof(T), T is integral or enum
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
|
||||
inline void endian_store( unsigned char * p, T const & v ) BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
|
||||
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
|
||||
|
||||
return detail::endian_store_impl<T, sizeof(T), order::native, N, Order>()( p, v );
|
||||
}
|
||||
|
||||
namespace detail
|
||||
{
|
||||
|
||||
// same endianness, same size
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_store_impl<T, N, O, N, O>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
std::memcpy( p, &v, N );
|
||||
}
|
||||
};
|
||||
|
||||
// same size, reverse endianness
|
||||
|
||||
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl<T, N, O1, N, O2>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
|
||||
|
||||
typename integral_by_size<N>::type tmp;
|
||||
std::memcpy( &tmp, &v, N );
|
||||
|
||||
endian_reverse_inplace( tmp );
|
||||
|
||||
std::memcpy( p, &tmp, N );
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 2 -> 1
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
boost::endian::endian_store<T, 2, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 2 ];
|
||||
boost::endian::endian_store<T, 2, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[1];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 4 -> 1
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[3];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 4 -> 2
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[2];
|
||||
p[1] = tmp[3];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 4 -> 3
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
p[2] = tmp[2];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 4 ];
|
||||
boost::endian::endian_store<T, 4, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[1];
|
||||
p[1] = tmp[2];
|
||||
p[2] = tmp[3];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 1
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 2
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[6];
|
||||
p[1] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 3
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
p[2] = tmp[2];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[5];
|
||||
p[1] = tmp[6];
|
||||
p[2] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 4
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
p[2] = tmp[2];
|
||||
p[3] = tmp[3];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[4];
|
||||
p[1] = tmp[5];
|
||||
p[2] = tmp[6];
|
||||
p[3] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 5
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
p[2] = tmp[2];
|
||||
p[3] = tmp[3];
|
||||
p[4] = tmp[4];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[3];
|
||||
p[1] = tmp[4];
|
||||
p[2] = tmp[5];
|
||||
p[3] = tmp[6];
|
||||
p[4] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 6
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
p[2] = tmp[2];
|
||||
p[3] = tmp[3];
|
||||
p[4] = tmp[4];
|
||||
p[5] = tmp[5];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[2];
|
||||
p[1] = tmp[3];
|
||||
p[2] = tmp[4];
|
||||
p[3] = tmp[5];
|
||||
p[4] = tmp[6];
|
||||
p[5] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
// truncating store 8 -> 7
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::little>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::little>( tmp, v );
|
||||
|
||||
p[0] = tmp[0];
|
||||
p[1] = tmp[1];
|
||||
p[2] = tmp[2];
|
||||
p[3] = tmp[3];
|
||||
p[4] = tmp[4];
|
||||
p[5] = tmp[5];
|
||||
p[6] = tmp[6];
|
||||
}
|
||||
};
|
||||
|
||||
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::big>
|
||||
{
|
||||
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
|
||||
{
|
||||
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
|
||||
|
||||
unsigned char tmp[ 8 ];
|
||||
boost::endian::endian_store<T, 8, order::big>( tmp, v );
|
||||
|
||||
p[0] = tmp[1];
|
||||
p[1] = tmp[2];
|
||||
p[2] = tmp[3];
|
||||
p[3] = tmp[4];
|
||||
p[4] = tmp[5];
|
||||
p[5] = tmp[6];
|
||||
p[6] = tmp[7];
|
||||
}
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_ENDIAN_STORE_HPP_INCLUDED
|
||||
57
linx64/include/boost/endian/detail/integral_by_size.hpp
Normal file
57
linx64/include/boost/endian/detail/integral_by_size.hpp
Normal file
@@ -0,0 +1,57 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/cstdint.hpp>
|
||||
#include <boost/config.hpp>
|
||||
#include <cstddef>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<std::size_t N> struct integral_by_size
|
||||
{
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<1>
|
||||
{
|
||||
typedef uint8_t type;
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<2>
|
||||
{
|
||||
typedef uint16_t type;
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<4>
|
||||
{
|
||||
typedef uint32_t type;
|
||||
};
|
||||
|
||||
template<> struct integral_by_size<8>
|
||||
{
|
||||
typedef uint64_t type;
|
||||
};
|
||||
|
||||
#if defined(BOOST_HAS_INT128)
|
||||
|
||||
template<> struct integral_by_size<16>
|
||||
{
|
||||
typedef uint128_type type;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
|
||||
@@ -18,7 +18,7 @@
|
||||
#define __has_builtin(x) 0 // Compatibility with non-clang compilers
|
||||
#endif
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
#if defined(_MSC_VER) && ( !defined(__clang__) || defined(__c2__) )
|
||||
// Microsoft documents these as being compatible since Windows 95 and specifically
|
||||
// lists runtime library support since Visual Studio 2003 (aka 7.1).
|
||||
// Clang/c2 uses the Microsoft rather than GCC intrinsics, so we check for
|
||||
@@ -46,6 +46,8 @@
|
||||
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
|
||||
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) __builtin_bswap64(x)
|
||||
|
||||
# define BOOST_ENDIAN_CONSTEXPR_INTRINSICS
|
||||
|
||||
// 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
|
||||
|
||||
35
linx64/include/boost/endian/detail/is_scoped_enum.hpp
Normal file
35
linx64/include/boost/endian/detail/is_scoped_enum.hpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
|
||||
|
||||
// Copyright 2020 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/type_traits/conditional.hpp>
|
||||
#include <boost/type_traits/is_enum.hpp>
|
||||
#include <boost/type_traits/is_convertible.hpp>
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<class T> struct negation: boost::integral_constant<bool, !T::value> {};
|
||||
|
||||
template<class T> struct is_scoped_enum:
|
||||
boost::conditional<
|
||||
boost::is_enum<T>::value,
|
||||
negation< boost::is_convertible<T, int> >,
|
||||
boost::false_type
|
||||
>::type
|
||||
{
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
|
||||
40
linx64/include/boost/endian/detail/is_trivially_copyable.hpp
Normal file
40
linx64/include/boost/endian/detail/is_trivially_copyable.hpp
Normal file
@@ -0,0 +1,40 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/type_traits/has_trivial_copy.hpp>
|
||||
#include <boost/type_traits/has_trivial_assign.hpp>
|
||||
#include <boost/type_traits/has_trivial_destructor.hpp>
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
# include <type_traits>
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
|
||||
|
||||
using std::is_trivially_copyable;
|
||||
|
||||
#else
|
||||
|
||||
template<class T> struct is_trivially_copyable: boost::integral_constant<bool,
|
||||
boost::has_trivial_copy<T>::value && boost::has_trivial_assign<T>::value && boost::has_trivial_destructor<T>::value> {};
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace detail
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
|
||||
@@ -1,223 +0,0 @@
|
||||
// boost/endian/detail/lightweight_test.hpp --------------------------------------------//
|
||||
|
||||
#ifndef BOOST_ENDIAN_LIGHTWEIGHT_TEST_HPP
|
||||
#define BOOST_ENDIAN_LIGHTWEIGHT_TEST_HPP
|
||||
|
||||
// MS compatible compilers support #pragma once
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# pragma once
|
||||
#endif
|
||||
|
||||
//
|
||||
// Copyright (c) 2002, 2009, 2014 Peter Dimov
|
||||
// Copyright (2) Beman Dawes 2010, 2011, 2015
|
||||
// Copyright (3) Ion Gaztanaga 2013
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
//
|
||||
|
||||
#include <boost/assert.hpp>
|
||||
#include <boost/current_function.hpp>
|
||||
#include <boost/core/no_exceptions_support.hpp>
|
||||
#include <cstring> // for memcmp
|
||||
#include <iostream>
|
||||
|
||||
// IDE's like Visual Studio perform better if output goes to std::cout or
|
||||
// some other stream, so allow user to configure output stream:
|
||||
#ifndef BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
# define BOOST_LIGHTWEIGHT_TEST_OSTREAM std::cerr
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
namespace detail
|
||||
{
|
||||
|
||||
struct report_errors_reminder
|
||||
{
|
||||
bool called_report_errors_function;
|
||||
|
||||
report_errors_reminder() : called_report_errors_function(false) {}
|
||||
|
||||
~report_errors_reminder()
|
||||
{
|
||||
BOOST_ASSERT(called_report_errors_function); // verify report_errors() was called
|
||||
}
|
||||
};
|
||||
|
||||
inline report_errors_reminder& report_errors_remind()
|
||||
{
|
||||
static report_errors_reminder r;
|
||||
return r;
|
||||
}
|
||||
|
||||
inline int & test_errors()
|
||||
{
|
||||
static int x = 0;
|
||||
report_errors_remind();
|
||||
return x;
|
||||
}
|
||||
|
||||
inline void test_failed_impl(char const * expr, char const * file, int line, char const * function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr << "' failed in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
|
||||
inline void error_impl(char const * msg, char const * file, int line, char const * function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): " << msg << " in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
|
||||
inline void throw_failed_impl(char const * excep, char const * file, int line, char const * function)
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): Exception '" << excep << "' not thrown in function '"
|
||||
<< function << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_eq_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t == u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " == " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << t << "' != '" << u << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
template<class T, class U> inline void test_ne_impl( char const * expr1, char const * expr2,
|
||||
char const * file, int line, char const * function, T const & t, U const & u )
|
||||
{
|
||||
if( t != u )
|
||||
{
|
||||
report_errors_remind();
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test '" << expr1 << " != " << expr2
|
||||
<< "' failed in function '" << function << "': "
|
||||
<< "'" << t << "' == '" << u << "'" << std::endl;
|
||||
++test_errors();
|
||||
}
|
||||
}
|
||||
|
||||
template <class T>
|
||||
std::string to_hex(const T& x)
|
||||
{
|
||||
const char hex[] = { '0','1','2','3','4','5','6','7','8','9','a','b','c','d','e','f' };
|
||||
std::string tmp;
|
||||
const unsigned char* p = reinterpret_cast<const unsigned char*>(&x);
|
||||
const unsigned char* e = p + sizeof(T);
|
||||
|
||||
for (; p < e; ++p)
|
||||
{
|
||||
tmp += hex[*p >> 4]; // high-order nibble
|
||||
tmp += hex[*p & 0x0f]; // low-order nibble
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
|
||||
template<class T, class U> inline bool test_memcmp_eq_impl(char const * expr1,
|
||||
char const * expr2, char const * file, int line, char const * function, T const & t,
|
||||
U const & u)
|
||||
{
|
||||
BOOST_ASSERT(sizeof(T) == sizeof(U));
|
||||
if (sizeof(T) == sizeof(U)
|
||||
&& std::memcmp(&t, &u, sizeof(T)) == 0)
|
||||
{
|
||||
report_errors_remind();
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< file << "(" << line << "): test 'std::memcmp(" << expr1 << ", " << expr2
|
||||
<< ") == 0' fails in function '" << function << "': "
|
||||
<< " with values '" << to_hex(t) << "' and '" << to_hex(u) << "'" << std::endl;
|
||||
++test_errors();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
|
||||
inline int report_errors()
|
||||
{
|
||||
boost::endian::detail::report_errors_remind().called_report_errors_function = true;
|
||||
|
||||
int errors = boost::endian::detail::test_errors();
|
||||
|
||||
if( errors == 0 )
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< "No errors detected." << std::endl;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
BOOST_LIGHTWEIGHT_TEST_OSTREAM
|
||||
<< errors << " error" << (errors == 1? "": "s") << " detected." << std::endl;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
// TODO: Should all test macros return bool? See BOOST_TEST_MEM_EQ usage in fp_exaustive_test,cpp
|
||||
//////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
#define BOOST_TEST(expr) \
|
||||
((expr)? (void)0: ::boost::endian::detail::test_failed_impl(#expr, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION))
|
||||
|
||||
#define BOOST_ERROR(msg) \
|
||||
( ::boost::endian::detail::error_impl(msg, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION) )
|
||||
|
||||
#define BOOST_TEST_EQ(expr1,expr2) \
|
||||
( ::boost::endian::detail::test_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
#define BOOST_TEST_NE(expr1,expr2) \
|
||||
( ::boost::endian::detail::test_ne_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2) )
|
||||
|
||||
#define BOOST_TEST_MEM_EQ(expr1,expr2) \
|
||||
(::boost::endian::detail::test_memcmp_eq_impl(#expr1, #expr2, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, expr1, expr2))
|
||||
|
||||
#ifndef BOOST_NO_EXCEPTIONS
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP ) \
|
||||
try { \
|
||||
EXPR; \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
catch(EXCEP const&) { \
|
||||
} \
|
||||
catch(...) { \
|
||||
::boost::detail::throw_failed_impl \
|
||||
(#EXCEP, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION); \
|
||||
} \
|
||||
//
|
||||
#else
|
||||
#define BOOST_TEST_THROWS( EXPR, EXCEP )
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_ENDIAN_LIGHTWEIGHT_TEST_HPP
|
||||
59
linx64/include/boost/endian/detail/order.hpp
Normal file
59
linx64/include/boost/endian/detail/order.hpp
Normal file
@@ -0,0 +1,59 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
|
||||
|
||||
// Copyright 2019 Peter Dimov
|
||||
//
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/core/scoped_enum.hpp>
|
||||
|
||||
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
||||
|
||||
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
|
||||
|
||||
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
|
||||
|
||||
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER big
|
||||
|
||||
#elif defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
|
||||
|
||||
# error The Boost.Endian library does not support platforms with PDP endianness.
|
||||
|
||||
#elif defined(__LITTLE_ENDIAN__)
|
||||
|
||||
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
|
||||
|
||||
#elif defined(__BIG_ENDIAN__)
|
||||
|
||||
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER big
|
||||
|
||||
#elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
|
||||
|
||||
#else
|
||||
|
||||
# error The Boost.Endian library could not determine the endianness of this platform.
|
||||
|
||||
#endif
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
|
||||
BOOST_SCOPED_ENUM_START(order)
|
||||
{
|
||||
big,
|
||||
little,
|
||||
native = BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
|
||||
|
||||
}; BOOST_SCOPED_ENUM_END
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#undef BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
|
||||
|
||||
#endif // BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
|
||||
23
linx64/include/boost/endian/detail/requires_cxx11.hpp
Normal file
23
linx64/include/boost/endian/detail/requires_cxx11.hpp
Normal file
@@ -0,0 +1,23 @@
|
||||
#ifndef BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
#define BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
|
||||
// Copyright 2023 Peter Dimov
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// https://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#include <boost/config.hpp>
|
||||
#include <boost/config/pragma_message.hpp>
|
||||
|
||||
#if defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || \
|
||||
defined(BOOST_NO_CXX11_RVALUE_REFERENCES) || \
|
||||
defined(BOOST_NO_CXX11_DECLTYPE) || \
|
||||
defined(BOOST_NO_CXX11_CONSTEXPR) || \
|
||||
defined(BOOST_NO_CXX11_NOEXCEPT) || \
|
||||
defined(BOOST_NO_CXX11_SCOPED_ENUMS) || \
|
||||
defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS)
|
||||
|
||||
BOOST_PRAGMA_MESSAGE("C++03 support was deprecated in Boost.Endian 1.82 and will be removed in Boost.Endian 1.84. Please open an issue in https://github.com/boostorg/endian if you want it retained.")
|
||||
|
||||
#endif
|
||||
|
||||
#endif // #ifndef BOOST_ENDIAN_DETAIL_REQUIRES_CXX11_HPP_INCLUDED
|
||||
Reference in New Issue
Block a user