forked from boostorg/endian
[cleanup] remove trailing whitespace from source code files
This commit is contained in:
@ -1,4 +1,4 @@
|
|||||||
// endian/example/conversion_use_case.cpp
|
// endian/example/conversion_use_case.cpp
|
||||||
|
|
||||||
// Copyright Beman Dawes 2014
|
// Copyright Beman Dawes 2014
|
||||||
|
|
||||||
@ -47,5 +47,5 @@ int main()
|
|||||||
out_rec.balance = boost::endian::native_to_big(out_rec.balance); // reverse if needed
|
out_rec.balance = boost::endian::native_to_big(out_rec.balance); // reverse if needed
|
||||||
out.write((const char*)&out_rec, sizeof(out_rec));
|
out.write((const char*)&out_rec, sizeof(out_rec));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
using namespace boost::endian;
|
using namespace boost::endian;
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
// This is an extract from a very widely used GIS file format. Why the designer
|
// This is an extract from a very widely used GIS file format. Why the designer
|
||||||
// decided to mix big and little endians in the same file is not known. But
|
// decided to mix big and little endians in the same file is not known. But
|
||||||
@ -39,7 +39,7 @@ namespace
|
|||||||
int main(int, char* [])
|
int main(int, char* [])
|
||||||
{
|
{
|
||||||
header h;
|
header h;
|
||||||
|
|
||||||
BOOST_STATIC_ASSERT(sizeof(h) == 16U); // reality check
|
BOOST_STATIC_ASSERT(sizeof(h) == 16U); // reality check
|
||||||
|
|
||||||
h.file_code = 0x01020304;
|
h.file_code = 0x01020304;
|
||||||
@ -54,7 +54,7 @@ int main(int, char* [])
|
|||||||
// does bulk I/O operations, <cstdio> fopen/fwrite is used for I/O in this example.
|
// does bulk I/O operations, <cstdio> fopen/fwrite is used for I/O in this example.
|
||||||
|
|
||||||
std::FILE* fi = std::fopen(filename, "wb"); // MUST BE BINARY
|
std::FILE* fi = std::fopen(filename, "wb"); // MUST BE BINARY
|
||||||
|
|
||||||
if (!fi)
|
if (!fi)
|
||||||
{
|
{
|
||||||
std::cout << "could not open " << filename << '\n';
|
std::cout << "could not open " << filename << '\n';
|
||||||
|
@ -121,7 +121,7 @@ using std::endl;
|
|||||||
// Recommended approach when conversion time is a concern
|
// Recommended approach when conversion time is a concern
|
||||||
//
|
//
|
||||||
// Conversion time is a concert with this application because (1) any conversions
|
// Conversion time is a concert with this application because (1) any conversions
|
||||||
// performed in the loop will consume a great deal of time and because (2)
|
// performed in the loop will consume a great deal of time and because (2)
|
||||||
// computation time will be much greater than I/O time.
|
// computation time will be much greater than I/O time.
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#ifndef BOOST_ENDIAN_ARITHMETIC_HPP
|
#ifndef BOOST_ENDIAN_ARITHMETIC_HPP
|
||||||
#define BOOST_ENDIAN_ARITHMETIC_HPP
|
#define BOOST_ENDIAN_ARITHMETIC_HPP
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -300,7 +300,7 @@ namespace endian
|
|||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
std::cout << "big, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
||||||
@ -325,7 +325,7 @@ namespace endian
|
|||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
|
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
std::cout << "little, unaligned, " << n_bits << "-bits, construct(" << val << ")\n";
|
||||||
@ -361,7 +361,7 @@ namespace endian
|
|||||||
this->m_value = ::boost::endian::native_to_big(val);
|
this->m_value = ::boost::endian::native_to_big(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
this->m_value = ::boost::endian::native_to_big(val);
|
this->m_value = ::boost::endian::native_to_big(val);
|
||||||
@ -390,7 +390,7 @@ namespace endian
|
|||||||
# endif
|
# endif
|
||||||
this->m_value = ::boost::endian::native_to_little(val);
|
this->m_value = ::boost::endian::native_to_little(val);
|
||||||
}
|
}
|
||||||
# endif
|
# endif
|
||||||
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
endian_arithmetic& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
this->m_value = ::boost::endian::native_to_little(val);
|
this->m_value = ::boost::endian::native_to_little(val);
|
||||||
@ -406,8 +406,8 @@ namespace endian
|
|||||||
# pragma pack(pop)
|
# pragma pack(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // BOOST_ENDIAN_ARITHMETIC_HPP
|
#endif // BOOST_ENDIAN_ARITHMETIC_HPP
|
||||||
|
@ -21,8 +21,8 @@
|
|||||||
#ifndef BOOST_ENDIAN_BUFFERS_HPP
|
#ifndef BOOST_ENDIAN_BUFFERS_HPP
|
||||||
#define BOOST_ENDIAN_BUFFERS_HPP
|
#define BOOST_ENDIAN_BUFFERS_HPP
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -195,7 +195,7 @@ namespace endian
|
|||||||
return os << x.value();
|
return os << x.value();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Stream extractor
|
// Stream extractor
|
||||||
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
|
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
|
||||||
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
|
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
|
||||||
std::basic_istream<charT, traits>&
|
std::basic_istream<charT, traits>&
|
||||||
@ -346,7 +346,7 @@ namespace endian
|
|||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian_buffer(T val) BOOST_NOEXCEPT
|
explicit endian_buffer(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "big, unaligned, "
|
std::cout << "big, unaligned, "
|
||||||
@ -365,7 +365,7 @@ namespace endian
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
value_type value() const BOOST_NOEXCEPT
|
value_type value() const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "big, unaligned, " << n_bits << "-bits, convert("
|
std::cout << "big, unaligned, " << n_bits << "-bits, convert("
|
||||||
@ -388,7 +388,7 @@ namespace endian
|
|||||||
# ifndef BOOST_ENDIAN_NO_CTORS
|
# ifndef BOOST_ENDIAN_NO_CTORS
|
||||||
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
|
||||||
explicit endian_buffer(T val) BOOST_NOEXCEPT
|
explicit endian_buffer(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "little, unaligned, " << n_bits << "-bits, construct("
|
std::cout << "little, unaligned, " << n_bits << "-bits, construct("
|
||||||
@ -400,7 +400,7 @@ namespace endian
|
|||||||
endian_buffer & operator=(T val) BOOST_NOEXCEPT
|
endian_buffer & operator=(T val) BOOST_NOEXCEPT
|
||||||
{ detail::store_little_endian<T, n_bits/8>(m_value, val); return *this; }
|
{ detail::store_little_endian<T, n_bits/8>(m_value, val); return *this; }
|
||||||
value_type value() const BOOST_NOEXCEPT
|
value_type value() const BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_LOG
|
# ifdef BOOST_ENDIAN_LOG
|
||||||
if ( endian_log )
|
if ( endian_log )
|
||||||
std::cout << "little, unaligned, " << n_bits << "-bits, convert("
|
std::cout << "little, unaligned, " << n_bits << "-bits, convert("
|
||||||
@ -435,14 +435,14 @@ namespace endian
|
|||||||
m_value = ::boost::endian::native_to_big(val);
|
m_value = ::boost::endian::native_to_big(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_value = ::boost::endian::native_to_big(val);
|
m_value = ::boost::endian::native_to_big(val);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
//operator value_type() const BOOST_NOEXCEPT
|
//operator value_type() const BOOST_NOEXCEPT
|
||||||
//{
|
//{
|
||||||
// return ::boost::endian::big_to_native(m_value);
|
// return ::boost::endian::big_to_native(m_value);
|
||||||
//}
|
//}
|
||||||
value_type value() const BOOST_NOEXCEPT
|
value_type value() const BOOST_NOEXCEPT
|
||||||
@ -480,7 +480,7 @@ namespace endian
|
|||||||
m_value = ::boost::endian::native_to_little(val);
|
m_value = ::boost::endian::native_to_little(val);
|
||||||
}
|
}
|
||||||
|
|
||||||
# endif
|
# endif
|
||||||
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
endian_buffer& operator=(T val) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
m_value = ::boost::endian::native_to_little(val);
|
m_value = ::boost::endian::native_to_little(val);
|
||||||
@ -508,8 +508,8 @@ namespace endian
|
|||||||
# pragma pack(pop)
|
# pragma pack(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // BOOST_ENDIAN_BUFFERS_HPP
|
#endif // BOOST_ENDIAN_BUFFERS_HPP
|
||||||
|
@ -48,12 +48,12 @@ namespace endian
|
|||||||
// by argument dependent lookup (ADL). //
|
// by argument dependent lookup (ADL). //
|
||||||
// //
|
// //
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
// customization for exact-length arithmetic types. See doc/conversion.html/#FAQ.
|
// customization for exact-length arithmetic types. See doc/conversion.html/#FAQ.
|
||||||
// Note: The omission of a overloads for the arithmetic type (typically long, or
|
// 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
|
// 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.
|
// design decision. Such overloads would be non-portable and thus error prone.
|
||||||
|
|
||||||
inline int8_t endian_reverse(int8_t x) BOOST_NOEXCEPT;
|
inline int8_t endian_reverse(int8_t x) BOOST_NOEXCEPT;
|
||||||
inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT;
|
inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT;
|
||||||
inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT;
|
inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT;
|
||||||
@ -112,7 +112,7 @@ namespace endian
|
|||||||
// //
|
// //
|
||||||
// user-defined types (UDTs) //
|
// 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 //
|
// 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 //
|
// 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 //
|
// customization point for any UDT that provides a "reverse_inplace" free-function //
|
||||||
@ -146,7 +146,7 @@ namespace endian
|
|||||||
// generic conditional reverse in place
|
// generic conditional reverse in place
|
||||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||||
class EndianReversibleInplace>
|
class EndianReversibleInplace>
|
||||||
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
|
||||||
|
|
||||||
// runtime reverse in place
|
// runtime reverse in place
|
||||||
template <class EndianReversibleInplace>
|
template <class EndianReversibleInplace>
|
||||||
@ -199,10 +199,10 @@ namespace endian
|
|||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int16_t endian_reverse(int16_t x) BOOST_NOEXCEPT
|
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)
|
return (static_cast<uint16_t>(x) << 8)
|
||||||
| (static_cast<uint16_t>(x) >> 8);
|
| (static_cast<uint16_t>(x) >> 8);
|
||||||
# else
|
# else
|
||||||
@ -212,7 +212,7 @@ namespace endian
|
|||||||
|
|
||||||
inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT
|
inline int32_t endian_reverse(int32_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||||
uint32_t step16;
|
uint32_t step16;
|
||||||
step16 = static_cast<uint32_t>(x) << 16 | static_cast<uint32_t>(x) >> 16;
|
step16 = static_cast<uint32_t>(x) << 16 | static_cast<uint32_t>(x) >> 16;
|
||||||
return
|
return
|
||||||
@ -225,7 +225,7 @@ namespace endian
|
|||||||
|
|
||||||
inline int64_t endian_reverse(int64_t x) BOOST_NOEXCEPT
|
inline int64_t endian_reverse(int64_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||||
uint64_t step32, step16;
|
uint64_t step32, step16;
|
||||||
step32 = static_cast<uint64_t>(x) << 32 | static_cast<uint64_t>(x) >> 32;
|
step32 = static_cast<uint64_t>(x) << 32 | static_cast<uint64_t>(x) >> 32;
|
||||||
step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16
|
step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16
|
||||||
@ -236,7 +236,7 @@ namespace endian
|
|||||||
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(static_cast<uint64_t>(x));
|
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(static_cast<uint64_t>(x));
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t endian_reverse(uint8_t x) BOOST_NOEXCEPT
|
inline uint8_t endian_reverse(uint8_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
return x;
|
return x;
|
||||||
@ -244,7 +244,7 @@ namespace endian
|
|||||||
|
|
||||||
inline uint16_t endian_reverse(uint16_t x) BOOST_NOEXCEPT
|
inline uint16_t endian_reverse(uint16_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||||
return (x << 8)
|
return (x << 8)
|
||||||
| (x >> 8);
|
| (x >> 8);
|
||||||
# else
|
# else
|
||||||
@ -252,9 +252,9 @@ namespace endian
|
|||||||
# endif
|
# 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;
|
uint32_t step16;
|
||||||
step16 = x << 16 | x >> 16;
|
step16 = x << 16 | x >> 16;
|
||||||
return
|
return
|
||||||
@ -267,7 +267,7 @@ namespace endian
|
|||||||
|
|
||||||
inline uint64_t endian_reverse(uint64_t x) BOOST_NOEXCEPT
|
inline uint64_t endian_reverse(uint64_t x) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
# ifdef BOOST_ENDIAN_NO_INTRINSICS
|
||||||
uint64_t step32, step16;
|
uint64_t step32, step16;
|
||||||
step32 = x << 32 | x >> 32;
|
step32 = x << 32 | x >> 32;
|
||||||
step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16
|
step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16
|
||||||
@ -402,7 +402,7 @@ namespace endian
|
|||||||
|
|
||||||
namespace detail
|
namespace detail
|
||||||
{
|
{
|
||||||
// Primary template and specializations support generic
|
// Primary template and specializations support generic
|
||||||
// endian_reverse_inplace().
|
// endian_reverse_inplace().
|
||||||
// See rationale in endian_reverse_inplace() below.
|
// See rationale in endian_reverse_inplace() below.
|
||||||
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
// See http://www.boost.org/LICENSE_1_0.txt
|
// See http://www.boost.org/LICENSE_1_0.txt
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
#ifndef BOOST_ENDIAN_CONFIG_HPP
|
#ifndef BOOST_ENDIAN_CONFIG_HPP
|
||||||
#define BOOST_ENDIAN_CONFIG_HPP
|
#define BOOST_ENDIAN_CONFIG_HPP
|
||||||
@ -31,14 +31,14 @@
|
|||||||
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ENDIAN_DYN_LINK)
|
#if defined(BOOST_ALL_DYN_LINK) || defined(BOOST_ENDIAN_DYN_LINK)
|
||||||
# if defined(BOOST_ENDIAN_SOURCE)
|
# if defined(BOOST_ENDIAN_SOURCE)
|
||||||
# define BOOST_ENDIAN_DECL BOOST_SYMBOL_EXPORT
|
# define BOOST_ENDIAN_DECL BOOST_SYMBOL_EXPORT
|
||||||
# else
|
# else
|
||||||
# define BOOST_ENDIAN_DECL BOOST_SYMBOL_IMPORT
|
# define BOOST_ENDIAN_DECL BOOST_SYMBOL_IMPORT
|
||||||
# endif
|
# endif
|
||||||
#else
|
#else
|
||||||
# define BOOST_ENDIAN_DECL
|
# define BOOST_ENDIAN_DECL
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// enable automatic library variant selection ----------------------------------------//
|
// enable automatic library variant selection ----------------------------------------//
|
||||||
|
|
||||||
#if !defined(BOOST_ENDIAN_SOURCE) && !defined(BOOST_ALL_NO_LIB) \
|
#if !defined(BOOST_ENDIAN_SOURCE) && !defined(BOOST_ALL_NO_LIB) \
|
||||||
&& !defined(BOOST_ENDIAN_NO_LIB)
|
&& !defined(BOOST_ENDIAN_NO_LIB)
|
||||||
|
@ -9,8 +9,8 @@
|
|||||||
#ifndef BOOST_ENDIAN_COVER_OPERATORS_HPP
|
#ifndef BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||||
#define BOOST_ENDIAN_COVER_OPERATORS_HPP
|
#define BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(push)
|
# pragma warning(push)
|
||||||
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
|
||||||
#endif
|
#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; }
|
||||||
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
|
# endif
|
||||||
|
|
||||||
// The basic arithmetic operations.
|
// The basic arithmetic operations.
|
||||||
friend D& operator+=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
friend D& operator+=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||||
{ return x = static_cast<ArithmeticT>(+x + y); }
|
{ return x = static_cast<ArithmeticT>(+x + y); }
|
||||||
@ -83,13 +83,13 @@ namespace boost
|
|||||||
{ return x = static_cast<ArithmeticT>(+x << y); }
|
{ return x = static_cast<ArithmeticT>(+x << y); }
|
||||||
friend D& operator>>=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
friend D& operator>>=(D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||||
{ return x = static_cast<ArithmeticT>(+x >> y); }
|
{ return x = static_cast<ArithmeticT>(+x >> y); }
|
||||||
|
|
||||||
// A few binary arithmetic operations not covered by operators base class.
|
// A few binary arithmetic operations not covered by operators base class.
|
||||||
friend ArithmeticT operator<<(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
friend ArithmeticT operator<<(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||||
{ return static_cast<ArithmeticT>(+x << y); }
|
{ return static_cast<ArithmeticT>(+x << y); }
|
||||||
friend ArithmeticT operator>>(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
friend ArithmeticT operator>>(const D& x, ArithmeticT y) BOOST_NOEXCEPT
|
||||||
{ return static_cast<ArithmeticT>(+x >> y); }
|
{ return static_cast<ArithmeticT>(+x >> y); }
|
||||||
|
|
||||||
// Auto-increment and auto-decrement can be defined in terms of the
|
// Auto-increment and auto-decrement can be defined in terms of the
|
||||||
// arithmetic operations.
|
// arithmetic operations.
|
||||||
friend D& operator++(D& x) BOOST_NOEXCEPT { return x += 1; }
|
friend D& operator++(D& x) BOOST_NOEXCEPT { return x += 1; }
|
||||||
@ -97,13 +97,13 @@ namespace boost
|
|||||||
|
|
||||||
# ifdef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
# ifdef BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
|
||||||
friend D operator++(D& x, int) BOOST_NOEXCEPT
|
friend D operator++(D& x, int) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
D tmp(x);
|
D tmp(x);
|
||||||
x += 1;
|
x += 1;
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
friend D operator--(D& x, int) BOOST_NOEXCEPT
|
friend D operator--(D& x, int) BOOST_NOEXCEPT
|
||||||
{
|
{
|
||||||
D tmp(x);
|
D tmp(x);
|
||||||
x -= 1;
|
x -= 1;
|
||||||
return tmp;
|
return tmp;
|
||||||
@ -117,10 +117,10 @@ namespace boost
|
|||||||
friend std::basic_ostream<charT, traits>&
|
friend std::basic_ostream<charT, traits>&
|
||||||
operator<<(std::basic_ostream<charT, traits>& os, const D& x)
|
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>
|
template <class charT, class traits>
|
||||||
friend std::basic_istream<charT, traits>&
|
friend std::basic_istream<charT, traits>&
|
||||||
operator>>(std::basic_istream<charT, traits>& is, D& x)
|
operator>>(std::basic_istream<charT, traits>& is, D& x)
|
||||||
@ -135,8 +135,8 @@ namespace boost
|
|||||||
} // namespace endian
|
} // namespace endian
|
||||||
} // namespace boost
|
} // namespace boost
|
||||||
|
|
||||||
#if defined(_MSC_VER)
|
#if defined(_MSC_VER)
|
||||||
# pragma warning(pop)
|
# pragma warning(pop)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif // BOOST_ENDIAN_COVER_OPERATORS_HPP
|
#endif // BOOST_ENDIAN_COVER_OPERATORS_HPP
|
||||||
|
@ -46,7 +46,7 @@
|
|||||||
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
|
# 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_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__)
|
#elif defined(__linux__)
|
||||||
// don't check for obsolete forms defined(linux) and defined(__linux) on the theory that
|
// 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.
|
// 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()
|
~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
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -41,24 +41,24 @@ namespace
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef boost::timer::nanosecond_type nanosecond_t;
|
typedef boost::timer::nanosecond_type nanosecond_t;
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
nanosecond_t benchmark(timee_func timee, const char* msg,
|
nanosecond_t benchmark(timee_func timee, const char* msg,
|
||||||
nanosecond_t overhead = 0)
|
nanosecond_t overhead = 0)
|
||||||
// Returns: total cpu time (i.e. system time + user time)
|
// Returns: total cpu time (i.e. system time + user time)
|
||||||
{
|
{
|
||||||
if (verbose)
|
if (verbose)
|
||||||
cout << "\nRunning benchmark..." << endl;
|
cout << "\nRunning benchmark..." << endl;
|
||||||
int64_t sum = 0;
|
int64_t sum = 0;
|
||||||
boost::timer::cpu_times times;
|
boost::timer::cpu_times times;
|
||||||
nanosecond_t cpu_time;
|
nanosecond_t cpu_time;
|
||||||
boost::timer::auto_cpu_timer t(places);
|
boost::timer::auto_cpu_timer t(places);
|
||||||
|
|
||||||
for (long long i = n_cases; i; --i)
|
for (long long i = n_cases; i; --i)
|
||||||
{
|
{
|
||||||
# ifndef BOOST_TWO_ARG
|
# ifndef BOOST_TWO_ARG
|
||||||
sum += timee(static_cast<int32_t>(i)) ;
|
sum += timee(static_cast<int32_t>(i)) ;
|
||||||
# else
|
# else
|
||||||
int32_t y;
|
int32_t y;
|
||||||
timee(static_cast<int32_t>(i), y);
|
timee(static_cast<int32_t>(i), y);
|
||||||
@ -71,13 +71,13 @@ namespace
|
|||||||
const long double sec = 1000000000.0L;
|
const long double sec = 1000000000.0L;
|
||||||
cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
|
cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
|
||||||
cout.precision(places);
|
cout.precision(places);
|
||||||
cout << msg << " " << cpu_time / sec << endl;
|
cout << msg << " " << cpu_time / sec << endl;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
t.report();
|
t.report();
|
||||||
cout << " Benchmark complete\n"
|
cout << " Benchmark complete\n"
|
||||||
" sum is " << sum << endl;
|
" sum is " << sum << endl;
|
||||||
}
|
}
|
||||||
return cpu_time;
|
return cpu_time;
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ namespace
|
|||||||
n_cases = _atoi64(argv[1]);
|
n_cases = _atoi64(argv[1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (; argc > 2; ++argv, --argc)
|
for (; argc > 2; ++argv, --argc)
|
||||||
{
|
{
|
||||||
if ( *(argv[2]+1) == 'p' )
|
if ( *(argv[2]+1) == 'p' )
|
||||||
places = atoi( argv[2]+2 );
|
places = atoi( argv[2]+2 );
|
||||||
@ -114,7 +114,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
cout << "Usage: benchmark n [Options]\n"
|
cout << "Usage: benchmark n [Options]\n"
|
||||||
" The argument n specifies the number of test cases to run\n"
|
" The argument n specifies the number of test cases to run\n"
|
||||||
@ -211,7 +211,7 @@ namespace
|
|||||||
|
|
||||||
//-------------------------------------- main() ---------------------------------------//
|
//-------------------------------------- main() ---------------------------------------//
|
||||||
|
|
||||||
int main(int argc, char * argv[])
|
int main(int argc, char * argv[])
|
||||||
{
|
{
|
||||||
process_command_line(argc, argv);
|
process_command_line(argc, argv);
|
||||||
|
|
||||||
|
@ -210,16 +210,16 @@ namespace
|
|||||||
be::conditional_reverse_inplace(x, be::order::big, be::order::native);
|
be::conditional_reverse_inplace(x, be::order::big, be::order::native);
|
||||||
BOOST_TEST_EQ(x, native);
|
BOOST_TEST_EQ(x, native);
|
||||||
x = little;
|
x = little;
|
||||||
be::conditional_reverse_inplace(x, be::order::little, be::order::big);
|
be::conditional_reverse_inplace(x, be::order::little, be::order::big);
|
||||||
BOOST_TEST_EQ(x, big);
|
BOOST_TEST_EQ(x, big);
|
||||||
x = little;
|
x = little;
|
||||||
be::conditional_reverse_inplace(x, be::order::little, be::order::native);
|
be::conditional_reverse_inplace(x, be::order::little, be::order::native);
|
||||||
BOOST_TEST_EQ(x, native);
|
BOOST_TEST_EQ(x, native);
|
||||||
x = native;
|
x = native;
|
||||||
be::conditional_reverse_inplace(x, be::order::native, be::order::big);
|
be::conditional_reverse_inplace(x, be::order::native, be::order::big);
|
||||||
BOOST_TEST_EQ(x, big);
|
BOOST_TEST_EQ(x, big);
|
||||||
x = native;
|
x = native;
|
||||||
be::conditional_reverse_inplace(x, be::order::native, be::order::little);
|
be::conditional_reverse_inplace(x, be::order::native, be::order::little);
|
||||||
BOOST_TEST_EQ(x, little);
|
BOOST_TEST_EQ(x, little);
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -270,8 +270,8 @@ namespace
|
|||||||
|
|
||||||
//--------------------------------------------------------------------------------------//
|
//--------------------------------------------------------------------------------------//
|
||||||
|
|
||||||
// User-defined types
|
// User-defined types
|
||||||
|
|
||||||
namespace user
|
namespace user
|
||||||
{
|
{
|
||||||
// UDT1 supplies both endian_reverse and endian_reverse_inplace
|
// UDT1 supplies both endian_reverse and endian_reverse_inplace
|
||||||
@ -331,7 +331,7 @@ namespace
|
|||||||
int cpp_main(int, char * [])
|
int cpp_main(int, char * [])
|
||||||
{
|
{
|
||||||
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
|
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
|
||||||
|
|
||||||
//std::cerr << std::hex;
|
//std::cerr << std::hex;
|
||||||
|
|
||||||
cout << "int8_t" << endl;
|
cout << "int8_t" << endl;
|
||||||
|
@ -29,7 +29,7 @@ union U
|
|||||||
big_int48_t big_48;
|
big_int48_t big_48;
|
||||||
big_int56_t big_56;
|
big_int56_t big_56;
|
||||||
big_int64_t big_64;
|
big_int64_t big_64;
|
||||||
|
|
||||||
big_uint8_t big_u8;
|
big_uint8_t big_u8;
|
||||||
big_uint16_t big_u16;
|
big_uint16_t big_u16;
|
||||||
big_uint24_t big_u24;
|
big_uint24_t big_u24;
|
||||||
@ -38,7 +38,7 @@ union U
|
|||||||
big_uint48_t big_u48;
|
big_uint48_t big_u48;
|
||||||
big_uint56_t big_u56;
|
big_uint56_t big_u56;
|
||||||
big_uint64_t big_u64;
|
big_uint64_t big_u64;
|
||||||
|
|
||||||
little_int8_t little_8;
|
little_int8_t little_8;
|
||||||
little_int16_t little_16;
|
little_int16_t little_16;
|
||||||
little_int24_t little_24;
|
little_int24_t little_24;
|
||||||
@ -47,7 +47,7 @@ union U
|
|||||||
little_int48_t little_48;
|
little_int48_t little_48;
|
||||||
little_int56_t little_56;
|
little_int56_t little_56;
|
||||||
little_int64_t little_64;
|
little_int64_t little_64;
|
||||||
|
|
||||||
little_uint8_t little_u8;
|
little_uint8_t little_u8;
|
||||||
little_uint16_t little_u16;
|
little_uint16_t little_u16;
|
||||||
little_uint24_t little_u24;
|
little_uint24_t little_u24;
|
||||||
@ -56,7 +56,7 @@ union U
|
|||||||
little_uint48_t little_u48;
|
little_uint48_t little_u48;
|
||||||
little_uint56_t little_u56;
|
little_uint56_t little_u56;
|
||||||
little_uint64_t little_u64;
|
little_uint64_t little_u64;
|
||||||
|
|
||||||
native_int8_t native_8;
|
native_int8_t native_8;
|
||||||
native_int16_t native_16;
|
native_int16_t native_16;
|
||||||
native_int24_t native_24;
|
native_int24_t native_24;
|
||||||
@ -65,7 +65,7 @@ union U
|
|||||||
native_int48_t native_48;
|
native_int48_t native_48;
|
||||||
native_int56_t native_56;
|
native_int56_t native_56;
|
||||||
native_int64_t native_64;
|
native_int64_t native_64;
|
||||||
|
|
||||||
native_uint8_t native_u8;
|
native_uint8_t native_u8;
|
||||||
native_uint16_t native_u16;
|
native_uint16_t native_u16;
|
||||||
native_uint24_t native_u24;
|
native_uint24_t native_u24;
|
||||||
|
@ -489,7 +489,7 @@ int cpp_main(int, char * [])
|
|||||||
be::endian_log = false;
|
be::endian_log = false;
|
||||||
|
|
||||||
test_inserter_and_extractor();
|
test_inserter_and_extractor();
|
||||||
|
|
||||||
// perform the indicated test on ~60*60 operand types
|
// perform the indicated test on ~60*60 operand types
|
||||||
|
|
||||||
op_test<default_construct>();
|
op_test<default_construct>();
|
||||||
|
@ -59,7 +59,7 @@ namespace
|
|||||||
cout << " A structure with an expected sizeof() " << expected
|
cout << " A structure with an expected sizeof() " << expected
|
||||||
<< " had an actual sizeof() " << actual
|
<< " had an actual sizeof() " << actual
|
||||||
<< "\n This will cause uses of endian types to fail\n";
|
<< "\n This will cause uses of endian types to fail\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
template <class Endian, class Base>
|
template <class Endian, class Base>
|
||||||
void verify_value_and_ops( const Base & expected, int line )
|
void verify_value_and_ops( const Base & expected, int line )
|
||||||
@ -112,13 +112,13 @@ namespace
|
|||||||
void detect_order()
|
void detect_order()
|
||||||
{
|
{
|
||||||
union View
|
union View
|
||||||
{
|
{
|
||||||
long long i;
|
long long i;
|
||||||
unsigned char c[8];
|
unsigned char c[8];
|
||||||
};
|
};
|
||||||
|
|
||||||
View v = { 0x0102030405060708LL }; // initialize v.i
|
View v = { 0x0102030405060708LL }; // initialize v.i
|
||||||
|
|
||||||
if ( memcmp( v.c, "\x8\7\6\5\4\3\2\1", 8) == 0 )
|
if ( memcmp( v.c, "\x8\7\6\5\4\3\2\1", 8) == 0 )
|
||||||
{
|
{
|
||||||
cout << "This machine is little-endian.\n";
|
cout << "This machine is little-endian.\n";
|
||||||
@ -128,7 +128,7 @@ namespace
|
|||||||
"Please report this problem to the Boost mailing list.\n";
|
"Please report this problem to the Boost mailing list.\n";
|
||||||
exit(1);
|
exit(1);
|
||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
else if ( memcmp( v.c, "\1\2\3\4\5\6\7\x8", 8) == 0 )
|
else if ( memcmp( v.c, "\1\2\3\4\5\6\7\x8", 8) == 0 )
|
||||||
{
|
{
|
||||||
cout << "This machine is big-endian.\n";
|
cout << "This machine is big-endian.\n";
|
||||||
@ -140,7 +140,7 @@ namespace
|
|||||||
# endif
|
# endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
cout << "This machine is neither strict big-endian nor strict little-endian\n"
|
cout << "This machine is neither strict big-endian nor strict little-endian\n"
|
||||||
"The Boost Endian library must be revised to work correctly on this system.\n"
|
"The Boost Endian library must be revised to work correctly on this system.\n"
|
||||||
"Please report this problem to the Boost mailing list.\n";
|
"Please report this problem to the Boost mailing list.\n";
|
||||||
@ -292,7 +292,7 @@ namespace
|
|||||||
VERIFY(little_align_uint16.data() == reinterpret_cast<const char *>(&little_align_uint16));
|
VERIFY(little_align_uint16.data() == reinterpret_cast<const char *>(&little_align_uint16));
|
||||||
VERIFY(little_align_uint32.data() == reinterpret_cast<const char *>(&little_align_uint32));
|
VERIFY(little_align_uint32.data() == reinterpret_cast<const char *>(&little_align_uint32));
|
||||||
VERIFY(little_align_uint64.data() == reinterpret_cast<const char *>(&little_align_uint64));
|
VERIFY(little_align_uint64.data() == reinterpret_cast<const char *>(&little_align_uint64));
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check_size ------------------------------------------------------------//
|
// check_size ------------------------------------------------------------//
|
||||||
@ -475,7 +475,7 @@ namespace
|
|||||||
};
|
};
|
||||||
|
|
||||||
// aligned test cases
|
// aligned test cases
|
||||||
|
|
||||||
struct big_aligned_struct
|
struct big_aligned_struct
|
||||||
{
|
{
|
||||||
big_int16_at v0;
|
big_int16_at v0;
|
||||||
@ -484,7 +484,7 @@ namespace
|
|||||||
// on a 32-bit system, the padding here may be 3 rather than 7 bytes
|
// on a 32-bit system, the padding here may be 3 rather than 7 bytes
|
||||||
big_int64_at v4;
|
big_int64_at v4;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct little_aligned_struct
|
struct little_aligned_struct
|
||||||
{
|
{
|
||||||
little_int16_at v0;
|
little_int16_at v0;
|
||||||
@ -506,7 +506,7 @@ namespace
|
|||||||
VERIFY( sizeof(little_aligned_struct) <= 24 );
|
VERIFY( sizeof(little_aligned_struct) <= 24 );
|
||||||
|
|
||||||
if ( saved_err_count == err_count )
|
if ( saved_err_count == err_count )
|
||||||
{
|
{
|
||||||
cout <<
|
cout <<
|
||||||
"Size and alignment for structures of endian types are as expected.\n";
|
"Size and alignment for structures of endian types are as expected.\n";
|
||||||
}
|
}
|
||||||
@ -760,7 +760,7 @@ namespace
|
|||||||
}
|
}
|
||||||
|
|
||||||
long iterations = 10000;
|
long iterations = 10000;
|
||||||
|
|
||||||
template< class Endian >
|
template< class Endian >
|
||||||
Endian timing_test( const char * s)
|
Endian timing_test( const char * s)
|
||||||
{
|
{
|
||||||
|
@ -67,7 +67,7 @@ namespace
|
|||||||
n = _atoi64(argv[1]);
|
n = _atoi64(argv[1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (; argc > 2; ++argv, --argc)
|
for (; argc > 2; ++argv, --argc)
|
||||||
{
|
{
|
||||||
if ( *(argv[2]+1) == 'p' )
|
if ( *(argv[2]+1) == 'p' )
|
||||||
places = atoi( argv[2]+2 );
|
places = atoi( argv[2]+2 );
|
||||||
@ -91,7 +91,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
cout << "Usage: loop_time_test n [Options]\n"
|
cout << "Usage: loop_time_test n [Options]\n"
|
||||||
" The argument n specifies the number of test cases to run\n"
|
" The argument n specifies the number of test cases to run\n"
|
||||||
@ -128,7 +128,7 @@ namespace
|
|||||||
void time()
|
void time()
|
||||||
{
|
{
|
||||||
T total = 0;
|
T total = 0;
|
||||||
{
|
{
|
||||||
// cout << "*************Endian integer approach...\n";
|
// cout << "*************Endian integer approach...\n";
|
||||||
EndianT x(0);
|
EndianT x(0);
|
||||||
boost::timer::cpu_timer t;
|
boost::timer::cpu_timer t;
|
||||||
@ -140,7 +140,7 @@ namespace
|
|||||||
total += x;
|
total += x;
|
||||||
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
|
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
|
||||||
}
|
}
|
||||||
{
|
{
|
||||||
// cout << "***************Endian conversion approach...\n";
|
// cout << "***************Endian conversion approach...\n";
|
||||||
T x(0);
|
T x(0);
|
||||||
boost::timer::cpu_timer t;
|
boost::timer::cpu_timer t;
|
||||||
@ -158,7 +158,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void test_big_align_int16()
|
void test_big_align_int16()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>16-bit aligned big endian</td>";
|
cout << "<tr><td>16-bit aligned big endian</td>";
|
||||||
@ -186,7 +186,7 @@ namespace
|
|||||||
time<int16_t, little_int16_t>();
|
time<int16_t, little_int16_t>();
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_big_align_int32()
|
void test_big_align_int32()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>32-bit aligned big endian</td>";
|
cout << "<tr><td>32-bit aligned big endian</td>";
|
||||||
@ -214,7 +214,7 @@ namespace
|
|||||||
time<int32_t, little_int32_t>();
|
time<int32_t, little_int32_t>();
|
||||||
cout << "</tr>\n";
|
cout << "</tr>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_big_align_int64()
|
void test_big_align_int64()
|
||||||
{
|
{
|
||||||
cout << "<tr><td>64-bit aligned big endian</td>";
|
cout << "<tr><td>64-bit aligned big endian</td>";
|
||||||
@ -250,10 +250,10 @@ namespace
|
|||||||
int cpp_main(int argc, char* argv[])
|
int cpp_main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
process_command_line(argc, argv);
|
process_command_line(argc, argv);
|
||||||
|
|
||||||
cout
|
cout
|
||||||
<< "<html>\n<head>\n<title>Endian Loop Time Test</title>\n</head>\n<body>\n"
|
<< "<html>\n<head>\n<title>Endian Loop Time Test</title>\n</head>\n<body>\n"
|
||||||
<< "<!-- boost-no-inspect -->\n"
|
<< "<!-- boost-no-inspect -->\n"
|
||||||
<< "<div align=\"center\"> <center>\n"
|
<< "<div align=\"center\"> <center>\n"
|
||||||
<< "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\""
|
<< "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\""
|
||||||
<< "style=\"border-collapse: collapse\" bordercolor=\"#111111\">\n"
|
<< "style=\"border-collapse: collapse\" bordercolor=\"#111111\">\n"
|
||||||
@ -268,7 +268,7 @@ int cpp_main(int argc, char* argv[])
|
|||||||
"<td align=\"center\"><b>Endian<br>conversion<br>function</b></td>\n"
|
"<td align=\"center\"><b>Endian<br>conversion<br>function</b></td>\n"
|
||||||
"</tr>\n"
|
"</tr>\n"
|
||||||
;
|
;
|
||||||
|
|
||||||
if (time_aligned)
|
if (time_aligned)
|
||||||
{
|
{
|
||||||
if (time_16)
|
if (time_16)
|
||||||
|
@ -53,7 +53,7 @@ namespace
|
|||||||
n = _atoi64(argv[1]);
|
n = _atoi64(argv[1]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
for (; argc > 2; ++argv, --argc)
|
for (; argc > 2; ++argv, --argc)
|
||||||
{
|
{
|
||||||
if ( *(argv[2]+1) == 'p' )
|
if ( *(argv[2]+1) == 'p' )
|
||||||
places = atoi( argv[2]+2 );
|
places = atoi( argv[2]+2 );
|
||||||
@ -67,7 +67,7 @@ namespace
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc < 2)
|
if (argc < 2)
|
||||||
{
|
{
|
||||||
cout << "Usage: speed_test n [Options]\n"
|
cout << "Usage: speed_test n [Options]\n"
|
||||||
" The argument n specifies the number of test cases to run\n"
|
" The argument n specifies the number of test cases to run\n"
|
||||||
@ -85,7 +85,7 @@ namespace
|
|||||||
{
|
{
|
||||||
T x(0);
|
T x(0);
|
||||||
EndianT y(0);
|
EndianT y(0);
|
||||||
boost::timer::cpu_timer t;
|
boost::timer::cpu_timer t;
|
||||||
for (uint64_t i = 0; i < n; ++i)
|
for (uint64_t i = 0; i < n; ++i)
|
||||||
{
|
{
|
||||||
f(x, y);
|
f(x, y);
|
||||||
@ -161,7 +161,7 @@ namespace
|
|||||||
int cpp_main(int argc, char* argv[])
|
int cpp_main(int argc, char* argv[])
|
||||||
{
|
{
|
||||||
process_command_line(argc, argv);
|
process_command_line(argc, argv);
|
||||||
|
|
||||||
cout
|
cout
|
||||||
<< "<html>\n<head>\n<title>Endian Speed Test</title>\n</head>\n<body>\n"
|
<< "<html>\n<head>\n<title>Endian Speed Test</title>\n</head>\n<body>\n"
|
||||||
<< "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\""
|
<< "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\""
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
// speed_test_functions.cpp ----------------------------------------------------------//
|
// speed_test_functions.cpp ----------------------------------------------------------//
|
||||||
|
|
||||||
// Copyright Beman Dawes 2013
|
// Copyright Beman Dawes 2013
|
||||||
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
Reference in New Issue
Block a user