| USRP Hardware Driver and Device Manual Version: 4.10.0.0 UHD and USRP Manual |

Loading...
Searching...
No Matches
byteswap.hpp
Go to the documentation of this file.
1//
2// Copyright 2010-2011 Ettus Research LLC
3// Copyright 2018 Ettus Research, a National Instruments Company
4//
5// SPDX-License-Identifier: GPL-3.0-or-later
6//
7
8#pragma once
9
10#include <uhd/config.hpp>
11#include <uhd/types/endianness.hpp>
12#include <stdint.h>
13
19 namespace uhd {
20
22uint16_t byteswap(uint16_t);
23
25uint32_t byteswap(uint32_t);
26
28uint64_t byteswap(uint64_t);
29
31 template <typename T>
32T ntohx(T);
33
35 template <typename T>
36T htonx(T);
37
39//
40// The argument is assumed to be little-endian (i.e, the inverse
41// of typical network endianness).
42 template <typename T>
43T wtohx(T);
44
46//
47// The return value is little-endian (i.e, the inverse
48// of typical network endianness).
49 template <typename T>
50T htowx(T);
51
53//
54// Use this if the link endianness ("network or worknet") is configurable as
55// template parameter. Note the host endianness is auto-detected at compile
56// time.
57//
58// \tparam endianness The link endianness.
59// \param num The value in host endianness, to be swapped.
60// \return The value byte-swapped to the link endianness.
61 template <endianness_t endianness, typename T>
62T htolx(T num);
63
65//
66// Use this if the link endianness ("network or worknet") is configurable as
67// template parameter. Note the host endianness is auto-detected at compile
68// time.
69//
70// \tparam endianness The link endianness.
71// \param num The value in link endianness, to be swapped.
72// \return The value byte-swapped to the host endianness.
73 template <endianness_t endianness, typename T>
74T ltohx(T num);
75
76} // namespace uhd
77
78#include <uhd/utils/byteswap.ipp>
byteswap.ipp
config.hpp
uhd
Definition build_info.hpp:12
uhd::ntohx
T ntohx(T)
network to host: short, long, or long-long
Definition byteswap.ipp:111
uhd::byteswap
uint16_t byteswap(uint16_t)
perform a byteswap on a 16 bit integer
Definition byteswap.ipp:86
uhd::htowx
T htowx(T)
host to worknet: short, long, or long-long
Definition byteswap.ipp:141
uhd::htolx
T htolx(T num)
Host to link with configurable endianness (16-bit, 32-bit, or 64-bit).
Definition byteswap.ipp:151
uhd::wtohx
T wtohx(T)
worknet to host: short, long, or long-long
Definition byteswap.ipp:131
uhd::ltohx
T ltohx(T num)
Link with configurable endianness to host (16-bit, 32-bit, or 64-bit).
Definition byteswap.ipp:169
uhd::htonx
T htonx(T)
host to network: short, long, or long-long
Definition byteswap.ipp:121