tlx
bswap_le.hpp
Go to the documentation of this file.
1
/*******************************************************************************
2
* tlx/math/bswap_le.hpp
3
*
4
* bswap16_le(), bswap32_le() and bswap64_le() to swap bytes to little-endian:
5
* no-operations on little-endian systems, bswaps on big-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_LE_HEADER
15
#define TLX_MATH_BSWAP_LE_HEADER
16
17
#include <
tlx/define/endian.hpp
>
18
#include <
tlx/math/bswap.hpp
>
19
20
namespace
tlx
{
21
22
//! \addtogroup tlx_math
23
//! \{
24
25
/******************************************************************************/
26
// bswap16_le() - swap 16-bit integers to little-endian
27
28
#if TLX_LITTLE_ENDIAN
29
static
inline
uint16_t bswap16_le(
const
uint16_t& v) {
30
return
v;
31
}
32
#elif TLX_BIG_ENDIAN
33
static
inline
uint16_t bswap16_le(
const
uint16_t& v) {
34
return
bswap16
(v);
35
}
36
#endif
37
38
/******************************************************************************/
39
// bswap32_le() - swap 32-bit integers to little-endian
40
41
#if TLX_LITTLE_ENDIAN
42
static
inline
uint32_t bswap32_le(
const
uint32_t& v) {
43
return
v;
44
}
45
#elif TLX_BIG_ENDIAN
46
static
inline
uint32_t bswap32_le(
const
uint32_t& v) {
47
return
bswap32
(v);
48
}
49
#endif
50
51
/******************************************************************************/
52
// bswap64_le() - swap 64-bit integers to little-endian
53
54
#if TLX_LITTLE_ENDIAN
55
static
inline
uint64_t bswap64_le(
const
uint64_t& v) {
56
return
v;
57
}
58
#elif TLX_BIG_ENDIAN
59
static
inline
uint64_t bswap64_le(
const
uint64_t& v) {
60
return
bswap64
(v);
61
}
62
#endif
63
64
/******************************************************************************/
65
66
//! \}
67
68
}
// namespace tlx
69
70
#endif // !TLX_MATH_BSWAP_LE_HEADER
71
72
/******************************************************************************/
tlx::bswap32
static uint32_t bswap32(const uint32_t &v)
bswap32 - generic
Definition:
bswap.hpp:94
endian.hpp
bswap.hpp
tlx
Definition:
exclusive_scan.hpp:17
tlx::bswap64
static uint64_t bswap64(const uint64_t &v)
bswap64 - generic
Definition:
bswap.hpp:132
tlx::bswap16
static uint16_t bswap16(const uint16_t &v)
bswap16 - generic
Definition:
bswap.hpp:62
tlx
math
bswap_le.hpp
Generated on Wed Jul 29 2020 00:00:00 for tlx by
1.8.18