|
|
1.1 root 1: #ifndef __SYS_KDEBUG_H__
2: #define __SYS_KDEBUG_H__
3:
4: /*
5: * This header defines debugging macros suitable for use in an operating
6: * system kernel. There can be a variety of handling disciplines in place
7: * for each different class of internal problem, depending on whether or
8: * not this is a production or debugging system (and on the presence of some
9: * kind of debugger which we might like to call upon).
10: *
11: * One aim is that the code which is being developed should be able to pass
12: * the strictest of "lint"-style checks. In the past it has often been the
13: * case that developers have not taken certain classes of diagnostics
14: * seriously, especially where the return value of a function is not used.
15: *
16: * In an operating system kernel, it is *never* safe to assume that any
17: * function that returns a value can have that value ignored. Even if there
18: * is no sane corrective action that can take place, developers should be
19: * able to expect assert ()-style checks will catch such "impossible"
20: * conditions.
21: */
22:
23: /*
24: *-IMPORTS:
25: * <common/ccompat.h>
26: * __EXTERN_C_BEGIN__
27: * __EXTERN_C_END__
28: * __STRING ()
29: * __PROTO ()
30: * <common/xdebug.h>
31: * __FILE_INFO__
32: */
33:
34: #include <common/xdebug.h>
35:
36:
37: __EXTERN_C_BEGIN__
38:
39: __NO_RETURN__ void
40: __assert_fail2 __PROTO ((__CONST__ char * _exp,
41: __CONST__ char * _info,
42: int _lineno));
43: __NO_RETURN__ void
44: __assert_fail __PROTO ((__CONST__ char * _exp));
45:
46: __EXTERN_C_END__
47:
48:
49: /*
50: * The ASSERT () macro evaluates it's argument and checks for a non-zero
51: * (boolean TRUE, in the C language) result. If any other value is returned,
52: * an assert ()-style diagnostic is issued to the system console via
53: * cmn_err () with a severity of CE_WARN.
54: *
55: * The name ASSERT () indicates that the value of the test expression is just
56: * that, a test, and may not be evaluated if the system is compiled with
57: * debugging facilities suppressed.
58: */
59:
60: #ifndef NDEBUG
61: # if __NO_FILE_INFO__
62: # define ASSERT(exp) ((void) ((exp) ? (void) 0 : \
63: __assert_fail (__STRING (exp), NULL, 0)))
64: # else
65: # define ASSERT(exp) ((void) ((exp) ? (void) 0 : \
66: __assert_fail2 (__STRING (exp), __FILE_INFO__)))
67: # endif
68: #else
69: # define ASSERT(exp) ((void) 0)
70: #endif
71:
72:
73: #endif /* ! defined (__SYS_KDEBUG_H__) */
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.