summaryrefslogtreecommitdiff
path: root/apps/plugins/xworld/awendian.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/xworld/awendian.h')
-rw-r--r--apps/plugins/xworld/awendian.h51
1 files changed, 51 insertions, 0 deletions
diff --git a/apps/plugins/xworld/awendian.h b/apps/plugins/xworld/awendian.h
new file mode 100644
index 0000000000..863b19bb47
--- /dev/null
+++ b/apps/plugins/xworld/awendian.h
@@ -0,0 +1,51 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2014 Franklin Wei, Benjamin Brown
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ***************************************************************************/
21
22#ifndef __SYS_H__
23#define __SYS_H__
24
25#include "rbendian.h"
26#include "stdint.h"
27
28
29#ifdef ROCKBOX_LITTLE_ENDIAN
30#define SYS_LITTLE_ENDIAN
31#else
32#define SYS_BIG_ENDIAN
33#endif
34
35
36#if defined SYS_LITTLE_ENDIAN
37#define READ_BE_UINT16(p) ((((const uint8_t*)p)[0] << 8) | ((const uint8_t*)p)[1])
38#define READ_BE_UINT32(p) ((((const uint8_t*)p)[0] << 24) | (((const uint8_t*)p)[1] << 16) | (((const uint8_t*)p)[2] << 8) | ((const uint8_t*)p)[3])
39
40#elif defined SYS_BIG_ENDIAN
41
42#define READ_BE_UINT16(p) (*(const uint16_t*)p)
43#define READ_BE_UINT32(p) (*(const uint32_t*)p)
44
45#else
46
47#error No endianness defined
48
49#endif
50
51#endif