summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/blargg_common.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/blargg_common.h')
-rw-r--r--apps/codecs/libgme/blargg_common.h159
1 files changed, 159 insertions, 0 deletions
diff --git a/apps/codecs/libgme/blargg_common.h b/apps/codecs/libgme/blargg_common.h
new file mode 100644
index 0000000000..be34379441
--- /dev/null
+++ b/apps/codecs/libgme/blargg_common.h
@@ -0,0 +1,159 @@
1// Sets up common environment for Shay Green's libraries.
2// To change configuration options, modify blargg_config.h, not this file.
3
4#ifndef BLARGG_COMMON_H
5#define BLARGG_COMMON_H
6
7#include <stddef.h>
8#include <stdlib.h>
9#include <string.h>
10#include <assert.h>
11#include <limits.h>
12
13#undef BLARGG_COMMON_H
14// allow blargg_config.h to #include blargg_common.h
15#include "blargg_config.h"
16#ifndef BLARGG_COMMON_H
17#define BLARGG_COMMON_H
18
19#if defined(ROCKBOX)
20#include "codeclib.h"
21#endif
22
23#if 1 /* IRAM configuration is not yet active for all libGME codecs. */
24 #undef ICODE_ATTR
25 #define ICODE_ATTR
26
27 #undef IDATA_ATTR
28 #define IDATA_ATTR
29
30 #undef ICONST_ATTR
31 #define ICONST_ATTR
32
33 #undef IBSS_ATTR
34 #define IBSS_ATTR
35#endif
36
37// BLARGG_RESTRICT: equivalent to C99's restrict, where supported
38#if __GNUC__ >= 3 || _MSC_VER >= 1100
39 #define BLARGG_RESTRICT __restrict
40#else
41 #define BLARGG_RESTRICT
42#endif
43
44// STATIC_CAST(T,expr): Used in place of static_cast<T> (expr)
45#ifndef STATIC_CAST
46 #define STATIC_CAST(T,expr) ((T) (expr))
47#endif
48
49// blargg_err_t (0 on success, otherwise error string)
50#ifndef blargg_err_t
51 typedef const char* blargg_err_t;
52#endif
53
54#define BLARGG_4CHAR( a, b, c, d ) \
55 ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF))
56
57// BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0.
58#ifndef BOOST_STATIC_ASSERT
59 #ifdef _MSC_VER
60 // MSVC6 (_MSC_VER < 1300) fails for use of __LINE__ when /Zl is specified
61 #define BOOST_STATIC_ASSERT( expr ) \
62 void blargg_failed_( int (*arg) [2 / (int) !!(expr) - 1] )
63 #else
64 // Some other compilers fail when declaring same function multiple times in class,
65 // so differentiate them by line
66 #define BOOST_STATIC_ASSERT( expr ) \
67 void blargg_failed_( int (*arg) [2 / !!(expr) - 1] [__LINE__] )
68 #endif
69#endif
70
71// BLARGG_COMPILER_HAS_BOOL: If 0, provides bool support for old compiler. If 1,
72// compiler is assumed to support bool. If undefined, availability is determined.
73#ifndef BLARGG_COMPILER_HAS_BOOL
74 #if defined (__MWERKS__)
75 #if !__option(bool)
76 #define BLARGG_COMPILER_HAS_BOOL 0
77 #endif
78 #elif defined (_MSC_VER)
79 #if _MSC_VER < 1100
80 #define BLARGG_COMPILER_HAS_BOOL 0
81 #endif
82 #elif defined (__GNUC__)
83 // supports bool
84 #elif __cplusplus < 199711
85 #define BLARGG_COMPILER_HAS_BOOL 0
86 #endif
87#endif
88#if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
89 // If you get errors here, modify your blargg_config.h file
90 typedef int bool;
91 static bool true = 1;
92 static bool false = 0;
93#endif
94
95// blargg_long/blargg_ulong = at least 32 bits, int if it's big enough
96#include <limits.h>
97
98#if INT_MAX >= 0x7FFFFFFF
99 typedef int blargg_long;
100#else
101 typedef long blargg_long;
102#endif
103
104#if UINT_MAX >= 0xFFFFFFFF
105 typedef unsigned blargg_ulong;
106#else
107 typedef unsigned long blargg_ulong;
108#endif
109
110// int8_t etc.
111
112
113// ROCKBOX: If defined, use <codeclib.h> for int_8_t etc
114#if defined (ROCKBOX)
115 #include <codecs/lib/codeclib.h>
116// HAVE_STDINT_H: If defined, use <stdint.h> for int8_t etc.
117#elif defined (HAVE_STDINT_H)
118 #include <stdint.h>
119 #define BOOST
120
121// HAVE_INTTYPES_H: If defined, use <stdint.h> for int8_t etc.
122#elif defined (HAVE_INTTYPES_H)
123 #include <inttypes.h>
124 #define BOOST
125
126#else
127 #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F
128 typedef signed char int8_t;
129 typedef unsigned char uint8_t;
130 #else
131 // No suitable 8-bit type available
132 typedef struct see_blargg_common_h int8_t;
133 typedef struct see_blargg_common_h uint8_t;
134 #endif
135
136 #if USHRT_MAX == 0xFFFF
137 typedef short int16_t;
138 typedef unsigned short uint16_t;
139 #else
140 // No suitable 16-bit type available
141 typedef struct see_blargg_common_h int16_t;
142 typedef struct see_blargg_common_h uint16_t;
143 #endif
144
145 #if ULONG_MAX == 0xFFFFFFFF
146 typedef long int32_t;
147 typedef unsigned long uint32_t;
148 #elif UINT_MAX == 0xFFFFFFFF
149 typedef int int32_t;
150 typedef unsigned int uint32_t;
151 #else
152 // No suitable 32-bit type available
153 typedef struct see_blargg_common_h int32_t;
154 typedef struct see_blargg_common_h uint32_t;
155 #endif
156#endif
157
158#endif
159#endif