forked from boostorg/endian
Delete the original conversion.hpp.
Rename conversion2.hpp to converters.hpp. Adjust infrastructure accordingly.
This commit is contained in:
@@ -1,222 +0,0 @@
|
||||
// boost/endian/conversion.hpp -------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2010, 2011
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
#ifndef BOOST_ENDIAN_CONVERSION_HPP
|
||||
#define BOOST_ENDIAN_CONVERSION_HPP
|
||||
|
||||
#include <boost/detail/endian.hpp>
|
||||
#include <boost/cstdint.hpp>
|
||||
|
||||
//------------------------------------- synopsis ---------------------------------------//
|
||||
|
||||
namespace boost
|
||||
{
|
||||
namespace endian
|
||||
{
|
||||
// unconditional modifying (i.e. in-place) reverse byte order
|
||||
|
||||
inline void reorder(int16_t& x);
|
||||
inline void reorder(int32_t& x);
|
||||
inline void reorder(int64_t& x);
|
||||
inline void reorder(uint16_t& x);
|
||||
inline void reorder(uint32_t& x);
|
||||
inline void reorder(uint64_t& x);
|
||||
|
||||
// unconditional non-modifying reverse byte order copy
|
||||
|
||||
inline void reorder(int16_t source, int16_t& target);
|
||||
inline void reorder(int32_t source, int32_t& target);
|
||||
inline void reorder(int64_t source, int64_t& target);
|
||||
inline void reorder(uint16_t source, uint16_t& target);
|
||||
inline void reorder(uint32_t source, uint32_t& target);
|
||||
inline void reorder(uint64_t source, uint64_t& target);
|
||||
|
||||
// conditional modifying (i.e. in-place) reverse byte order;
|
||||
// no effect if native endianness and indicated endianness are the same
|
||||
|
||||
template <class T> inline void native_to_big(T& x);
|
||||
template <class T> inline void native_to_little(T& x);
|
||||
template <class T> inline void big_to_native(T& x);
|
||||
template <class T> inline void little_to_native(T& x);
|
||||
|
||||
// non-modifying conditional reverse byte order copy;
|
||||
// copy the source argument to the target argument, converting to or from the
|
||||
// indicated endianness if different than native endianness
|
||||
|
||||
template <class T> inline void native_to_big(T source, T& target);
|
||||
template <class T> inline void native_to_little(T source, T& target);
|
||||
template <class T> inline void big_to_native(T source, T& target);
|
||||
template <class T> inline void little_to_native(T source, T& target);
|
||||
|
||||
//----------------------------------- implementation -----------------------------------//
|
||||
|
||||
inline void reorder(int16_t& x)
|
||||
{
|
||||
char* rep = reinterpret_cast<char*>(&x);
|
||||
char tmp;
|
||||
tmp = *rep;
|
||||
*rep = *(rep+1);
|
||||
*(rep+1) = tmp;
|
||||
}
|
||||
|
||||
inline void reorder(int32_t& x)
|
||||
{
|
||||
char* rep = reinterpret_cast<char*>(&x);
|
||||
char tmp;
|
||||
tmp = *rep;
|
||||
*rep = *(rep+3);
|
||||
*(rep+3) = tmp;
|
||||
tmp = *(rep+1);
|
||||
*(rep+1) = *(rep+2);
|
||||
*(rep+2) = tmp;
|
||||
}
|
||||
|
||||
inline void reorder(int64_t& x)
|
||||
{
|
||||
char* rep = reinterpret_cast<char*>(&x);
|
||||
char tmp;
|
||||
tmp = *rep;
|
||||
*rep = *(rep+7);
|
||||
*(rep+7) = tmp;
|
||||
tmp = *(rep+1);
|
||||
*(rep+1) = *(rep+6);
|
||||
*(rep+6) = tmp;
|
||||
tmp = *(rep+2);
|
||||
*(rep+2) = *(rep+5);
|
||||
*(rep+5) = tmp;
|
||||
tmp = *(rep+3);
|
||||
*(rep+3) = *(rep+4);
|
||||
*(rep+4) = tmp;
|
||||
}
|
||||
|
||||
inline void reorder(uint16_t& x)
|
||||
{
|
||||
char* rep = reinterpret_cast<char*>(&x);
|
||||
char tmp;
|
||||
tmp = *rep;
|
||||
*rep = *(rep+1);
|
||||
*(rep+1) = tmp;
|
||||
}
|
||||
|
||||
inline void reorder(uint32_t& x)
|
||||
{
|
||||
char* rep = reinterpret_cast<char*>(&x);
|
||||
char tmp;
|
||||
tmp = *rep;
|
||||
*rep = *(rep+3);
|
||||
*(rep+3) = tmp;
|
||||
tmp = *(rep+1);
|
||||
*(rep+1) = *(rep+2);
|
||||
*(rep+2) = tmp;
|
||||
}
|
||||
|
||||
inline void reorder(uint64_t& x)
|
||||
{
|
||||
char* rep = reinterpret_cast<char*>(&x);
|
||||
char tmp;
|
||||
tmp = *rep;
|
||||
*rep = *(rep+7);
|
||||
*(rep+7) = tmp;
|
||||
tmp = *(rep+1);
|
||||
*(rep+1) = *(rep+6);
|
||||
*(rep+6) = tmp;
|
||||
tmp = *(rep+2);
|
||||
*(rep+2) = *(rep+5);
|
||||
*(rep+5) = tmp;
|
||||
tmp = *(rep+3);
|
||||
*(rep+3) = *(rep+4);
|
||||
*(rep+4) = tmp;
|
||||
}
|
||||
|
||||
inline void reorder(int16_t source, int16_t& target)
|
||||
{
|
||||
const char* s (reinterpret_cast<const char*>(&source));
|
||||
char * t (reinterpret_cast<char*>(&target) + sizeof(target) - 1);
|
||||
*t = *s;
|
||||
*--t = *++s;
|
||||
}
|
||||
|
||||
inline void reorder(int32_t source, int32_t& target)
|
||||
{
|
||||
const char* s (reinterpret_cast<const char*>(&source));
|
||||
char * t (reinterpret_cast<char*>(&target) + sizeof(target) - 1);
|
||||
*t = *s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
}
|
||||
|
||||
inline void reorder(int64_t source, int64_t& target)
|
||||
{
|
||||
const char* s (reinterpret_cast<const char*>(&source));
|
||||
char * t (reinterpret_cast<char*>(&target) + sizeof(target) - 1);
|
||||
*t = *s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
}
|
||||
|
||||
inline void reorder(uint16_t source, uint16_t& target)
|
||||
{
|
||||
const char* s (reinterpret_cast<const char*>(&source));
|
||||
char * t (reinterpret_cast<char*>(&target) + sizeof(target) - 1);
|
||||
*t = *s;
|
||||
*--t = *++s;
|
||||
}
|
||||
|
||||
inline void reorder(uint32_t source, uint32_t& target)
|
||||
{
|
||||
const char* s (reinterpret_cast<const char*>(&source));
|
||||
char * t (reinterpret_cast<char*>(&target) + sizeof(target) - 1);
|
||||
*t = *s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
}
|
||||
|
||||
inline void reorder(uint64_t source, uint64_t& target)
|
||||
{
|
||||
const char* s (reinterpret_cast<const char*>(&source));
|
||||
char * t (reinterpret_cast<char*>(&target) + sizeof(target) - 1);
|
||||
*t = *s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
*--t = *++s;
|
||||
}
|
||||
|
||||
#ifdef BOOST_LITTLE_ENDIAN
|
||||
template <class T> inline void native_to_big(T& x) { reorder(x); }
|
||||
template <class T> inline void native_to_little(T&) {}
|
||||
template <class T> inline void big_to_native(T& x) { reorder(x); }
|
||||
template <class T> inline void little_to_native(T&) {}
|
||||
template <class T> inline void native_to_big(T source, T& target) { reorder(source, target); }
|
||||
template <class T> inline void native_to_little(T source, T& target) { target = source; }
|
||||
template <class T> inline void big_to_native(T source, T& target) { reorder(source, target); }
|
||||
template <class T> inline void little_to_native(T source, T& target) { target = source; }
|
||||
#else
|
||||
template <class T> inline void native_to_big(T&) {}
|
||||
template <class T> inline void native_to_little(T& x) { reorder(x); }
|
||||
template <class T> inline void big_to_native(T&) {}
|
||||
template <class T> inline void little_to_native(T& x) { reorder(x); }
|
||||
template <class T> inline void native_to_big(T native, T& big) { target = source; }
|
||||
template <class T> inline void native_to_little(T native, T& little) { reorder(source, target); }
|
||||
template <class T> inline void big_to_native(T big, T& native) { target = source; }
|
||||
template <class T> inline void little_to_native(T little, T& native) { reorder(source, target); }
|
||||
#endif
|
||||
|
||||
} // namespace endian
|
||||
} // namespace boost
|
||||
|
||||
#endif // BOOST_ENDIAN_CONVERSION_HPP
|
@@ -21,6 +21,5 @@ project
|
||||
]
|
||||
[ run endian_operations_test.cpp ]
|
||||
[ run endian_in_union_test.cpp ]
|
||||
[ run conversion_test.cpp ]
|
||||
[ run conversion2_test.cpp ]
|
||||
[ run converter_test.cpp ]
|
||||
;
|
||||
|
@@ -1,442 +0,0 @@
|
||||
// conversion_test.cpp ---------------------------------------------------------------//
|
||||
|
||||
// Copyright Beman Dawes 2010
|
||||
|
||||
// Distributed under the Boost Software License, Version 1.0.
|
||||
// See http://www.boost.org/LICENSE_1_0.txt
|
||||
|
||||
//--------------------------------------------------------------------------------------//
|
||||
|
||||
#include <boost/endian/detail/disable_warnings.hpp>
|
||||
|
||||
#include <boost/endian/conversion.hpp>
|
||||
#include <boost/detail/lightweight_main.hpp>
|
||||
#include <boost/detail/lightweight_test.hpp>
|
||||
#include <iostream>
|
||||
|
||||
namespace be = boost::endian;
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
void test_in_place_reorder()
|
||||
{
|
||||
std::cout << "test_in_place_reorder...\n";
|
||||
|
||||
boost::int64_t i64 = 0x0102030405060708LL;
|
||||
be::reorder(i64);
|
||||
BOOST_TEST_EQ(i64, 0x0807060504030201LL);
|
||||
be::reorder(i64);
|
||||
BOOST_TEST_EQ(i64, 0x0102030405060708LL);
|
||||
|
||||
i64 = 0xfefdfcfbfaf9f8f7LL;
|
||||
be::reorder(i64);
|
||||
BOOST_TEST_EQ(i64, static_cast<boost::int64_t>(0xf7f8f9fafbfcfdfeULL));
|
||||
be::reorder(i64);
|
||||
BOOST_TEST_EQ(i64, static_cast<boost::int64_t>(0xfefdfcfbfaf9f8f7ULL));
|
||||
|
||||
boost::int32_t i32 = 0x01020304;
|
||||
be::reorder(i32);
|
||||
BOOST_TEST_EQ(i32, 0x04030201);
|
||||
be::reorder(i32);
|
||||
BOOST_TEST_EQ(i32, 0x01020304);
|
||||
|
||||
i32 = 0xfefdfcfb;
|
||||
be::reorder(i32);
|
||||
BOOST_TEST_EQ(i32, static_cast<boost::int32_t>(0xfbfcfdfe));
|
||||
be::reorder(i32);
|
||||
BOOST_TEST_EQ(i32, static_cast<boost::int32_t>(0xfefdfcfb));
|
||||
|
||||
boost::int16_t i16 = 0x0102;
|
||||
be::reorder(i16);
|
||||
BOOST_TEST_EQ(i16, 0x0201);
|
||||
be::reorder(i16);
|
||||
BOOST_TEST_EQ(i16, 0x0102);
|
||||
|
||||
i16 = static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd));
|
||||
be::reorder(i16);
|
||||
BOOST_TEST_EQ(i16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfdfe)));
|
||||
be::reorder(i16);
|
||||
BOOST_TEST_EQ(i16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd)));
|
||||
|
||||
boost::uint64_t ui64 = 0x0102030405060708ULL;
|
||||
be::reorder(ui64);
|
||||
BOOST_TEST_EQ(ui64, 0x0807060504030201ULL);
|
||||
be::reorder(ui64);
|
||||
BOOST_TEST_EQ(ui64, 0x0102030405060708ULL);
|
||||
|
||||
boost::uint32_t ui32 = 0x01020304;
|
||||
be::reorder(ui32);
|
||||
BOOST_TEST_EQ(ui32, static_cast<boost::uint32_t>(0x04030201));
|
||||
be::reorder(ui32);
|
||||
BOOST_TEST_EQ(ui32, static_cast<boost::uint32_t>(0x01020304));
|
||||
|
||||
boost::uint16_t ui16 = 0x0102;
|
||||
be::reorder(ui16);
|
||||
BOOST_TEST_EQ(ui16, 0x0201);
|
||||
be::reorder(ui16);
|
||||
BOOST_TEST_EQ(ui16, static_cast<boost::uint16_t>(0x0102));
|
||||
|
||||
std::cout << " test_in_place_reorder complete\n";
|
||||
}
|
||||
|
||||
void test_copying_reorder()
|
||||
{
|
||||
std::cout << "test_copying_reorder...\n";
|
||||
|
||||
boost::int64_t i64 = 0x0102030405060708LL, j64, k64;
|
||||
be::reorder(i64, j64);
|
||||
BOOST_TEST_EQ(j64, 0x0807060504030201LL);
|
||||
BOOST_TEST_EQ(i64, 0x0102030405060708LL);
|
||||
be::reorder(j64, k64);
|
||||
BOOST_TEST_EQ(k64, 0x0102030405060708LL);
|
||||
|
||||
i64 = 0xfefdfcfbfaf9f8f7LL;
|
||||
be::reorder(i64, j64);
|
||||
BOOST_TEST_EQ(j64, static_cast<boost::int64_t>(0xf7f8f9fafbfcfdfeLL));
|
||||
be::reorder(j64, k64);
|
||||
BOOST_TEST_EQ(k64, static_cast<boost::int64_t>(0xfefdfcfbfaf9f8f7LL));
|
||||
|
||||
boost::int32_t i32 = 0x01020304, j32, k32;
|
||||
be::reorder(i32, j32);
|
||||
BOOST_TEST_EQ(j32, 0x04030201);
|
||||
be::reorder(j32, k32);
|
||||
BOOST_TEST_EQ(k32, 0x01020304);
|
||||
|
||||
i32 = 0xfefdfcfb;
|
||||
be::reorder(i32, j32);
|
||||
BOOST_TEST_EQ(j32, static_cast<boost::int32_t>(0xfbfcfdfe));
|
||||
be::reorder(j32, k32);
|
||||
BOOST_TEST_EQ(k32, static_cast<boost::int32_t>(0xfefdfcfb));
|
||||
|
||||
boost::int16_t i16 = 0x0102, j16, k16;
|
||||
be::reorder(i16, j16);
|
||||
BOOST_TEST_EQ(j16, 0x0201);
|
||||
be::reorder(j16, k16);
|
||||
BOOST_TEST_EQ(k16, 0x0102);
|
||||
|
||||
i16 = static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd));
|
||||
be::reorder(i16, j16);
|
||||
BOOST_TEST_EQ(j16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfdfe)));
|
||||
be::reorder(j16, k16);
|
||||
BOOST_TEST_EQ(k16, static_cast<boost::int16_t>(static_cast<boost::uint16_t>(0xfefd)));
|
||||
|
||||
boost::uint64_t ui64 = 0x0102030405060708ULL, uj64, uk64;
|
||||
be::reorder(ui64, uj64);
|
||||
BOOST_TEST_EQ(uj64, 0x0807060504030201ULL);
|
||||
be::reorder(uj64, uk64);
|
||||
BOOST_TEST_EQ(uk64, 0x0102030405060708ULL);
|
||||
|
||||
boost::uint32_t ui32 = 0x01020304, uj32, uk32;
|
||||
be::reorder(ui32, uj32);
|
||||
BOOST_TEST_EQ(uj32, static_cast<boost::uint32_t>(0x04030201));
|
||||
be::reorder(uj32, uk32);
|
||||
BOOST_TEST_EQ(uk32, static_cast<boost::uint32_t>(0x01020304));
|
||||
|
||||
boost::uint16_t ui16 = 0x0102, uj16, uk16;
|
||||
be::reorder(ui16, uj16);
|
||||
BOOST_TEST_EQ(uj16, 0x0201);
|
||||
be::reorder(uj16, uk16);
|
||||
BOOST_TEST_EQ(uk16, 0x0102);
|
||||
|
||||
std::cout << " test_copying_reorder complete\n";
|
||||
}
|
||||
|
||||
const boost::int64_t ni64 = 0x0102030405060708LL;
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
const boost::int64_t bi64 = 0x0102030405060708LL;
|
||||
const boost::int64_t li64 = 0x0807060504030201LL;
|
||||
# else
|
||||
const boost::int64_t bi64 = 0x0807060504030201LL;
|
||||
const boost::int64_t li64 = 0x0102030405060708LL;
|
||||
# endif
|
||||
|
||||
const boost::int32_t ni32 = 0x01020304;
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
const boost::int32_t bi32 = 0x01020304;
|
||||
const boost::int32_t li32 = 0x04030201;
|
||||
# else
|
||||
const boost::int32_t bi32 = 0x04030201;
|
||||
const boost::int32_t li32 = 0x01020304;
|
||||
# endif
|
||||
|
||||
const boost::int16_t ni16 = 0x0102;
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
const boost::int16_t bi16 = 0x0102;
|
||||
const boost::int16_t li16 = 0x0201;
|
||||
# else
|
||||
const boost::int16_t bi16 = 0x0201;
|
||||
const boost::int16_t li16 = 0x0102;
|
||||
# endif
|
||||
|
||||
const boost::uint64_t nui64 = 0x0102030405060708ULL;
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
const boost::uint64_t bui64 = 0x0102030405060708ULL;
|
||||
const boost::uint64_t lui64 = 0x0807060504030201ULL;
|
||||
# else
|
||||
const boost::uint64_t bui64 = 0x0807060504030201ULL;
|
||||
const boost::uint64_t lui64 = 0x0102030405060708ULL;
|
||||
# endif
|
||||
|
||||
const boost::uint32_t nui32 = 0x01020304;
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
const boost::uint32_t bui32 = 0x01020304;
|
||||
const boost::uint32_t lui32 = 0x04030201;
|
||||
# else
|
||||
const boost::uint32_t bui32 = 0x04030201;
|
||||
const boost::uint32_t lui32 = 0x01020304;
|
||||
# endif
|
||||
|
||||
const boost::uint16_t nui16 = 0x0102;
|
||||
# ifdef BOOST_BIG_ENDIAN
|
||||
const boost::uint16_t bui16 = 0x0102;
|
||||
const boost::uint16_t lui16 = 0x0201;
|
||||
# else
|
||||
const boost::uint16_t bui16 = 0x0201;
|
||||
const boost::uint16_t lui16 = 0x0102;
|
||||
# endif
|
||||
|
||||
void test_in_place_conditional_reorder()
|
||||
{
|
||||
std::cout << "test_in_place_conditional_reorder...\n";
|
||||
|
||||
boost::int64_t i64;
|
||||
|
||||
i64 = ni64;
|
||||
be::native_to_big(i64);
|
||||
BOOST_TEST_EQ(i64, bi64);
|
||||
|
||||
i64 = ni64;
|
||||
be::native_to_little(i64);
|
||||
BOOST_TEST_EQ(i64, li64);
|
||||
|
||||
i64 = bi64;
|
||||
be::big_to_native(i64);
|
||||
BOOST_TEST_EQ(i64, ni64);
|
||||
|
||||
i64 = li64;
|
||||
be::little_to_native(i64);
|
||||
BOOST_TEST_EQ(i64, ni64);
|
||||
|
||||
boost::uint64_t ui64;
|
||||
|
||||
ui64 = nui64;
|
||||
be::native_to_big(ui64);
|
||||
BOOST_TEST_EQ(ui64, bui64);
|
||||
|
||||
ui64 = nui64;
|
||||
be::native_to_little(ui64);
|
||||
BOOST_TEST_EQ(ui64, lui64);
|
||||
|
||||
ui64 = bui64;
|
||||
be::big_to_native(ui64);
|
||||
BOOST_TEST_EQ(ui64, nui64);
|
||||
|
||||
ui64 = lui64;
|
||||
be::little_to_native(ui64);
|
||||
BOOST_TEST_EQ(ui64, nui64);
|
||||
|
||||
boost::int32_t i32;
|
||||
|
||||
i32 = ni32;
|
||||
be::native_to_big(i32);
|
||||
BOOST_TEST_EQ(i32, bi32);
|
||||
|
||||
i32 = ni32;
|
||||
be::native_to_little(i32);
|
||||
BOOST_TEST_EQ(i32, li32);
|
||||
|
||||
i32 = bi32;
|
||||
be::big_to_native(i32);
|
||||
BOOST_TEST_EQ(i32, ni32);
|
||||
|
||||
i32 = li32;
|
||||
be::little_to_native(i32);
|
||||
BOOST_TEST_EQ(i32, ni32);
|
||||
|
||||
boost::uint32_t ui32;
|
||||
|
||||
ui32 = nui32;
|
||||
be::native_to_big(ui32);
|
||||
BOOST_TEST_EQ(ui32, bui32);
|
||||
|
||||
ui32 = nui32;
|
||||
be::native_to_little(ui32);
|
||||
BOOST_TEST_EQ(ui32, lui32);
|
||||
|
||||
ui32 = bui32;
|
||||
be::big_to_native(ui32);
|
||||
BOOST_TEST_EQ(ui32, nui32);
|
||||
|
||||
ui32 = lui32;
|
||||
be::little_to_native(ui32);
|
||||
BOOST_TEST_EQ(ui32, nui32);
|
||||
|
||||
boost::int16_t i16;
|
||||
|
||||
i16 = ni16;
|
||||
be::native_to_big(i16);
|
||||
BOOST_TEST_EQ(i16, bi16);
|
||||
|
||||
i16 = ni16;
|
||||
be::native_to_little(i16);
|
||||
BOOST_TEST_EQ(i16, li16);
|
||||
|
||||
i16 = bi16;
|
||||
be::big_to_native(i16);
|
||||
BOOST_TEST_EQ(i16, ni16);
|
||||
|
||||
i16 = li16;
|
||||
be::little_to_native(i16);
|
||||
BOOST_TEST_EQ(i16, ni16);
|
||||
|
||||
boost::uint16_t ui16;
|
||||
|
||||
ui16 = nui16;
|
||||
be::native_to_big(ui16);
|
||||
BOOST_TEST_EQ(ui16, bui16);
|
||||
|
||||
ui16 = nui16;
|
||||
be::native_to_little(ui16);
|
||||
BOOST_TEST_EQ(ui16, lui16);
|
||||
|
||||
ui16 = bui16;
|
||||
be::big_to_native(ui16);
|
||||
BOOST_TEST_EQ(ui16, nui16);
|
||||
|
||||
ui16 = lui16;
|
||||
be::little_to_native(ui16);
|
||||
BOOST_TEST_EQ(ui16, nui16);
|
||||
|
||||
std::cout << " test_in_place_conditional_reorder complete\n";
|
||||
}
|
||||
|
||||
void test_copying_conditional_reorder()
|
||||
{
|
||||
std::cout << "test_copying_conditional_reorder...\n";
|
||||
|
||||
boost::int64_t i64, ti64;
|
||||
|
||||
i64 = ni64;
|
||||
be::native_to_big(i64, ti64);
|
||||
BOOST_TEST_EQ(ti64, bi64);
|
||||
|
||||
i64 = ni64;
|
||||
be::native_to_little(i64, ti64);
|
||||
BOOST_TEST_EQ(ti64, li64);
|
||||
|
||||
i64 = bi64;
|
||||
be::big_to_native(i64, ti64);
|
||||
BOOST_TEST_EQ(ti64, ni64);
|
||||
|
||||
i64 = li64;
|
||||
be::little_to_native(i64, ti64);
|
||||
BOOST_TEST_EQ(ti64, ni64);
|
||||
|
||||
boost::uint64_t ui64, tui64;
|
||||
|
||||
ui64 = nui64;
|
||||
be::native_to_big(ui64, tui64);
|
||||
BOOST_TEST_EQ(tui64, bui64);
|
||||
|
||||
ui64 = nui64;
|
||||
be::native_to_little(ui64, tui64);
|
||||
BOOST_TEST_EQ(tui64, lui64);
|
||||
|
||||
ui64 = bui64;
|
||||
be::big_to_native(ui64, tui64);
|
||||
BOOST_TEST_EQ(tui64, nui64);
|
||||
|
||||
ui64 = lui64;
|
||||
be::little_to_native(ui64, tui64);
|
||||
BOOST_TEST_EQ(tui64, nui64);
|
||||
|
||||
boost::int32_t i32, ti32;
|
||||
|
||||
i32 = ni32;
|
||||
be::native_to_big(i32, ti32);
|
||||
BOOST_TEST_EQ(ti32, bi32);
|
||||
|
||||
i32 = ni32;
|
||||
be::native_to_little(i32, ti32);
|
||||
BOOST_TEST_EQ(ti32, li32);
|
||||
|
||||
i32 = bi32;
|
||||
be::big_to_native(i32, ti32);
|
||||
BOOST_TEST_EQ(ti32, ni32);
|
||||
|
||||
i32 = li32;
|
||||
be::little_to_native(i32, ti32);
|
||||
BOOST_TEST_EQ(ti32, ni32);
|
||||
|
||||
boost::uint32_t ui32, tui32;
|
||||
|
||||
ui32 = nui32;
|
||||
be::native_to_big(ui32, tui32);
|
||||
BOOST_TEST_EQ(tui32, bui32);
|
||||
|
||||
ui32 = nui32;
|
||||
be::native_to_little(ui32, tui32);
|
||||
BOOST_TEST_EQ(tui32, lui32);
|
||||
|
||||
ui32 = bui32;
|
||||
be::big_to_native(ui32, tui32);
|
||||
BOOST_TEST_EQ(tui32, nui32);
|
||||
|
||||
ui32 = lui32;
|
||||
be::little_to_native(ui32, tui32);
|
||||
BOOST_TEST_EQ(tui32, nui32);
|
||||
|
||||
boost::int16_t i16, ti16;
|
||||
|
||||
i16 = ni16;
|
||||
be::native_to_big(i16, ti16);
|
||||
BOOST_TEST_EQ(ti16, bi16);
|
||||
|
||||
i16 = ni16;
|
||||
be::native_to_little(i16, ti16);
|
||||
BOOST_TEST_EQ(ti16, li16);
|
||||
|
||||
i16 = bi16;
|
||||
be::big_to_native(i16, ti16);
|
||||
BOOST_TEST_EQ(ti16, ni16);
|
||||
|
||||
i16 = li16;
|
||||
be::little_to_native(i16, ti16);
|
||||
BOOST_TEST_EQ(ti16, ni16);
|
||||
|
||||
boost::uint16_t ui16, tui16;
|
||||
|
||||
ui16 = nui16;
|
||||
be::native_to_big(ui16, tui16);
|
||||
BOOST_TEST_EQ(tui16, bui16);
|
||||
|
||||
ui16 = nui16;
|
||||
be::native_to_little(ui16, tui16);
|
||||
BOOST_TEST_EQ(tui16, lui16);
|
||||
|
||||
ui16 = bui16;
|
||||
be::big_to_native(ui16, tui16);
|
||||
BOOST_TEST_EQ(tui16, nui16);
|
||||
|
||||
ui16 = lui16;
|
||||
be::little_to_native(ui16, tui16);
|
||||
BOOST_TEST_EQ(tui16, nui16);
|
||||
|
||||
std::cout << " test_copying_conditional_reorder complete\n";
|
||||
}
|
||||
|
||||
} // unnamed namespace
|
||||
|
||||
int cpp_main(int, char * [])
|
||||
{
|
||||
std::cerr << std::hex;
|
||||
test_in_place_reorder();
|
||||
test_copying_reorder();
|
||||
test_in_place_conditional_reorder();
|
||||
test_copying_conditional_reorder();
|
||||
|
||||
return ::boost::report_errors();
|
||||
}
|
||||
|
||||
#include <boost/endian/detail/disable_warnings_pop.hpp>
|
@@ -1,84 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{6FAF820B-F436-46A2-A1DD-4A4B7025C3D0}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>conversion2_test</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\conversion2_test.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
@@ -1,91 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\..\conversion_test.cpp" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{9FA33B0B-2B00-49E8-A892-E049D86076A9}</ProjectGuid>
|
||||
<RootNamespace>endian_flip_test</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\common.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\common.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
|
||||
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<MinimalRebuild>true</MinimalRebuild>
|
||||
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
|
||||
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<TargetMachine>MachineX86</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
Reference in New Issue
Block a user