aboutsummaryrefslogtreecommitdiffstats
path: root/host/include
diff options
context:
space:
mode:
authorMartin Braun <martin.braun@ettus.com>2019-01-14 13:49:05 -0800
committerBrent Stapleton <brent.stapleton@ettus.com>2019-01-21 14:00:34 -0800
commitb459e02eedf358ef564020d698a9d96b711bf14e (patch)
tree6319539db3d01787975c74794cdcf60ebfa948a8 /host/include
parent764c5cd8087b560d4ef36679c82f7f8b25a6642b (diff)
downloaduhd-b459e02eedf358ef564020d698a9d96b711bf14e.tar.gz
uhd-b459e02eedf358ef564020d698a9d96b711bf14e.tar.bz2
uhd-b459e02eedf358ef564020d698a9d96b711bf14e.zip
endianness: Replace Boost macros with custom ones
Boost changed the macros for endianness identification in 1.69, and the deprecation warning is a pretty noisy one during compilation. This abstracts away the Boost macro, so we have two UHD macros, UHD_BIG_ENDIAN and UHD_LITTLE_ENDIAN. They indicate big and little endian byte order.
Diffstat (limited to 'host/include')
-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
3 files changed, 37 insertions, 6 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;