import of ftp.dlink.com/GPL/DSMG-600_reB/ppclinux.tar.gz
[linux-2.4.21-pre4.git] / fs / jfs / jfs_debug.h
1 /*
2  *   Copyright (c) International Business Machines Corp., 2000-2002
3  *   Portions Copyright (c) Christoph Hellwig, 2001-2002
4  *
5  *   This program is free software;  you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY;  without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
13  *   the GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License
16  *   along with this program;  if not, write to the Free Software
17  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19 #ifndef _H_JFS_DEBUG
20 #define _H_JFS_DEBUG
21
22 /*
23  *      jfs_debug.h
24  *
25  * global debug message, data structure/macro definitions
26  * under control of CONFIG_JFS_DEBUG, CONFIG_JFS_STATISTICS;
27  */
28
29 /*
30  * Create /proc/fs/jfs if procfs is enabled andeither
31  * CONFIG_JFS_DEBUG or CONFIG_JFS_STATISTICS is defined
32  */
33 #if defined(CONFIG_PROC_FS) && (defined(CONFIG_JFS_DEBUG) || defined(CONFIG_JFS_STATISTICS))
34         #define PROC_FS_JFS
35 #endif
36
37 /*
38  *      assert with traditional printf/panic
39  */
40 #ifdef CONFIG_KERNEL_ASSERTS
41 /* kgdb stuff */
42 #define assert(p) KERNEL_ASSERT(#p, p)
43 #else
44 #define assert(p) {\
45 if (!(p))\
46         {\
47                 printk("assert(%s)\n",#p);\
48                 BUG();\
49         }\
50 }
51 #endif
52
53 /*
54  *      debug ON
55  *      --------
56  */
57 #ifdef CONFIG_JFS_DEBUG
58 #define ASSERT(p) assert(p)
59
60 /* dump memory contents */
61 extern void dump_mem(char *label, void *data, int length);
62 extern int jfsloglevel;
63
64 /* information message: e.g., configuration, major event */
65 #define jFYI(button, prspec) \
66         do { if (button && jfsloglevel > 1) printk prspec; } while (0)
67
68 /* error event message: e.g., i/o error */
69 extern int jfsERROR;
70 #define jERROR(button, prspec) \
71         do { if (button && jfsloglevel > 0) { printk prspec; } } while (0)
72
73 /* debug event message: */
74 #define jEVENT(button,prspec) \
75         do { if (button) printk prspec; } while (0)
76
77 /*
78  *      debug OFF
79  *      ---------
80  */
81 #else                           /* CONFIG_JFS_DEBUG */
82 #define dump_mem(label,data,length)
83 #define ASSERT(p)
84 #define jEVENT(button,prspec)
85 #define jERROR(button,prspec)
86 #define jFYI(button,prspec)
87 #endif                          /* CONFIG_JFS_DEBUG */
88
89 /*
90  *      statistics
91  *      ----------
92  */
93 #ifdef  CONFIG_JFS_STATISTICS
94 #define INCREMENT(x)            ((x)++)
95 #define DECREMENT(x)            ((x)--)
96 #define HIGHWATERMARK(x,y)      ((x) = max((x), (y)))
97 #else
98 #define INCREMENT(x)
99 #define DECREMENT(x)
100 #define HIGHWATERMARK(x,y)
101 #endif                          /* CONFIG_JFS_STATISTICS */
102
103 #endif                          /* _H_JFS_DEBUG */