1 #ifndef _WRAPPER_H 2 #define _WRAPPER_H 3 4 #include <KernelExport.h> 5 #include <lock.h> 6 7 8 // benaphores 9 10 #define INIT_BEN(x, prefix) (mutex_init_etc(x, prefix, MUTEX_FLAG_CLONE_NAME), \ 11 B_OK) 12 #define DELETE_BEN(x) mutex_destroy(x) 13 #define ACQUIRE_BEN(x) mutex_lock(x) 14 #define RELEASE_BEN(x) mutex_unlock(x) 15 16 // debug output 17 18 #ifdef DEBUG_WAIT_ON_MSG 19 # define DEBUG_WAIT snooze( DEBUG_WAIT_ON_MSG ); 20 #else 21 # define DEBUG_WAIT 22 #endif 23 24 #ifdef DEBUG_WAIT_ON_ERROR 25 # define DEBUG_WAIT_ERROR snooze( DEBUG_WAIT_ON_ERROR ); 26 #else 27 # define DEBUG_WAIT_ERROR 28 #endif 29 30 #ifndef DEBUG_MAX_LEVEL_FLOW 31 # define DEBUG_MAX_LEVEL_FLOW 4 32 #endif 33 34 #ifndef DEBUG_MAX_LEVEL_INFO 35 # define DEBUG_MAX_LEVEL_INFO 4 36 #endif 37 38 #ifndef DEBUG_MAX_LEVEL_ERROR 39 # define DEBUG_MAX_LEVEL_ERROR 4 40 #endif 41 42 #ifndef DEBUG_MSG_PREFIX 43 # define DEBUG_MSG_PREFIX "" 44 #endif 45 46 #ifndef debug_level_flow 47 # define debug_level_flow 3 48 #endif 49 50 #ifndef debug_level_info 51 # define debug_level_info 2 52 #endif 53 54 #ifndef debug_level_error 55 # define debug_level_error 1 56 #endif 57 58 #define FUNC_NAME DEBUG_MSG_PREFIX __FUNCTION__ ": " 59 60 #define SHOW_FLOW(seriousness, format, param...) \ 61 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \ 62 dprintf( "%s"##format"\n", FUNC_NAME, param ); DEBUG_WAIT \ 63 }} while( 0 ) 64 65 #define SHOW_FLOW0(seriousness, format) \ 66 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \ 67 dprintf( "%s"##format"\n", FUNC_NAME); DEBUG_WAIT \ 68 }} while( 0 ) 69 70 #define SHOW_INFO(seriousness, format, param...) \ 71 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \ 72 dprintf( "%s"##format"\n", FUNC_NAME, param ); DEBUG_WAIT \ 73 }} while( 0 ) 74 75 #define SHOW_INFO0(seriousness, format) \ 76 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \ 77 dprintf( "%s"##format"\n", FUNC_NAME); DEBUG_WAIT \ 78 }} while( 0 ) 79 80 #define SHOW_ERROR(seriousness, format, param...) \ 81 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \ 82 dprintf( "%s"##format"\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \ 83 }} while( 0 ) 84 85 #define SHOW_ERROR0(seriousness, format) \ 86 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \ 87 dprintf( "%s"##format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \ 88 }} while( 0 ) 89 90 #endif /* _BENAPHORE_H */ 91