diff options
author | Josh Blum <josh@joshknows.com> | 2011-06-16 18:30:52 -0700 |
---|---|---|
committer | Josh Blum <josh@joshknows.com> | 2011-06-16 18:30:52 -0700 |
commit | 4caf9db3dbe6d04c98236072d562a805afce9085 (patch) | |
tree | 5c4074a87a72ca72b84d2b4550cbed449773be15 /host | |
parent | 8b57d850d651c04d1c36cffce81f30b596754c84 (diff) | |
download | uhd-4caf9db3dbe6d04c98236072d562a805afce9085.tar.gz uhd-4caf9db3dbe6d04c98236072d562a805afce9085.tar.bz2 uhd-4caf9db3dbe6d04c98236072d562a805afce9085.zip |
uhd: added host to/from worknet conversion to byteswap header
Diffstat (limited to 'host')
-rw-r--r-- | host/include/uhd/utils/byteswap.hpp | 8 | ||||
-rw-r--r-- | host/include/uhd/utils/byteswap.ipp | 16 |
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 */ |