diff options
| author | Paul Eggert | 2012-06-17 01:21:25 -0700 |
|---|---|---|
| committer | Paul Eggert | 2012-06-17 01:21:25 -0700 |
| commit | 310fbfa8e2c800b684425a603926b19c45c9f283 (patch) | |
| tree | 33ad405dd358dad0552b5e06ae30359f1cb2abd3 /src | |
| parent | 27bb1ca4b00cb47153db3016ced27c0327932fce (diff) | |
| download | emacs-310fbfa8e2c800b684425a603926b19c45c9f283.tar.gz emacs-310fbfa8e2c800b684425a603926b19c45c9f283.zip | |
* lisp.h (eassert): Assume C89 or later.
This removes the need for CHECK.
(CHECK): Remove. Its comments about always evaluating its
argument were confusing, as 'eassert' typically does not evaluate
its argument.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 6 | ||||
| -rw-r--r-- | src/lisp.h | 40 |
2 files changed, 17 insertions, 29 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index ded14de2c41..84be53f43d6 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,5 +1,11 @@ | |||
| 1 | 2012-06-17 Paul Eggert <eggert@cs.ucla.edu> | 1 | 2012-06-17 Paul Eggert <eggert@cs.ucla.edu> |
| 2 | 2 | ||
| 3 | * lisp.h (eassert): Assume C89 or later. | ||
| 4 | This removes the need for CHECK. | ||
| 5 | (CHECK): Remove. Its comments about always evaluating its | ||
| 6 | argument were confusing, as 'eassert' typically does not evaluate | ||
| 7 | its argument. | ||
| 8 | |||
| 3 | * coding.c (produce_chars): Use ptrdiff_t, not int. | 9 | * coding.c (produce_chars): Use ptrdiff_t, not int. |
| 4 | 10 | ||
| 5 | * xterm.c (x_draw_underwave): Check for integer overflow. | 11 | * xterm.c (x_draw_underwave): Check for integer overflow. |
diff --git a/src/lisp.h b/src/lisp.h index 8093682f0fb..a88bf10c8bc 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -106,7 +106,12 @@ typedef EMACS_UINT uprintmax_t; | |||
| 106 | 106 | ||
| 107 | /* Extra internal type checking? */ | 107 | /* Extra internal type checking? */ |
| 108 | 108 | ||
| 109 | #ifdef ENABLE_CHECKING | 109 | /* Define an Emacs version of 'assert (COND)', since some |
| 110 | system-defined 'assert's are flaky. COND should be free of side | ||
| 111 | effects; it may or may not be evaluated. */ | ||
| 112 | #ifndef ENABLE_CHECKING | ||
| 113 | # define eassert(X) ((void) (0 && (X))) /* Check that X compiles. */ | ||
| 114 | #else /* ENABLE_CHECKING */ | ||
| 110 | 115 | ||
| 111 | extern void die (const char *, const char *, int) NO_RETURN; | 116 | extern void die (const char *, const char *, int) NO_RETURN; |
| 112 | 117 | ||
| @@ -114,39 +119,16 @@ extern void die (const char *, const char *, int) NO_RETURN; | |||
| 114 | it to 1 using a debugger to temporarily disable aborting on | 119 | it to 1 using a debugger to temporarily disable aborting on |
| 115 | detected internal inconsistencies or error conditions. | 120 | detected internal inconsistencies or error conditions. |
| 116 | 121 | ||
| 117 | Testing suppress_checking after the supplied condition ensures that | ||
| 118 | the side effects produced by CHECK will be consistent, independent | ||
| 119 | of whether ENABLE_CHECKING is defined, or whether the checks are | ||
| 120 | suppressed at run time. | ||
| 121 | |||
| 122 | In some cases, a good compiler may be able to optimize away the | 122 | In some cases, a good compiler may be able to optimize away the |
| 123 | CHECK macro altogether, e.g., if XSTRING (x) uses CHECK to test | 123 | eassert macro altogether, e.g., if XSTRING (x) uses eassert to test |
| 124 | STRINGP (x), but a particular use of XSTRING is invoked only after | 124 | STRINGP (x), but a particular use of XSTRING is invoked only after |
| 125 | testing that STRINGP (x) is true, making the test redundant. */ | 125 | testing that STRINGP (x) is true, making the test redundant. */ |
| 126 | |||
| 127 | extern int suppress_checking EXTERNALLY_VISIBLE; | 126 | extern int suppress_checking EXTERNALLY_VISIBLE; |
| 128 | 127 | ||
| 129 | #define CHECK(check,msg) (((check) || suppress_checking \ | 128 | # define eassert(cond) \ |
| 130 | ? (void) 0 \ | 129 | ((cond) || suppress_checking \ |
| 131 | : die ((msg), __FILE__, __LINE__)), \ | 130 | ? (void) 0 \ |
| 132 | 0) | 131 | : die ("assertion failed: " # cond, __FILE__, __LINE__)) |
| 133 | #else | ||
| 134 | |||
| 135 | /* Produce same side effects and result, but don't complain. */ | ||
| 136 | #define CHECK(check,msg) ((check),0) | ||
| 137 | |||
| 138 | #endif | ||
| 139 | |||
| 140 | /* Define an Emacs version of "assert", since some system ones are | ||
| 141 | flaky. */ | ||
| 142 | #ifndef ENABLE_CHECKING | ||
| 143 | #define eassert(X) ((void) (0 && (X))) /* Check that X compiles. */ | ||
| 144 | #else /* ENABLE_CHECKING */ | ||
| 145 | #if defined (__GNUC__) && __GNUC__ >= 2 && defined (__STDC__) | ||
| 146 | #define eassert(cond) CHECK (cond, "assertion failed: " #cond) | ||
| 147 | #else | ||
| 148 | #define eassert(cond) CHECK (cond, "assertion failed") | ||
| 149 | #endif | ||
| 150 | #endif /* ENABLE_CHECKING */ | 132 | #endif /* ENABLE_CHECKING */ |
| 151 | 133 | ||
| 152 | /* Use the configure flag --enable-check-lisp-object-type to make | 134 | /* Use the configure flag --enable-check-lisp-object-type to make |