aboutsummaryrefslogtreecommitdiffstats
path: root/host
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 19:24:12 -0700
commit0729cfef86687f897d74043bb2fdf9e8559413f8 (patch)
treef50378c362653b6f3463e28640a3488e24e612ba /host
parent251530456bcd76d800fcc11490a98d2008fea791 (diff)
downloaduhd-0729cfef86687f897d74043bb2fdf9e8559413f8.tar.gz
uhd-0729cfef86687f897d74043bb2fdf9e8559413f8.tar.bz2
uhd-0729cfef86687f897d74043bb2fdf9e8559413f8.zip
uhd: added host to/from worknet conversion to byteswap header
Diffstat (limited to 'host')
-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 */