xref: /haiku/headers/private/bluetooth/btDebug.h (revision 820dca4df6c7bf955c46e8f6521b9408f50b2900)
1 /*
2  * Copyright 2007 Oliver Ruiz Dorantes, oliver.ruiz.dorantes_at_gmail.com
3  *
4  * All rights reserved. Distributed under the terms of the MIT License.
5  *
6  */
7 
8 
9 #ifdef BT_DEBUG_THIS_MODULE
10 	#ifndef MODULE_NAME
11 	//#warning MODULE_NAME not defined for Haiku BT debugging tools
12 	#define MODULE_NAME "BT"
13 	#endif
14 
15 	#ifndef SUBMODULE_NAME
16 	//#warning SUBMODULE_NAME not defined for Haiku BT debugging tools
17 	#define SUBMODULE_NAME ""
18 	#endif
19 
20 	#ifndef SUBMODULE_COLOR
21 	//#warning SUBMODULE_COLOR not defined for Haiku BT debugging tools
22 	#define SUBMODULE_COLOR 38
23 	#endif
24 
25 	#define debugf(a,param...) dprintf("\x1b[%dm" MODULE_NAME " " SUBMODULE_NAME " " "%s\x1b[0m: " a,SUBMODULE_COLOR,__FUNCTION__, param);
26 	#define flowf(a) dprintf("\x1b[%dm" MODULE_NAME " " SUBMODULE_NAME " " "%s\x1b[0m: " a,SUBMODULE_COLOR,__FUNCTION__);
27 #else
28 	#define debugf(a,param...)
29 	#define flowf(a,param...)
30 #endif
31 #undef BT_DEBUG_THIS_MODULE
32 
33 #define TOUCH(x) ((void)(x))
34 
35 /* */
36 #if 0
37 #pragma mark - Kernel Auxiliary Stuff -
38 #endif
39 
40 /* tricking bits */
41 #define SET_BIT(byte,bit_mask)			{byte|=bit_mask;}
42 #define CLEAR_BIT(byte,bit_mask)		{byte&=~bit_mask;}
43 #define GET_BIT(byte,bit_mask)			((byte&bit_mask)!=0)
44 #define TOOGLE_BIT(byte,bit_mask)		{byte^=bit_mask;}
45 
46 //#define TEST_AND_SET(byte,bit_mask)     (((byte|=bit_mask)&bit_mask)!=0)
47 //#define TEST_AND_CLEAR(byte,bit_mask)   (((byte&=~bit_mask)&bit_mask)!=0)
48 
49 static inline uint32 TEST_AND_SET(uint32 *byte, uint32 bit_mask) {
50 
51 	uint32 val = (*byte&bit_mask)!=0;
52 	*byte |= bit_mask;
53 	return val;
54 }
55 
56 static inline uint32 TEST_AND_CLEAR(uint32* byte, uint32 bit_mask) {
57 
58 	uint32 val = (*byte&bit_mask)!=0;
59 	*byte &= ~bit_mask;
60 	return val;
61 }
62