15#include <boost/mpl/assert.hpp>
24#if __BYTE_ORDER != __LITTLE_ENDIAN
25#error Byte order of host must be little endian for ArchData to run properly
28#define HOST_INT_SIZE sizeof(uint32_t)
82 inline typename std::enable_if<std::is_integral<T>::value, T>::type
85 throw SpartaException(
"Do not know how to byteswap type '") <<
typeid(T).name()
86 <<
"' for value " << val;
103 inline uint16_t
byte_swap(uint16_t val) {
104 return (val << 8 | val >> 8);
110 return (val << 8 | val >> 8);
115 inline uint32_t
byte_swap(uint32_t val) {
116 return __builtin_bswap32(val);
122 return __builtin_bswap32(val);
127 inline uint64_t
byte_swap(uint64_t val) {
128 return __builtin_bswap64(val);
134 return __builtin_bswap64(val);
140 template <
typename T, enum ByteOrder BO>
142 typename std::enable_if<std::is_same<boost::mpl::int_<BO>, boost::mpl::int_<BE> >::value , T>::type
144 return byte_swap<T>(t);
149 template <
typename T, enum ByteOrder BO>
151 typename std::enable_if<std::is_same<boost::mpl::int_<BO>, boost::mpl::int_<LE> >::value , T>::type
Set of macros for Sparta assertions. Caught by the framework.
Exception class for all of Sparta.
Used to construct and throw a standard C++ exception. Inherits from std::exception.
Macros for handling exponential backoff.
std::enable_if< std::is_same< boost::mpl::int_< BO >, boost::mpl::int_< BE > >::value, T >::type reorder(const T &t)
std::enable_if< std::is_integral< T >::value, T >::type byte_swap(T val)
Swaps the order of bytes for various types.
ByteOrder
Byte order enum for read/write methods.