diff options
| author | Paul Eggert | 2013-10-10 23:32:29 -0700 |
|---|---|---|
| committer | Paul Eggert | 2013-10-10 23:32:29 -0700 |
| commit | b9ff995e4c091ca99c8752bb996e155ce7147a00 (patch) | |
| tree | 2606b847e60957359df7942004b774b4c68b119f /src/lisp.h | |
| parent | 33ac026599404c7d5177eecb4fcd0aa527180ee2 (diff) | |
| download | emacs-b9ff995e4c091ca99c8752bb996e155ce7147a00.tar.gz emacs-b9ff995e4c091ca99c8752bb996e155ce7147a00.zip | |
* lisp.h (eassume): New macro.
Also, include <verify.h>, for 'assume'.
* alloc.c (bool_vector_payload_bytes, Fmake_bool_vector)
(vroundup, vector_nbytes):
* data.c (bool_vector_spare_mask, bool_vector_binop_driver)
(Fbool_vector_not, Fbool_vector_count_matches)
(Fbool_vector_count_matches_at):
Use eassume, not eassert.
* casetab.c (set_identity, shuffle):
* composite.c (composition_gstring_put_cache):
* dispnew.c (update_frame_1):
* ftfont.c (ftfont_shape_by_flt):
* image.c (gif_load):
* intervals.c (offset_intervals):
* macfont.m (macfont_shape):
Remove calls to 'assume' that are no longer needed, because
--enable-gcc-warnings no longer generates bogus warnings
when these calls are removed.
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/lisp.h b/src/lisp.h index 6638cc66e9f..e4a2caa1083 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -31,6 +31,7 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ | |||
| 31 | #include <limits.h> | 31 | #include <limits.h> |
| 32 | 32 | ||
| 33 | #include <intprops.h> | 33 | #include <intprops.h> |
| 34 | #include <verify.h> | ||
| 34 | 35 | ||
| 35 | INLINE_HEADER_BEGIN | 36 | INLINE_HEADER_BEGIN |
| 36 | 37 | ||
| @@ -113,28 +114,48 @@ typedef EMACS_UINT uprintmax_t; | |||
| 113 | 114 | ||
| 114 | /* Extra internal type checking? */ | 115 | /* Extra internal type checking? */ |
| 115 | 116 | ||
| 116 | /* Define an Emacs version of 'assert (COND)'. COND should be free of | 117 | /* Define Emacs versions of <assert.h>'s 'assert (COND)' and <verify.h>'s |
| 117 | side effects; it may be evaluated zero or more times. */ | 118 | 'assume (COND)'. COND should be free of side effects, as it may or |
| 119 | may not be evaluated. | ||
| 120 | |||
| 121 | 'eassert (COND)' checks COND at runtime if ENABLE_CHECKING is | ||
| 122 | defined and suppress_checking is false, and does nothing otherwise. | ||
| 123 | Emacs dies if COND is checked and is false. The suppress_checking | ||
| 124 | variable is initialized to 0 in alloc.c. Set it to 1 using a | ||
| 125 | debugger to temporarily disable aborting on detected internal | ||
| 126 | inconsistencies or error conditions. | ||
| 127 | |||
| 128 | In some cases, a good compiler may be able to optimize away the | ||
| 129 | eassert macro even if ENABLE_CHECKING is true, e.g., if XSTRING (x) | ||
| 130 | uses eassert to test STRINGP (x), but a particular use of XSTRING | ||
| 131 | is invoked only after testing that STRINGP (x) is true, making the | ||
| 132 | test redundant. | ||
| 133 | |||
| 134 | eassume is like eassert except that it also causes the compiler to | ||
| 135 | assume that COND is true afterwards, regardless of whether runtime | ||
| 136 | checking is enabled. This can improve performance in some cases, | ||
| 137 | though it can degrade performance in others. It's often suboptimal | ||
| 138 | for COND to call external functions or access volatile storage. */ | ||
| 139 | |||
| 118 | #ifndef ENABLE_CHECKING | 140 | #ifndef ENABLE_CHECKING |
| 119 | # define eassert(cond) ((void) (0 && (cond))) /* Check that COND compiles. */ | 141 | # define eassert(cond) ((void) (0 && (cond))) /* Check that COND compiles. */ |
| 142 | # define eassume(cond) assume (cond) | ||
| 120 | #else /* ENABLE_CHECKING */ | 143 | #else /* ENABLE_CHECKING */ |
| 121 | 144 | ||
| 122 | extern _Noreturn void die (const char *, const char *, int); | 145 | extern _Noreturn void die (const char *, const char *, int); |
| 123 | 146 | ||
| 124 | /* The suppress_checking variable is initialized to 0 in alloc.c. Set | ||
| 125 | it to 1 using a debugger to temporarily disable aborting on | ||
| 126 | detected internal inconsistencies or error conditions. | ||
| 127 | |||
| 128 | In some cases, a good compiler may be able to optimize away the | ||
| 129 | eassert macro altogether, e.g., if XSTRING (x) uses eassert to test | ||
| 130 | STRINGP (x), but a particular use of XSTRING is invoked only after | ||
| 131 | testing that STRINGP (x) is true, making the test redundant. */ | ||
| 132 | extern bool suppress_checking EXTERNALLY_VISIBLE; | 147 | extern bool suppress_checking EXTERNALLY_VISIBLE; |
| 133 | 148 | ||
| 134 | # define eassert(cond) \ | 149 | # define eassert(cond) \ |
| 135 | (suppress_checking || (cond) \ | 150 | (suppress_checking || (cond) \ |
| 136 | ? (void) 0 \ | 151 | ? (void) 0 \ |
| 137 | : die (# cond, __FILE__, __LINE__)) | 152 | : die (# cond, __FILE__, __LINE__)) |
| 153 | # define eassume(cond) \ | ||
| 154 | (suppress_checking \ | ||
| 155 | ? assume (cond) \ | ||
| 156 | : (cond) \ | ||
| 157 | ? (void) 0 \ | ||
| 158 | : die (# cond, __FILE__, __LINE__)) | ||
| 138 | #endif /* ENABLE_CHECKING */ | 159 | #endif /* ENABLE_CHECKING */ |
| 139 | 160 | ||
| 140 | 161 | ||