LMMS
Loading...
Searching...
No Matches
endian_handling.h
Go to the documentation of this file.
1/*
2 * endian_handling.h - handle endianness
3 *
4 * Copyright (c) 2005-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
5 *
6 * This file is part of LMMS - https://lmms.io
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public
10 * License as published by the Free Software Foundation; either
11 * version 2 of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public
19 * License along with this program (see COPYING); if not, write to the
20 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 * Boston, MA 02110-1301 USA.
22 *
23 */
24
25#ifndef LMMS_ENDIAN_HANDLING_H
26#define LMMS_ENDIAN_HANDLING_H
27
28#include <cstdint>
29#include <QSysInfo>
30
31
32namespace lmms
33{
34
35
36inline bool isLittleEndian()
37{
38 return( QSysInfo::ByteOrder == QSysInfo::LittleEndian );
39}
40
41
43{
44 return( isLittleEndian() ? i : ( ( i & 0xFF ) << 8) | ( ( i >> 8 ) & 0xFF ) );
45}
46
47
49{
50 return( isLittleEndian() ? i : ( ( i & 0xff000000 ) >> 24 ) |
51 ( ( i & 0x00ff0000 ) >> 8 ) |
52 ( ( i & 0x0000ff00 ) << 8 ) |
53 ( ( i & 0x000000ff ) << 24 ) );
54}
55
56
57} // namespace lmms
58
59#endif // LMMS_ENDIAN_HANDLING_H
register unsigned i
Definition inflate.c:1575
int int32_t
Definition mid.cpp:97
short int16_t
Definition mid.cpp:96
Definition AudioAlsa.cpp:35
bool isLittleEndian()
Definition endian_handling.h:36
int32_t swap32IfBE(int32_t i)
Definition endian_handling.h:48
int16_t swap16IfBE(int16_t i)
Definition endian_handling.h:42