Mercurial > audlegacy
comparison Plugins/Input/console/blargg_source.h @ 493:c04dff121e1d trunk
[svn] hostile merge, phase 2: reimport based on new plugin code
author | nenolod |
---|---|
date | Tue, 24 Jan 2006 20:19:01 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
492:ccb68bad47b2 | 493:c04dff121e1d |
---|---|
1 | |
2 // By default, #included at beginning of library source files. | |
3 // Can be overridden by #defining BLARGG_SOURCE_BEGIN to path of alternate file. | |
4 | |
5 // Copyright (C) 2005 Shay Green. | |
6 | |
7 #ifndef BLARGG_SOURCE_H | |
8 #define BLARGG_SOURCE_H | |
9 | |
10 // If debugging is enabled, abort program if expr is false. Meant for checking | |
11 // internal state and consistency. A failed assertion indicates a bug in the module. | |
12 // void assert( bool expr ); | |
13 #include <assert.h> | |
14 | |
15 // If debugging is enabled and expr is false, abort program. Meant for checking | |
16 // caller-supplied parameters and operations that are outside the control of the | |
17 // module. A failed requirement indicates a bug outside the module. | |
18 // void require( bool expr ); | |
19 #undef require | |
20 #define require( expr ) assert( expr ) | |
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 #undef dprintf | |
26 #ifdef BLARGG_DPRINTF | |
27 #define dprintf BLARGG_DPRINTF | |
28 #else | |
29 inline void blargg_dprintf_( const char*, ... ) { } | |
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 #ifdef BLARGG_CHECK | |
38 #define check( expr ) BLARGG_CHECK( expr ) | |
39 #else | |
40 #define check( expr ) ((void) 0) | |
41 #endif | |
42 | |
43 // If expr returns non-NULL error string, return it from current function, otherwise continue. | |
44 #define BLARGG_RETURN_ERR( expr ) do { \ | |
45 blargg_err_t blargg_return_err_ = (expr); \ | |
46 if ( blargg_return_err_ ) return blargg_return_err_; \ | |
47 } while ( 0 ) | |
48 | |
49 // If ptr is NULL, return out of memory error string. | |
50 #define BLARGG_CHECK_ALLOC( ptr ) do { if ( (ptr) == 0 ) return "Out of memory"; } while ( 0 ) | |
51 | |
52 // Avoid any macros which evaluate their arguments multiple times | |
53 #undef min | |
54 #undef max | |
55 | |
56 // using const references generates crappy code, and I am currenly only using these | |
57 // for built-in types, so they take arguments by value | |
58 | |
59 template<class T> | |
60 inline T min( T x, T y ) | |
61 { | |
62 if ( x < y ) | |
63 return x; | |
64 return y; | |
65 } | |
66 | |
67 template<class T> | |
68 inline T max( T x, T y ) | |
69 { | |
70 if ( x < y ) | |
71 return y; | |
72 return x; | |
73 } | |
74 | |
75 #endif | |
76 |