aboutsummaryrefslogtreecommitdiffstats
path: root/host
diff options
context:
space:
mode:
Diffstat (limited to 'host')
-rw-r--r--host/include/uhd/types/endianness.hpp32
-rw-r--r--host/include/uhd/utils/byteswap.hpp1
-rw-r--r--host/include/uhd/utils/byteswap.ipp10
-rw-r--r--host/lib/convert/convert_with_tables.cpp2
-rw-r--r--host/lib/transport/chdr.cpp2
-rw-r--r--host/lib/transport/gen_vrt_if_packet.py4
6 files changed, 41 insertions, 10 deletions
diff --git a/host/include/uhd/types/endianness.hpp b/host/include/uhd/types/endianness.hpp
index a14bfcd23..b74564415 100644
--- a/host/include/uhd/types/endianness.hpp
+++ b/host/include/uhd/types/endianness.hpp
@@ -10,6 +10,38 @@
#include <uhd/config.hpp>
+/******************************************************************************
+ * Detect host endianness
+ *****************************************************************************/
+#if BOOST_VERSION >= 105500
+
+# include <boost/predef/other/endian.h>
+
+// In Boost 1.55, the meaning of the macros changed. They are now always
+// defined, but don't always have the same value.
+# if BOOST_ENDIAN_BIG_BYTE
+# define UHD_BIG_ENDIAN
+# elif BOOST_ENDIAN_LITTLE_BYTE
+# define UHD_LITTLE_ENDIAN
+# else
+# error "Unsupported endianness!"
+# endif
+
+#else
+
+# include <boost/detail/endian.hpp>
+
+# if defined(BOOST_BIG_ENDIAN)
+# define UHD_BIG_ENDIAN
+# elif defined(BOOST_LITTLE_ENDIAN)
+# define UHD_LITTLE_ENDIAN
+# else
+# error "Unsupported endianness!"
+# endif
+
+#endif
+
+
namespace uhd {
enum endianness_t { ENDIANNESS_BIG, ENDIANNESS_LITTLE };
diff --git a/host/include/uhd/utils/byteswap.hpp b/host/include/uhd/utils/byteswap.hpp
index e05a6cced..07b25b4e9 100644
--- a/host/include/uhd/utils/byteswap.hpp
+++ b/host/include/uhd/utils/byteswap.hpp
@@ -9,6 +9,7 @@
#define INCLUDED_UHD_UTILS_BYTESWAP_HPP
#include <uhd/config.hpp>
+#include <uhd/types/endianness.hpp>
#include <stdint.h>
/*! \file byteswap.hpp
diff --git a/host/include/uhd/utils/byteswap.ipp b/host/include/uhd/utils/byteswap.ipp
index 06d12c746..7e13d6260 100644
--- a/host/include/uhd/utils/byteswap.ipp
+++ b/host/include/uhd/utils/byteswap.ipp
@@ -107,13 +107,11 @@ UHD_INLINE uint64_t uhd::byteswap(uint64_t x)
/***********************************************************************
* Define the templated network to/from host conversions
**********************************************************************/
-#include <boost/detail/endian.hpp>
-
namespace uhd {
template <typename T> UHD_INLINE T ntohx(T num)
{
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
return num;
#else
return uhd::byteswap(num);
@@ -122,7 +120,7 @@ template <typename T> UHD_INLINE T ntohx(T num)
template <typename T> UHD_INLINE T htonx(T num)
{
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
return num;
#else
return uhd::byteswap(num);
@@ -131,7 +129,7 @@ template <typename T> UHD_INLINE T htonx(T num)
template <typename T> UHD_INLINE T wtohx(T num)
{
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
return uhd::byteswap(num);
#else
return num;
@@ -140,7 +138,7 @@ template <typename T> UHD_INLINE T wtohx(T num)
template <typename T> UHD_INLINE T htowx(T num)
{
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
return uhd::byteswap(num);
#else
return num;
diff --git a/host/lib/convert/convert_with_tables.cpp b/host/lib/convert/convert_with_tables.cpp
index 40efc5190..5c9248052 100644
--- a/host/lib/convert/convert_with_tables.cpp
+++ b/host/lib/convert/convert_with_tables.cpp
@@ -168,7 +168,7 @@ private:
* Factory functions and registration
**********************************************************************/
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
# define SHIFT_PAIR0 16, 0
# define SHIFT_PAIR1 0, 16
# define BE_SWAP false
diff --git a/host/lib/transport/chdr.cpp b/host/lib/transport/chdr.cpp
index ff3b6475a..312cca318 100644
--- a/host/lib/transport/chdr.cpp
+++ b/host/lib/transport/chdr.cpp
@@ -10,7 +10,7 @@
#include <uhd/utils/byteswap.hpp>
// define the endian macros to convert integers
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
# define BE_MACRO(x) (x)
# define LE_MACRO(x) uhd::byteswap(x)
#else
diff --git a/host/lib/transport/gen_vrt_if_packet.py b/host/lib/transport/gen_vrt_if_packet.py
index 225a59dfe..6a17d9e3b 100644
--- a/host/lib/transport/gen_vrt_if_packet.py
+++ b/host/lib/transport/gen_vrt_if_packet.py
@@ -23,11 +23,11 @@ TMPL_TEXT = """<% import time %>
#include <uhd/exception.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <boost/detail/endian.hpp>
+#include <uhd/types/endianness.hpp>
#include <vector>
//define the endian macros to convert integers
-#ifdef BOOST_BIG_ENDIAN
+#ifdef UHD_BIG_ENDIAN
#define BE_MACRO(x) (x)
#define LE_MACRO(x) uhd::byteswap(x)
#else