Fix makefile conditions
[maemo-rb.git] / apps / codecs / libgme / blargg_source.h
blobab8e1b072bd6a1261e13bde64cf5ed4ce2dcbed4
1 // Included at the beginning of library source files, after all other #include lines
2 #ifndef BLARGG_SOURCE_H
3 #define BLARGG_SOURCE_H
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
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
25 static inline void blargg_dprintf_( const char* fmt, ... ) { }
26 #undef dprintf
27 #define dprintf (1) ? (void) 0 : blargg_dprintf_
28 #endif
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)
36 /* If expr yields non-NULL error string, returns it from current function,
37 otherwise 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 )
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 )
54 #ifndef max
55 #define max(a,b) (((a) > (b)) ? (a) : (b))
56 #endif
58 #ifndef min
59 #define min(a,b) (((a) < (b)) ? (a) : (b))
60 #endif
62 // typedef unsigned char byte;
63 typedef unsigned char blargg_byte;
64 #undef byte
65 #define byte blargg_byte
67 // deprecated
68 #define BLARGG_CHECK_ALLOC CHECK_ALLOC
69 #define BLARGG_RETURN_ERR RETURN_ERR
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
76 #endif