5 #include "bcsignals.inc"
9 #define TRON(x) BC_Signals::new_function(x);
10 #define TROFF(x) BC_Signals::delete_function(x);
12 // BC_Signals must be initialized at the start of every program using
19 //#define TRACE_MEMORY
22 // Need to use structs to avoid the memory manager.
23 // One of these tables is created every time someone locks a lock.
24 // After successfully locking, the table is flagged as being the owner of the lock.
25 // In the unlock function, the table flagged as the owner of the lock is deleted.
43 virtual void signal_handler(int signum
);
47 #define TRACE(text) BC_Signals::new_trace(text);
48 #define SET_TRACE BC_Signals::new_trace(__FILE__, __FUNCTION__, __LINE__);
51 #define UNTRACE BC_Signals::delete_traces();
63 // Before user acquires
64 #define SET_LOCK(ptr, title, location) int table_id = BC_Signals::set_lock(ptr, title, location);
65 // After successful acquisition
66 #define SET_LOCK2 BC_Signals::set_lock2(table_id);
67 // Release current lock table after failing to acquire
68 #define UNSET_LOCK2 BC_Signals::unset_lock2(table_id);
70 // Release current owner of lock
71 #define UNSET_LOCK(ptr) BC_Signals::unset_lock(ptr);
74 #define UNSET_ALL_LOCKS(ptr) BC_Signals::unset_all_locks(ptr);
78 #define SET_LOCK(ptr, title, location) ;
80 #define UNSET_LOCK(ptr) ;
82 #define UNSET_ALL_LOCKS(ptr) ;
89 #define ENABLE_BUFFER BC_Signals::enable_memory();
90 #define DISABLE_BUFFER BC_Signals::disable_memory();
91 #define BUFFER(size, ptr, location) BC_Signals::set_buffer(size, ptr, location);
92 #define UNBUFFER(ptr) BC_Signals::unset_buffer(ptr);
96 #define ENABLE_BUFFER ;
97 #define DISABLE_BUFFER ;
98 #define BUFFER(size, ptr, location);
99 #define UNBUFFER(ptr);
103 // Handling of temporary files in crash
104 #define SET_TEMP BC_Signals::set_temp
105 #define UNSET_TEMP BC_Signals::unset_temp
108 static void delete_temps();
109 static void set_temp(char *string
);
110 static void unset_temp(char *string
);
115 static int set_lock(void *ptr
, char *title
, char *location
);
116 static void set_lock2(int table_id
);
117 static void unset_lock2(int table_id
);
118 static void unset_lock(void *ptr
);
119 // Used in lock destructors so takes away all references
120 static void unset_all_locks(void *ptr
);
122 static void new_trace(char *text
);
123 static void new_trace(const char *file
, const char *function
, int line
);
124 static void delete_traces();
126 static void enable_memory();
127 static void disable_memory();
128 static void set_buffer(int size
, void *ptr
, char* location
);
129 // This one returns 1 if the buffer wasn't found.
130 static int unset_buffer(void *ptr
);
132 static void dump_traces();
133 static void dump_locks();
134 static void dump_buffers();
136 // Convert signum to text
137 static char* sig_to_str(int number
);
139 static BC_Signals
*global_signals
;