Partially sync files.el from XEmacs 21.5 for wildcard support.
[sxemacs] / src / debug.h
1 /* Debugging aids -- togglable assertions.
2    Copyright (C) 1994 Free Software Foundation, Inc.
3
4 This file is part of SXEmacs
5
6 SXEmacs is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 SXEmacs is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with this program.  If not, see <http://www.gnu.org/licenses/>. */
18
19
20 /* Synched up with: Not in FSF. */
21
22 /* Written by Chuck Thompson */
23
24 #ifndef INCLUDED_debug_h_
25 #define INCLUDED_debug_h_
26
27 #define DEBUG_STDERR    1
28 #define DEBUG_ABORT     2
29
30 #ifdef DEBUG_SXEMACS
31
32 #include <stdio.h>
33
34 struct debug_classes {
35         unsigned int redisplay:1;
36         unsigned int buffers:1;
37         unsigned int extents:1;
38         unsigned int faces:1;
39         unsigned int windows:1;
40         unsigned int frames:1;
41         unsigned int devices:1;
42         unsigned int byte_code:1;
43
44         unsigned int types_of_redisplay;
45         unsigned int types_of_buffers;
46         unsigned int types_of_extents;
47         unsigned int types_of_faces;
48         unsigned int types_of_windows;
49         unsigned int types_of_frames;
50         unsigned int types_of_devices;
51         unsigned int types_of_byte_code;
52 };
53
54 extern struct debug_classes active_debug_classes;
55
56 #define DASSERT(class, desired_type, action, assertion) do              \
57 {                                                                       \
58   if (active_debug_classes.##class                                      \
59       && (active_debug_classes.types_of_##class & desired_type))        \
60     {                                                                   \
61       if (! (assertion))                                                \
62         {                                                               \
63           if (action == DEBUG_STDERR)                                   \
64             stderr_out ("Assertion failed in %s at line %d\n",          \
65                         __FILE__, __LINE__);                            \
66           else                                                          \
67             abort ();                                                   \
68         }                                                               \
69     }                                                                   \
70 } while (0)
71 #else                           /* !DEBUG_SXEMACS */
72
73 #define DASSERT(class, desired_type, action, assertion) ((void) 0)
74
75 #endif                          /* !DEBUG_SXEMACS */
76
77 #endif                          /* INCLUDED_debug_h_ */