aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
authorPaul Eggert2015-01-19 00:56:18 -0800
committerPaul Eggert2015-01-19 01:01:58 -0800
commitb7f83adda5a32140811e8e7decc4394d64cada3d (patch)
tree98d7d6763a62fc033464e4f2d5edde5c937623dd /src/lisp.h
parent9592a014df784e67a4647d5b6424f2758dfaad3c (diff)
downloademacs-b7f83adda5a32140811e8e7decc4394d64cada3d.tar.gz
emacs-b7f83adda5a32140811e8e7decc4394d64cada3d.zip
Prefer memset to repeatedly assigning Qnil
* alloc.c (allocate_pseudovector): Catch more bogus values. * alloc.c (allocate_pseudovector): * callint.c (Fcall_interactively): * coding.c (syms_of_coding): * fringe.c (init_fringe): Verify that Qnil == 0. * callint.c (Fcall_interactively): * eval.c (Fapply, Ffuncall): * fns.c (mapcar1, larger_vector): * font.c (font_expand_wildcards): * fringe.c (init_fringe): Prefer memset to assigning zeros by hand. * callint.c (Fcall_interactively): Remove duplicate assignment of Qnil to args[i]. * coding.c (syms_of_coding): Prefer LISP_INITIALLY_ZERO to assigning zeros by hand. * fileio.c (Ffile_selinux_context): Rewrite to avoid need for Lisp_Object array. * lisp.h (XLI_BUILTIN_LISPSYM): New macro. (DEFINE_LISP_SYMBOL_END): Use it. (NIL_IS_ZERO): New constant. (memsetnil): New function.
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h24
1 files changed, 21 insertions, 3 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 7c7d3f3e2e5..a1ea35574c3 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -732,14 +732,18 @@ struct Lisp_Symbol
732 TAG_PTR (Lisp_Symbol, \ 732 TAG_PTR (Lisp_Symbol, \
733 ((uintptr_t) (offset) >> (USE_LSB_TAG ? 0 : GCTYPEBITS))) 733 ((uintptr_t) (offset) >> (USE_LSB_TAG ? 0 : GCTYPEBITS)))
734 734
735/* XLI_BUILTIN_LISPSYM (iQwhatever) is equivalent to
736 XLI (builtin_lisp_symbol (Qwhatever)),
737 except the former expands to an integer constant expression. */
738#define XLI_BUILTIN_LISPSYM(iname) TAG_SYMOFFSET ((iname) * sizeof *lispsym)
739
735/* Declare extern constants for Lisp symbols. These can be helpful 740/* Declare extern constants for Lisp symbols. These can be helpful
736 when using a debugger like GDB, on older platforms where the debug 741 when using a debugger like GDB, on older platforms where the debug
737 format does not represent C macros. */ 742 format does not represent C macros. */
738#define DEFINE_LISP_SYMBOL_BEGIN(name) \ 743#define DEFINE_LISP_SYMBOL_BEGIN(name) \
739 DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name) 744 DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name)
740#define DEFINE_LISP_SYMBOL_END(name) \ 745#define DEFINE_LISP_SYMBOL_END(name) \
741 DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (TAG_SYMOFFSET (i##name \ 746 DEFINE_GDB_SYMBOL_END (LISP_INITIALLY (XLI_BUILTIN_LISPSYM (i##name)))
742 * sizeof *lispsym)))
743 747
744#include "globals.h" 748#include "globals.h"
745 749
@@ -1499,6 +1503,20 @@ gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
1499 XVECTOR (array)->contents[idx] = val; 1503 XVECTOR (array)->contents[idx] = val;
1500} 1504}
1501 1505
1506/* True, since Qnil's representation is zero. Every place in the code
1507 that assumes Qnil is zero should verify (NIL_IS_ZERO), to make it easy
1508 to find such assumptions later if we change Qnil to be nonzero. */
1509enum { NIL_IS_ZERO = XLI_BUILTIN_LISPSYM (iQnil) == 0 };
1510
1511/* Set a Lisp_Object array V's SIZE entries to nil. */
1512INLINE void
1513memsetnil (Lisp_Object *v, ptrdiff_t size)
1514{
1515 eassert (0 <= size);
1516 verify (NIL_IS_ZERO);
1517 memset (v, 0, size * sizeof *v);
1518}
1519
1502/* If a struct is made to look like a vector, this macro returns the length 1520/* If a struct is made to look like a vector, this macro returns the length
1503 of the shortest vector that would hold that struct. */ 1521 of the shortest vector that would hold that struct. */
1504 1522