From 0729cfef86687f897d74043bb2fdf9e8559413f8 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Thu, 16 Jun 2011 18:30:52 -0700 Subject: uhd: added host to/from worknet conversion to byteswap header --- host/include/uhd/utils/byteswap.hpp | 8 +++++++- host/include/uhd/utils/byteswap.ipp | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) (limited to 'host/include') 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 T htonx(T); + //! worknet to host: short, long, or long-long + template T wtohx(T); + + //! host to worknet: short, long, or long-long + template T htowx(T); + } //namespace uhd #include 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 UHD_INLINE T uhd::htonx(T num){ #endif } +template UHD_INLINE T uhd::wtohx(T num){ + #ifdef BOOST_BIG_ENDIAN + return uhd::byteswap(num); + #else + return num; + #endif +} + +template 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 */ -- cgit v1.2.3