-# define obd_debug(f, a...) { \
- printk ("SYM OBD DEBUG (%s, %d): %s:", \
- __FILE__, __LINE__, __FUNCTION__); \
- printk (f, ## a); \
- }
-#else
-# define obd_debug(f, a...) /**/
-#endif
+#define CDEBUG(mask, format, a...) \
+ do { \
+ if (obd_debug_level & mask) { \
+ printk("(%s,l. %d): ", __FUNCTION__, __LINE__); \
+ printk(format, ## a); } \
+ } while (0);
+
+#define ENTRY \
+ if (obd_print_entry) \
+ printk("Process %d entered %s\n", current->pid, __FUNCTION__)
+
+#define EXIT \
+ if (obd_print_entry) \
+ printk("Process %d leaving %s\n", current->pid, __FUNCTION__)
+
+#else /* SYM_OBD_DEBUG */
+
+# define CDEBUG(mask, format, a...) ;
+# define ENTRY ;
+# define EXIT ;
+
+#endif /* SYM_OBD_DEBUG */
+
+
+
+#define OBD_ALLOC(ptr, cast, size) \
+do { \
+ if (size <= 4096) { \
+ ptr = (cast)kmalloc((unsigned long) size, GFP_KERNEL); \
+ CDEBUG(D_MALLOC, "kmalloced: %x at %x.\n", \
+ (int) size, (int) ptr); \
+ } else { \
+ ptr = (cast)vmalloc((unsigned long) size); \
+ CDEBUG(D_MALLOC, "vmalloced: %x at %x.\n", \
+ (int) size, (int) ptr); \
+ } \
+ if (ptr == 0) { \
+ printk("kernel malloc returns 0 at %s:%d\n", \
+ __FILE__, __LINE__); \
+ } \
+ memset(ptr, 0, size); \
+} while (0)
+
+#define OBD_FREE(ptr,size) \
+do { \
+ if (size <= 4096) { \
+ kfree_s((ptr), (size)); \
+ CDEBUG(D_MALLOC, "kfreed: %x at %x.\n", \
+ (int) size, (int) ptr); \
+ } else { \
+ vfree((ptr)); \
+ CDEBUG(D_MALLOC, "vfreed: %x at %x.\n", \
+ (int) size, (int) ptr); \
+ } \
+} while (0)
+