diff options
Diffstat (limited to 'src/lisp.h')
-rw-r--r-- | src/lisp.h | 190 |
1 files changed, 102 insertions, 88 deletions
diff --git a/src/lisp.h b/src/lisp.h index c4b36557eac..1e68b152dfc 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -23,7 +23,6 @@ along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ #include <setjmp.h> #include <stdalign.h> #include <stdarg.h> -#include <stdbool.h> #include <stddef.h> #include <float.h> #include <inttypes.h> @@ -170,7 +169,7 @@ typedef EMACS_UINT uprintmax_t; for COND to call external functions or access volatile storage. */ #ifndef ENABLE_CHECKING -# define eassert(cond) ((void) (0 && (cond))) /* Check that COND compiles. */ +# define eassert(cond) ((void) (false && (cond))) /* Check COND compiles. */ # define eassume(cond) assume (cond) #else /* ENABLE_CHECKING */ @@ -251,20 +250,20 @@ enum Lisp_Bits On hosts where pointers-as-ints do not exceed VAL_MAX, USE_LSB_TAG is: a. unnecessary, because the top bits of an EMACS_INT are unused, and b. slower, because it typically requires extra masking. - So, default USE_LSB_TAG to 1 only on hosts where it might be useful. */ + So, default USE_LSB_TAG to true only on hosts where it might be useful. */ # if VAL_MAX < UINTPTR_MAX -# define USE_LSB_TAG 1 +# define USE_LSB_TAG true # endif # endif # endif #endif #ifdef USE_LSB_TAG # undef USE_LSB_TAG -enum enum_USE_LSB_TAG { USE_LSB_TAG = 1 }; -# define USE_LSB_TAG 1 +enum enum_USE_LSB_TAG { USE_LSB_TAG = true }; +# define USE_LSB_TAG true #else -enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 }; -# define USE_LSB_TAG 0 +enum enum_USE_LSB_TAG { USE_LSB_TAG = false }; +# define USE_LSB_TAG false #endif #ifndef alignas @@ -356,7 +355,7 @@ enum enum_USE_LSB_TAG { USE_LSB_TAG = 0 }; /* When compiling via gcc -O0, define the key operations as macros, as Emacs is too slow otherwise. To disable this optimization, compile - with -DINLINING=0. */ + with -DINLINING=false. */ #if (defined __NO_INLINE__ \ && ! defined __OPTIMIZE__ && ! defined __OPTIMIZE_SIZE__ \ && ! (defined INLINING && ! INLINING)) @@ -550,14 +549,14 @@ typedef struct { EMACS_INT i; } Lisp_Object; #define LISP_INITIALLY_ZERO {0} #undef CHECK_LISP_OBJECT_TYPE -enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 1 }; +enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = true }; #else /* CHECK_LISP_OBJECT_TYPE */ /* If a struct type is not wanted, define Lisp_Object as just a number. */ typedef EMACS_INT Lisp_Object; #define LISP_INITIALLY_ZERO 0 -enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = 0 }; +enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = false }; #endif /* CHECK_LISP_OBJECT_TYPE */ /* Convert a Lisp_Object to the corresponding EMACS_INT and vice versa. @@ -736,7 +735,7 @@ make_natnum (EMACS_INT n) /* Return true if X and Y are the same object. */ LISP_MACRO_DEFUN (EQ, bool, (Lisp_Object x, Lisp_Object y), (x, y)) -/* Value is non-zero if I doesn't fit into a Lisp fixnum. It is +/* Value is true if I doesn't fit into a Lisp fixnum. It is written this way so that it also works if I is of unsigned type or if I is a NaN. */ @@ -1085,17 +1084,23 @@ STRING_MULTIBYTE (Lisp_Object str) ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1)) /* Mark STR as a unibyte string. */ -#define STRING_SET_UNIBYTE(STR) \ - do { if (EQ (STR, empty_multibyte_string)) \ - (STR) = empty_unibyte_string; \ - else XSTRING (STR)->size_byte = -1; } while (0) +#define STRING_SET_UNIBYTE(STR) \ + do { \ + if (EQ (STR, empty_multibyte_string)) \ + (STR) = empty_unibyte_string; \ + else \ + XSTRING (STR)->size_byte = -1; \ + } while (false) /* Mark STR as a multibyte string. Assure that STR contains only ASCII characters in advance. */ -#define STRING_SET_MULTIBYTE(STR) \ - do { if (EQ (STR, empty_unibyte_string)) \ - (STR) = empty_multibyte_string; \ - else XSTRING (STR)->size_byte = XSTRING (STR)->size; } while (0) +#define STRING_SET_MULTIBYTE(STR) \ + do { \ + if (EQ (STR, empty_unibyte_string)) \ + (STR) = empty_multibyte_string; \ + else \ + XSTRING (STR)->size_byte = XSTRING (STR)->size; \ + } while (false) /* Convenience functions for dealing with Lisp strings. */ @@ -1348,14 +1353,14 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val) /* Compute A OP B, using the unsigned comparison operator OP. A and B should be integer expressions. This is not the same as mathematical comparison; for example, UNSIGNED_CMP (0, <, -1) - returns 1. For efficiency, prefer plain unsigned comparison if A + returns true. For efficiency, prefer plain unsigned comparison if A and B's sizes both fit (after integer promotion). */ #define UNSIGNED_CMP(a, op, b) \ (max (sizeof ((a) + 0), sizeof ((b) + 0)) <= sizeof (unsigned) \ ? ((a) + (unsigned) 0) op ((b) + (unsigned) 0) \ : ((a) + (uintmax_t) 0) op ((b) + (uintmax_t) 0)) -/* Nonzero iff C is an ASCII character. */ +/* True iff C is an ASCII character. */ #define ASCII_CHAR_P(c) UNSIGNED_CMP (c, <, 0x80) /* A char-table is a kind of vectorlike, with contents are like a @@ -1536,7 +1541,7 @@ enum symbol_redirect struct Lisp_Symbol { - unsigned gcmarkbit : 1; + bool_bf gcmarkbit : 1; /* Indicates where the value can be found: 0 : it's a plain var, the value is in the `value' field. @@ -1554,9 +1559,9 @@ struct Lisp_Symbol enum symbol_interned. */ unsigned interned : 2; - /* Non-zero means that this variable has been explicitly declared + /* True means that this variable has been explicitly declared special (with `defvar' etc), and shouldn't be lexically bound. */ - unsigned declared_special : 1; + bool_bf declared_special : 1; /* The symbol's name, as a Lisp string. */ Lisp_Object name; @@ -1654,7 +1659,7 @@ SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (Lisp_Object sym) LISP_MACRO_DEFUN (SYMBOL_CONSTANT_P, int, (Lisp_Object sym), (sym)) #define DEFSYM(sym, name) \ - do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (0) + do { (sym) = intern_c_string ((name)); staticpro (&(sym)); } while (false) /*********************************************************************** @@ -1832,22 +1837,22 @@ SXHASH_REDUCE (EMACS_UINT x) struct Lisp_Misc_Any /* Supertype of all Misc types. */ { ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_??? */ - unsigned gcmarkbit : 1; + bool_bf gcmarkbit : 1; unsigned spacer : 15; }; struct Lisp_Marker { ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Marker */ - unsigned gcmarkbit : 1; + bool_bf gcmarkbit : 1; unsigned spacer : 13; /* This flag is temporarily used in the functions decode/encode_coding_object to record that the marker position must be adjusted after the conversion. */ - unsigned int need_adjustment : 1; - /* 1 means normal insertion at the marker's position + bool_bf need_adjustment : 1; + /* True means normal insertion at the marker's position leaves the marker after the inserted text. */ - unsigned int insertion_type : 1; + bool_bf insertion_type : 1; /* This is the buffer that the marker points into, or 0 if it points nowhere. Note: a chain of markers can contain markers pointing into different buffers (the chain is per buffer_text rather than per buffer, so it's @@ -1893,7 +1898,7 @@ struct Lisp_Overlay */ { ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Overlay */ - unsigned gcmarkbit : 1; + bool_bf gcmarkbit : 1; unsigned spacer : 15; struct Lisp_Overlay *next; Lisp_Object start; @@ -1971,7 +1976,7 @@ typedef void (*voidfuncptr) (void); struct Lisp_Save_Value { ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */ - unsigned gcmarkbit : 1; + bool_bf gcmarkbit : 1; unsigned spacer : 32 - (16 + 1 + SAVE_TYPE_BITS); /* V->data may hold up to SAVE_VALUE_SLOTS entries. The type of @@ -2047,7 +2052,7 @@ XSAVE_OBJECT (Lisp_Object obj, int n) struct Lisp_Free { ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Free */ - unsigned gcmarkbit : 1; + bool_bf gcmarkbit : 1; unsigned spacer : 15; union Lisp_Misc *chain; }; @@ -2116,8 +2121,8 @@ struct Lisp_Intfwd /* Boolean forwarding pointer to an int variable. This is like Lisp_Intfwd except that the ostensible - "value" of the symbol is t if the int variable is nonzero, - nil if it is zero. */ + "value" of the symbol is t if the bool variable is true, + nil if it is false. */ struct Lisp_Boolfwd { enum Lisp_Fwd_Type type; /* = Lisp_Fwd_Bool */ @@ -2170,15 +2175,15 @@ struct Lisp_Buffer_Objfwd struct Lisp_Buffer_Local_Value { - /* 1 means that merely setting the variable creates a local + /* True means that merely setting the variable creates a local binding for the current buffer. */ - unsigned int local_if_set : 1; - /* 1 means this variable can have frame-local bindings, otherwise, it is + bool_bf local_if_set : 1; + /* True means this variable can have frame-local bindings, otherwise, it is can have buffer-local bindings. The two cannot be combined. */ - unsigned int frame_local : 1; - /* 1 means that the binding now loaded was found. + bool_bf frame_local : 1; + /* True means that the binding now loaded was found. Presumably equivalent to (defcell!=valcell). */ - unsigned int found : 1; + bool_bf found : 1; /* If non-NULL, a forwarding to the C var where it should also be set. */ union Lisp_Fwd *fwd; /* Should never be (Buffer|Kboard)_Objfwd. */ /* The buffer or frame for which the loaded binding was found. */ @@ -2373,7 +2378,7 @@ INLINE bool PSEUDOVECTORP (Lisp_Object a, int code) { if (! VECTORLIKEP (a)) - return 0; + return false; else { /* Converting to struct vectorlike_header * avoids aliasing issues. */ @@ -2541,18 +2546,22 @@ CHECK_NATNUM (Lisp_Object x) ? MOST_NEGATIVE_FIXNUM \ : (lo)), \ make_number (min (hi, MOST_POSITIVE_FIXNUM))); \ - } while (0) + } while (false) #define CHECK_TYPE_RANGED_INTEGER(type, x) \ do { \ if (TYPE_SIGNED (type)) \ CHECK_RANGED_INTEGER (x, TYPE_MINIMUM (type), TYPE_MAXIMUM (type)); \ else \ CHECK_RANGED_INTEGER (x, 0, TYPE_MAXIMUM (type)); \ - } while (0) + } while (false) -#define CHECK_NUMBER_COERCE_MARKER(x) \ - do { if (MARKERP ((x))) XSETFASTINT (x, marker_position (x)); \ - else CHECK_TYPE (INTEGERP (x), Qinteger_or_marker_p, x); } while (0) +#define CHECK_NUMBER_COERCE_MARKER(x) \ + do { \ + if (MARKERP ((x))) \ + XSETFASTINT (x, marker_position (x)); \ + else \ + CHECK_TYPE (INTEGERP (x), Qinteger_or_marker_p, x); \ + } while (false) INLINE double XFLOATINT (Lisp_Object n) @@ -2566,9 +2575,13 @@ CHECK_NUMBER_OR_FLOAT (Lisp_Object x) CHECK_TYPE (FLOATP (x) || INTEGERP (x), Qnumberp, x); } -#define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x) \ - do { if (MARKERP (x)) XSETFASTINT (x, marker_position (x)); \ - else CHECK_TYPE (INTEGERP (x) || FLOATP (x), Qnumber_or_marker_p, x); } while (0) +#define CHECK_NUMBER_OR_FLOAT_COERCE_MARKER(x) \ + do { \ + if (MARKERP (x)) \ + XSETFASTINT (x, marker_position (x)); \ + else \ + CHECK_TYPE (INTEGERP (x) || FLOATP (x), Qnumber_or_marker_p, x); \ + } while (false) /* Since we can't assign directly to the CAR or CDR fields of a cons cell, use these when checking that those fields contain numbers. */ @@ -2701,34 +2714,34 @@ extern void defvar_kboard (struct Lisp_Kboard_Objfwd *, const char *, int); do { \ static struct Lisp_Objfwd o_fwd; \ defvar_lisp (&o_fwd, lname, &globals.f_ ## vname); \ - } while (0) + } while (false) #define DEFVAR_LISP_NOPRO(lname, vname, doc) \ do { \ static struct Lisp_Objfwd o_fwd; \ defvar_lisp_nopro (&o_fwd, lname, &globals.f_ ## vname); \ - } while (0) + } while (false) #define DEFVAR_BOOL(lname, vname, doc) \ do { \ static struct Lisp_Boolfwd b_fwd; \ defvar_bool (&b_fwd, lname, &globals.f_ ## vname); \ - } while (0) + } while (false) #define DEFVAR_INT(lname, vname, doc) \ do { \ static struct Lisp_Intfwd i_fwd; \ defvar_int (&i_fwd, lname, &globals.f_ ## vname); \ - } while (0) + } while (false) #define DEFVAR_BUFFER_DEFAULTS(lname, vname, doc) \ do { \ static struct Lisp_Objfwd o_fwd; \ defvar_lisp_nopro (&o_fwd, lname, &BVAR (&buffer_defaults, vname)); \ - } while (0) + } while (false) #define DEFVAR_KBOARD(lname, vname, doc) \ do { \ static struct Lisp_Kboard_Objfwd ko_fwd; \ defvar_kboard (&ko_fwd, lname, offsetof (KBOARD, vname ## _)); \ - } while (0) + } while (false) /* Save and restore the instruction and environment pointers, without affecting the signal mask. */ @@ -2812,7 +2825,7 @@ union specbinding } let; struct { ENUM_BF (specbind_tag) kind : CHAR_BIT; - unsigned debug_on_exit : 1; + bool_bf debug_on_exit : 1; Lisp_Object function; Lisp_Object *args; ptrdiff_t nargs; @@ -2869,7 +2882,7 @@ struct handler /* Most global vars are reset to their value via the specpdl mechanism, but a few others are handled by storing their value here. */ -#if 1 /* GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS, but they're defined later. */ +#if true /* GC_MARK_STACK == GC_MAKE_GCPROS_NOOPS, but defined later. */ struct gcpro *gcpro; #endif sys_jmp_buf jmp; @@ -2917,7 +2930,7 @@ extern char *stack_bottom; Unless that is impossible, of course. But it is very desirable to avoid creating loops where QUIT is impossible. - Exception: if you set immediate_quit to nonzero, + Exception: if you set immediate_quit to true, then the handler that responds to the C-g does the quit itself. This is a good thing to do around a loop that has no side effects and (in particular) cannot call arbitrary Lisp code. @@ -2935,10 +2948,10 @@ extern void process_quit_flag (void); process_quit_flag (); \ else if (pending_signals) \ process_pending_signals (); \ - } while (0) + } while (false) -/* Nonzero if ought to quit now. */ +/* True if ought to quit now. */ #define QUITP (!NILP (Vquit_flag) && NILP (Vinhibit_quit)) @@ -3121,9 +3134,9 @@ extern int gcpro_level; gcprolist = &gcpro6; } #define UNGCPRO \ - ((--gcpro_level != gcpro1.level) \ - ? (emacs_abort (), 0) \ - : ((gcprolist = gcpro1.next), 0)) + (--gcpro_level != gcpro1.level \ + ? emacs_abort () \ + : (void) (gcprolist = gcpro1.next)) #endif /* DEBUG_GCPRO */ #endif /* GC_MARK_STACK != GC_MAKE_GCPROS_NOOPS */ @@ -3131,14 +3144,14 @@ extern int gcpro_level; /* Evaluate expr, UNGCPRO, and then return the value of expr. */ #define RETURN_UNGCPRO(expr) \ -do \ + do \ { \ Lisp_Object ret_ungc_val; \ ret_ungc_val = (expr); \ UNGCPRO; \ return ret_ungc_val; \ } \ -while (0) + while (false) /* Call staticpro (&var) to protect static variable `var'. */ @@ -4390,13 +4403,13 @@ enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; extern void *record_xmalloc (size_t); #define USE_SAFE_ALLOCA \ - ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = 0 + ptrdiff_t sa_count = SPECPDL_INDEX (); bool sa_must_free = false /* SAFE_ALLOCA allocates a simple buffer. */ #define SAFE_ALLOCA(size) ((size) < MAX_ALLOCA \ ? alloca (size) \ - : (sa_must_free = 1, record_xmalloc (size))) + : (sa_must_free = true, record_xmalloc (size))) /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER * NITEMS items, each of the same type as *BUF. MULTIPLIER must @@ -4409,20 +4422,20 @@ extern void *record_xmalloc (size_t); else \ { \ (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ - sa_must_free = 1; \ + sa_must_free = true; \ record_unwind_protect_ptr (xfree, buf); \ } \ - } while (0) + } while (false) /* SAFE_FREE frees xmalloced memory and enables GC as needed. */ #define SAFE_FREE() \ do { \ if (sa_must_free) { \ - sa_must_free = 0; \ + sa_must_free = false; \ unbind_to (sa_count, Qnil); \ } \ - } while (0) + } while (false) /* SAFE_ALLOCA_LISP allocates an array of Lisp_Objects. */ @@ -4430,39 +4443,40 @@ extern void *record_xmalloc (size_t); #define SAFE_ALLOCA_LISP(buf, nelt) \ do { \ if ((nelt) < MAX_ALLOCA / word_size) \ - buf = alloca ((nelt) * word_size); \ + (buf) = alloca ((nelt) * word_size); \ else if ((nelt) < min (PTRDIFF_MAX, SIZE_MAX) / word_size) \ { \ Lisp_Object arg_; \ - buf = xmalloc ((nelt) * word_size); \ + (buf) = xmalloc ((nelt) * word_size); \ arg_ = make_save_memory (buf, nelt); \ - sa_must_free = 1; \ + sa_must_free = true; \ record_unwind_protect (free_save_value, arg_); \ } \ else \ memory_full (SIZE_MAX); \ - } while (0) + } while (false) /* Loop over all tails of a list, checking for cycles. FIXME: Make tortoise and n internal declarations. FIXME: Unroll the loop body so we don't need `n'. */ #define FOR_EACH_TAIL(hare, list, tortoise, n) \ - for (tortoise = hare = (list), n = true; \ + for ((tortoise) = (hare) = (list), (n) = true; \ CONSP (hare); \ - (hare = XCDR (hare), n = !n, \ - (n \ - ? ((EQ (hare, tortoise) \ - && (xsignal1 (Qcircular_list, (list)), 0))) \ + (hare = XCDR (hare), (n) = !(n), \ + ((n) \ + ? (EQ (hare, tortoise) \ + ? xsignal1 (Qcircular_list, list) \ + : (void) 0) \ /* Move tortoise before the next iteration, in case */ \ /* the next iteration does an Fsetcdr. */ \ - : (tortoise = XCDR (tortoise), 0)))) + : (void) ((tortoise) = XCDR (tortoise))))) /* Do a `for' loop over alist values. */ #define FOR_EACH_ALIST_VALUE(head_var, list_var, value_var) \ - for (list_var = head_var; \ - (CONSP (list_var) && (value_var = XCDR (XCAR (list_var)), 1)); \ - list_var = XCDR (list_var)) + for ((list_var) = (head_var); \ + (CONSP (list_var) && ((value_var) = XCDR (XCAR (list_var)), true)); \ + (list_var) = XCDR (list_var)) /* Check whether it's time for GC, and run it if so. */ @@ -4498,14 +4512,14 @@ functionp (Lisp_Object object) if (SUBRP (object)) return XSUBR (object)->max_args != UNEVALLED; else if (COMPILEDP (object)) - return 1; + return true; else if (CONSP (object)) { Lisp_Object car = XCAR (object); return EQ (car, Qlambda) || EQ (car, Qclosure); } else - return 0; + return false; } INLINE_HEADER_END |