summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJosh Blum <josh@joshknows.com>2011-06-16 18:30:52 -0700
committerJosh Blum <josh@joshknows.com>2011-06-16 18:30:52 -0700
commit4caf9db3dbe6d04c98236072d562a805afce9085 (patch)
tree5c4074a87a72ca72b84d2b4550cbed449773be15
parent8b57d850d651c04d1c36cffce81f30b596754c84 (diff)
downloaduhd-4caf9db3dbe6d04c98236072d562a805afce9085.tar.gz
uhd-4caf9db3dbe6d04c98236072d562a805afce9085.tar.bz2
uhd-4caf9db3dbe6d04c98236072d562a805afce9085.zip
uhd: added host to/from worknet conversion to byteswap header
-rw-r--r--host/include/uhd/utils/byteswap.hpp8
-rw-r--r--host/include/uhd/utils/byteswap.ipp16
2 files changed, 23 insertions, 1 deletions
diff --git a/host/include/uhd/utils/byteswap.hpp b/host/include/uhd/utils/byteswap.hpp
index 9a1871210..2b5a46c66 100644
--- a/host/include/uhd/utils/byteswap.hpp
+++ b/host/include/uhd/utils/byteswap.hpp
@@ -1,5 +1,5 @@
//
-// Copyright 2010 Ettus Research LLC
+// Copyright 2010-2011 Ettus Research LLC
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
@@ -43,6 +43,12 @@ namespace uhd{
//! host to network: short, long, or long-long
template<typename T> T htonx(T);
+ //! worknet to host: short, long, or long-long
+ template<typename T> T wtohx(T);
+
+ //! host to worknet: short, long, or long-long
+ template<typename T> T htowx(T);
+
} //namespace uhd
#include <uhd/utils/byteswap.ipp>
diff --git a/host/include/uhd/utils/byteswap.ipp b/host/include/uhd/utils/byteswap.ipp
index c090dee55..51e9c28a0 100644
--- a/host/include/uhd/utils/byteswap.ipp
+++ b/host/include/uhd/utils/byteswap.ipp
@@ -117,4 +117,20 @@ template<typename T> UHD_INLINE T uhd::htonx(T num){
#endif
}
+template<typename T> UHD_INLINE T uhd::wtohx(T num){
+ #ifdef BOOST_BIG_ENDIAN
+ return uhd::byteswap(num);
+ #else
+ return num;
+ #endif
+}
+
+template<typename T> UHD_INLINE T uhd::htowx(T num){
+ #ifdef BOOST_BIG_ENDIAN
+ return uhd::byteswap(num);
+ #else
+ return num;
+ #endif
+}
+
#endif /* INCLUDED_UHD_UTILS_BYTESWAP_IPP */