ceptr
 All Data Structures Files Functions Variables Typedefs Macros Modules Pages
debug.h
Go to the documentation of this file.
1 
7 #ifndef CEPTR_DEBUG_H
8 #define CEPTR_DEBUG_H
9 
10 #define CEPTR_DEBUG
11 #ifdef CEPTR_DEBUG
12 
13 enum {D_NONE=0x0000,D_ALL=0xFFFF,D_SPEC=0x8000,D_SIGNALS=0x0001,D_REDUCE=0x0002,D_REDUCEV=0x0004,D_STX_MATCH=0x0008,D_CLOCK=0x0010,D_STREAM=0x0020,D_LOCK=0x0040,D_LISTEN=0x0080,D_PROTOCOL=0x0100,D_TREE=0x0200,D_TRANSCODE=0x0400,D_STEP=0x0800,D_SOCKET=0x1000,D_BOOT=0x2000,D_STX_BUILD=0x4000};
14 
15 #define DEBUG_DEFAULT_MASK D_NONE
16 //#define DEBUG_DEFAULT_MASK D_SIGNALS
17 
18 #ifndef DEBUG_MASK
19 #define DEBUG_MASK 0
20 #endif
21 
22 #include <stdio.h>
23 
24 #define DEBUGGER raise(SIGINT)
25 
26 #define debugging(type) ((type)&G_debug_mask)
27 
28 char *dtypestr(int type);
29 void debug_enable(int type);
30 void debug_disable(int type);
31 int G_debug_mask;
32 
33 
34 #define _debug(type,...) do {fprintf(stderr,"D%s: ",dtypestr(type));fprintf(stderr,__VA_ARGS__);}while(0);
35 #define debug(type,...) do {if debugging(type) _debug(type,__VA_ARGS__);} while(0);
36 
37 #else
38 
39 #define debug(type,...)
40 #endif
41 
42 #endif