]> git.eshelyaron.com Git - emacs.git/commitdiff
* lisp.h (eassert): Assume C89 or later.
authorPaul Eggert <eggert@cs.ucla.edu>
Sun, 17 Jun 2012 08:21:25 +0000 (01:21 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Sun, 17 Jun 2012 08:21:25 +0000 (01:21 -0700)
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.

src/ChangeLog
src/lisp.h

index ded14de2c4138ef706c366992554b31d455df82e..84be53f43d60f660b0a7de2b124ac5eb6e2cb292 100644 (file)
@@ -1,5 +1,11 @@
 2012-06-17  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * 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.
+
        * coding.c (produce_chars): Use ptrdiff_t, not int.
 
        * xterm.c (x_draw_underwave): Check for integer overflow.
index 8093682f0fb7de825c659a20cb03857c4c92e743..a88bf10c8bc3488100cb9917e808e44c2688ea76 100644 (file)
@@ -106,7 +106,12 @@ typedef EMACS_UINT uprintmax_t;
 
 /* Extra internal type checking?  */
 
-#ifdef ENABLE_CHECKING
+/* Define an Emacs version of 'assert (COND)', since some
+   system-defined 'assert's are flaky.  COND should be free of side
+   effects; it may or may not be evaluated.  */
+#ifndef ENABLE_CHECKING
+# define eassert(X) ((void) (0 && (X))) /* Check that X compiles.  */
+#else /* ENABLE_CHECKING */
 
 extern void die (const char *, const char *, int) NO_RETURN;
 
@@ -114,39 +119,16 @@ extern void die (const char *, const char *, int) NO_RETURN;
    it to 1 using a debugger to temporarily disable aborting on
    detected internal inconsistencies or error conditions.
 
-   Testing suppress_checking after the supplied condition ensures that
-   the side effects produced by CHECK will be consistent, independent
-   of whether ENABLE_CHECKING is defined, or whether the checks are
-   suppressed at run time.
-
    In some cases, a good compiler may be able to optimize away the
-   CHECK macro altogether, e.g., if XSTRING (x) uses CHECK to test
+   eassert macro altogether, e.g., if XSTRING (x) uses eassert to test
    STRINGP (x), but a particular use of XSTRING is invoked only after
    testing that STRINGP (x) is true, making the test redundant.  */
-
 extern int suppress_checking EXTERNALLY_VISIBLE;
 
-#define CHECK(check,msg) (((check) || suppress_checking                \
-                          ? (void) 0                           \
-                          : die ((msg), __FILE__, __LINE__)),  \
-                         0)
-#else
-
-/* Produce same side effects and result, but don't complain.  */
-#define CHECK(check,msg) ((check),0)
-
-#endif
-
-/* Define an Emacs version of "assert", since some system ones are
-   flaky.  */
-#ifndef ENABLE_CHECKING
-#define eassert(X) ((void) (0 && (X))) /* Check that X compiles.  */
-#else /* ENABLE_CHECKING */
-#if defined (__GNUC__) && __GNUC__ >= 2 && defined (__STDC__)
-#define eassert(cond) CHECK (cond, "assertion failed: " #cond)
-#else
-#define eassert(cond) CHECK (cond, "assertion failed")
-#endif
+# define eassert(cond)                                         \
+   ((cond) || suppress_checking                                        \
+    ? (void) 0                                                 \
+    : die ("assertion failed: " # cond, __FILE__, __LINE__))
 #endif /* ENABLE_CHECKING */
 \f
 /* Use the configure flag --enable-check-lisp-object-type to make