1 // Sets up common environment for Shay Green's libraries.
2 // To change configuration options, modify blargg_config.h, not this file.
4 #ifndef BLARGG_COMMON_H
5 #define BLARGG_COMMON_H
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
23 #if 1 /* IRAM configuration is not yet active for all libGME codecs. */
37 // BLARGG_RESTRICT: equivalent to C99's restrict, where supported
38 #if __GNUC__ >= 3 || _MSC_VER >= 1100
39 #define BLARGG_RESTRICT __restrict
41 #define BLARGG_RESTRICT
44 // STATIC_CAST(T,expr): Used in place of static_cast<T> (expr)
46 #define STATIC_CAST(T,expr) ((T) (expr))
49 // blargg_err_t (0 on success, otherwise error string)
51 typedef const char* blargg_err_t
;
54 #define BLARGG_4CHAR( a, b, c, d ) \
55 ((a&0xFF)*0x1000000L + (b&0xFF)*0x10000L + (c&0xFF)*0x100L + (d&0xFF))
57 // BOOST_STATIC_ASSERT( expr ): Generates compile error if expr is 0.
58 #ifndef BOOST_STATIC_ASSERT
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] )
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__] )
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__)
76 #define BLARGG_COMPILER_HAS_BOOL 0
78 #elif defined (_MSC_VER)
80 #define BLARGG_COMPILER_HAS_BOOL 0
82 #elif defined (__GNUC__)
84 #elif __cplusplus < 199711
85 #define BLARGG_COMPILER_HAS_BOOL 0
88 #if defined (BLARGG_COMPILER_HAS_BOOL) && !BLARGG_COMPILER_HAS_BOOL
89 // If you get errors here, modify your blargg_config.h file
92 static bool false = 0;
95 // blargg_long/blargg_ulong = at least 32 bits, int if it's big enough
98 #if INT_MAX >= 0x7FFFFFFF
99 typedef int blargg_long
;
101 typedef long blargg_long
;
104 #if UINT_MAX >= 0xFFFFFFFF
105 typedef unsigned blargg_ulong
;
107 typedef unsigned long blargg_ulong
;
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)
121 // HAVE_INTTYPES_H: If defined, use <stdint.h> for int8_t etc.
122 #elif defined (HAVE_INTTYPES_H)
123 #include <inttypes.h>
127 #if UCHAR_MAX == 0xFF && SCHAR_MAX == 0x7F
128 typedef signed char int8_t;
129 typedef unsigned char uint8_t;
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;
136 #if USHRT_MAX == 0xFFFF
137 typedef short int16_t;
138 typedef unsigned short uint16_t;
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;
145 #if ULONG_MAX == 0xFFFFFFFF
146 typedef long int32_t;
147 typedef unsigned long uint32_t;
148 #elif UINT_MAX == 0xFFFFFFFF
150 typedef unsigned int uint32_t;
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;