tlx
Toggle main menu visibility
Loading...
Searching...
No Matches
bswap_be.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/math/bswap_be.hpp
3
*
4
* bswap16_be(), bswap32_be() and bswap64_be() to swap bytes to big-endian:
5
* no-operations on big-endian systems, bswaps on little-endian systems.
6
*
7
* Part of tlx - http://panthema.net/tlx
8
*
9
* Copyright (C) 2018 Timo Bingmann <tb@panthema.net>
10
*
11
* All rights reserved. Published under the Boost Software License, Version 1.0
12
******************************************************************************/
13
14
#ifndef TLX_MATH_BSWAP_BE_HEADER
15
#define TLX_MATH_BSWAP_BE_HEADER
16
17
#include <cstdint>
18
#include <
tlx/define/endian.hpp
>
19
#include <
tlx/math/bswap.hpp
>
20
21
namespace
tlx
{
22
23
//! \addtogroup tlx_math
24
//! \{
25
26
/******************************************************************************/
27
// bswap16_be() - swap 16-bit integers to big-endian
28
29
#if TLX_LITTLE_ENDIAN
30
static
inline
std::uint16_t bswap16_be(
const
std::uint16_t& v) {
31
return
bswap16
(v);
32
}
33
#elif TLX_BIG_ENDIAN
34
static
inline
std::uint16_t bswap16_be(
const
std::uint16_t& v) {
35
return
v;
36
}
37
#endif
38
39
/******************************************************************************/
40
// bswap32_be() - swap 32-bit integers to big-endian
41
42
#if TLX_LITTLE_ENDIAN
43
static
inline
std::uint32_t bswap32_be(
const
std::uint32_t& v) {
44
return
bswap32
(v);
45
}
46
#elif TLX_BIG_ENDIAN
47
static
inline
std::uint32_t bswap32_be(
const
std::uint32_t& v) {
48
return
v;
49
}
50
#endif
51
52
/******************************************************************************/
53
// bswap64_be() - swap 64-bit integers to big-endian
54
55
#if TLX_LITTLE_ENDIAN
56
static
inline
std::uint64_t bswap64_be(
const
std::uint64_t& v) {
57
return
bswap64
(v);
58
}
59
#elif TLX_BIG_ENDIAN
60
static
inline
std::uint64_t bswap64_be(
const
std::uint64_t& v) {
61
return
v;
62
}
63
#endif
64
65
/******************************************************************************/
66
67
//! \}
68
69
}
// namespace tlx
70
71
#endif
// !TLX_MATH_BSWAP_BE_HEADER
72
73
/******************************************************************************/
bswap.hpp
endian.hpp
tlx::bswap16
static std::uint16_t bswap16(const std::uint16_t &v)
bswap16 - generic
Definition
bswap.hpp:52
tlx::bswap64
static std::uint64_t bswap64(const std::uint64_t &v)
bswap64 - generic
Definition
bswap.hpp:122
tlx::bswap32
static std::uint32_t bswap32(const std::uint32_t &v)
bswap32 - generic
Definition
bswap.hpp:84
tlx
Definition
exclusive_scan.hpp:17
tlx
math
bswap_be.hpp
Generated on
for tlx by
1.17.0