BPicture: Fix archive constructor.
[haiku.git] / src / add-ons / kernel / bus_managers / ide / wrapper.h
blob07a659b2962688c5d3ea62883a94b14bdaed7169
1 #ifndef _WRAPPER_H
2 #define _WRAPPER_H
4 #include <KernelExport.h>
5 #include <lock.h>
8 // benaphores
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)
16 // debug output
18 #ifdef DEBUG_WAIT_ON_MSG
19 # define DEBUG_WAIT snooze( DEBUG_WAIT_ON_MSG );
20 #else
21 # define DEBUG_WAIT
22 #endif
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
30 #ifndef DEBUG_MAX_LEVEL_FLOW
31 # define DEBUG_MAX_LEVEL_FLOW 4
32 #endif
34 #ifndef DEBUG_MAX_LEVEL_INFO
35 # define DEBUG_MAX_LEVEL_INFO 4
36 #endif
38 #ifndef DEBUG_MAX_LEVEL_ERROR
39 # define DEBUG_MAX_LEVEL_ERROR 4
40 #endif
42 #ifndef DEBUG_MSG_PREFIX
43 # define DEBUG_MSG_PREFIX ""
44 #endif
46 #ifndef debug_level_flow
47 # define debug_level_flow 4
48 #endif
50 #ifndef debug_level_info
51 # define debug_level_info 4
52 #endif
54 #ifndef debug_level_error
55 # define debug_level_error 4
56 #endif
58 #define FUNC_NAME DEBUG_MSG_PREFIX, __FUNCTION__
60 #define SHOW_FLOW(seriousness, format, param...) \
61 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
62 dprintf( "%s%s: "format"\n", FUNC_NAME, param ); DEBUG_WAIT \
63 }} while( 0 )
65 #define SHOW_FLOW0(seriousness, format) \
66 do { if( seriousness <= debug_level_flow && seriousness <= DEBUG_MAX_LEVEL_FLOW ) { \
67 dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT \
68 }} while( 0 )
70 #define SHOW_INFO(seriousness, format, param...) \
71 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
72 dprintf( "%s%s: "format"\n", FUNC_NAME, param ); DEBUG_WAIT \
73 }} while( 0 )
75 #define SHOW_INFO0(seriousness, format) \
76 do { if( seriousness <= debug_level_info && seriousness <= DEBUG_MAX_LEVEL_INFO ) { \
77 dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT \
78 }} while( 0 )
80 #define SHOW_ERROR(seriousness, format, param...) \
81 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
82 dprintf( "%s%s: "format"\n", FUNC_NAME, param ); DEBUG_WAIT_ERROR \
83 }} while( 0 )
85 #define SHOW_ERROR0(seriousness, format) \
86 do { if( seriousness <= debug_level_error && seriousness <= DEBUG_MAX_LEVEL_ERROR ) { \
87 dprintf( "%s%s: "format"\n", FUNC_NAME); DEBUG_WAIT_ERROR \
88 }} while( 0 )
90 #endif /* _BENAPHORE_H */