diff options
author | Max Kellermann <max@musicpd.org> | 2020-09-21 11:15:21 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2020-09-21 11:15:45 +0200 |
commit | b72801abf3bba84565bb040215071a21182e698c (patch) | |
tree | ae99184908d620252e73bea0113d3f675c219d5f /src/util | |
parent | 23d5a2b8620cea69958d087fc7e13fe1e5adb83d (diff) |
util/ByteOrder: add FromLE16S()
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/ByteOrder.hxx | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/util/ByteOrder.hxx b/src/util/ByteOrder.hxx index f52c2bd38..121f458f2 100644 --- a/src/util/ByteOrder.hxx +++ b/src/util/ByteOrder.hxx @@ -243,4 +243,15 @@ ToLE64(uint64_t value) noexcept return IsLittleEndian() ? value : ByteSwap64(value); } +/** + * Converts a 16 bit integer from little endian to the host byte order + * and returns it as a signed integer. + */ +constexpr int16_t +FromLE16S(uint16_t value) noexcept +{ + /* assuming two's complement representation */ + return static_cast<int16_t>(FromLE16(value)); +} + #endif |