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.h39
1 files changed, 22 insertions, 17 deletions
diff --git a/apps/codecs/libgme/blargg_source.h b/apps/codecs/libgme/blargg_source.h
index 4bea02a48b..ab8e1b072b 100644
--- a/apps/codecs/libgme/blargg_source.h
+++ b/apps/codecs/libgme/blargg_source.h
@@ -2,16 +2,13 @@
2#ifndef BLARGG_SOURCE_H 2#ifndef BLARGG_SOURCE_H
3#define BLARGG_SOURCE_H 3#define BLARGG_SOURCE_H
4 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 5// 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 6// caller-supplied parameters and operations that are outside the control of the
12// module. A failed requirement indicates a bug outside the module. 7// module. A failed requirement indicates a bug outside the module.
13// void require( bool expr ); 8// void require( bool expr );
14#if defined(ROCKBOX) 9#if defined(ROCKBOX)
10#undef assert
11#define assert( expr )
15#undef require 12#undef require
16#define require( expr ) 13#define require( expr )
17#else 14#else
@@ -36,28 +33,36 @@ static inline void blargg_dprintf_( const char* fmt, ... ) { }
36#undef check 33#undef check
37#define check( expr ) ((void) 0) 34#define check( expr ) ((void) 0)
38 35
39// If expr yields error string, return it from current function, otherwise continue. 36/* If expr yields non-NULL error string, returns it from current function,
40#undef RETURN_ERR 37otherwise continues normally. */
41#define RETURN_ERR( expr ) do { \ 38#undef RETURN_ERR
42 blargg_err_t blargg_return_err_ = (expr); \ 39#define RETURN_ERR( expr ) \
43 if ( blargg_return_err_ ) return blargg_return_err_; \ 40 do {\
41 blargg_err_t blargg_return_err_ = (expr);\
42 if ( blargg_return_err_ )\
43 return blargg_return_err_;\
44 } while ( 0 ) 44 } while ( 0 )
45 45
46// If ptr is 0, return out of memory error string. 46/* If ptr is NULL, returns out-of-memory error, otherwise continues normally. */
47#undef CHECK_ALLOC 47#undef CHECK_ALLOC
48#define CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 ) 48#define CHECK_ALLOC( ptr ) \
49 do {\
50 if ( !(ptr) )\
51 return "Out of memory";\
52 } while ( 0 )
49 53
50#ifndef max 54#ifndef max
51 #define max(a,b) (((a) > (b)) ? (a) : (b)) 55 #define max(a,b) (((a) > (b)) ? (a) : (b))
52#endif 56#endif
57
53#ifndef min 58#ifndef min
54 #define min(a,b) (((a) < (b)) ? (a) : (b)) 59 #define min(a,b) (((a) < (b)) ? (a) : (b))
55#endif 60#endif
56 61
57// TODO: good idea? bad idea? 62// typedef unsigned char byte;
58#undef byte 63typedef unsigned char blargg_byte;
59#define byte byte_ 64#undef byte
60typedef unsigned char byte; 65#define byte blargg_byte
61 66
62// deprecated 67// deprecated
63#define BLARGG_CHECK_ALLOC CHECK_ALLOC 68#define BLARGG_CHECK_ALLOC CHECK_ALLOC