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