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