summaryrefslogtreecommitdiff
path: root/apps/codecs/libgme/blargg_source.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libgme/blargg_source.h')
-rw-r--r--apps/codecs/libgme/blargg_source.h71
1 files changed, 71 insertions, 0 deletions
diff --git a/apps/codecs/libgme/blargg_source.h b/apps/codecs/libgme/blargg_source.h
new file mode 100644
index 0000000000..4bea02a48b
--- /dev/null
+++ b/apps/codecs/libgme/blargg_source.h
@@ -0,0 +1,71 @@
1// Included at the beginning of library source files, after all other #include lines
2#ifndef BLARGG_SOURCE_H
3#define BLARGG_SOURCE_H
4
5// If debugging is enabled, abort program if expr is false. Meant for checking
6// internal state and consistency. A failed assertion indicates a bug in the module.
7// void assert( bool expr );
8#include <assert.h>
9
10// If debugging is enabled and expr is false, abort program. Meant for checking
11// caller-supplied parameters and operations that are outside the control of the
12// module. A failed requirement indicates a bug outside the module.
13// void require( bool expr );
14#if defined(ROCKBOX)
15#undef require
16#define require( expr )
17#else
18#undef require
19#define require( expr ) assert( expr )
20#endif
21
22// Like printf() except output goes to debug log file. Might be defined to do
23// nothing (not even evaluate its arguments).
24// void dprintf( const char* format, ... );
25#if defined(ROCKBOX)
26#define dprintf DEBUGF
27#else
28static inline void blargg_dprintf_( const char* fmt, ... ) { }
29#undef dprintf
30#define dprintf (1) ? (void) 0 : blargg_dprintf_
31#endif
32
33// If enabled, evaluate expr and if false, make debug log entry with source file
34// and line. Meant for finding situations that should be examined further, but that
35// don't indicate a problem. In all cases, execution continues normally.
36#undef check
37#define check( expr ) ((void) 0)
38
39// If expr yields error string, return it from current function, otherwise continue.
40#undef RETURN_ERR
41#define RETURN_ERR( expr ) do { \
42 blargg_err_t blargg_return_err_ = (expr); \
43 if ( blargg_return_err_ ) return blargg_return_err_; \
44 } while ( 0 )
45
46// If ptr is 0, return out of memory error string.
47#undef CHECK_ALLOC
48#define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 )
49
50#ifndef max
51 #define max(a,b) (((a) > (b)) ? (a) : (b))
52#endif
53#ifndef min
54 #define min(a,b) (((a) < (b)) ? (a) : (b))
55#endif
56
57// TODO: good idea? bad idea?
58#undef byte
59#define byte byte_
60typedef unsigned char byte;
61
62// deprecated
63#define BLARGG_CHECK_ALLOC CHECK_ALLOC
64#define BLARGG_RETURN_ERR RETURN_ERR
65
66// BLARGG_SOURCE_BEGIN: If defined, #included, allowing redefition of dprintf and check
67#ifdef BLARGG_SOURCE_BEGIN
68 #include BLARGG_SOURCE_BEGIN
69#endif
70
71#endif