root/src/lisp.h

/* [<][>][^][v][top][bottom][index][help] */

INCLUDED FROM


DEFINITIONS

This source file includes following definitions.
  1. DEFINE_GDB_SYMBOL_END
  2. bignum_to_double
  3. will_dump_p
  4. will_bootstrap_p
  5. will_dump_with_pdumper_p
  6. dumped_with_pdumper_p
  7. will_dump_with_unexec_p
  8. dumped_with_unexec_p
  9. definitely_will_not_unexec_p
  10. DEFINE_GDB_SYMBOL_END
  11. PSEUDOVECTORP
  12. XSYMBOL_WITH_POS
  13. make_lisp_symbol
  14. builtin_lisp_symbol
  15. c_symbol_p
  16. make_ufixnum
  17. make_fixnum
  18. XFIXNUM_RAW
  19. make_ufixnum
  20. XFIXNUM
  21. XUFIXNUM_RAW
  22. XUFIXNUM
  23. make_fixed_natnum
  24. clip_to_bounds
  25. make_lisp_ptr
  26. dead_object
  27. XFIXNUMPTR
  28. make_pointer_integer_unsafe
  29. make_pointer_integer
  30. CHECK_CONS
  31. xcar_addr
  32. xcdr_addr
  33. XSETCAR
  34. XSETCDR
  35. CAR
  36. CDR
  37. CAR_SAFE
  38. CDR_SAFE
  39. STRINGP
  40. CHECK_STRING
  41. XSTRING
  42. STRING_MULTIBYTE
  43. STRING_SET_MULTIBYTE
  44. SDATA
  45. SSDATA
  46. SREF
  47. SSET
  48. SCHARS
  49. STRING_BYTES
  50. SBYTES
  51. STRING_SET_CHARS
  52. CHECK_STRING_NULL_BYTES
  53. string_immovable_p
  54. XVECTOR
  55. ASIZE
  56. gc_asize
  57. PVSIZE
  58. VECTORP
  59. CHECK_VECTOR
  60. PSEUDOVECTOR_TYPE
  61. PSEUDOVECTOR_TYPEP
  62. bool_vector_words
  63. bool_vector_bytes
  64. BOOL_VECTOR_P
  65. CHECK_BOOL_VECTOR
  66. XBOOL_VECTOR
  67. bool_vector_size
  68. bool_vector_data
  69. bool_vector_uchar_data
  70. bool_vector_bitref
  71. bool_vector_ref
  72. bool_vector_set
  73. AREF
  74. aref_addr
  75. ASET
  76. gc_aset
  77. memclear
  78. ASCII_CHAR_P
  79. CHAR_TABLE_P
  80. XCHAR_TABLE
  81. SUB_CHAR_TABLE_P
  82. XSUB_CHAR_TABLE
  83. CHAR_TABLE_REF_ASCII
  84. CHAR_TABLE_REF
  85. CHAR_TABLE_SET
  86. SUBRP
  87. XSUBR
  88. VALID_DOCSTRING_P
  89. CHAR_TABLE_EXTRA_SLOTS
  90. SYMBOL_ALIAS
  91. SYMBOL_BLV
  92. SYMBOL_FWD
  93. SET_SYMBOL_ALIAS
  94. SET_SYMBOL_BLV
  95. SET_SYMBOL_FWD
  96. SYMBOL_NAME
  97. SYMBOL_INTERNED_P
  98. SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P
  99. HASH_TABLE_P
  100. XHASH_TABLE
  101. HASH_KEY
  102. HASH_VALUE
  103. HASH_HASH
  104. HASH_TABLE_SIZE
  105. sxhash_combine
  106. SXHASH_REDUCE
  107. make_mint_ptr
  108. mint_ptrp
  109. xmint_pointer
  110. FINALIZERP
  111. XFINALIZER
  112. MARKERP
  113. XMARKER
  114. OVERLAYP
  115. XOVERLAY
  116. SYMBOL_WITH_POS_SYM
  117. SYMBOL_WITH_POS_POS
  118. USER_PTRP
  119. XUSER_PTR
  120. SQLITEP
  121. SQLITE
  122. CHECK_SQLITE
  123. XSQLITE
  124. BIGNUMP
  125. INTEGERP
  126. make_int
  127. make_uint
  128. XFWDTYPE
  129. BUFFER_OBJFWDP
  130. XBUFFER_OBJFWD
  131. XFLOAT
  132. XFLOAT_DATA
  133. FIXNATP
  134. XFIXNAT
  135. NUMBERP
  136. RANGED_FIXNUMP
  137. AUTOLOADP
  138. WINDOW_CONFIGURATIONP
  139. COMPILEDP
  140. FRAMEP
  141. RECORDP
  142. CHECK_RECORD
  143. IMAGEP
  144. ARRAYP
  145. CHECK_LIST
  146. CHECK_LIST_END
  147. CHECK_STRING_CAR
  148. CHECK_VECTOR_OR_STRING
  149. CHECK_ARRAY
  150. CHECK_FIXNAT
  151. XFLOATINT
  152. CHECK_NUMBER
  153. CHECK_INTEGER
  154. CHECK_SUBR
  155. call0
  156. call1
  157. call2
  158. call3
  159. call4
  160. call5
  161. call6
  162. call7
  163. call8
  164. wrap_specpdl_ref
  165. unwrap_specpdl_ref
  166. specpdl_count_to_ref
  167. specpdl_ref_to_count
  168. specpdl_ref_eq
  169. specpdl_ref_lt
  170. specpdl_ref_valid_p
  171. make_invalid_specpdl_ref
  172. specpdl_ref_add
  173. specpdl_ref_to_ptr
  174. SPECPDL_INDEX
  175. backtrace_debug_on_exit
  176. grow_specpdl
  177. record_in_backtrace
  178. maybe_quit
  179. rarely_quit
  180. xvector_contents_addr
  181. xvector_contents
  182. vcopy
  183. set_hash_key_slot
  184. set_hash_value_slot
  185. set_symbol_function
  186. set_symbol_plist
  187. set_symbol_next
  188. make_symbol_constant
  189. blv_found
  190. set_overlay_plist
  191. string_intervals
  192. set_string_intervals
  193. set_char_table_defalt
  194. set_char_table_purpose
  195. set_char_table_extras
  196. set_char_table_contents
  197. set_sub_char_table_contents
  198. bignum_to_intmax
  199. integer_to_uintmax
  200. modiff_incr
  201. modiff_to_integer
  202. flush_stack_call_func
  203. list1i
  204. list2i
  205. list3i
  206. list4i
  207. make_formatted_string
  208. build_unibyte_string
  209. build_pure_c_string
  210. build_string
  211. allocate_nil_vector
  212. make_uninit_sub_char_table
  213. make_nil_vector
  214. esprintf
  215. intern
  216. intern_c_string
  217. xsignal
  218. push_handler
  219. XMODULE_FUNCTION
  220. splice_dir_file
  221. fast_string_match_ignore_case
  222. fast_c_string_match
  223. fast_c_string_match_ignore_case
  224. fixup_locale
  225. synchronize_system_messages_locale
  226. synchronize_system_time_locale
  227. make_environment_block
  228. set_act_rec
  229. maybe_disable_address_randomization
  230. emacs_abort
  231. SUBR_NATIVE_COMPILED_DYNP
  232. SUBR_TYPE
  233. allocate_native_comp_unit
  234. SUBR_NATIVE_COMPILEDP
  235. SUBR_NATIVE_COMPILED_DYNP
  236. xmalloc
  237. __lsan_ignore_object
  238. egetenv
  239. safe_free
  240. safe_free_unbind_to
  241. maybe_gc

     1 /* Fundamental definitions for GNU Emacs Lisp interpreter. -*- coding: utf-8 -*-
     2 
     3 Copyright (C) 1985-2023 Free Software Foundation, Inc.
     4 
     5 This file is part of GNU Emacs.
     6 
     7 GNU Emacs is free software: you can redistribute it and/or modify
     8 it under the terms of the GNU General Public License as published by
     9 the Free Software Foundation, either version 3 of the License, or (at
    10 your option) any later version.
    11 
    12 GNU Emacs is distributed in the hope that it will be useful,
    13 but WITHOUT ANY WARRANTY; without even the implied warranty of
    14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    15 GNU General Public License for more details.
    16 
    17 You should have received a copy of the GNU General Public License
    18 along with GNU Emacs.  If not, see <https://www.gnu.org/licenses/>.  */
    19 
    20 #ifndef EMACS_LISP_H
    21 #define EMACS_LISP_H
    22 
    23 #include <alloca.h>
    24 #include <setjmp.h>
    25 #include <stdalign.h>
    26 #include <stdarg.h>
    27 #include <stddef.h>
    28 #include <string.h>
    29 #include <float.h>
    30 #include <inttypes.h>
    31 #include <limits.h>
    32 
    33 #include <attribute.h>
    34 #include <intprops.h>
    35 #include <verify.h>
    36 
    37 INLINE_HEADER_BEGIN
    38 
    39 /* Define a TYPE constant ID as an externally visible name.  Use like this:
    40 
    41       DEFINE_GDB_SYMBOL_BEGIN (TYPE, ID)
    42       # define ID (some integer preprocessor expression of type TYPE)
    43       DEFINE_GDB_SYMBOL_END (ID)
    44 
    45    This hack is for the benefit of compilers that do not make macro
    46    definitions or enums visible to the debugger.  It's used for symbols
    47    that .gdbinit needs.  */
    48 
    49 #define DECLARE_GDB_SYM(type, id) type const id EXTERNALLY_VISIBLE
    50 #ifdef MAIN_PROGRAM
    51 # define DEFINE_GDB_SYMBOL_BEGIN(type, id) DECLARE_GDB_SYM (type, id)
    52 # define DEFINE_GDB_SYMBOL_END(id) = id;
    53 #else
    54 # define DEFINE_GDB_SYMBOL_BEGIN(type, id) extern DECLARE_GDB_SYM (type, id)
    55 # define DEFINE_GDB_SYMBOL_END(val) ;
    56 #endif
    57 
    58 /* The ubiquitous max and min macros.  */
    59 #undef min
    60 #undef max
    61 #define max(a, b) ((a) > (b) ? (a) : (b))
    62 #define min(a, b) ((a) < (b) ? (a) : (b))
    63 
    64 /* Number of elements in an array.  */
    65 #define ARRAYELTS(arr) (sizeof (arr) / sizeof (arr)[0])
    66 
    67 /* Number of bits in a Lisp_Object tag.  */
    68 DEFINE_GDB_SYMBOL_BEGIN (int, GCTYPEBITS)
    69 #define GCTYPEBITS 3
    70 DEFINE_GDB_SYMBOL_END (GCTYPEBITS)
    71 
    72 /* EMACS_INT - signed integer wide enough to hold an Emacs value
    73    EMACS_INT_WIDTH - width in bits of EMACS_INT
    74    EMACS_INT_MAX - maximum value of EMACS_INT; can be used in #if
    75    pI - printf length modifier for EMACS_INT
    76    EMACS_UINT - unsigned variant of EMACS_INT */
    77 #ifndef EMACS_INT_MAX
    78 # if INTPTR_MAX <= 0
    79 #  error "INTPTR_MAX misconfigured"
    80 # elif INTPTR_MAX <= INT_MAX && !defined WIDE_EMACS_INT
    81 typedef int EMACS_INT;
    82 typedef unsigned int EMACS_UINT;
    83 enum { EMACS_INT_WIDTH = INT_WIDTH, EMACS_UINT_WIDTH = UINT_WIDTH };
    84 #  define EMACS_INT_MAX INT_MAX
    85 #  define pI ""
    86 # elif INTPTR_MAX <= LONG_MAX && !defined WIDE_EMACS_INT
    87 typedef long int EMACS_INT;
    88 typedef unsigned long EMACS_UINT;
    89 enum { EMACS_INT_WIDTH = LONG_WIDTH, EMACS_UINT_WIDTH = ULONG_WIDTH };
    90 #  define EMACS_INT_MAX LONG_MAX
    91 #  define pI "l"
    92 # elif INTPTR_MAX <= LLONG_MAX
    93 typedef long long int EMACS_INT;
    94 typedef unsigned long long int EMACS_UINT;
    95 enum { EMACS_INT_WIDTH = LLONG_WIDTH, EMACS_UINT_WIDTH = ULLONG_WIDTH };
    96 #  define EMACS_INT_MAX LLONG_MAX
    97 /* MinGW supports %lld only if __USE_MINGW_ANSI_STDIO is non-zero,
    98    which is arranged by config.h, and (for mingw.org) if GCC is 6.0 or
    99    later and the runtime version is 5.0.0 or later.  Otherwise,
   100    printf-like functions are declared with __ms_printf__ attribute,
   101    which will cause a warning for %lld etc.  */
   102 #  if defined __MINGW32__                                               \
   103   && (!defined __USE_MINGW_ANSI_STDIO                                   \
   104       || (!defined MINGW_W64                                            \
   105           && !(GNUC_PREREQ (6, 0, 0) && __MINGW32_MAJOR_VERSION >= 5)))
   106 #   define pI "I64"
   107 #  else  /* ! MinGW */
   108 #   define pI "ll"
   109 #  endif
   110 # else
   111 #  error "INTPTR_MAX too large"
   112 # endif
   113 #endif
   114 
   115 /* Number of bits to put in each character in the internal representation
   116    of bool vectors.  This should not vary across implementations.  */
   117 enum {  BOOL_VECTOR_BITS_PER_CHAR =
   118 #define BOOL_VECTOR_BITS_PER_CHAR 8
   119         BOOL_VECTOR_BITS_PER_CHAR
   120 };
   121 
   122 /* An unsigned integer type representing a fixed-length bit sequence,
   123    suitable for bool vector words, GC mark bits, etc.  Normally it is size_t
   124    for speed, but on weird platforms it is unsigned char and not all
   125    its bits are used.  */
   126 #if BOOL_VECTOR_BITS_PER_CHAR == CHAR_BIT
   127 typedef size_t bits_word;
   128 # define BITS_WORD_MAX SIZE_MAX
   129 enum { BITS_PER_BITS_WORD = SIZE_WIDTH };
   130 #else
   131 typedef unsigned char bits_word;
   132 # define BITS_WORD_MAX ((1u << BOOL_VECTOR_BITS_PER_CHAR) - 1)
   133 enum { BITS_PER_BITS_WORD = BOOL_VECTOR_BITS_PER_CHAR };
   134 #endif
   135 verify (BITS_WORD_MAX >> (BITS_PER_BITS_WORD - 1) == 1);
   136 
   137 /* Use pD to format ptrdiff_t values, which suffice for indexes into
   138    buffers and strings.  Emacs never allocates objects larger than
   139    PTRDIFF_MAX bytes, as they cause problems with pointer subtraction.
   140    In C99, pD can always be "t", as we no longer need to worry about
   141    pre-C99 libraries such as glibc 2.0 (1997) and Solaris 8 (2000).  */
   142 #define pD "t"
   143 
   144 /* Convenience macro for rarely-used functions that do not return.  */
   145 #define AVOID _Noreturn ATTRIBUTE_COLD void
   146 
   147 /* Extra internal type checking?  */
   148 
   149 /* Define Emacs versions of <assert.h>'s 'assert (COND)' and <verify.h>'s
   150    'assume (COND)'.  COND should be free of side effects, as it may or
   151    may not be evaluated.
   152 
   153    'eassert (COND)' checks COND at runtime if ENABLE_CHECKING is
   154    defined and suppress_checking is false, and does nothing otherwise.
   155    Emacs dies if COND is checked and is false.  The suppress_checking
   156    variable is initialized to 0 in alloc.c.  Set it to 1 using a
   157    debugger to temporarily disable aborting on detected internal
   158    inconsistencies or error conditions.
   159 
   160    In some cases, a good compiler may be able to optimize away the
   161    eassert macro even if ENABLE_CHECKING is true, e.g., if XSTRING (x)
   162    uses eassert to test STRINGP (x), but a particular use of XSTRING
   163    is invoked only after testing that STRINGP (x) is true, making the
   164    test redundant.
   165 
   166    eassume is like eassert except that it also causes the compiler to
   167    assume that COND is true afterwards, regardless of whether runtime
   168    checking is enabled.  This can improve performance in some cases,
   169    though it can degrade performance in others.  It's often suboptimal
   170    for COND to call external functions or access volatile storage.  */
   171 
   172 #ifndef ENABLE_CHECKING
   173 # define eassert(cond) ((void) (false && (cond))) /* Check COND compiles.  */
   174 # define eassume(cond) assume (cond)
   175 #else /* ENABLE_CHECKING */
   176 
   177 extern AVOID die (const char *, const char *, int);
   178 
   179 extern bool suppress_checking EXTERNALLY_VISIBLE;
   180 
   181 # define eassert(cond)                                          \
   182    (suppress_checking || (cond)                                 \
   183     ? (void) 0                                                  \
   184     : die (# cond, __FILE__, __LINE__))
   185 # define eassume(cond)                                          \
   186    (suppress_checking                                           \
   187     ? assume (cond)                                             \
   188     : (cond)                                                    \
   189     ? (void) 0                                                  \
   190     : die (# cond, __FILE__, __LINE__))
   191 #endif /* ENABLE_CHECKING */
   192 
   193 
   194 /* Use the configure flag --enable-check-lisp-object-type to make
   195    Lisp_Object use a struct type instead of the default int.  The flag
   196    causes CHECK_LISP_OBJECT_TYPE to be defined.  */
   197 
   198 /***** Select the tagging scheme.  *****/
   199 /* The following option controls the tagging scheme:
   200    - USE_LSB_TAG means that we can assume the least 3 bits of pointers are
   201      always 0, and we can thus use them to hold tag bits, without
   202      restricting our addressing space.
   203 
   204    If ! USE_LSB_TAG, then use the top 3 bits for tagging, thus
   205    restricting our possible address range.
   206 
   207    USE_LSB_TAG not only requires the least 3 bits of pointers returned by
   208    malloc to be 0 but also needs to be able to impose a mult-of-8 alignment
   209    on some non-GC Lisp_Objects, all of which are aligned via
   210    GCALIGNED_UNION_MEMBER.  */
   211 
   212 enum Lisp_Bits
   213   {
   214     /* Number of bits in a Lisp_Object value, not counting the tag.  */
   215     VALBITS = EMACS_INT_WIDTH - GCTYPEBITS,
   216 
   217     /* Number of bits in a fixnum value, not counting the tag.  */
   218     FIXNUM_BITS = VALBITS + 1
   219   };
   220 
   221 /* Number of bits in a fixnum tag; can be used in #if.  */
   222 DEFINE_GDB_SYMBOL_BEGIN (int, INTTYPEBITS)
   223 #define INTTYPEBITS (GCTYPEBITS - 1)
   224 DEFINE_GDB_SYMBOL_END (INTTYPEBITS)
   225 
   226 /* The maximum value that can be stored in a EMACS_INT, assuming all
   227    bits other than the type bits contribute to a nonnegative signed value.
   228    This can be used in #if, e.g., '#if USE_LSB_TAG' below expands to an
   229    expression involving VAL_MAX.  */
   230 #define VAL_MAX (EMACS_INT_MAX >> (GCTYPEBITS - 1))
   231 
   232 /* Whether the least-significant bits of an EMACS_INT contain the tag.
   233    On hosts where pointers-as-ints do not exceed VAL_MAX / 2, USE_LSB_TAG is:
   234     a. unnecessary, because the top bits of an EMACS_INT are unused, and
   235     b. slower, because it typically requires extra masking.
   236    So, USE_LSB_TAG is true only on hosts where it might be useful.  */
   237 DEFINE_GDB_SYMBOL_BEGIN (bool, USE_LSB_TAG)
   238 #define USE_LSB_TAG (VAL_MAX / 2 < INTPTR_MAX)
   239 DEFINE_GDB_SYMBOL_END (USE_LSB_TAG)
   240 
   241 /* Mask for the value (as opposed to the type bits) of a Lisp object.  */
   242 DEFINE_GDB_SYMBOL_BEGIN (EMACS_INT, VALMASK)
   243 # define VALMASK (USE_LSB_TAG ? - (1 << GCTYPEBITS) : VAL_MAX)
   244 DEFINE_GDB_SYMBOL_END (VALMASK)
   245 
   246 /* Ignore 'alignas' on compilers lacking it.  */
   247 #if (!defined alignas && !defined __alignas_is_defined \
   248      && __STDC_VERSION__ < 202311 && __cplusplus < 201103)
   249 # define alignas(a)
   250 #endif
   251 
   252 /* Minimum alignment requirement for Lisp objects, imposed by the
   253    internal representation of tagged pointers.  It is 2**GCTYPEBITS if
   254    USE_LSB_TAG, 1 otherwise.  It must be a literal integer constant,
   255    for older versions of GCC (through at least 4.9).  */
   256 #if USE_LSB_TAG
   257 # define GCALIGNMENT 8
   258 # if GCALIGNMENT != 1 << GCTYPEBITS
   259 #  error "GCALIGNMENT and GCTYPEBITS are inconsistent"
   260 # endif
   261 #else
   262 # define GCALIGNMENT 1
   263 #endif
   264 
   265 /* To cause a union to have alignment of at least GCALIGNMENT, put
   266    GCALIGNED_UNION_MEMBER in its member list.
   267 
   268    If a struct is always GC-aligned (either by the GC, or via
   269    allocation in a containing union that has GCALIGNED_UNION_MEMBER)
   270    and does not contain a GC-aligned struct or union, putting
   271    GCALIGNED_STRUCT after its closing '}' can help the compiler
   272    generate better code.  Also, such structs should be added to the
   273    emacs_align_type union in alloc.c.
   274 
   275    Although these macros are reasonably portable, they are not
   276    guaranteed on non-GCC platforms, as C11 does not require support
   277    for alignment to GCALIGNMENT and older compilers may ignore
   278    alignment requests.  For any type T where garbage collection
   279    requires alignment, use verify (GCALIGNED (T)) to verify the
   280    requirement on the current platform.  Types need this check if
   281    their objects can be allocated outside the garbage collector.  For
   282    example, struct Lisp_Symbol needs the check because of lispsym and
   283    struct Lisp_Cons needs it because of STACK_CONS.  */
   284 
   285 #define GCALIGNED_UNION_MEMBER char alignas (GCALIGNMENT) gcaligned;
   286 #if HAVE_STRUCT_ATTRIBUTE_ALIGNED
   287 # define GCALIGNED_STRUCT __attribute__ ((aligned (GCALIGNMENT)))
   288 #else
   289 # define GCALIGNED_STRUCT
   290 #endif
   291 #define GCALIGNED(type) (alignof (type) % GCALIGNMENT == 0)
   292 
   293 /* Lisp_Word is a scalar word suitable for holding a tagged pointer or
   294    integer.  Usually it is a pointer to a deliberately-incomplete type
   295    'struct Lisp_X'.  However, it is EMACS_INT when Lisp_Objects and
   296    pointers differ in width.  */
   297 
   298 #define LISP_WORDS_ARE_POINTERS (EMACS_INT_MAX == INTPTR_MAX)
   299 #if LISP_WORDS_ARE_POINTERS
   300 typedef struct Lisp_X *Lisp_Word;
   301 #else
   302 typedef EMACS_INT Lisp_Word;
   303 #endif
   304 
   305 /* Some operations are so commonly executed that they are implemented
   306    as macros, not functions, because otherwise runtime performance would
   307    suffer too much when compiling with GCC without optimization.
   308    There's no need to inline everything, just the operations that
   309    would otherwise cause a serious performance problem.
   310 
   311    For each such operation OP, define a macro lisp_h_OP that contains
   312    the operation's implementation.  That way, OP can be implemented
   313    via a macro definition like this:
   314 
   315      #define OP(x) lisp_h_OP (x)
   316 
   317    and/or via a function definition like this:
   318 
   319      Lisp_Object (OP) (Lisp_Object x) { return lisp_h_OP (x); }
   320 
   321    without worrying about the implementations diverging, since
   322    lisp_h_OP defines the actual implementation.  The lisp_h_OP macros
   323    are intended to be private to this include file, and should not be
   324    used elsewhere.
   325 
   326    FIXME: Remove the lisp_h_OP macros, and define just the inline OP
   327    functions, once "gcc -Og" (new to GCC 4.8) or equivalent works well
   328    enough for Emacs developers.  Maybe in the year 2025.  See Bug#11935.
   329 
   330    For the macros that have corresponding functions (defined later),
   331    see these functions for commentary.  */
   332 
   333 /* Convert among the various Lisp-related types: I for EMACS_INT, L
   334    for Lisp_Object, P for void *.
   335 
   336    These use the following mnemonics:
   337 
   338    XLI: Lisp_Object to Integer;
   339    XIL: Integer to Lisp_Object;
   340    XLP: Lisp_Object to Pointer.  */
   341 
   342 #if !CHECK_LISP_OBJECT_TYPE
   343 # if LISP_WORDS_ARE_POINTERS
   344 #  define lisp_h_XLI(o) ((EMACS_INT) (o))
   345 #  define lisp_h_XIL(i) ((Lisp_Object) (i))
   346 #  define lisp_h_XLP(o) ((void *) (o))
   347 # else
   348 #  define lisp_h_XLI(o) (o)
   349 #  define lisp_h_XIL(i) (i)
   350 #  define lisp_h_XLP(o) ((void *) (uintptr_t) (o))
   351 # endif
   352 # define lisp_h_Qnil 0
   353 #else
   354 # if LISP_WORDS_ARE_POINTERS
   355 #  define lisp_h_XLI(o) ((EMACS_INT) (o).i)
   356 #  define lisp_h_XIL(i) ((Lisp_Object) {(Lisp_Word) (i)})
   357 #  define lisp_h_XLP(o) ((void *) (o).i)
   358 # else
   359 #  define lisp_h_XLI(o) ((o).i)
   360 #  define lisp_h_XIL(i) ((Lisp_Object) {i})
   361 #  define lisp_h_XLP(o) ((void *) (uintptr_t) (o).i)
   362 # endif
   363 # define lisp_h_Qnil {0}
   364 #endif
   365 
   366 #define lisp_h_PSEUDOVECTORP(a,code)                            \
   367   (lisp_h_VECTORLIKEP((a)) &&                                   \
   368    ((XUNTAG ((a), Lisp_Vectorlike, union vectorlike_header)->size     \
   369      & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK))                    \
   370     == (PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS))))
   371 
   372 #define lisp_h_CHECK_FIXNUM(x) CHECK_TYPE (FIXNUMP (x), Qfixnump, x)
   373 #define lisp_h_CHECK_SYMBOL(x) CHECK_TYPE (SYMBOLP (x), Qsymbolp, x)
   374 #define lisp_h_CHECK_TYPE(ok, predicate, x) \
   375    ((ok) ? (void) 0 : wrong_type_argument (predicate, x))
   376 #define lisp_h_CONSP(x) TAGGEDP (x, Lisp_Cons)
   377 #define lisp_h_BASE_EQ(x, y) (XLI (x) == XLI (y))
   378 #define lisp_h_BASE2_EQ(x, y)                               \
   379   (BASE_EQ (x, y)                                           \
   380    || (symbols_with_pos_enabled                             \
   381        && SYMBOL_WITH_POS_P (x)                             \
   382        && BASE_EQ (XSYMBOL_WITH_POS (x)->sym, y)))
   383 
   384 /* FIXME: Do we really need to inline the whole thing?
   385  * What about keeping the part after `symbols_with_pos_enabled` in
   386  * a separate function?  */
   387 #define lisp_h_EQ(x, y)                                     \
   388   ((XLI ((x)) == XLI ((y)))                                 \
   389    || (symbols_with_pos_enabled                             \
   390        && (SYMBOL_WITH_POS_P ((x))                          \
   391            ? (BARE_SYMBOL_P ((y))                           \
   392               ? XLI (XSYMBOL_WITH_POS((x))->sym) == XLI (y) \
   393               : SYMBOL_WITH_POS_P((y))                      \
   394                 && (XLI (XSYMBOL_WITH_POS((x))->sym)        \
   395                     == XLI (XSYMBOL_WITH_POS((y))->sym)))   \
   396            : (SYMBOL_WITH_POS_P ((y))                       \
   397               && BARE_SYMBOL_P ((x))                        \
   398               && (XLI (x) == XLI ((XSYMBOL_WITH_POS ((y)))->sym))))))
   399 
   400 #define lisp_h_FIXNUMP(x) \
   401    (! (((unsigned) (XLI (x) >> (USE_LSB_TAG ? 0 : FIXNUM_BITS)) \
   402         - (unsigned) (Lisp_Int0 >> !USE_LSB_TAG)) \
   403        & ((1 << INTTYPEBITS) - 1)))
   404 #define lisp_h_FLOATP(x) TAGGEDP (x, Lisp_Float)
   405 #define lisp_h_NILP(x)  BASE_EQ (x, Qnil)
   406 #define lisp_h_SET_SYMBOL_VAL(sym, v) \
   407    (eassert ((sym)->u.s.redirect == SYMBOL_PLAINVAL), \
   408     (sym)->u.s.val.value = (v))
   409 #define lisp_h_SYMBOL_CONSTANT_P(sym) \
   410    (XSYMBOL (sym)->u.s.trapped_write == SYMBOL_NOWRITE)
   411 #define lisp_h_SYMBOL_TRAPPED_WRITE_P(sym) (XSYMBOL (sym)->u.s.trapped_write)
   412 #define lisp_h_SYMBOL_VAL(sym) \
   413    (eassert ((sym)->u.s.redirect == SYMBOL_PLAINVAL), (sym)->u.s.val.value)
   414 #define lisp_h_SYMBOL_WITH_POS_P(x) PSEUDOVECTORP ((x), PVEC_SYMBOL_WITH_POS)
   415 #define lisp_h_BARE_SYMBOL_P(x) TAGGEDP ((x), Lisp_Symbol)
   416 #define lisp_h_SYMBOLP(x) ((BARE_SYMBOL_P ((x)) ||               \
   417                             (symbols_with_pos_enabled && (SYMBOL_WITH_POS_P ((x))))))
   418 #define lisp_h_TAGGEDP(a, tag) \
   419    (! (((unsigned) (XLI (a) >> (USE_LSB_TAG ? 0 : VALBITS)) \
   420         - (unsigned) (tag)) \
   421        & ((1 << GCTYPEBITS) - 1)))
   422 #define lisp_h_VECTORLIKEP(x) TAGGEDP (x, Lisp_Vectorlike)
   423 #define lisp_h_XCAR(c) XCONS (c)->u.s.car
   424 #define lisp_h_XCDR(c) XCONS (c)->u.s.u.cdr
   425 #define lisp_h_XCONS(a) \
   426    (eassert (CONSP (a)), XUNTAG (a, Lisp_Cons, struct Lisp_Cons))
   427 #define lisp_h_XHASH(a) XUFIXNUM_RAW (a)
   428 #if USE_LSB_TAG
   429 # define lisp_h_make_fixnum_wrap(n) \
   430     XIL ((EMACS_INT) (((EMACS_UINT) (n) << INTTYPEBITS) + Lisp_Int0))
   431 # if defined HAVE_STATEMENT_EXPRESSIONS && defined HAVE_TYPEOF
   432 #  define lisp_h_make_fixnum(n) \
   433      ({ typeof (+(n)) lisp_h_make_fixnum_n = n; \
   434         eassert (!FIXNUM_OVERFLOW_P (lisp_h_make_fixnum_n)); \
   435         lisp_h_make_fixnum_wrap (lisp_h_make_fixnum_n); })
   436 # else
   437 #  define lisp_h_make_fixnum(n) lisp_h_make_fixnum_wrap (n)
   438 # endif
   439 # define lisp_h_XFIXNUM_RAW(a) (XLI (a) >> INTTYPEBITS)
   440 # define lisp_h_XTYPE(a) ((enum Lisp_Type) (XLI (a) & ~VALMASK))
   441 #endif
   442 
   443 /* When DEFINE_KEY_OPS_AS_MACROS, define key operations as macros to
   444    cajole the compiler into inlining them; otherwise define them as
   445    inline functions as this is cleaner and can be more efficient.
   446    The default is true if the compiler is GCC-like and if function
   447    inlining is disabled because the compiler is not optimizing or is
   448    optimizing for size.  Otherwise the default is false.  */
   449 #ifndef DEFINE_KEY_OPS_AS_MACROS
   450 # if (defined __NO_INLINE__ \
   451       && ! defined __OPTIMIZE__ && ! defined __OPTIMIZE_SIZE__)
   452 #  define DEFINE_KEY_OPS_AS_MACROS true
   453 # else
   454 #  define DEFINE_KEY_OPS_AS_MACROS false
   455 # endif
   456 #endif
   457 
   458 #if DEFINE_KEY_OPS_AS_MACROS
   459 # define XLI(o) lisp_h_XLI (o)
   460 # define XIL(i) lisp_h_XIL (i)
   461 # define XLP(o) lisp_h_XLP (o)
   462 # define BARE_SYMBOL_P(x) lisp_h_BARE_SYMBOL_P (x)
   463 # define CHECK_FIXNUM(x) lisp_h_CHECK_FIXNUM (x)
   464 # define CHECK_SYMBOL(x) lisp_h_CHECK_SYMBOL (x)
   465 # define CHECK_TYPE(ok, predicate, x) lisp_h_CHECK_TYPE (ok, predicate, x)
   466 # define CONSP(x) lisp_h_CONSP (x)
   467 # define BASE_EQ(x, y) lisp_h_BASE_EQ (x, y)
   468 # define BASE2_EQ(x, y) lisp_h_BASE2_EQ (x, y)
   469 # define FLOATP(x) lisp_h_FLOATP (x)
   470 # define FIXNUMP(x) lisp_h_FIXNUMP (x)
   471 # define NILP(x) lisp_h_NILP (x)
   472 # define SET_SYMBOL_VAL(sym, v) lisp_h_SET_SYMBOL_VAL (sym, v)
   473 # define SYMBOL_CONSTANT_P(sym) lisp_h_SYMBOL_CONSTANT_P (sym)
   474 # define SYMBOL_TRAPPED_WRITE_P(sym) lisp_h_SYMBOL_TRAPPED_WRITE_P (sym)
   475 # define SYMBOL_VAL(sym) lisp_h_SYMBOL_VAL (sym)
   476 /* # define SYMBOLP(x) lisp_h_SYMBOLP (x) */ /* X is accessed more than once. */
   477 # define TAGGEDP(a, tag) lisp_h_TAGGEDP (a, tag)
   478 # define VECTORLIKEP(x) lisp_h_VECTORLIKEP (x)
   479 # define XCAR(c) lisp_h_XCAR (c)
   480 # define XCDR(c) lisp_h_XCDR (c)
   481 # define XCONS(a) lisp_h_XCONS (a)
   482 # define XHASH(a) lisp_h_XHASH (a)
   483 # if USE_LSB_TAG
   484 #  define make_fixnum(n) lisp_h_make_fixnum (n)
   485 #  define XFIXNUM_RAW(a) lisp_h_XFIXNUM_RAW (a)
   486 #  define XTYPE(a) lisp_h_XTYPE (a)
   487 # endif
   488 #endif
   489 
   490 
   491 /* Define the fundamental Lisp data structures.  */
   492 
   493 /* This is the set of Lisp data types.  If you want to define a new
   494    data type, read the comments after Lisp_Fwd_Type definition
   495    below.  */
   496 
   497 /* Fixnums use 2 tags, to give them one extra bit, thus
   498    extending their range from, e.g., -2^28..2^28-1 to -2^29..2^29-1.  */
   499 #define INTMASK (EMACS_INT_MAX >> (INTTYPEBITS - 1))
   500 #define case_Lisp_Int case Lisp_Int0: case Lisp_Int1
   501 
   502 /* Idea stolen from GDB.  Pedantic GCC complains about enum bitfields,
   503    and xlc and Oracle Studio c99 complain vociferously about them.  */
   504 #if (defined __STRICT_ANSI__ || defined __IBMC__ \
   505      || (defined __SUNPRO_C && __STDC__))
   506 #define ENUM_BF(TYPE) unsigned int
   507 #else
   508 #define ENUM_BF(TYPE) enum TYPE
   509 #endif
   510 
   511 
   512 enum Lisp_Type
   513   {
   514     /* Symbol.  XSYMBOL (object) points to a struct Lisp_Symbol.  */
   515     Lisp_Symbol = 0,
   516 
   517     /* Type 1 is currently unused.  */
   518     Lisp_Type_Unused0 = 1,
   519 
   520     /* Fixnum.  XFIXNUM (obj) is the integer value.  */
   521     Lisp_Int0 = 2,
   522     Lisp_Int1 = USE_LSB_TAG ? 6 : 3,
   523 
   524     /* String.  XSTRING (object) points to a struct Lisp_String.
   525        The length of the string, and its contents, are stored therein.  */
   526     Lisp_String = 4,
   527 
   528     /* Vector of Lisp objects, or something resembling it.
   529        XVECTOR (object) points to a struct Lisp_Vector, which contains
   530        the size and contents.  The size field also contains the type
   531        information, if it's not a real vector object.  */
   532     Lisp_Vectorlike = 5,
   533 
   534     /* Cons.  XCONS (object) points to a struct Lisp_Cons.  */
   535     Lisp_Cons = USE_LSB_TAG ? 3 : 6,
   536 
   537     /* Must be last entry in Lisp_Type enumeration.  */
   538     Lisp_Float = 7
   539   };
   540 
   541 /* These are the types of forwarding objects used in the value slot
   542    of symbols for special built-in variables whose value is stored in
   543    C variables.  */
   544 enum Lisp_Fwd_Type
   545   {
   546     Lisp_Fwd_Int,               /* Fwd to a C `int' variable.  */
   547     Lisp_Fwd_Bool,              /* Fwd to a C boolean var.  */
   548     Lisp_Fwd_Obj,               /* Fwd to a C Lisp_Object variable.  */
   549     Lisp_Fwd_Buffer_Obj,        /* Fwd to a Lisp_Object field of buffers.  */
   550     Lisp_Fwd_Kboard_Obj         /* Fwd to a Lisp_Object field of kboards.  */
   551   };
   552 
   553 /* If you want to define a new Lisp data type, here are some
   554    instructions.
   555 
   556    First, there are already a couple of Lisp types that can be used if
   557    your new type does not need to be exposed to Lisp programs nor
   558    displayed to users.  These are Lisp_Misc_Ptr and PVEC_OTHER,
   559    which are both vectorlike objects.  The former
   560    is suitable for stashing a pointer in a Lisp object; the pointer
   561    might be to some low-level C object that contains auxiliary
   562    information.  The latter is useful for vector-like Lisp objects
   563    that need to be used as part of other objects, but which are never
   564    shown to users or Lisp code (search for PVEC_OTHER in xterm.c for
   565    an example).
   566 
   567    These two types don't look pretty when printed, so they are
   568    unsuitable for Lisp objects that can be exposed to users.
   569 
   570    To define a new data type, add a pseudovector subtype by extending
   571    the pvec_type enumeration.  A pseudovector provides one or more
   572    slots for Lisp objects, followed by struct members that are
   573    accessible only from C.
   574 
   575    There is no way to explicitly free a Lisp Object; only the garbage
   576    collector frees them.
   577 
   578    For a new pseudovector, it's highly desirable to limit the size
   579    of your data type by VBLOCK_BYTES_MAX bytes (defined in alloc.c).
   580    Otherwise you will need to change sweep_vectors (also in alloc.c).
   581 
   582    Then you will need to add switch branches in print.c (in
   583    print_object, to print your object, and possibly also in
   584    print_preprocess) and to alloc.c, to mark your object (in
   585    mark_object) and to free it (in gc_sweep).  The latter is also the
   586    right place to call any code specific to your data type that needs
   587    to run when the object is recycled -- e.g., free any additional
   588    resources allocated for it that are not Lisp objects.  You can even
   589    make a pointer to the function that frees the resources a slot in
   590    your object -- this way, the same object could be used to represent
   591    several disparate C structures.
   592 
   593    In addition, you need to add switch branches in data.c for Ftype_of.
   594 
   595    You also need to add the new type to the constant
   596    `cl--typeof-types' in lisp/emacs-lisp/cl-preloaded.el.  */
   597 
   598 
   599 /* A Lisp_Object is a tagged pointer or integer.  Ordinarily it is a
   600    Lisp_Word.  However, if CHECK_LISP_OBJECT_TYPE, it is a wrapper
   601    around Lisp_Word, to help catch thinkos like 'Lisp_Object x = 0;'.
   602 
   603    LISP_INITIALLY (W) initializes a Lisp object with a tagged value
   604    that is a Lisp_Word W.  It can be used in a static initializer.  */
   605 
   606 #ifdef CHECK_LISP_OBJECT_TYPE
   607 typedef struct Lisp_Object { Lisp_Word i; } Lisp_Object;
   608 # define LISP_OBJECT_IS_STRUCT
   609 # define LISP_INITIALLY(w) {w}
   610 # undef CHECK_LISP_OBJECT_TYPE
   611 enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = true };
   612 #else
   613 typedef Lisp_Word Lisp_Object;
   614 # define LISP_INITIALLY(w) (w)
   615 enum CHECK_LISP_OBJECT_TYPE { CHECK_LISP_OBJECT_TYPE = false };
   616 #endif
   617 
   618 /* Forward declarations.  */
   619 
   620 /* Defined in this file.  */
   621 INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t,
   622                                               Lisp_Object);
   623 
   624 /* Defined in bignum.c.  */
   625 extern int check_int_nonnegative (Lisp_Object);
   626 extern intmax_t check_integer_range (Lisp_Object, intmax_t, intmax_t);
   627 extern double bignum_to_double (Lisp_Object) ATTRIBUTE_CONST;
   628 extern Lisp_Object make_bigint (intmax_t);
   629 extern Lisp_Object make_biguint (uintmax_t);
   630 extern uintmax_t check_uinteger_max (Lisp_Object, uintmax_t);
   631 
   632 /* Defined in chartab.c.  */
   633 extern Lisp_Object char_table_ref (Lisp_Object, int) ATTRIBUTE_PURE;
   634 extern void char_table_set (Lisp_Object, int, Lisp_Object);
   635 
   636 /* Defined in data.c.  */
   637 extern AVOID args_out_of_range_3 (Lisp_Object, Lisp_Object, Lisp_Object);
   638 extern AVOID wrong_type_argument (Lisp_Object, Lisp_Object);
   639 extern Lisp_Object default_value (Lisp_Object symbol);
   640 extern void defalias (Lisp_Object symbol, Lisp_Object definition);
   641 extern char *fixnum_to_string (EMACS_INT number, char *buffer, char *end);
   642 
   643 
   644 /* Defined in emacs.c.  */
   645 
   646 /* Set after Emacs has started up the first time.
   647    Prevents reinitialization of the Lisp world and keymaps on
   648    subsequent starts.  */
   649 extern bool initialized;
   650 
   651 extern struct gflags
   652 {
   653   /* True means this Emacs instance was born to dump.  */
   654   bool will_dump_ : 1;
   655   bool will_bootstrap_ : 1;
   656 #ifdef HAVE_PDUMPER
   657   /* Set in an Emacs process that will likely dump with pdumper; all
   658      Emacs processes may dump with pdumper, however.  */
   659   bool will_dump_with_pdumper_ : 1;
   660   /* Set in an Emacs process that has been restored from a portable
   661      dump.  */
   662   bool dumped_with_pdumper_ : 1;
   663 #endif
   664 #ifdef HAVE_UNEXEC
   665   bool will_dump_with_unexec_ : 1;
   666   /* Set in an Emacs process that has been restored from an unexec
   667      dump.  */
   668   bool dumped_with_unexec_ : 1;
   669   /* We promise not to unexec: useful for hybrid malloc.  */
   670   bool will_not_unexec_ : 1;
   671 #endif
   672 } gflags;
   673 
   674 INLINE bool
   675 will_dump_p (void)
   676 {
   677 #if HAVE_PDUMPER || defined HAVE_UNEXEC
   678   return gflags.will_dump_;
   679 #else
   680   return false;
   681 #endif
   682 }
   683 
   684 INLINE bool
   685 will_bootstrap_p (void)
   686 {
   687 #if HAVE_PDUMPER || defined HAVE_UNEXEC
   688   return gflags.will_bootstrap_;
   689 #else
   690   return false;
   691 #endif
   692 }
   693 
   694 INLINE bool
   695 will_dump_with_pdumper_p (void)
   696 {
   697 #if HAVE_PDUMPER
   698   return gflags.will_dump_with_pdumper_;
   699 #else
   700   return false;
   701 #endif
   702 }
   703 
   704 INLINE bool
   705 dumped_with_pdumper_p (void)
   706 {
   707 #if HAVE_PDUMPER
   708   return gflags.dumped_with_pdumper_;
   709 #else
   710   return false;
   711 #endif
   712 }
   713 
   714 INLINE bool
   715 will_dump_with_unexec_p (void)
   716 {
   717 #ifdef HAVE_UNEXEC
   718   return gflags.will_dump_with_unexec_;
   719 #else
   720   return false;
   721 #endif
   722 }
   723 
   724 INLINE bool
   725 dumped_with_unexec_p (void)
   726 {
   727 #ifdef HAVE_UNEXEC
   728   return gflags.dumped_with_unexec_;
   729 #else
   730   return false;
   731 #endif
   732 }
   733 
   734 /* This function is the opposite of will_dump_with_unexec_p(), except
   735    that it returns false before main runs.  It's important to use
   736    gmalloc for any pre-main allocations if we're going to unexec.  */
   737 INLINE bool
   738 definitely_will_not_unexec_p (void)
   739 {
   740 #ifdef HAVE_UNEXEC
   741   return gflags.will_not_unexec_;
   742 #else
   743   return true;
   744 #endif
   745 }
   746 
   747 /* Defined in floatfns.c.  */
   748 extern double extract_float (Lisp_Object);
   749 
   750 
   751 /* Low-level conversion and type checking.  */
   752 
   753 /* Convert among various types use to implement Lisp_Object.  At the
   754    machine level, these operations may widen or narrow their arguments
   755    if pointers differ in width from EMACS_INT; otherwise they are
   756    no-ops.  */
   757 
   758 INLINE EMACS_INT
   759 (XLI) (Lisp_Object o)
   760 {
   761   return lisp_h_XLI (o);
   762 }
   763 
   764 INLINE Lisp_Object
   765 (XIL) (EMACS_INT i)
   766 {
   767   return lisp_h_XIL (i);
   768 }
   769 
   770 INLINE void *
   771 (XLP) (Lisp_Object o)
   772 {
   773   return lisp_h_XLP (o);
   774 }
   775 
   776 /* Extract A's type.  */
   777 
   778 INLINE enum Lisp_Type
   779 (XTYPE) (Lisp_Object a)
   780 {
   781 #if USE_LSB_TAG
   782   return lisp_h_XTYPE (a);
   783 #else
   784   EMACS_UINT i = XLI (a);
   785   return USE_LSB_TAG ? i & ~VALMASK : i >> VALBITS;
   786 #endif
   787 }
   788 
   789 /* True if A has type tag TAG.
   790    Equivalent to XTYPE (a) == TAG, but often faster.  */
   791 
   792 INLINE bool
   793 (TAGGEDP) (Lisp_Object a, enum Lisp_Type tag)
   794 {
   795   return lisp_h_TAGGEDP (a, tag);
   796 }
   797 
   798 INLINE void
   799 (CHECK_TYPE) (int ok, Lisp_Object predicate, Lisp_Object x)
   800 {
   801   lisp_h_CHECK_TYPE (ok, predicate, x);
   802 }
   803 
   804 /* Extract A's pointer value, assuming A's Lisp type is TYPE and the
   805    extracted pointer's type is CTYPE *.  */
   806 
   807 #define XUNTAG(a, type, ctype) ((ctype *) \
   808                                 ((char *) XLP (a) - LISP_WORD_TAG (type)))
   809 
   810 /* A forwarding pointer to a value.  It uses a generic pointer to
   811    avoid alignment bugs that could occur if it used a pointer to a
   812    union of the possible values (struct Lisp_Objfwd, struct
   813    Lisp_Intfwd, etc.).  The pointer is packaged inside a struct to
   814    help static checking.  */
   815 typedef struct { void const *fwdptr; } lispfwd;
   816 
   817 /* Interned state of a symbol.  */
   818 
   819 enum symbol_interned
   820 {
   821   SYMBOL_UNINTERNED = 0,
   822   SYMBOL_INTERNED = 1,
   823   SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2
   824 };
   825 
   826 enum symbol_redirect
   827 {
   828   SYMBOL_PLAINVAL  = 4,
   829   SYMBOL_VARALIAS  = 1,
   830   SYMBOL_LOCALIZED = 2,
   831   SYMBOL_FORWARDED = 3
   832 };
   833 
   834 enum symbol_trapped_write
   835 {
   836   SYMBOL_UNTRAPPED_WRITE = 0,
   837   SYMBOL_NOWRITE = 1,
   838   SYMBOL_TRAPPED_WRITE = 2
   839 };
   840 
   841 struct Lisp_Symbol
   842 {
   843   union
   844   {
   845     struct
   846     {
   847       bool_bf gcmarkbit : 1;
   848 
   849       /* Indicates where the value can be found:
   850          0 : it's a plain var, the value is in the `value' field.
   851          1 : it's a varalias, the value is really in the `alias' symbol.
   852          2 : it's a localized var, the value is in the `blv' object.
   853          3 : it's a forwarding variable, the value is in `forward'.  */
   854       ENUM_BF (symbol_redirect) redirect : 3;
   855 
   856       /* 0 : normal case, just set the value
   857          1 : constant, cannot set, e.g. nil, t, :keywords.
   858          2 : trap the write, call watcher functions.  */
   859       ENUM_BF (symbol_trapped_write) trapped_write : 2;
   860 
   861       /* Interned state of the symbol.  This is an enumerator from
   862          enum symbol_interned.  */
   863       unsigned interned : 2;
   864 
   865       /* True means that this variable has been explicitly declared
   866          special (with `defvar' etc), and shouldn't be lexically bound.  */
   867       bool_bf declared_special : 1;
   868 
   869       /* True if pointed to from purespace and hence can't be GC'd.  */
   870       bool_bf pinned : 1;
   871 
   872       /* The symbol's name, as a Lisp string.  */
   873       Lisp_Object name;
   874 
   875       /* Value of the symbol or Qunbound if unbound.  Which alternative of the
   876          union is used depends on the `redirect' field above.  */
   877       union {
   878         Lisp_Object value;
   879         struct Lisp_Symbol *alias;
   880         struct Lisp_Buffer_Local_Value *blv;
   881         lispfwd fwd;
   882       } val;
   883 
   884       /* Function value of the symbol or Qnil if not fboundp.  */
   885       Lisp_Object function;
   886 
   887       /* The symbol's property list.  */
   888       Lisp_Object plist;
   889 
   890       /* Next symbol in obarray bucket, if the symbol is interned.  */
   891       struct Lisp_Symbol *next;
   892     } s;
   893     GCALIGNED_UNION_MEMBER
   894   } u;
   895 };
   896 verify (GCALIGNED (struct Lisp_Symbol));
   897 
   898 /* Declare a Lisp-callable function.  The MAXARGS parameter has the same
   899    meaning as in the DEFUN macro, and is used to construct a prototype.  */
   900 /* We can use the same trick as in the DEFUN macro to generate the
   901    appropriate prototype.  */
   902 #define EXFUN(fnname, maxargs) \
   903   extern Lisp_Object fnname DEFUN_ARGS_ ## maxargs
   904 
   905 /* Note that the weird token-substitution semantics of ANSI C makes
   906    this work for MANY and UNEVALLED.  */
   907 #define DEFUN_ARGS_MANY         (ptrdiff_t, Lisp_Object *)
   908 #define DEFUN_ARGS_UNEVALLED    (Lisp_Object)
   909 #define DEFUN_ARGS_0    (void)
   910 #define DEFUN_ARGS_1    (Lisp_Object)
   911 #define DEFUN_ARGS_2    (Lisp_Object, Lisp_Object)
   912 #define DEFUN_ARGS_3    (Lisp_Object, Lisp_Object, Lisp_Object)
   913 #define DEFUN_ARGS_4    (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
   914 #define DEFUN_ARGS_5    (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
   915                          Lisp_Object)
   916 #define DEFUN_ARGS_6    (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
   917                          Lisp_Object, Lisp_Object)
   918 #define DEFUN_ARGS_7    (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
   919                          Lisp_Object, Lisp_Object, Lisp_Object)
   920 #define DEFUN_ARGS_8    (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, \
   921                          Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object)
   922 
   923 /* untagged_ptr represents a pointer before tagging, and Lisp_Word_tag
   924    contains a possibly-shifted tag to be added to an untagged_ptr to
   925    convert it to a Lisp_Word.  */
   926 #if LISP_WORDS_ARE_POINTERS
   927 /* untagged_ptr is a pointer so that the compiler knows that TAG_PTR
   928    yields a pointer.  It is char * so that adding a tag uses simple
   929    machine addition.  */
   930 typedef char *untagged_ptr;
   931 typedef uintptr_t Lisp_Word_tag;
   932 #else
   933 /* untagged_ptr is an unsigned integer instead of a pointer, so that
   934    it can be added to the possibly-wider Lisp_Word_tag type without
   935    losing information.  */
   936 typedef uintptr_t untagged_ptr;
   937 typedef EMACS_UINT Lisp_Word_tag;
   938 #endif
   939 
   940 /* A integer value tagged with TAG, and otherwise all zero.  */
   941 #define LISP_WORD_TAG(tag) \
   942   ((Lisp_Word_tag) (tag) << (USE_LSB_TAG ? 0 : VALBITS))
   943 
   944 /* An initializer for a Lisp_Object that contains TAG along with PTR.  */
   945 #define TAG_PTR(tag, ptr) \
   946   LISP_INITIALLY ((Lisp_Word) ((untagged_ptr) (ptr) + LISP_WORD_TAG (tag)))
   947 
   948 /* LISPSYM_INITIALLY (Qfoo) is equivalent to Qfoo except it is
   949    designed for use as an initializer, even for a constant initializer.  */
   950 #define LISPSYM_INITIALLY(name) \
   951   TAG_PTR (Lisp_Symbol, (char *) (intptr_t) ((i##name) * sizeof *lispsym))
   952 
   953 /* Declare extern constants for Lisp symbols.  These can be helpful
   954    when using a debugger like GDB, on older platforms where the debug
   955    format does not represent C macros.  However, they are unbounded
   956    and would just be asking for trouble if checking pointer bounds.  */
   957 #define DEFINE_LISP_SYMBOL(name) \
   958   DEFINE_GDB_SYMBOL_BEGIN (Lisp_Object, name) \
   959   DEFINE_GDB_SYMBOL_END (LISPSYM_INITIALLY (name))
   960 
   961 /* The index of the C-defined Lisp symbol SYM.
   962    This can be used in a static initializer.  */
   963 #define SYMBOL_INDEX(sym) i##sym
   964 
   965 /* By default, define macros for Qt, etc., as this leads to a bit
   966    better performance in the core Emacs interpreter.  A plugin can
   967    define DEFINE_NON_NIL_Q_SYMBOL_MACROS to be false, to be portable to
   968    other Emacs instances that assign different values to Qt, etc.  */
   969 #ifndef DEFINE_NON_NIL_Q_SYMBOL_MACROS
   970 # define DEFINE_NON_NIL_Q_SYMBOL_MACROS true
   971 #endif
   972 
   973 /* True if N is a power of 2.  N should be positive.  */
   974 
   975 #define POWER_OF_2(n) (((n) & ((n) - 1)) == 0)
   976 
   977 /* Return X rounded to the next multiple of Y.  Y should be positive,
   978    and Y - 1 + X should not overflow.  Arguments should not have side
   979    effects, as they are evaluated more than once.  Tune for Y being a
   980    power of 2.  */
   981 
   982 #define ROUNDUP(x, y) (POWER_OF_2 (y)                                   \
   983                        ? ((y) - 1 + (x)) & ~ ((y) - 1)                  \
   984                        : ((y) - 1 + (x)) - ((y) - 1 + (x)) % (y))
   985 
   986 #include <globals.h>
   987 
   988 /* Header of vector-like objects.  This documents the layout constraints on
   989    vectors and pseudovectors (objects of PVEC_xxx subtype).  It also prevents
   990    compilers from being fooled by Emacs's type punning: XSETPSEUDOVECTOR
   991    and PSEUDOVECTORP cast their pointers to union vectorlike_header *,
   992    because when two such pointers potentially alias, a compiler won't
   993    incorrectly reorder loads and stores to their size fields.  See
   994    Bug#8546.  This union formerly contained more members, and there's
   995    no compelling reason to change it to a struct merely because the
   996    number of members has been reduced to one.  */
   997 union vectorlike_header
   998   {
   999     /* The main member contains various pieces of information:
  1000        - The MSB (ARRAY_MARK_FLAG) holds the gcmarkbit.
  1001        - The next bit (PSEUDOVECTOR_FLAG) indicates whether this is a plain
  1002          vector (0) or a pseudovector (1).
  1003        - If PSEUDOVECTOR_FLAG is 0, the rest holds the size (number
  1004          of slots) of the vector.
  1005        - If PSEUDOVECTOR_FLAG is 1, the rest is subdivided into three fields:
  1006          - a) pseudovector subtype held in PVEC_TYPE_MASK field;
  1007          - b) number of Lisp_Objects slots at the beginning of the object
  1008            held in PSEUDOVECTOR_SIZE_MASK field.  These objects are always
  1009            traced by the GC;
  1010          - c) size of the rest fields held in PSEUDOVECTOR_REST_MASK and
  1011            measured in word_size units.  Rest fields may also include
  1012            Lisp_Objects, but these objects usually needs some special treatment
  1013            during GC.
  1014          There are some exceptions.  For PVEC_FREE, b) is always zero.  For
  1015          PVEC_BOOL_VECTOR and PVEC_SUBR, both b) and c) are always zero.
  1016          Current layout limits the pseudovectors to 63 PVEC_xxx subtypes,
  1017          4095 Lisp_Objects in GC-ed area and 4095 word-sized other slots.  */
  1018     ptrdiff_t size;
  1019   };
  1020 
  1021 struct Lisp_Symbol_With_Pos
  1022 {
  1023   union vectorlike_header header;
  1024   Lisp_Object sym;              /* A symbol */
  1025   Lisp_Object pos;              /* A fixnum */
  1026 } GCALIGNED_STRUCT;
  1027 
  1028 /* In the size word of a vector, this bit means the vector has been marked.  */
  1029 
  1030 DEFINE_GDB_SYMBOL_BEGIN (ptrdiff_t, ARRAY_MARK_FLAG)
  1031 # define ARRAY_MARK_FLAG PTRDIFF_MIN
  1032 DEFINE_GDB_SYMBOL_END (ARRAY_MARK_FLAG)
  1033 
  1034 /* In the size word of a struct Lisp_Vector, this bit means it's really
  1035    some other vector-like object.  */
  1036 DEFINE_GDB_SYMBOL_BEGIN (ptrdiff_t, PSEUDOVECTOR_FLAG)
  1037 # define PSEUDOVECTOR_FLAG (PTRDIFF_MAX - PTRDIFF_MAX / 2)
  1038 DEFINE_GDB_SYMBOL_END (PSEUDOVECTOR_FLAG)
  1039 
  1040 /* In a pseudovector, the size field actually contains a word with one
  1041    PSEUDOVECTOR_FLAG bit set, and one of the following values extracted
  1042    with PVEC_TYPE_MASK to indicate the actual type.  */
  1043 enum pvec_type
  1044 {
  1045   PVEC_NORMAL_VECTOR,   /* Should be first, for sxhash_obj.  */
  1046   PVEC_FREE,
  1047   PVEC_BIGNUM,
  1048   PVEC_MARKER,
  1049   PVEC_OVERLAY,
  1050   PVEC_FINALIZER,
  1051   PVEC_SYMBOL_WITH_POS,
  1052   PVEC_MISC_PTR,
  1053   PVEC_USER_PTR,
  1054   PVEC_PROCESS,
  1055   PVEC_FRAME,
  1056   PVEC_WINDOW,
  1057   PVEC_BOOL_VECTOR,
  1058   PVEC_BUFFER,
  1059   PVEC_HASH_TABLE,
  1060   PVEC_TERMINAL,
  1061   PVEC_WINDOW_CONFIGURATION,
  1062   PVEC_SUBR,
  1063   PVEC_OTHER,            /* Should never be visible to Elisp code.  */
  1064   PVEC_XWIDGET,
  1065   PVEC_XWIDGET_VIEW,
  1066   PVEC_THREAD,
  1067   PVEC_MUTEX,
  1068   PVEC_CONDVAR,
  1069   PVEC_MODULE_FUNCTION,
  1070   PVEC_NATIVE_COMP_UNIT,
  1071   PVEC_TS_PARSER,
  1072   PVEC_TS_NODE,
  1073   PVEC_TS_COMPILED_QUERY,
  1074   PVEC_SQLITE,
  1075 
  1076   /* These should be last, for internal_equal and sxhash_obj.  */
  1077   PVEC_COMPILED,
  1078   PVEC_CHAR_TABLE,
  1079   PVEC_SUB_CHAR_TABLE,
  1080   PVEC_RECORD,
  1081   PVEC_FONT /* Should be last because it's used for range checking.  */
  1082 };
  1083 
  1084 enum More_Lisp_Bits
  1085   {
  1086     /* For convenience, we also store the number of elements in these bits.
  1087        Note that this size is not necessarily the memory-footprint size, but
  1088        only the number of Lisp_Object fields (that need to be traced by GC).
  1089        The distinction is used, e.g., by Lisp_Process, which places extra
  1090        non-Lisp_Object fields at the end of the structure.  */
  1091     PSEUDOVECTOR_SIZE_BITS = 12,
  1092     PSEUDOVECTOR_SIZE_MASK = (1 << PSEUDOVECTOR_SIZE_BITS) - 1,
  1093 
  1094     /* To calculate the memory footprint of the pseudovector, it's useful
  1095        to store the size of non-Lisp area in word_size units here.  */
  1096     PSEUDOVECTOR_REST_BITS = 12,
  1097     PSEUDOVECTOR_REST_MASK = (((1 << PSEUDOVECTOR_REST_BITS) - 1)
  1098                               << PSEUDOVECTOR_SIZE_BITS),
  1099 
  1100     /* Used to extract pseudovector subtype information.  */
  1101     PSEUDOVECTOR_AREA_BITS = PSEUDOVECTOR_SIZE_BITS + PSEUDOVECTOR_REST_BITS,
  1102     PVEC_TYPE_MASK = 0x3f << PSEUDOVECTOR_AREA_BITS
  1103   };
  1104 
  1105 /* These functions extract various sorts of values from a Lisp_Object.
  1106    For example, if tem is a Lisp_Object whose type is Lisp_Cons,
  1107    XCONS (tem) is the struct Lisp_Cons * pointing to the memory for
  1108    that cons.  */
  1109 
  1110 /* Largest and smallest representable fixnum values.  These are the C
  1111    values.  They are macros for use in #if and static initializers.  */
  1112 #define MOST_POSITIVE_FIXNUM (EMACS_INT_MAX >> INTTYPEBITS)
  1113 #define MOST_NEGATIVE_FIXNUM (-1 - MOST_POSITIVE_FIXNUM)
  1114 
  1115 INLINE bool
  1116 PSEUDOVECTORP (Lisp_Object a, int code)
  1117 {
  1118   return lisp_h_PSEUDOVECTORP (a, code);
  1119 }
  1120 
  1121 INLINE bool
  1122 (BARE_SYMBOL_P) (Lisp_Object x)
  1123 {
  1124   return lisp_h_BARE_SYMBOL_P (x);
  1125 }
  1126 
  1127 INLINE bool
  1128 (SYMBOL_WITH_POS_P) (Lisp_Object x)
  1129 {
  1130   return lisp_h_SYMBOL_WITH_POS_P (x);
  1131 }
  1132 
  1133 INLINE bool
  1134 (SYMBOLP) (Lisp_Object x)
  1135 {
  1136   return lisp_h_SYMBOLP (x);
  1137 }
  1138 
  1139 INLINE struct Lisp_Symbol_With_Pos *
  1140 XSYMBOL_WITH_POS (Lisp_Object a)
  1141 {
  1142     eassert (SYMBOL_WITH_POS_P (a));
  1143     return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Symbol_With_Pos);
  1144 }
  1145 
  1146 INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED
  1147 (XBARE_SYMBOL) (Lisp_Object a)
  1148 {
  1149   eassert (BARE_SYMBOL_P (a));
  1150   intptr_t i = (intptr_t) XUNTAG (a, Lisp_Symbol, struct Lisp_Symbol);
  1151   void *p = (char *) lispsym + i;
  1152   return p;
  1153 }
  1154 
  1155 INLINE struct Lisp_Symbol * ATTRIBUTE_NO_SANITIZE_UNDEFINED
  1156 (XSYMBOL) (Lisp_Object a)
  1157 {
  1158   eassert (SYMBOLP ((a)));
  1159   if (!symbols_with_pos_enabled || BARE_SYMBOL_P (a))
  1160     return XBARE_SYMBOL (a);
  1161   return XBARE_SYMBOL (XSYMBOL_WITH_POS (a)->sym);
  1162 }
  1163 
  1164 INLINE Lisp_Object
  1165 make_lisp_symbol (struct Lisp_Symbol *sym)
  1166 {
  1167   /* GCC 7 x86-64 generates faster code if lispsym is
  1168      cast to char * rather than to intptr_t.  */
  1169   char *symoffset = (char *) ((char *) sym - (char *) lispsym);
  1170   Lisp_Object a = TAG_PTR (Lisp_Symbol, symoffset);
  1171   eassert (XSYMBOL (a) == sym);
  1172   return a;
  1173 }
  1174 
  1175 INLINE Lisp_Object
  1176 builtin_lisp_symbol (int index)
  1177 {
  1178   return make_lisp_symbol (&lispsym[index]);
  1179 }
  1180 
  1181 INLINE bool
  1182 c_symbol_p (struct Lisp_Symbol *sym)
  1183 {
  1184   char *bp = (char *) lispsym;
  1185   char *sp = (char *) sym;
  1186   if (PTRDIFF_MAX < INTPTR_MAX)
  1187     return bp <= sp && sp < bp + sizeof lispsym;
  1188   else
  1189     {
  1190       ptrdiff_t offset = sp - bp;
  1191       return 0 <= offset && offset < sizeof lispsym;
  1192     }
  1193 }
  1194 
  1195 INLINE void
  1196 (CHECK_SYMBOL) (Lisp_Object x)
  1197 {
  1198   lisp_h_CHECK_SYMBOL (x);
  1199 }
  1200 
  1201 /* True if the possibly-unsigned integer I doesn't fit in a fixnum.  */
  1202 
  1203 #define FIXNUM_OVERFLOW_P(i) \
  1204   (! ((0 <= (i) || MOST_NEGATIVE_FIXNUM <= (i)) && (i) <= MOST_POSITIVE_FIXNUM))
  1205 
  1206 #if USE_LSB_TAG
  1207 
  1208 INLINE Lisp_Object
  1209 (make_fixnum) (EMACS_INT n)
  1210 {
  1211   eassert (!FIXNUM_OVERFLOW_P (n));
  1212   return lisp_h_make_fixnum_wrap (n);
  1213 }
  1214 
  1215 INLINE EMACS_INT
  1216 (XFIXNUM_RAW) (Lisp_Object a)
  1217 {
  1218   return lisp_h_XFIXNUM_RAW (a);
  1219 }
  1220 
  1221 INLINE Lisp_Object
  1222 make_ufixnum (EMACS_INT n)
  1223 {
  1224   eassert (0 <= n && n <= INTMASK);
  1225   return lisp_h_make_fixnum_wrap (n);
  1226 }
  1227 
  1228 #else /* ! USE_LSB_TAG */
  1229 
  1230 /* Although compiled only if ! USE_LSB_TAG, the following functions
  1231    also work when USE_LSB_TAG; this is to aid future maintenance when
  1232    the lisp_h_* macros are eventually removed.  */
  1233 
  1234 /* Make a fixnum representing the value of the low order bits of N.  */
  1235 INLINE Lisp_Object
  1236 make_fixnum (EMACS_INT n)
  1237 {
  1238   eassert (! FIXNUM_OVERFLOW_P (n));
  1239   EMACS_INT int0 = Lisp_Int0;
  1240   if (USE_LSB_TAG)
  1241     {
  1242       EMACS_UINT u = n;
  1243       n = u << INTTYPEBITS;
  1244       n += int0;
  1245     }
  1246   else
  1247     {
  1248       n &= INTMASK;
  1249       n += (int0 << VALBITS);
  1250     }
  1251   return XIL (n);
  1252 }
  1253 
  1254 /* Extract A's value as a signed integer.  Unlike XFIXNUM, this works
  1255    on any Lisp object, although the resulting integer is useful only
  1256    for things like hashing when A is not a fixnum.  */
  1257 INLINE EMACS_INT
  1258 XFIXNUM_RAW (Lisp_Object a)
  1259 {
  1260   EMACS_INT i = XLI (a);
  1261   if (! USE_LSB_TAG)
  1262     {
  1263       EMACS_UINT u = i;
  1264       i = u << INTTYPEBITS;
  1265     }
  1266   return i >> INTTYPEBITS;
  1267 }
  1268 
  1269 INLINE Lisp_Object
  1270 make_ufixnum (EMACS_INT n)
  1271 {
  1272   eassert (0 <= n && n <= INTMASK);
  1273   EMACS_INT int0 = Lisp_Int0;
  1274   if (USE_LSB_TAG)
  1275     {
  1276       EMACS_UINT u = n;
  1277       n = u << INTTYPEBITS;
  1278       n += int0;
  1279     }
  1280   else
  1281     n += int0 << VALBITS;
  1282   return XIL (n);
  1283 }
  1284 
  1285 #endif /* ! USE_LSB_TAG */
  1286 
  1287 INLINE bool
  1288 (FIXNUMP) (Lisp_Object x)
  1289 {
  1290   return lisp_h_FIXNUMP (x);
  1291 }
  1292 
  1293 INLINE EMACS_INT
  1294 XFIXNUM (Lisp_Object a)
  1295 {
  1296   eassert (FIXNUMP (a));
  1297   return XFIXNUM_RAW (a);
  1298 }
  1299 
  1300 /* Extract A's value as an unsigned integer in the range 0..INTMASK.  */
  1301 INLINE EMACS_UINT
  1302 XUFIXNUM_RAW (Lisp_Object a)
  1303 {
  1304   EMACS_UINT i = XLI (a);
  1305   return USE_LSB_TAG ? i >> INTTYPEBITS : i & INTMASK;
  1306 }
  1307 INLINE EMACS_UINT
  1308 XUFIXNUM (Lisp_Object a)
  1309 {
  1310   eassert (FIXNUMP (a));
  1311   return XUFIXNUM_RAW (a);
  1312 }
  1313 
  1314 /* Return A's hash, which is in the range 0..INTMASK.  */
  1315 INLINE EMACS_INT
  1316 (XHASH) (Lisp_Object a)
  1317 {
  1318   return lisp_h_XHASH (a);
  1319 }
  1320 
  1321 /* Like make_fixnum (N), but may be faster.  N must be in nonnegative range.  */
  1322 INLINE Lisp_Object
  1323 make_fixed_natnum (EMACS_INT n)
  1324 {
  1325   eassert (0 <= n && n <= MOST_POSITIVE_FIXNUM);
  1326   EMACS_INT int0 = Lisp_Int0;
  1327   return USE_LSB_TAG ? make_fixnum (n) : XIL (n + (int0 << VALBITS));
  1328 }
  1329 
  1330 /* Return true if X and Y are the same object.  */
  1331 INLINE bool
  1332 (BASE_EQ) (Lisp_Object x, Lisp_Object y)
  1333 {
  1334   return lisp_h_BASE_EQ (x, y);
  1335 }
  1336 
  1337 /* Return true if X and Y are the same object, reckoning X to be the
  1338    same as a bare symbol Y if X is Y with position.  */
  1339 INLINE bool
  1340 (BASE2_EQ) (Lisp_Object x, Lisp_Object y)
  1341 {
  1342   return lisp_h_BASE2_EQ (x, y);
  1343 }
  1344 
  1345 /* Return true if X and Y are the same object, reckoning a symbol with
  1346    position as being the same as the bare symbol.  */
  1347 INLINE bool
  1348 (EQ) (Lisp_Object x, Lisp_Object y)
  1349 {
  1350   return lisp_h_EQ (x, y);
  1351 }
  1352 
  1353 INLINE intmax_t
  1354 clip_to_bounds (intmax_t lower, intmax_t num, intmax_t upper)
  1355 {
  1356   return num < lower ? lower : num <= upper ? num : upper;
  1357 }
  1358 
  1359 /* Construct a Lisp_Object from a value or address.  */
  1360 
  1361 INLINE Lisp_Object
  1362 make_lisp_ptr (void *ptr, enum Lisp_Type type)
  1363 {
  1364   Lisp_Object a = TAG_PTR (type, ptr);
  1365   eassert (TAGGEDP (a, type) && XUNTAG (a, type, char) == ptr);
  1366   return a;
  1367 }
  1368 
  1369 #define XSETINT(a, b) ((a) = make_fixnum (b))
  1370 #define XSETFASTINT(a, b) ((a) = make_fixed_natnum (b))
  1371 #define XSETCONS(a, b) ((a) = make_lisp_ptr (b, Lisp_Cons))
  1372 #define XSETVECTOR(a, b) ((a) = make_lisp_ptr (b, Lisp_Vectorlike))
  1373 #define XSETSTRING(a, b) ((a) = make_lisp_ptr (b, Lisp_String))
  1374 #define XSETSYMBOL(a, b) ((a) = make_lisp_symbol (b))
  1375 #define XSETFLOAT(a, b) ((a) = make_lisp_ptr (b, Lisp_Float))
  1376 
  1377 /* Return a Lisp_Object value that does not correspond to any object.
  1378    This can make some Lisp objects on free lists recognizable in O(1).  */
  1379 
  1380 INLINE Lisp_Object
  1381 dead_object (void)
  1382 {
  1383   return make_lisp_ptr (NULL, Lisp_String);
  1384 }
  1385 
  1386 /* Pseudovector types.  */
  1387 
  1388 #define XSETPVECTYPE(v, code)                                           \
  1389   ((v)->header.size |= PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS))
  1390 #define PVECHEADERSIZE(code, lispsize, restsize) \
  1391   (PSEUDOVECTOR_FLAG | ((code) << PSEUDOVECTOR_AREA_BITS) \
  1392    | ((restsize) << PSEUDOVECTOR_SIZE_BITS) | (lispsize))
  1393 #define XSETPVECTYPESIZE(v, code, lispsize, restsize)           \
  1394   ((v)->header.size = PVECHEADERSIZE (code, lispsize, restsize))
  1395 
  1396 /* The cast to union vectorlike_header * avoids aliasing issues.  */
  1397 #define XSETPSEUDOVECTOR(a, b, code) \
  1398   XSETTYPED_PSEUDOVECTOR (a, b,                                 \
  1399                           (XUNTAG (a, Lisp_Vectorlike,          \
  1400                                    union vectorlike_header)     \
  1401                            ->size),                             \
  1402                           code)
  1403 #define XSETTYPED_PSEUDOVECTOR(a, b, size, code)                        \
  1404   (XSETVECTOR (a, b),                                                   \
  1405    eassert ((size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK))               \
  1406             == (PSEUDOVECTOR_FLAG | (code << PSEUDOVECTOR_AREA_BITS))))
  1407 
  1408 #define XSETWINDOW_CONFIGURATION(a, b) \
  1409   (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW_CONFIGURATION))
  1410 #define XSETPROCESS(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_PROCESS))
  1411 #define XSETWINDOW(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_WINDOW))
  1412 #define XSETTERMINAL(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_TERMINAL))
  1413 #define XSETSUBR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUBR))
  1414 #define XSETBUFFER(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BUFFER))
  1415 #define XSETCHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CHAR_TABLE))
  1416 #define XSETBOOL_VECTOR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_BOOL_VECTOR))
  1417 #define XSETSUB_CHAR_TABLE(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_SUB_CHAR_TABLE))
  1418 #define XSETTHREAD(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_THREAD))
  1419 #define XSETMUTEX(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_MUTEX))
  1420 #define XSETCONDVAR(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_CONDVAR))
  1421 #define XSETNATIVE_COMP_UNIT(a, b) (XSETPSEUDOVECTOR (a, b, PVEC_NATIVE_COMP_UNIT))
  1422 
  1423 /* Efficiently convert a pointer to a Lisp object and back.  The
  1424    pointer is represented as a fixnum, so the garbage collector
  1425    does not know about it.  The pointer should not have both Lisp_Int1
  1426    bits set, which makes this conversion inherently unportable.  */
  1427 
  1428 INLINE void *
  1429 XFIXNUMPTR (Lisp_Object a)
  1430 {
  1431   return XUNTAG (a, Lisp_Int0, char);
  1432 }
  1433 
  1434 INLINE Lisp_Object
  1435 make_pointer_integer_unsafe (void *p)
  1436 {
  1437   Lisp_Object a = TAG_PTR (Lisp_Int0, p);
  1438   return a;
  1439 }
  1440 
  1441 INLINE Lisp_Object
  1442 make_pointer_integer (void *p)
  1443 {
  1444   Lisp_Object a = make_pointer_integer_unsafe (p);
  1445   eassert (FIXNUMP (a) && XFIXNUMPTR (a) == p);
  1446   return a;
  1447 }
  1448 
  1449 /* See the macros in intervals.h.  */
  1450 
  1451 typedef struct interval *INTERVAL;
  1452 
  1453 struct Lisp_Cons
  1454 {
  1455   union
  1456   {
  1457     struct
  1458     {
  1459       /* Car of this cons cell.  */
  1460       Lisp_Object car;
  1461 
  1462       union
  1463       {
  1464         /* Cdr of this cons cell.  */
  1465         Lisp_Object cdr;
  1466 
  1467         /* Used to chain conses on a free list.  */
  1468         struct Lisp_Cons *chain;
  1469       } u;
  1470     } s;
  1471     GCALIGNED_UNION_MEMBER
  1472   } u;
  1473 };
  1474 verify (GCALIGNED (struct Lisp_Cons));
  1475 
  1476 INLINE bool
  1477 (NILP) (Lisp_Object x)
  1478 {
  1479   return lisp_h_NILP (x);
  1480 }
  1481 
  1482 INLINE bool
  1483 (CONSP) (Lisp_Object x)
  1484 {
  1485   return lisp_h_CONSP (x);
  1486 }
  1487 
  1488 INLINE void
  1489 CHECK_CONS (Lisp_Object x)
  1490 {
  1491   CHECK_TYPE (CONSP (x), Qconsp, x);
  1492 }
  1493 
  1494 INLINE struct Lisp_Cons *
  1495 (XCONS) (Lisp_Object a)
  1496 {
  1497   return lisp_h_XCONS (a);
  1498 }
  1499 
  1500 /* Take the car or cdr of something known to be a cons cell.  */
  1501 /* The _addr functions shouldn't be used outside of the minimal set
  1502    of code that has to know what a cons cell looks like.  Other code not
  1503    part of the basic lisp implementation should assume that the car and cdr
  1504    fields are not accessible.  (What if we want to switch to
  1505    a copying collector someday?  Cached cons cell field addresses may be
  1506    invalidated at arbitrary points.)  */
  1507 INLINE Lisp_Object *
  1508 xcar_addr (Lisp_Object c)
  1509 {
  1510   return &XCONS (c)->u.s.car;
  1511 }
  1512 INLINE Lisp_Object *
  1513 xcdr_addr (Lisp_Object c)
  1514 {
  1515   return &XCONS (c)->u.s.u.cdr;
  1516 }
  1517 
  1518 /* Use these from normal code.  */
  1519 
  1520 INLINE Lisp_Object
  1521 (XCAR) (Lisp_Object c)
  1522 {
  1523   return lisp_h_XCAR (c);
  1524 }
  1525 
  1526 INLINE Lisp_Object
  1527 (XCDR) (Lisp_Object c)
  1528 {
  1529   return lisp_h_XCDR (c);
  1530 }
  1531 
  1532 /* Use these to set the fields of a cons cell.
  1533 
  1534    Note that both arguments may refer to the same object, so 'n'
  1535    should not be read after 'c' is first modified.  */
  1536 INLINE void
  1537 XSETCAR (Lisp_Object c, Lisp_Object n)
  1538 {
  1539   *xcar_addr (c) = n;
  1540 }
  1541 INLINE void
  1542 XSETCDR (Lisp_Object c, Lisp_Object n)
  1543 {
  1544   *xcdr_addr (c) = n;
  1545 }
  1546 
  1547 /* Take the car or cdr of something whose type is not known.  */
  1548 INLINE Lisp_Object
  1549 CAR (Lisp_Object c)
  1550 {
  1551   if (CONSP (c))
  1552     return XCAR (c);
  1553   if (!NILP (c))
  1554     wrong_type_argument (Qlistp, c);
  1555   return Qnil;
  1556 }
  1557 INLINE Lisp_Object
  1558 CDR (Lisp_Object c)
  1559 {
  1560   if (CONSP (c))
  1561     return XCDR (c);
  1562   if (!NILP (c))
  1563     wrong_type_argument (Qlistp, c);
  1564   return Qnil;
  1565 }
  1566 
  1567 /* Take the car or cdr of something whose type is not known.  */
  1568 INLINE Lisp_Object
  1569 CAR_SAFE (Lisp_Object c)
  1570 {
  1571   return CONSP (c) ? XCAR (c) : Qnil;
  1572 }
  1573 INLINE Lisp_Object
  1574 CDR_SAFE (Lisp_Object c)
  1575 {
  1576   return CONSP (c) ? XCDR (c) : Qnil;
  1577 }
  1578 
  1579 /* In a string or vector, the sign bit of u.s.size is the gc mark bit.  */
  1580 
  1581 struct Lisp_String
  1582 {
  1583   union
  1584   {
  1585     struct
  1586     {
  1587       /* Number of characters in string; MSB is used as the mark bit.  */
  1588       ptrdiff_t size;
  1589       /* If nonnegative, number of bytes in the string (which is multibyte).
  1590          If negative, the string is unibyte:
  1591          -1 for data normally allocated
  1592          -2 for data in rodata (C string constants)
  1593          -3 for data that must be immovable (used for bytecode)  */
  1594       ptrdiff_t size_byte;
  1595 
  1596       INTERVAL intervals;       /* Text properties in this string.  */
  1597       unsigned char *data;
  1598     } s;
  1599     struct Lisp_String *next;
  1600     GCALIGNED_UNION_MEMBER
  1601   } u;
  1602 };
  1603 verify (GCALIGNED (struct Lisp_String));
  1604 
  1605 INLINE bool
  1606 STRINGP (Lisp_Object x)
  1607 {
  1608   return TAGGEDP (x, Lisp_String);
  1609 }
  1610 
  1611 INLINE void
  1612 CHECK_STRING (Lisp_Object x)
  1613 {
  1614   CHECK_TYPE (STRINGP (x), Qstringp, x);
  1615 }
  1616 
  1617 INLINE struct Lisp_String *
  1618 XSTRING (Lisp_Object a)
  1619 {
  1620   eassert (STRINGP (a));
  1621   return XUNTAG (a, Lisp_String, struct Lisp_String);
  1622 }
  1623 
  1624 /* True if STR is a multibyte string.  */
  1625 INLINE bool
  1626 STRING_MULTIBYTE (Lisp_Object str)
  1627 {
  1628   return 0 <= XSTRING (str)->u.s.size_byte;
  1629 }
  1630 
  1631 /* An upper bound on the number of bytes in a Lisp string, not
  1632    counting the terminating null.  This a tight enough bound to
  1633    prevent integer overflow errors that would otherwise occur during
  1634    string size calculations.  A string cannot contain more bytes than
  1635    a fixnum can represent, nor can it be so long that C pointer
  1636    arithmetic stops working on the string plus its terminating null.
  1637    Although the actual size limit (see STRING_BYTES_MAX in alloc.c)
  1638    may be a bit smaller than STRING_BYTES_BOUND, calculating it here
  1639    would expose alloc.c internal details that we'd rather keep
  1640    private.
  1641 
  1642    This is a macro for use in static initializers.  The cast to
  1643    ptrdiff_t ensures that the macro is signed.  */
  1644 #define STRING_BYTES_BOUND  \
  1645   ((ptrdiff_t) min (MOST_POSITIVE_FIXNUM, min (SIZE_MAX, PTRDIFF_MAX) - 1))
  1646 
  1647 /* Mark STR as a unibyte string.  */
  1648 #define STRING_SET_UNIBYTE(STR)                         \
  1649   do {                                                  \
  1650     if (XSTRING (STR)->u.s.size == 0)                   \
  1651       (STR) = empty_unibyte_string;                     \
  1652     else                                                \
  1653       XSTRING (STR)->u.s.size_byte = -1;                \
  1654   } while (false)
  1655 
  1656 /* Mark STR as a multibyte string.  Assure that STR contains only
  1657    ASCII characters in advance.  */
  1658 INLINE void
  1659 STRING_SET_MULTIBYTE (Lisp_Object str)
  1660 {
  1661   /* The 0-length strings are unique&shared so we can't modify them.  */
  1662   eassert (XSTRING (str)->u.s.size > 0);
  1663   XSTRING (str)->u.s.size_byte = XSTRING (str)->u.s.size;
  1664 }
  1665 
  1666 /* Convenience functions for dealing with Lisp strings.  */
  1667 
  1668 /* WARNING: Use the 'char *' pointers to string data with care in code
  1669    that could GC: GC can relocate string data, invalidating such
  1670    pointers.  It is best to use string character or byte index
  1671    instead, delaying the access through SDATA/SSDATA pointers to the
  1672    latest possible moment.  If you must use the 'char *' pointers
  1673    (e.g., for speed), be sure to adjust them after any call that could
  1674    potentially GC.  */
  1675 
  1676 INLINE unsigned char *
  1677 SDATA (Lisp_Object string)
  1678 {
  1679   return XSTRING (string)->u.s.data;
  1680 }
  1681 INLINE char *
  1682 SSDATA (Lisp_Object string)
  1683 {
  1684   /* Avoid "differ in sign" warnings.  */
  1685   return (char *) SDATA (string);
  1686 }
  1687 INLINE unsigned char
  1688 SREF (Lisp_Object string, ptrdiff_t index)
  1689 {
  1690   return SDATA (string)[index];
  1691 }
  1692 INLINE void
  1693 SSET (Lisp_Object string, ptrdiff_t index, unsigned char new)
  1694 {
  1695   SDATA (string)[index] = new;
  1696 }
  1697 INLINE ptrdiff_t
  1698 SCHARS (Lisp_Object string)
  1699 {
  1700   ptrdiff_t nchars = XSTRING (string)->u.s.size;
  1701   eassume (0 <= nchars);
  1702   return nchars;
  1703 }
  1704 
  1705 #ifdef GC_CHECK_STRING_BYTES
  1706 extern ptrdiff_t string_bytes (struct Lisp_String *);
  1707 #endif
  1708 INLINE ptrdiff_t
  1709 STRING_BYTES (struct Lisp_String *s)
  1710 {
  1711 #ifdef GC_CHECK_STRING_BYTES
  1712   ptrdiff_t nbytes = string_bytes (s);
  1713 #else
  1714   ptrdiff_t nbytes = s->u.s.size_byte < 0 ? s->u.s.size : s->u.s.size_byte;
  1715 #endif
  1716   eassume (0 <= nbytes);
  1717   return nbytes;
  1718 }
  1719 
  1720 INLINE ptrdiff_t
  1721 SBYTES (Lisp_Object string)
  1722 {
  1723   return STRING_BYTES (XSTRING (string));
  1724 }
  1725 INLINE void
  1726 STRING_SET_CHARS (Lisp_Object string, ptrdiff_t newsize)
  1727 {
  1728   /* This function cannot change the size of data allocated for the
  1729      string when it was created.  */
  1730   eassert (STRING_MULTIBYTE (string)
  1731            ? 0 <= newsize && newsize <= SBYTES (string)
  1732            : newsize == SCHARS (string));
  1733   XSTRING (string)->u.s.size = newsize;
  1734 }
  1735 
  1736 INLINE void
  1737 CHECK_STRING_NULL_BYTES (Lisp_Object string)
  1738 {
  1739   CHECK_TYPE (memchr (SSDATA (string), '\0', SBYTES (string)) == NULL,
  1740               Qfilenamep, string);
  1741 }
  1742 
  1743 /* True if STR is immovable (whose data won't move during GC).  */
  1744 INLINE bool
  1745 string_immovable_p (Lisp_Object str)
  1746 {
  1747   return XSTRING (str)->u.s.size_byte == -3;
  1748 }
  1749 
  1750 /* A regular vector is just a header plus an array of Lisp_Objects.  */
  1751 
  1752 struct Lisp_Vector
  1753   {
  1754     union vectorlike_header header;
  1755     Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
  1756   } GCALIGNED_STRUCT;
  1757 
  1758 INLINE bool
  1759 (VECTORLIKEP) (Lisp_Object x)
  1760 {
  1761   return lisp_h_VECTORLIKEP (x);
  1762 }
  1763 
  1764 INLINE struct Lisp_Vector *
  1765 XVECTOR (Lisp_Object a)
  1766 {
  1767   eassert (VECTORLIKEP (a));
  1768   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Vector);
  1769 }
  1770 
  1771 INLINE ptrdiff_t
  1772 ASIZE (Lisp_Object array)
  1773 {
  1774   ptrdiff_t size = XVECTOR (array)->header.size;
  1775   eassume (0 <= size);
  1776   return size;
  1777 }
  1778 
  1779 INLINE ptrdiff_t
  1780 gc_asize (Lisp_Object array)
  1781 {
  1782   /* Like ASIZE, but also can be used in the garbage collector.  */
  1783   return XVECTOR (array)->header.size & ~ARRAY_MARK_FLAG;
  1784 }
  1785 
  1786 INLINE ptrdiff_t
  1787 PVSIZE (Lisp_Object pv)
  1788 {
  1789   return ASIZE (pv) & PSEUDOVECTOR_SIZE_MASK;
  1790 }
  1791 
  1792 INLINE bool
  1793 VECTORP (Lisp_Object x)
  1794 {
  1795   return VECTORLIKEP (x) && ! (ASIZE (x) & PSEUDOVECTOR_FLAG);
  1796 }
  1797 
  1798 INLINE void
  1799 CHECK_VECTOR (Lisp_Object x)
  1800 {
  1801   CHECK_TYPE (VECTORP (x), Qvectorp, x);
  1802 }
  1803 
  1804 
  1805 /* A pseudovector is like a vector, but has other non-Lisp components.  */
  1806 
  1807 INLINE enum pvec_type
  1808 PSEUDOVECTOR_TYPE (const struct Lisp_Vector *v)
  1809 {
  1810   ptrdiff_t size = v->header.size;
  1811   return (size & PSEUDOVECTOR_FLAG
  1812           ? (size & PVEC_TYPE_MASK) >> PSEUDOVECTOR_AREA_BITS
  1813           : PVEC_NORMAL_VECTOR);
  1814 }
  1815 
  1816 /* Can't be used with PVEC_NORMAL_VECTOR.  */
  1817 INLINE bool
  1818 PSEUDOVECTOR_TYPEP (const union vectorlike_header *a, enum pvec_type code)
  1819 {
  1820   /* We don't use PSEUDOVECTOR_TYPE here so as to avoid a shift
  1821    * operation when `code' is known.  */
  1822   return ((a->size & (PSEUDOVECTOR_FLAG | PVEC_TYPE_MASK))
  1823           == (PSEUDOVECTOR_FLAG | (code << PSEUDOVECTOR_AREA_BITS)));
  1824 }
  1825 
  1826 /* A boolvector is a kind of vectorlike, with contents like a string.  */
  1827 
  1828 struct Lisp_Bool_Vector
  1829   {
  1830     /* HEADER.SIZE is the vector's size field.  It doesn't have the real size,
  1831        just the subtype information.  */
  1832     union vectorlike_header header;
  1833     /* This is the size in bits.  */
  1834     EMACS_INT size;
  1835     /* The actual bits, packed into bytes.
  1836        Zeros fill out the last word if needed.
  1837        The bits are in little-endian order in the bytes, and
  1838        the bytes are in little-endian order in the words.  */
  1839     bits_word data[FLEXIBLE_ARRAY_MEMBER];
  1840   } GCALIGNED_STRUCT;
  1841 
  1842 /* Some handy constants for calculating sizes
  1843    and offsets, mostly of vectorlike objects.
  1844 
  1845    The garbage collector assumes that the initial part of any struct
  1846    that starts with a union vectorlike_header followed by N
  1847    Lisp_Objects (some possibly in arrays and/or a trailing flexible
  1848    array) will be laid out like a struct Lisp_Vector with N
  1849    Lisp_Objects.  This assumption is true in practice on known Emacs
  1850    targets even though the C standard does not guarantee it.  This
  1851    header contains a few sanity checks that should suffice to detect
  1852    violations of this assumption on plausible practical hosts.  */
  1853 
  1854 enum
  1855   {
  1856     header_size = offsetof (struct Lisp_Vector, contents),
  1857     bool_header_size = offsetof (struct Lisp_Bool_Vector, data),
  1858     word_size = sizeof (Lisp_Object)
  1859   };
  1860 
  1861 /* The number of data words and bytes in a bool vector with SIZE bits.  */
  1862 
  1863 INLINE EMACS_INT
  1864 bool_vector_words (EMACS_INT size)
  1865 {
  1866   eassume (0 <= size && size <= EMACS_INT_MAX - (BITS_PER_BITS_WORD - 1));
  1867   return (size + BITS_PER_BITS_WORD - 1) / BITS_PER_BITS_WORD;
  1868 }
  1869 
  1870 INLINE EMACS_INT
  1871 bool_vector_bytes (EMACS_INT size)
  1872 {
  1873   eassume (0 <= size && size <= EMACS_INT_MAX - (BITS_PER_BITS_WORD - 1));
  1874   return (size + BOOL_VECTOR_BITS_PER_CHAR - 1) / BOOL_VECTOR_BITS_PER_CHAR;
  1875 }
  1876 
  1877 INLINE bool
  1878 BOOL_VECTOR_P (Lisp_Object a)
  1879 {
  1880   return PSEUDOVECTORP (a, PVEC_BOOL_VECTOR);
  1881 }
  1882 
  1883 INLINE void
  1884 CHECK_BOOL_VECTOR (Lisp_Object x)
  1885 {
  1886   CHECK_TYPE (BOOL_VECTOR_P (x), Qbool_vector_p, x);
  1887 }
  1888 
  1889 INLINE struct Lisp_Bool_Vector *
  1890 XBOOL_VECTOR (Lisp_Object a)
  1891 {
  1892   eassert (BOOL_VECTOR_P (a));
  1893   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Bool_Vector);
  1894 }
  1895 
  1896 INLINE EMACS_INT
  1897 bool_vector_size (Lisp_Object a)
  1898 {
  1899   EMACS_INT size = XBOOL_VECTOR (a)->size;
  1900   eassume (0 <= size);
  1901   return size;
  1902 }
  1903 
  1904 INLINE bits_word *
  1905 bool_vector_data (Lisp_Object a)
  1906 {
  1907   return XBOOL_VECTOR (a)->data;
  1908 }
  1909 
  1910 INLINE unsigned char *
  1911 bool_vector_uchar_data (Lisp_Object a)
  1912 {
  1913   return (unsigned char *) bool_vector_data (a);
  1914 }
  1915 
  1916 /* True if A's Ith bit is set.  */
  1917 
  1918 INLINE bool
  1919 bool_vector_bitref (Lisp_Object a, EMACS_INT i)
  1920 {
  1921   eassume (0 <= i);
  1922   eassert (i < bool_vector_size (a));
  1923   return !! (bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR]
  1924              & (1 << (i % BOOL_VECTOR_BITS_PER_CHAR)));
  1925 }
  1926 
  1927 INLINE Lisp_Object
  1928 bool_vector_ref (Lisp_Object a, EMACS_INT i)
  1929 {
  1930   return bool_vector_bitref (a, i) ? Qt : Qnil;
  1931 }
  1932 
  1933 /* Set A's Ith bit to B.  */
  1934 
  1935 INLINE void
  1936 bool_vector_set (Lisp_Object a, EMACS_INT i, bool b)
  1937 {
  1938   eassume (0 <= i);
  1939   eassert (i < bool_vector_size (a));
  1940 
  1941   unsigned char *addr
  1942     = &bool_vector_uchar_data (a)[i / BOOL_VECTOR_BITS_PER_CHAR];
  1943   if (b)
  1944     *addr |= 1 << (i % BOOL_VECTOR_BITS_PER_CHAR);
  1945   else
  1946     *addr &= ~ (1 << (i % BOOL_VECTOR_BITS_PER_CHAR));
  1947 }
  1948 
  1949 /* Conveniences for dealing with Lisp arrays.  */
  1950 
  1951 INLINE Lisp_Object
  1952 AREF (Lisp_Object array, ptrdiff_t idx)
  1953 {
  1954   eassert (0 <= idx && idx < gc_asize (array));
  1955   return XVECTOR (array)->contents[idx];
  1956 }
  1957 
  1958 INLINE Lisp_Object *
  1959 aref_addr (Lisp_Object array, ptrdiff_t idx)
  1960 {
  1961   eassert (0 <= idx && idx <= gc_asize (array));
  1962   return & XVECTOR (array)->contents[idx];
  1963 }
  1964 
  1965 INLINE void
  1966 ASET (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
  1967 {
  1968   eassert (0 <= idx && idx < ASIZE (array));
  1969   XVECTOR (array)->contents[idx] = val;
  1970 }
  1971 
  1972 INLINE void
  1973 gc_aset (Lisp_Object array, ptrdiff_t idx, Lisp_Object val)
  1974 {
  1975   /* Like ASET, but also can be used in the garbage collector:
  1976      sweep_weak_table calls set_hash_key etc. while the table is marked.  */
  1977   eassert (0 <= idx && idx < gc_asize (array));
  1978   XVECTOR (array)->contents[idx] = val;
  1979 }
  1980 
  1981 /* True, since Qnil's representation is zero.  Every place in the code
  1982    that assumes Qnil is zero should verify (NIL_IS_ZERO), to make it easy
  1983    to find such assumptions later if we change Qnil to be nonzero.
  1984    Test iQnil and Lisp_Symbol instead of Qnil directly, since the latter
  1985    is not suitable for use in an integer constant expression.  */
  1986 enum { NIL_IS_ZERO = iQnil == 0 && Lisp_Symbol == 0 };
  1987 
  1988 /* Clear the object addressed by P, with size NBYTES, so that all its
  1989    bytes are zero and all its Lisp values are nil.  */
  1990 INLINE void
  1991 memclear (void *p, ptrdiff_t nbytes)
  1992 {
  1993   eassert (0 <= nbytes);
  1994   verify (NIL_IS_ZERO);
  1995   /* Since Qnil is zero, memset suffices.  */
  1996   memset (p, 0, nbytes);
  1997 }
  1998 
  1999 /* If a struct is made to look like a vector, this macro returns the length
  2000    of the shortest vector that would hold that struct.  */
  2001 
  2002 #define VECSIZE(type)                                           \
  2003   ((sizeof (type) - header_size + word_size - 1) / word_size)
  2004 
  2005 /* Like VECSIZE, but used when the pseudo-vector has non-Lisp_Object fields
  2006    at the end and we need to compute the number of Lisp_Object fields (the
  2007    ones that the GC needs to trace).  */
  2008 
  2009 #define PSEUDOVECSIZE(type, lastlispfield)                              \
  2010   (offsetof (type, lastlispfield) + word_size < header_size             \
  2011    ? 0 : (offsetof (type, lastlispfield) + word_size - header_size) / word_size)
  2012 
  2013 /* True iff C is an ASCII character.  */
  2014 INLINE bool
  2015 ASCII_CHAR_P (intmax_t c)
  2016 {
  2017   return 0 <= c && c < 0x80;
  2018 }
  2019 
  2020 /* A char-table is a kind of vectorlike, with contents like a vector,
  2021    but with a few additional slots.  For some purposes, it makes sense
  2022    to handle a char-table as type 'struct Lisp_Vector'.  An element of
  2023    a char-table can be any Lisp object, but if it is a sub-char-table,
  2024    we treat it as a table that contains information of a specific
  2025    range of characters.  A sub-char-table is like a vector, but with
  2026    two integer fields between the header and Lisp data, which means
  2027    that it has to be marked with some precautions (see mark_char_table
  2028    in alloc.c).  A sub-char-table appears only in an element of a
  2029    char-table, and there's no way to access it directly from a Lisp
  2030    program.  */
  2031 
  2032 enum CHARTAB_SIZE_BITS
  2033   {
  2034     CHARTAB_SIZE_BITS_0 = 6,
  2035     CHARTAB_SIZE_BITS_1 = 4,
  2036     CHARTAB_SIZE_BITS_2 = 5,
  2037     CHARTAB_SIZE_BITS_3 = 7
  2038   };
  2039 
  2040 extern const int chartab_size[4];
  2041 
  2042 struct Lisp_Char_Table
  2043   {
  2044     /* HEADER.SIZE is the vector's size field, which also holds the
  2045        pseudovector type information.  It holds the size, too.
  2046        The size counts the defalt, parent, purpose, ascii,
  2047        contents, and extras slots.  */
  2048     union vectorlike_header header;
  2049 
  2050     /* This holds the default value, which is used whenever the value
  2051        for a specific character is nil.  */
  2052     Lisp_Object defalt;
  2053 
  2054     /* This points to another char table, from which we inherit when the
  2055        value for a specific character is nil.  The `defalt' slot takes
  2056        precedence over this.  */
  2057     Lisp_Object parent;
  2058 
  2059     /* This is a symbol which says what kind of use this char-table is
  2060        meant for.  */
  2061     Lisp_Object purpose;
  2062 
  2063     /* The bottom sub char-table for characters in the range 0..127.  It
  2064        is nil if no ASCII character has a specific value.  */
  2065     Lisp_Object ascii;
  2066 
  2067     Lisp_Object contents[(1 << CHARTAB_SIZE_BITS_0)];
  2068 
  2069     /* These hold additional data.  It is a vector.  */
  2070     Lisp_Object extras[FLEXIBLE_ARRAY_MEMBER];
  2071   } GCALIGNED_STRUCT;
  2072 
  2073 INLINE bool
  2074 CHAR_TABLE_P (Lisp_Object a)
  2075 {
  2076   return PSEUDOVECTORP (a, PVEC_CHAR_TABLE);
  2077 }
  2078 
  2079 INLINE struct Lisp_Char_Table *
  2080 XCHAR_TABLE (Lisp_Object a)
  2081 {
  2082   eassert (CHAR_TABLE_P (a));
  2083   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Char_Table);
  2084 }
  2085 
  2086 struct Lisp_Sub_Char_Table
  2087   {
  2088     /* HEADER.SIZE is the vector's size field, which also holds the
  2089        pseudovector type information.  It holds the size, too.  */
  2090     union vectorlike_header header;
  2091 
  2092     /* Depth of this sub char-table.  It should be 1, 2, or 3.  A sub
  2093        char-table of depth 1 contains 16 elements, and each element
  2094        covers 4096 (128*32) characters.  A sub char-table of depth 2
  2095        contains 32 elements, and each element covers 128 characters.  A
  2096        sub char-table of depth 3 contains 128 elements, and each element
  2097        is for one character.  */
  2098     int depth;
  2099 
  2100     /* Minimum character covered by the sub char-table.  */
  2101     int min_char;
  2102 
  2103     /* Use set_sub_char_table_contents to set this.  */
  2104     Lisp_Object contents[FLEXIBLE_ARRAY_MEMBER];
  2105   } GCALIGNED_STRUCT;
  2106 
  2107 INLINE bool
  2108 SUB_CHAR_TABLE_P (Lisp_Object a)
  2109 {
  2110   return PSEUDOVECTORP (a, PVEC_SUB_CHAR_TABLE);
  2111 }
  2112 
  2113 INLINE struct Lisp_Sub_Char_Table *
  2114 XSUB_CHAR_TABLE (Lisp_Object a)
  2115 {
  2116   eassert (SUB_CHAR_TABLE_P (a));
  2117   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Sub_Char_Table);
  2118 }
  2119 
  2120 INLINE Lisp_Object
  2121 CHAR_TABLE_REF_ASCII (Lisp_Object ct, ptrdiff_t idx)
  2122 {
  2123   for (struct Lisp_Char_Table *tbl = XCHAR_TABLE (ct); ;
  2124        tbl = XCHAR_TABLE (tbl->parent))
  2125     {
  2126       Lisp_Object val = (SUB_CHAR_TABLE_P (tbl->ascii)
  2127                          ? XSUB_CHAR_TABLE (tbl->ascii)->contents[idx]
  2128                          : tbl->ascii);
  2129       if (NILP (val))
  2130         val = tbl->defalt;
  2131       if (!NILP (val) || NILP (tbl->parent))
  2132         return val;
  2133     }
  2134 }
  2135 
  2136 /* Almost equivalent to Faref (CT, IDX) with optimization for ASCII
  2137    characters.  Does not check validity of CT.  */
  2138 INLINE Lisp_Object
  2139 CHAR_TABLE_REF (Lisp_Object ct, int idx)
  2140 {
  2141   return (ASCII_CHAR_P (idx)
  2142           ? CHAR_TABLE_REF_ASCII (ct, idx)
  2143           : char_table_ref (ct, idx));
  2144 }
  2145 
  2146 /* Equivalent to Faset (CT, IDX, VAL) with optimization for ASCII and
  2147    8-bit European characters.  Does not check validity of CT.  */
  2148 INLINE void
  2149 CHAR_TABLE_SET (Lisp_Object ct, int idx, Lisp_Object val)
  2150 {
  2151   if (ASCII_CHAR_P (idx) && SUB_CHAR_TABLE_P (XCHAR_TABLE (ct)->ascii))
  2152     set_sub_char_table_contents (XCHAR_TABLE (ct)->ascii, idx, val);
  2153   else
  2154     char_table_set (ct, idx, val);
  2155 }
  2156 
  2157 #include "comp.h"
  2158 
  2159 /* This structure describes a built-in function.
  2160    It is generated by the DEFUN macro only.
  2161    defsubr makes it into a Lisp object.  */
  2162 
  2163 struct Lisp_Subr
  2164   {
  2165     union vectorlike_header header;
  2166     union {
  2167       Lisp_Object (*a0) (void);
  2168       Lisp_Object (*a1) (Lisp_Object);
  2169       Lisp_Object (*a2) (Lisp_Object, Lisp_Object);
  2170       Lisp_Object (*a3) (Lisp_Object, Lisp_Object, Lisp_Object);
  2171       Lisp_Object (*a4) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  2172       Lisp_Object (*a5) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  2173       Lisp_Object (*a6) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  2174       Lisp_Object (*a7) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  2175       Lisp_Object (*a8) (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  2176       Lisp_Object (*aUNEVALLED) (Lisp_Object args);
  2177       Lisp_Object (*aMANY) (ptrdiff_t, Lisp_Object *);
  2178     } function;
  2179     short min_args, max_args;
  2180     const char *symbol_name;
  2181     union {
  2182       const char *string;
  2183       Lisp_Object native;
  2184     } intspec;
  2185     Lisp_Object command_modes;
  2186     EMACS_INT doc;
  2187 #ifdef HAVE_NATIVE_COMP
  2188     Lisp_Object native_comp_u;
  2189     char *native_c_name;
  2190     Lisp_Object lambda_list;
  2191     Lisp_Object type;
  2192 #endif
  2193   } GCALIGNED_STRUCT;
  2194 union Aligned_Lisp_Subr
  2195   {
  2196     struct Lisp_Subr s;
  2197     GCALIGNED_UNION_MEMBER
  2198   };
  2199 verify (GCALIGNED (union Aligned_Lisp_Subr));
  2200 
  2201 INLINE bool
  2202 SUBRP (Lisp_Object a)
  2203 {
  2204   return PSEUDOVECTORP (a, PVEC_SUBR);
  2205 }
  2206 
  2207 INLINE struct Lisp_Subr *
  2208 XSUBR (Lisp_Object a)
  2209 {
  2210   eassert (SUBRP (a));
  2211   return &XUNTAG (a, Lisp_Vectorlike, union Aligned_Lisp_Subr)->s;
  2212 }
  2213 
  2214 /* Return whether a value might be a valid docstring.
  2215    Used to distinguish the presence of non-docstring in the docstring slot,
  2216    as in the case of OClosures.  */
  2217 INLINE bool
  2218 VALID_DOCSTRING_P (Lisp_Object doc)
  2219 {
  2220   return FIXNUMP (doc) || STRINGP (doc)
  2221          || (CONSP (doc) && STRINGP (XCAR (doc)) && FIXNUMP (XCDR (doc)));
  2222 }
  2223 
  2224 enum char_table_specials
  2225   {
  2226     /* This is the number of slots that every char table must have.  This
  2227        counts the ordinary slots and the top, defalt, parent, and purpose
  2228        slots.  */
  2229     CHAR_TABLE_STANDARD_SLOTS
  2230       = (PSEUDOVECSIZE (struct Lisp_Char_Table, contents) - 1
  2231          + (1 << CHARTAB_SIZE_BITS_0)),
  2232 
  2233     /* This is the index of the first Lisp_Object field in Lisp_Sub_Char_Table
  2234        when the latter is treated as an ordinary Lisp_Vector.  */
  2235     SUB_CHAR_TABLE_OFFSET
  2236       = PSEUDOVECSIZE (struct Lisp_Sub_Char_Table, contents) - 1
  2237   };
  2238 
  2239 /* Sanity-check pseudovector layout.  */
  2240 verify (offsetof (struct Lisp_Char_Table, defalt) == header_size);
  2241 verify (offsetof (struct Lisp_Char_Table, extras)
  2242         == header_size + CHAR_TABLE_STANDARD_SLOTS * sizeof (Lisp_Object));
  2243 verify (offsetof (struct Lisp_Sub_Char_Table, contents)
  2244         == header_size + SUB_CHAR_TABLE_OFFSET * sizeof (Lisp_Object));
  2245 
  2246 /* Return the number of "extra" slots in the char table CT.  */
  2247 
  2248 INLINE int
  2249 CHAR_TABLE_EXTRA_SLOTS (struct Lisp_Char_Table *ct)
  2250 {
  2251   return ((ct->header.size & PSEUDOVECTOR_SIZE_MASK)
  2252           - CHAR_TABLE_STANDARD_SLOTS);
  2253 }
  2254 
  2255 
  2256 /* Save and restore the instruction and environment pointers,
  2257    without affecting the signal mask.  */
  2258 
  2259 #ifdef HAVE__SETJMP
  2260 typedef jmp_buf sys_jmp_buf;
  2261 # define sys_setjmp(j) _setjmp (j)
  2262 # define sys_longjmp(j, v) _longjmp (j, v)
  2263 #elif defined HAVE_SIGSETJMP
  2264 typedef sigjmp_buf sys_jmp_buf;
  2265 # define sys_setjmp(j) sigsetjmp (j, 0)
  2266 # define sys_longjmp(j, v) siglongjmp (j, v)
  2267 #else
  2268 /* A platform that uses neither _longjmp nor siglongjmp; assume
  2269    longjmp does not affect the sigmask.  */
  2270 typedef jmp_buf sys_jmp_buf;
  2271 # define sys_setjmp(j) setjmp (j)
  2272 # define sys_longjmp(j, v) longjmp (j, v)
  2273 #endif
  2274 
  2275 #include "thread.h"
  2276 
  2277 /***********************************************************************
  2278                                Symbols
  2279  ***********************************************************************/
  2280 
  2281 /* Value is name of symbol.  */
  2282 
  2283 INLINE Lisp_Object
  2284 (SYMBOL_VAL) (struct Lisp_Symbol *sym)
  2285 {
  2286   return lisp_h_SYMBOL_VAL (sym);
  2287 }
  2288 
  2289 INLINE struct Lisp_Symbol *
  2290 SYMBOL_ALIAS (struct Lisp_Symbol *sym)
  2291 {
  2292   eassume (sym->u.s.redirect == SYMBOL_VARALIAS && sym->u.s.val.alias);
  2293   return sym->u.s.val.alias;
  2294 }
  2295 INLINE struct Lisp_Buffer_Local_Value *
  2296 SYMBOL_BLV (struct Lisp_Symbol *sym)
  2297 {
  2298   eassume (sym->u.s.redirect == SYMBOL_LOCALIZED && sym->u.s.val.blv);
  2299   return sym->u.s.val.blv;
  2300 }
  2301 INLINE lispfwd
  2302 SYMBOL_FWD (struct Lisp_Symbol *sym)
  2303 {
  2304   eassume (sym->u.s.redirect == SYMBOL_FORWARDED && sym->u.s.val.fwd.fwdptr);
  2305   return sym->u.s.val.fwd;
  2306 }
  2307 
  2308 INLINE void
  2309 (SET_SYMBOL_VAL) (struct Lisp_Symbol *sym, Lisp_Object v)
  2310 {
  2311   lisp_h_SET_SYMBOL_VAL (sym, v);
  2312 }
  2313 
  2314 INLINE void
  2315 SET_SYMBOL_ALIAS (struct Lisp_Symbol *sym, struct Lisp_Symbol *v)
  2316 {
  2317   eassume (sym->u.s.redirect == SYMBOL_VARALIAS && v);
  2318   sym->u.s.val.alias = v;
  2319 }
  2320 INLINE void
  2321 SET_SYMBOL_BLV (struct Lisp_Symbol *sym, struct Lisp_Buffer_Local_Value *v)
  2322 {
  2323   eassume (sym->u.s.redirect == SYMBOL_LOCALIZED && v);
  2324   sym->u.s.val.blv = v;
  2325 }
  2326 INLINE void
  2327 SET_SYMBOL_FWD (struct Lisp_Symbol *sym, void const *v)
  2328 {
  2329   eassume (sym->u.s.redirect == SYMBOL_FORWARDED && v);
  2330   sym->u.s.val.fwd.fwdptr = v;
  2331 }
  2332 
  2333 INLINE Lisp_Object
  2334 SYMBOL_NAME (Lisp_Object sym)
  2335 {
  2336   return XSYMBOL (sym)->u.s.name;
  2337 }
  2338 
  2339 /* Value is true if SYM is an interned symbol.  */
  2340 
  2341 INLINE bool
  2342 SYMBOL_INTERNED_P (Lisp_Object sym)
  2343 {
  2344   return XSYMBOL (sym)->u.s.interned != SYMBOL_UNINTERNED;
  2345 }
  2346 
  2347 /* Value is true if SYM is interned in initial_obarray.  */
  2348 
  2349 INLINE bool
  2350 SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P (Lisp_Object sym)
  2351 {
  2352   return XSYMBOL (sym)->u.s.interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY;
  2353 }
  2354 
  2355 /* Value is non-zero if symbol cannot be changed through a simple set,
  2356    i.e. it's a constant (e.g. nil, t, :keywords), or it has some
  2357    watching functions.  */
  2358 
  2359 INLINE int
  2360 (SYMBOL_TRAPPED_WRITE_P) (Lisp_Object sym)
  2361 {
  2362   return lisp_h_SYMBOL_TRAPPED_WRITE_P (sym);
  2363 }
  2364 
  2365 /* Value is non-zero if symbol cannot be changed at all, i.e. it's a
  2366    constant (e.g. nil, t, :keywords).  Code that actually wants to
  2367    write to SYM, should also check whether there are any watching
  2368    functions.  */
  2369 
  2370 INLINE int
  2371 (SYMBOL_CONSTANT_P) (Lisp_Object sym)
  2372 {
  2373   return lisp_h_SYMBOL_CONSTANT_P (sym);
  2374 }
  2375 
  2376 /* Placeholder for make-docfile to process.  The actual symbol
  2377    definition is done by lread.c's define_symbol.  */
  2378 #define DEFSYM(sym, name) /* empty */
  2379 
  2380 
  2381 /***********************************************************************
  2382                              Hash Tables
  2383  ***********************************************************************/
  2384 
  2385 /* The structure of a Lisp hash table.  */
  2386 
  2387 struct Lisp_Hash_Table;
  2388 
  2389 struct hash_table_test
  2390 {
  2391   /* Name of the function used to compare keys.  */
  2392   Lisp_Object name;
  2393 
  2394   /* User-supplied hash function, or nil.  */
  2395   Lisp_Object user_hash_function;
  2396 
  2397   /* User-supplied key comparison function, or nil.  */
  2398   Lisp_Object user_cmp_function;
  2399 
  2400   /* C function to compare two keys.  */
  2401   Lisp_Object (*cmpfn) (Lisp_Object, Lisp_Object, struct Lisp_Hash_Table *);
  2402 
  2403   /* C function to compute hash code.  */
  2404   Lisp_Object (*hashfn) (Lisp_Object, struct Lisp_Hash_Table *);
  2405 };
  2406 
  2407 struct Lisp_Hash_Table
  2408 {
  2409   /* Change pdumper.c if you change the fields here.  */
  2410 
  2411   /* This is for Lisp; the hash table code does not refer to it.  */
  2412   union vectorlike_header header;
  2413 
  2414   /* Nil if table is non-weak.  Otherwise a symbol describing the
  2415      weakness of the table.  */
  2416   Lisp_Object weak;
  2417 
  2418   /* Vector of hash codes, or nil if the table needs rehashing.
  2419      If the I-th entry is unused, then hash[I] should be nil.  */
  2420   Lisp_Object hash;
  2421 
  2422   /* Vector used to chain entries.  If entry I is free, next[I] is the
  2423      entry number of the next free item.  If entry I is non-free,
  2424      next[I] is the index of the next entry in the collision chain,
  2425      or -1 if there is such entry.  */
  2426   Lisp_Object next;
  2427 
  2428   /* Bucket vector.  An entry of -1 indicates no item is present,
  2429      and a nonnegative entry is the index of the first item in
  2430      a collision chain.  This vector's size can be larger than the
  2431      hash table size to reduce collisions.  */
  2432   Lisp_Object index;
  2433 
  2434   /* Only the fields above are traced normally by the GC.  The ones after
  2435      'index' are special and are either ignored by the GC or traced in
  2436      a special way (e.g. because of weakness).  */
  2437 
  2438   /* Number of key/value entries in the table.  */
  2439   ptrdiff_t count;
  2440 
  2441   /* Index of first free entry in free list, or -1 if none.  */
  2442   ptrdiff_t next_free;
  2443 
  2444   /* True if the table can be purecopied.  The table cannot be
  2445      changed afterwards.  */
  2446   bool purecopy;
  2447 
  2448   /* True if the table is mutable.  Ordinarily tables are mutable, but
  2449      pure tables are not, and while a table is being mutated it is
  2450      immutable for recursive attempts to mutate it.  */
  2451   bool mutable;
  2452 
  2453   /* Resize hash table when number of entries / table size is >= this
  2454      ratio.  */
  2455   float rehash_threshold;
  2456 
  2457   /* Used when the table is resized.  If equal to a negative integer,
  2458      the user rehash-size is the integer -REHASH_SIZE, and the new
  2459      size is the old size plus -REHASH_SIZE.  If positive, the user
  2460      rehash-size is the floating-point value REHASH_SIZE + 1, and the
  2461      new size is the old size times REHASH_SIZE + 1.  */
  2462   float rehash_size;
  2463 
  2464   /* Vector of keys and values.  The key of item I is found at index
  2465      2 * I, the value is found at index 2 * I + 1.
  2466      If the key is equal to Qunbound, then this slot is unused.
  2467      This is gc_marked specially if the table is weak.  */
  2468   Lisp_Object key_and_value;
  2469 
  2470   /* The comparison and hash functions.  */
  2471   struct hash_table_test test;
  2472 
  2473   /* Next weak hash table if this is a weak hash table.  The head of
  2474      the list is in weak_hash_tables.  Used only during garbage
  2475      collection --- at other times, it is NULL.  */
  2476   struct Lisp_Hash_Table *next_weak;
  2477 } GCALIGNED_STRUCT;
  2478 
  2479 /* Sanity-check pseudovector layout.  */
  2480 verify (offsetof (struct Lisp_Hash_Table, weak) == header_size);
  2481 
  2482 INLINE bool
  2483 HASH_TABLE_P (Lisp_Object a)
  2484 {
  2485   return PSEUDOVECTORP (a, PVEC_HASH_TABLE);
  2486 }
  2487 
  2488 INLINE struct Lisp_Hash_Table *
  2489 XHASH_TABLE (Lisp_Object a)
  2490 {
  2491   eassert (HASH_TABLE_P (a));
  2492   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Hash_Table);
  2493 }
  2494 
  2495 #define XSET_HASH_TABLE(VAR, PTR) \
  2496      (XSETPSEUDOVECTOR (VAR, PTR, PVEC_HASH_TABLE))
  2497 
  2498 /* Value is the key part of entry IDX in hash table H.  */
  2499 INLINE Lisp_Object
  2500 HASH_KEY (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
  2501 {
  2502   return AREF (h->key_and_value, 2 * idx);
  2503 }
  2504 
  2505 /* Value is the value part of entry IDX in hash table H.  */
  2506 INLINE Lisp_Object
  2507 HASH_VALUE (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
  2508 {
  2509   return AREF (h->key_and_value, 2 * idx + 1);
  2510 }
  2511 
  2512 /* Value is the hash code computed for entry IDX in hash table H.  */
  2513 INLINE Lisp_Object
  2514 HASH_HASH (const struct Lisp_Hash_Table *h, ptrdiff_t idx)
  2515 {
  2516   return AREF (h->hash, idx);
  2517 }
  2518 
  2519 /* Value is the size of hash table H.  */
  2520 INLINE ptrdiff_t
  2521 HASH_TABLE_SIZE (const struct Lisp_Hash_Table *h)
  2522 {
  2523   ptrdiff_t size = ASIZE (h->next);
  2524   eassume (0 < size);
  2525   return size;
  2526 }
  2527 
  2528 void hash_table_rehash (Lisp_Object);
  2529 
  2530 /* Default size for hash tables if not specified.  */
  2531 
  2532 enum DEFAULT_HASH_SIZE { DEFAULT_HASH_SIZE = 65 };
  2533 
  2534 /* Default threshold specifying when to resize a hash table.  The
  2535    value gives the ratio of current entries in the hash table and the
  2536    size of the hash table.  */
  2537 
  2538 static float const DEFAULT_REHASH_THRESHOLD = 0.8125;
  2539 
  2540 /* Default factor by which to increase the size of a hash table, minus 1.  */
  2541 
  2542 static float const DEFAULT_REHASH_SIZE = 1.5 - 1;
  2543 
  2544 /* Combine two integers X and Y for hashing.  The result might exceed
  2545    INTMASK.  */
  2546 
  2547 INLINE EMACS_UINT
  2548 sxhash_combine (EMACS_UINT x, EMACS_UINT y)
  2549 {
  2550   return (x << 4) + (x >> (EMACS_INT_WIDTH - 4)) + y;
  2551 }
  2552 
  2553 /* Hash X, returning a value in the range 0..INTMASK.  */
  2554 
  2555 INLINE EMACS_UINT
  2556 SXHASH_REDUCE (EMACS_UINT x)
  2557 {
  2558   return (x ^ x >> (EMACS_INT_WIDTH - FIXNUM_BITS)) & INTMASK;
  2559 }
  2560 
  2561 struct Lisp_Marker
  2562 {
  2563   union vectorlike_header header;
  2564 
  2565   /* This is the buffer that the marker points into, or 0 if it points nowhere.
  2566      Note: a chain of markers can contain markers pointing into different
  2567      buffers (the chain is per buffer_text rather than per buffer, so it's
  2568      shared between indirect buffers).  */
  2569   /* This is used for (other than NULL-checking):
  2570      - Fmarker_buffer
  2571      - Fset_marker: check eq(oldbuf, newbuf) to avoid unchain+rechain.
  2572      - unchain_marker: to find the list from which to unchain.
  2573      - Fkill_buffer: to only unchain the markers of current indirect buffer.
  2574      */
  2575   struct buffer *buffer;
  2576 
  2577   /* This flag is temporarily used in the functions
  2578      decode/encode_coding_object to record that the marker position
  2579      must be adjusted after the conversion.  */
  2580   bool_bf need_adjustment : 1;
  2581   /* True means normal insertion at the marker's position
  2582      leaves the marker after the inserted text.  */
  2583   bool_bf insertion_type : 1;
  2584 
  2585   /* The remaining fields are meaningless in a marker that
  2586      does not point anywhere.  */
  2587 
  2588   /* For markers that point somewhere,
  2589      this is used to chain of all the markers in a given buffer.
  2590      The chain does not preserve markers from garbage collection;
  2591      instead, markers are removed from the chain when freed by GC.  */
  2592   /* We could remove it and use an array in buffer_text instead.
  2593      That would also allow us to preserve it ordered.  */
  2594   struct Lisp_Marker *next;
  2595   /* This is the char position where the marker points.  */
  2596   ptrdiff_t charpos;
  2597   /* This is the byte position.
  2598      It's mostly used as a charpos<->bytepos cache (i.e. it's not directly
  2599      used to implement the functionality of markers, but rather to (ab)use
  2600      markers as a cache for char<->byte mappings).  */
  2601   ptrdiff_t bytepos;
  2602 } GCALIGNED_STRUCT;
  2603 
  2604 struct Lisp_Overlay
  2605 /* An overlay's real data content is:
  2606    - plist
  2607    - buffer
  2608    - itree node
  2609    - start buffer position (field of the itree node)
  2610    - end buffer position (field of the itree node)
  2611    - insertion types of both ends (fields of the itree node).  */
  2612   {
  2613     union vectorlike_header header;
  2614     Lisp_Object plist;
  2615     struct buffer *buffer;        /* eassert (live buffer || NULL). */
  2616     struct itree_node *interval;
  2617   } GCALIGNED_STRUCT;
  2618 
  2619 struct Lisp_Misc_Ptr
  2620   {
  2621     union vectorlike_header header;
  2622     void *pointer;
  2623   } GCALIGNED_STRUCT;
  2624 
  2625 extern Lisp_Object make_misc_ptr (void *);
  2626 
  2627 /* A mint_ptr object OBJ represents a C-language pointer P efficiently.
  2628    Preferably (and typically), OBJ is a fixnum I such that
  2629    XFIXNUMPTR (I) == P, as this represents P within a single Lisp value
  2630    without requiring any auxiliary memory.  However, if P would be
  2631    damaged by being tagged as an integer and then untagged via
  2632    XFIXNUMPTR, then OBJ is a Lisp_Misc_Ptr with pointer component P.
  2633 
  2634    mint_ptr objects are efficiency hacks intended for C code.
  2635    Although xmint_ptr can be given any mint_ptr generated by non-buggy
  2636    C code, it should not be given a mint_ptr generated from Lisp code
  2637    as that would allow Lisp code to coin pointers from integers and
  2638    could lead to crashes.  To package a C pointer into a Lisp-visible
  2639    object you can put the pointer into a pseudovector instead; see
  2640    Lisp_User_Ptr for an example.  */
  2641 
  2642 INLINE Lisp_Object
  2643 make_mint_ptr (void *a)
  2644 {
  2645   Lisp_Object val = TAG_PTR (Lisp_Int0, a);
  2646   return FIXNUMP (val) && XFIXNUMPTR (val) == a ? val : make_misc_ptr (a);
  2647 }
  2648 
  2649 INLINE bool
  2650 mint_ptrp (Lisp_Object x)
  2651 {
  2652   return FIXNUMP (x) || PSEUDOVECTORP (x, PVEC_MISC_PTR);
  2653 }
  2654 
  2655 INLINE void *
  2656 xmint_pointer (Lisp_Object a)
  2657 {
  2658   eassert (mint_ptrp (a));
  2659   if (FIXNUMP (a))
  2660     return XFIXNUMPTR (a);
  2661   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Misc_Ptr)->pointer;
  2662 }
  2663 
  2664 struct Lisp_Sqlite
  2665 {
  2666   union vectorlike_header header;
  2667   void *db;
  2668   void *stmt;
  2669   char *name;
  2670   void (*finalizer) (void *);
  2671   bool eof;
  2672   bool is_statement;
  2673 } GCALIGNED_STRUCT;
  2674 
  2675 struct Lisp_User_Ptr
  2676 {
  2677   union vectorlike_header header;
  2678   void (*finalizer) (void *);
  2679   void *p;
  2680 } GCALIGNED_STRUCT;
  2681 
  2682 /* A finalizer sentinel.  */
  2683 struct Lisp_Finalizer
  2684   {
  2685     union vectorlike_header header;
  2686 
  2687     /* Call FUNCTION when the finalizer becomes unreachable, even if
  2688        FUNCTION contains a reference to the finalizer; i.e., call
  2689        FUNCTION when it is reachable _only_ through finalizers.  */
  2690     Lisp_Object function;
  2691 
  2692     /* Circular list of all active weak references.  */
  2693     struct Lisp_Finalizer *prev;
  2694     struct Lisp_Finalizer *next;
  2695   } GCALIGNED_STRUCT;
  2696 
  2697 extern struct Lisp_Finalizer finalizers;
  2698 extern struct Lisp_Finalizer doomed_finalizers;
  2699 
  2700 INLINE bool
  2701 FINALIZERP (Lisp_Object x)
  2702 {
  2703   return PSEUDOVECTORP (x, PVEC_FINALIZER);
  2704 }
  2705 
  2706 INLINE struct Lisp_Finalizer *
  2707 XFINALIZER (Lisp_Object a)
  2708 {
  2709   eassert (FINALIZERP (a));
  2710   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Finalizer);
  2711 }
  2712 
  2713 INLINE bool
  2714 MARKERP (Lisp_Object x)
  2715 {
  2716   return PSEUDOVECTORP (x, PVEC_MARKER);
  2717 }
  2718 
  2719 INLINE struct Lisp_Marker *
  2720 XMARKER (Lisp_Object a)
  2721 {
  2722   eassert (MARKERP (a));
  2723   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Marker);
  2724 }
  2725 
  2726 INLINE bool
  2727 OVERLAYP (Lisp_Object x)
  2728 {
  2729   return PSEUDOVECTORP (x, PVEC_OVERLAY);
  2730 }
  2731 
  2732 INLINE struct Lisp_Overlay *
  2733 XOVERLAY (Lisp_Object a)
  2734 {
  2735   eassert (OVERLAYP (a));
  2736   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Overlay);
  2737 }
  2738 
  2739 INLINE Lisp_Object
  2740 SYMBOL_WITH_POS_SYM (Lisp_Object a)
  2741 {
  2742   if (!SYMBOL_WITH_POS_P (a))
  2743     wrong_type_argument (Qsymbol_with_pos_p, a);
  2744   return XSYMBOL_WITH_POS (a)->sym;
  2745 }
  2746 
  2747 INLINE Lisp_Object
  2748 SYMBOL_WITH_POS_POS (Lisp_Object a)
  2749 {
  2750   if (!SYMBOL_WITH_POS_P (a))
  2751     wrong_type_argument (Qsymbol_with_pos_p, a);
  2752   return XSYMBOL_WITH_POS (a)->pos;
  2753 }
  2754 
  2755 INLINE bool
  2756 USER_PTRP (Lisp_Object x)
  2757 {
  2758   return PSEUDOVECTORP (x, PVEC_USER_PTR);
  2759 }
  2760 
  2761 INLINE struct Lisp_User_Ptr *
  2762 XUSER_PTR (Lisp_Object a)
  2763 {
  2764   eassert (USER_PTRP (a));
  2765   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_User_Ptr);
  2766 }
  2767 
  2768 INLINE bool
  2769 SQLITEP (Lisp_Object x)
  2770 {
  2771   return PSEUDOVECTORP (x, PVEC_SQLITE);
  2772 }
  2773 
  2774 INLINE bool
  2775 SQLITE (Lisp_Object a)
  2776 {
  2777   return PSEUDOVECTORP (a, PVEC_SQLITE);
  2778 }
  2779 
  2780 INLINE void
  2781 CHECK_SQLITE (Lisp_Object x)
  2782 {
  2783   CHECK_TYPE (SQLITE (x), Qsqlitep, x);
  2784 }
  2785 
  2786 INLINE struct Lisp_Sqlite *
  2787 XSQLITE (Lisp_Object a)
  2788 {
  2789   eassert (SQLITEP (a));
  2790   return XUNTAG (a, Lisp_Vectorlike, struct Lisp_Sqlite);
  2791 }
  2792 
  2793 INLINE bool
  2794 BIGNUMP (Lisp_Object x)
  2795 {
  2796   return PSEUDOVECTORP (x, PVEC_BIGNUM);
  2797 }
  2798 
  2799 INLINE bool
  2800 INTEGERP (Lisp_Object x)
  2801 {
  2802   return FIXNUMP (x) || BIGNUMP (x);
  2803 }
  2804 
  2805 /* Return a Lisp integer with value taken from N.  */
  2806 INLINE Lisp_Object
  2807 make_int (intmax_t n)
  2808 {
  2809   return FIXNUM_OVERFLOW_P (n) ? make_bigint (n) : make_fixnum (n);
  2810 }
  2811 INLINE Lisp_Object
  2812 make_uint (uintmax_t n)
  2813 {
  2814   return FIXNUM_OVERFLOW_P (n) ? make_biguint (n) : make_fixnum (n);
  2815 }
  2816 
  2817 /* Return a Lisp integer equal to the value of the C integer EXPR.  */
  2818 #define INT_TO_INTEGER(expr) \
  2819   (EXPR_SIGNED (expr) ? make_int (expr) : make_uint (expr))
  2820 
  2821 
  2822 /* Forwarding pointer to an int variable.
  2823    This is allowed only in the value cell of a symbol,
  2824    and it means that the symbol's value really lives in the
  2825    specified int variable.  */
  2826 struct Lisp_Intfwd
  2827   {
  2828     enum Lisp_Fwd_Type type;    /* = Lisp_Fwd_Int */
  2829     intmax_t *intvar;
  2830   };
  2831 
  2832 /* Boolean forwarding pointer to an int variable.
  2833    This is like Lisp_Intfwd except that the ostensible
  2834    "value" of the symbol is t if the bool variable is true,
  2835    nil if it is false.  */
  2836 struct Lisp_Boolfwd
  2837   {
  2838     enum Lisp_Fwd_Type type;    /* = Lisp_Fwd_Bool */
  2839     bool *boolvar;
  2840   };
  2841 
  2842 /* Forwarding pointer to a Lisp_Object variable.
  2843    This is allowed only in the value cell of a symbol,
  2844    and it means that the symbol's value really lives in the
  2845    specified variable.  */
  2846 struct Lisp_Objfwd
  2847   {
  2848     enum Lisp_Fwd_Type type;    /* = Lisp_Fwd_Obj */
  2849     Lisp_Object *objvar;
  2850   };
  2851 
  2852 /* Like Lisp_Objfwd except that value lives in a slot in the
  2853    current buffer.  Value is byte index of slot within buffer.  */
  2854 struct Lisp_Buffer_Objfwd
  2855   {
  2856     enum Lisp_Fwd_Type type;    /* = Lisp_Fwd_Buffer_Obj */
  2857     int offset;
  2858     /* One of Qnil, Qintegerp, Qsymbolp, Qstringp, Qfloatp or Qnumberp.  */
  2859     Lisp_Object predicate;
  2860   };
  2861 
  2862 /* struct Lisp_Buffer_Local_Value is used in a symbol value cell when
  2863    the symbol has buffer-local bindings.  (Exception:
  2864    some buffer-local variables are built-in, with their values stored
  2865    in the buffer structure itself.  They are handled differently,
  2866    using struct Lisp_Buffer_Objfwd.)
  2867 
  2868    The `valcell' slot holds the variable's current value (unless `fwd'
  2869    is set).  This value is the one that corresponds to the loaded binding.
  2870    To read or set the variable, you must first make sure the right binding
  2871    is loaded; then you can access the value in (or through) `valcell'.
  2872 
  2873    `where' is the buffer for which the loaded binding was found.
  2874    If it has changed, to make sure the right binding is loaded it is
  2875    necessary to find which binding goes with the current buffer, then
  2876    load it.  To load it, first unload the previous binding.
  2877 
  2878    `local_if_set' indicates that merely setting the variable creates a
  2879    local binding for the current buffer.  Otherwise the latter, setting
  2880    the variable does not do that; only make-local-variable does that.  */
  2881 
  2882 struct Lisp_Buffer_Local_Value
  2883   {
  2884     /* True means that merely setting the variable creates a local
  2885        binding for the current buffer.  */
  2886     bool_bf local_if_set : 1;
  2887     /* True means that the binding now loaded was found.
  2888        Presumably equivalent to (defcell!=valcell).  */
  2889     bool_bf found : 1;
  2890     /* If non-NULL, a forwarding to the C var where it should also be set.  */
  2891     lispfwd fwd;        /* Should never be (Buffer|Kboard)_Objfwd.  */
  2892     /* The buffer for which the loaded binding was found.  */
  2893     Lisp_Object where;
  2894     /* A cons cell that holds the default value.  It has the form
  2895        (SYMBOL . DEFAULT-VALUE).  */
  2896     Lisp_Object defcell;
  2897     /* The cons cell from `where's parameter alist.
  2898        It always has the form (SYMBOL . VALUE)
  2899        Note that if `fwd' is non-NULL, VALUE may be out of date.
  2900        Also if the currently loaded binding is the default binding, then
  2901        this is `eq'ual to defcell.  */
  2902     Lisp_Object valcell;
  2903   };
  2904 
  2905 /* Like Lisp_Objfwd except that value lives in a slot in the
  2906    current kboard.  */
  2907 struct Lisp_Kboard_Objfwd
  2908   {
  2909     enum Lisp_Fwd_Type type;    /* = Lisp_Fwd_Kboard_Obj */
  2910     int offset;
  2911   };
  2912 
  2913 INLINE enum Lisp_Fwd_Type
  2914 XFWDTYPE (lispfwd a)
  2915 {
  2916   enum Lisp_Fwd_Type const *p = a.fwdptr;
  2917   return *p;
  2918 }
  2919 
  2920 INLINE bool
  2921 BUFFER_OBJFWDP (lispfwd a)
  2922 {
  2923   return XFWDTYPE (a) == Lisp_Fwd_Buffer_Obj;
  2924 }
  2925 
  2926 INLINE struct Lisp_Buffer_Objfwd const *
  2927 XBUFFER_OBJFWD (lispfwd a)
  2928 {
  2929   eassert (BUFFER_OBJFWDP (a));
  2930   return a.fwdptr;
  2931 }
  2932 
  2933 /* Lisp floating point type.  */
  2934 struct Lisp_Float
  2935   {
  2936     union
  2937     {
  2938       double data;
  2939       struct Lisp_Float *chain;
  2940       GCALIGNED_UNION_MEMBER
  2941     } u;
  2942   };
  2943 verify (GCALIGNED (struct Lisp_Float));
  2944 
  2945 INLINE bool
  2946 (FLOATP) (Lisp_Object x)
  2947 {
  2948   return lisp_h_FLOATP (x);
  2949 }
  2950 
  2951 INLINE struct Lisp_Float *
  2952 XFLOAT (Lisp_Object a)
  2953 {
  2954   eassert (FLOATP (a));
  2955   return XUNTAG (a, Lisp_Float, struct Lisp_Float);
  2956 }
  2957 
  2958 INLINE double
  2959 XFLOAT_DATA (Lisp_Object f)
  2960 {
  2961   return XFLOAT (f)->u.data;
  2962 }
  2963 
  2964 /* Most hosts nowadays use IEEE floating point, so they use IEC 60559
  2965    representations, have infinities and NaNs, and do not trap on
  2966    exceptions.  Define IEEE_FLOATING_POINT to 1 if this host is one of the
  2967    typical ones.  The C11 macro __STDC_IEC_559__ is close to what is
  2968    wanted here, but is not quite right because Emacs does not require
  2969    all the features of C11 Annex F (and does not require C11 at all,
  2970    for that matter).  */
  2971 
  2972 #define IEEE_FLOATING_POINT (FLT_RADIX == 2 && FLT_MANT_DIG == 24 \
  2973                              && FLT_MIN_EXP == -125 && FLT_MAX_EXP == 128)
  2974 
  2975 /* Meanings of slots in a Lisp_Compiled:  */
  2976 
  2977 enum Lisp_Compiled
  2978   {
  2979     COMPILED_ARGLIST = 0,
  2980     COMPILED_BYTECODE = 1,
  2981     COMPILED_CONSTANTS = 2,
  2982     COMPILED_STACK_DEPTH = 3,
  2983     COMPILED_DOC_STRING = 4,
  2984     COMPILED_INTERACTIVE = 5
  2985   };
  2986 
  2987 /* Flag bits in a character.  These also get used in termhooks.h.
  2988    Emacs needs 22 bits for the character value itself, see MAX_CHAR,
  2989    so we shouldn't use any bits lower than 0x0400000.  */
  2990 enum char_bits
  2991   {
  2992     CHAR_ALT = 0x0400000,
  2993     CHAR_SUPER = 0x0800000,
  2994     CHAR_HYPER = 0x1000000,
  2995     CHAR_SHIFT = 0x2000000,
  2996     CHAR_CTL = 0x4000000,
  2997     CHAR_META = 0x8000000,
  2998 
  2999     CHAR_MODIFIER_MASK =
  3000       CHAR_ALT | CHAR_SUPER | CHAR_HYPER | CHAR_SHIFT | CHAR_CTL | CHAR_META,
  3001 
  3002     /* Actually, the current Emacs uses 22 bits for the character value
  3003        itself.  */
  3004     CHARACTERBITS = 22
  3005   };
  3006 
  3007 /* Data type checking.  */
  3008 
  3009 INLINE bool
  3010 FIXNATP (Lisp_Object x)
  3011 {
  3012   return FIXNUMP (x) && 0 <= XFIXNUM (x);
  3013 }
  3014 
  3015 /* Like XFIXNUM (A), but may be faster.  A must be nonnegative.  */
  3016 INLINE EMACS_INT
  3017 XFIXNAT (Lisp_Object a)
  3018 {
  3019   eassert (FIXNUMP (a));
  3020   EMACS_INT int0 = Lisp_Int0;
  3021   EMACS_INT result = USE_LSB_TAG ? XFIXNUM (a) : XLI (a) - (int0 << VALBITS);
  3022   eassume (0 <= result);
  3023   return result;
  3024 }
  3025 
  3026 INLINE bool
  3027 NUMBERP (Lisp_Object x)
  3028 {
  3029   return INTEGERP (x) || FLOATP (x);
  3030 }
  3031 
  3032 INLINE bool
  3033 RANGED_FIXNUMP (intmax_t lo, Lisp_Object x, intmax_t hi)
  3034 {
  3035   return FIXNUMP (x) && lo <= XFIXNUM (x) && XFIXNUM (x) <= hi;
  3036 }
  3037 
  3038 #define TYPE_RANGED_FIXNUMP(type, x) \
  3039   (FIXNUMP (x)                        \
  3040    && (TYPE_SIGNED (type) ? TYPE_MINIMUM (type) <= XFIXNUM (x) : 0 <= XFIXNUM (x)) \
  3041    && XFIXNUM (x) <= TYPE_MAXIMUM (type))
  3042 
  3043 INLINE bool
  3044 AUTOLOADP (Lisp_Object x)
  3045 {
  3046   return CONSP (x) && EQ (Qautoload, XCAR (x));
  3047 }
  3048 
  3049 
  3050 /* Test for specific pseudovector types.  */
  3051 
  3052 INLINE bool
  3053 WINDOW_CONFIGURATIONP (Lisp_Object a)
  3054 {
  3055   return PSEUDOVECTORP (a, PVEC_WINDOW_CONFIGURATION);
  3056 }
  3057 
  3058 INLINE bool
  3059 COMPILEDP (Lisp_Object a)
  3060 {
  3061   return PSEUDOVECTORP (a, PVEC_COMPILED);
  3062 }
  3063 
  3064 INLINE bool
  3065 FRAMEP (Lisp_Object a)
  3066 {
  3067   return PSEUDOVECTORP (a, PVEC_FRAME);
  3068 }
  3069 
  3070 INLINE bool
  3071 RECORDP (Lisp_Object a)
  3072 {
  3073   return PSEUDOVECTORP (a, PVEC_RECORD);
  3074 }
  3075 
  3076 INLINE void
  3077 CHECK_RECORD (Lisp_Object x)
  3078 {
  3079   CHECK_TYPE (RECORDP (x), Qrecordp, x);
  3080 }
  3081 
  3082 /* Test for image (image . spec)  */
  3083 INLINE bool
  3084 IMAGEP (Lisp_Object x)
  3085 {
  3086   return CONSP (x) && EQ (XCAR (x), Qimage);
  3087 }
  3088 
  3089 /* Array types.  */
  3090 INLINE bool
  3091 ARRAYP (Lisp_Object x)
  3092 {
  3093   return VECTORP (x) || STRINGP (x) || CHAR_TABLE_P (x) || BOOL_VECTOR_P (x);
  3094 }
  3095 
  3096 INLINE void
  3097 CHECK_LIST (Lisp_Object x)
  3098 {
  3099   CHECK_TYPE (CONSP (x) || NILP (x), Qlistp, x);
  3100 }
  3101 
  3102 INLINE void
  3103 CHECK_LIST_END (Lisp_Object x, Lisp_Object y)
  3104 {
  3105   CHECK_TYPE (NILP (x), Qlistp, y);
  3106 }
  3107 
  3108 INLINE void
  3109 (CHECK_FIXNUM) (Lisp_Object x)
  3110 {
  3111   lisp_h_CHECK_FIXNUM (x);
  3112 }
  3113 
  3114 INLINE void
  3115 CHECK_STRING_CAR (Lisp_Object x)
  3116 {
  3117   CHECK_TYPE (STRINGP (XCAR (x)), Qstringp, XCAR (x));
  3118 }
  3119 /* This is a bit special because we always need size afterwards.  */
  3120 INLINE ptrdiff_t
  3121 CHECK_VECTOR_OR_STRING (Lisp_Object x)
  3122 {
  3123   if (VECTORP (x))
  3124     return ASIZE (x);
  3125   if (STRINGP (x))
  3126     return SCHARS (x);
  3127   wrong_type_argument (Qarrayp, x);
  3128 }
  3129 INLINE void
  3130 CHECK_ARRAY (Lisp_Object x, Lisp_Object predicate)
  3131 {
  3132   CHECK_TYPE (ARRAYP (x), predicate, x);
  3133 }
  3134 INLINE void
  3135 CHECK_FIXNAT (Lisp_Object x)
  3136 {
  3137   CHECK_TYPE (FIXNATP (x), Qwholenump, x);
  3138 }
  3139 
  3140 INLINE double
  3141 XFLOATINT (Lisp_Object n)
  3142 {
  3143   return (FIXNUMP (n) ? XFIXNUM (n)
  3144           : FLOATP (n) ? XFLOAT_DATA (n)
  3145           : bignum_to_double (n));
  3146 }
  3147 
  3148 INLINE void
  3149 CHECK_NUMBER (Lisp_Object x)
  3150 {
  3151   CHECK_TYPE (NUMBERP (x), Qnumberp, x);
  3152 }
  3153 
  3154 INLINE void
  3155 CHECK_INTEGER (Lisp_Object x)
  3156 {
  3157   CHECK_TYPE (INTEGERP (x), Qintegerp, x);
  3158 }
  3159 
  3160 INLINE void
  3161 CHECK_SUBR (Lisp_Object x)
  3162 {
  3163   CHECK_TYPE (SUBRP (x), Qsubrp, x);
  3164 }
  3165 
  3166 
  3167 /* If we're not dumping using the legacy dumper and we might be using
  3168    the portable dumper, try to bunch all the subr structures together
  3169    for more efficient dump loading.  */
  3170 #ifndef HAVE_UNEXEC
  3171 # ifdef DARWIN_OS
  3172 #  define SUBR_SECTION_ATTRIBUTE ATTRIBUTE_SECTION ("__DATA,subrs")
  3173 # else
  3174 #  define SUBR_SECTION_ATTRIBUTE ATTRIBUTE_SECTION (".subrs")
  3175 # endif
  3176 #else
  3177 # define SUBR_SECTION_ATTRIBUTE
  3178 #endif
  3179 
  3180 /* Define a built-in function for calling from Lisp.
  3181  `lname' should be the name to give the function in Lisp,
  3182     as a null-terminated C string.
  3183  `fnname' should be the name of the function in C.
  3184     By convention, it starts with F.
  3185  `sname' should be the name for the C constant structure
  3186     that records information on this function for internal use.
  3187     By convention, it should be the same as `fnname' but with S instead of F.
  3188     It's too bad that C macros can't compute this from `fnname'.
  3189  `minargs' should be a number, the minimum number of arguments allowed.
  3190  `maxargs' should be a number, the maximum number of arguments allowed,
  3191     or else MANY or UNEVALLED.
  3192     MANY means there are &rest arguments.  Here we pass a vector
  3193         of evaluated arguments in the form of an integer
  3194         number-of-arguments followed by the address of a vector of
  3195         Lisp_Objects which contains the argument values.  (We also use
  3196         this convention when calling a subr with more than 8 parameters.)
  3197     UNEVALLED means pass the list of unevaluated arguments
  3198  `intspec' says how interactive arguments are to be fetched.
  3199     If the string starts with a `(', `intspec' is evaluated and the resulting
  3200     list is the list of arguments.
  3201     If it's a string that doesn't start with `(', the value should follow
  3202     the one of the doc string for `interactive'.
  3203     A null string means call interactively with no arguments.
  3204  `doc' is documentation for the user.  */
  3205 
  3206 /* This version of DEFUN declares a function prototype with the right
  3207    arguments, so we can catch errors with maxargs at compile-time.  */
  3208 #define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
  3209   SUBR_SECTION_ATTRIBUTE                                            \
  3210   static union Aligned_Lisp_Subr sname =                            \
  3211      {{{ PVEC_SUBR << PSEUDOVECTOR_AREA_BITS },                     \
  3212        { .a ## maxargs = fnname },                                  \
  3213        minargs, maxargs, lname, {intspec}, lisp_h_Qnil}};           \
  3214    Lisp_Object fnname
  3215 
  3216 /* defsubr (Sname);
  3217    is how we define the symbol for function `name' at start-up time.  */
  3218 extern void defsubr (union Aligned_Lisp_Subr *);
  3219 
  3220 enum maxargs
  3221   {
  3222     MANY = -2,
  3223     UNEVALLED = -1
  3224   };
  3225 
  3226 /* Call a function F that accepts many args, passing it ARRAY's elements.  */
  3227 #define CALLMANY(f, array) (f) (ARRAYELTS (array), array)
  3228 
  3229 /* Call a function F that accepts many args, passing it the remaining args,
  3230    E.g., 'return CALLN (Fformat, fmt, text);' is less error-prone than
  3231    '{ Lisp_Object a[2]; a[0] = fmt; a[1] = text; return Fformat (2, a); }'.
  3232    CALLN requires at least one function argument (as C99 prohibits
  3233    empty initializers), and is overkill for simple usages like
  3234    'Finsert (1, &text);'.  */
  3235 #define CALLN(f, ...) CALLMANY (f, ((Lisp_Object []) {__VA_ARGS__}))
  3236 
  3237 /* Call function fn on no arguments.  */
  3238 INLINE Lisp_Object
  3239 call0 (Lisp_Object fn)
  3240 {
  3241   return Ffuncall (1, &fn);
  3242 }
  3243 
  3244 /* Call function fn with 1 argument arg1.  */
  3245 INLINE Lisp_Object
  3246 call1 (Lisp_Object fn, Lisp_Object arg1)
  3247 {
  3248   return CALLN (Ffuncall, fn, arg1);
  3249 }
  3250 
  3251 /* Call function fn with 2 arguments arg1, arg2.  */
  3252 INLINE Lisp_Object
  3253 call2 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2)
  3254 {
  3255   return CALLN (Ffuncall, fn, arg1, arg2);
  3256 }
  3257 
  3258 /* Call function fn with 3 arguments arg1, arg2, arg3.  */
  3259 INLINE Lisp_Object
  3260 call3 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3)
  3261 {
  3262   return CALLN (Ffuncall, fn, arg1, arg2, arg3);
  3263 }
  3264 
  3265 /* Call function fn with 4 arguments arg1, arg2, arg3, arg4.  */
  3266 INLINE Lisp_Object
  3267 call4 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
  3268        Lisp_Object arg4)
  3269 {
  3270   return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4);
  3271 }
  3272 
  3273 /* Call function fn with 5 arguments arg1, arg2, arg3, arg4, arg5.  */
  3274 INLINE Lisp_Object
  3275 call5 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
  3276        Lisp_Object arg4, Lisp_Object arg5)
  3277 {
  3278   return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5);
  3279 }
  3280 
  3281 /* Call function fn with 6 arguments arg1, arg2, arg3, arg4, arg5, arg6.  */
  3282 INLINE Lisp_Object
  3283 call6 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
  3284        Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6)
  3285 {
  3286   return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6);
  3287 }
  3288 
  3289 /* Call function fn with 7 arguments arg1, arg2, arg3, arg4, arg5, arg6, arg7.  */
  3290 INLINE Lisp_Object
  3291 call7 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
  3292        Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7)
  3293 {
  3294   return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7);
  3295 }
  3296 
  3297 /* Call function fn with 8 arguments arg1, arg2, arg3, arg4, arg5,
  3298    arg6, arg7, arg8.  */
  3299 INLINE Lisp_Object
  3300 call8 (Lisp_Object fn, Lisp_Object arg1, Lisp_Object arg2, Lisp_Object arg3,
  3301        Lisp_Object arg4, Lisp_Object arg5, Lisp_Object arg6, Lisp_Object arg7,
  3302        Lisp_Object arg8)
  3303 {
  3304   return CALLN (Ffuncall, fn, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8);
  3305 }
  3306 
  3307 extern void defvar_lisp (struct Lisp_Objfwd const *, char const *);
  3308 extern void defvar_lisp_nopro (struct Lisp_Objfwd const *, char const *);
  3309 extern void defvar_bool (struct Lisp_Boolfwd const *, char const *);
  3310 extern void defvar_int (struct Lisp_Intfwd const *, char const *);
  3311 extern void defvar_kboard (struct Lisp_Kboard_Objfwd const *, char const *);
  3312 
  3313 /* Macros we use to define forwarded Lisp variables.
  3314    These are used in the syms_of_FILENAME functions.
  3315 
  3316    An ordinary (not in buffer_defaults, per-buffer, or per-keyboard)
  3317    lisp variable is actually a field in `struct emacs_globals'.  The
  3318    field's name begins with "f_", which is a convention enforced by
  3319    these macros.  Each such global has a corresponding #define in
  3320    globals.h; the plain name should be used in the code.
  3321 
  3322    E.g., the global "cons_cells_consed" is declared as "int
  3323    f_cons_cells_consed" in globals.h, but there is a define:
  3324 
  3325       #define cons_cells_consed globals.f_cons_cells_consed
  3326 
  3327    All C code uses the `cons_cells_consed' name.  This is all done
  3328    this way to support indirection for multi-threaded Emacs.  */
  3329 
  3330 #define DEFVAR_LISP(lname, vname, doc)          \
  3331   do {                                          \
  3332     static struct Lisp_Objfwd const o_fwd       \
  3333       = {Lisp_Fwd_Obj, &globals.f_##vname};     \
  3334     defvar_lisp (&o_fwd, lname);                \
  3335   } while (false)
  3336 #define DEFVAR_LISP_NOPRO(lname, vname, doc)    \
  3337   do {                                          \
  3338     static struct Lisp_Objfwd const o_fwd       \
  3339       = {Lisp_Fwd_Obj, &globals.f_##vname};     \
  3340     defvar_lisp_nopro (&o_fwd, lname);          \
  3341   } while (false)
  3342 #define DEFVAR_BOOL(lname, vname, doc)          \
  3343   do {                                          \
  3344     static struct Lisp_Boolfwd const b_fwd      \
  3345       = {Lisp_Fwd_Bool, &globals.f_##vname};    \
  3346     defvar_bool (&b_fwd, lname);                \
  3347   } while (false)
  3348 #define DEFVAR_INT(lname, vname, doc)           \
  3349   do {                                          \
  3350     static struct Lisp_Intfwd const i_fwd       \
  3351       = {Lisp_Fwd_Int, &globals.f_##vname};     \
  3352     defvar_int (&i_fwd, lname);                 \
  3353   } while (false)
  3354 
  3355 #define DEFVAR_KBOARD(lname, vname, doc)                        \
  3356   do {                                                          \
  3357     static struct Lisp_Kboard_Objfwd const ko_fwd               \
  3358       = {Lisp_Fwd_Kboard_Obj, offsetof (KBOARD, vname##_)};     \
  3359     defvar_kboard (&ko_fwd, lname);                             \
  3360   } while (false)
  3361 
  3362 
  3363 /* Elisp uses multiple stacks:
  3364    - The C stack.
  3365    - The specpdl stack keeps track of backtraces, unwind-protects and
  3366      dynamic let-bindings.  It is allocated from the 'specpdl' array,
  3367      a manually managed stack.
  3368    - The handler stack keeps track of active catch tags and condition-case
  3369      handlers.  It is allocated in a manually managed stack implemented by a
  3370      doubly-linked list allocated via xmalloc and never freed.  */
  3371 
  3372 /* Structure for recording Lisp call stack for backtrace purposes.  */
  3373 
  3374 /* The special binding stack holds the outer values of variables while
  3375    they are bound by a function application or a let form, stores the
  3376    code to be executed for unwind-protect forms.
  3377 
  3378    NOTE: The specbinding union is defined here, because SPECPDL_INDEX is
  3379    used all over the place, needs to be fast, and needs to know the size of
  3380    union specbinding.  But only eval.c should access it.  */
  3381 
  3382 enum specbind_tag {
  3383   SPECPDL_UNWIND,               /* An unwind_protect function on Lisp_Object.  */
  3384   SPECPDL_UNWIND_ARRAY,         /* Likewise, on an array that needs freeing.
  3385                                    Its elements are potential Lisp_Objects.  */
  3386   SPECPDL_UNWIND_PTR,           /* Likewise, on void *.  */
  3387   SPECPDL_UNWIND_INT,           /* Likewise, on int.  */
  3388   SPECPDL_UNWIND_INTMAX,        /* Likewise, on intmax_t.  */
  3389   SPECPDL_UNWIND_EXCURSION,     /* Likewise, on an excursion.  */
  3390   SPECPDL_UNWIND_VOID,          /* Likewise, with no arg.  */
  3391   SPECPDL_BACKTRACE,            /* An element of the backtrace.  */
  3392   SPECPDL_NOP,                  /* A filler.  */
  3393 #ifdef HAVE_MODULES
  3394   SPECPDL_MODULE_RUNTIME,       /* A live module runtime.  */
  3395   SPECPDL_MODULE_ENVIRONMENT,   /* A live module environment.  */
  3396 #endif
  3397   SPECPDL_LET,                  /* A plain and simple dynamic let-binding.  */
  3398   /* Tags greater than SPECPDL_LET must be "subkinds" of LET.  */
  3399   SPECPDL_LET_LOCAL,            /* A buffer-local let-binding.  */
  3400   SPECPDL_LET_DEFAULT           /* A global binding for a localized var.  */
  3401 };
  3402 
  3403 union specbinding
  3404   {
  3405     /* Aligning similar members consistently might help efficiency slightly
  3406        (Bug#31996#25).  */
  3407     ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3408     struct {
  3409       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3410       void (*func) (Lisp_Object);
  3411       Lisp_Object arg;
  3412       EMACS_INT eval_depth;
  3413     } unwind;
  3414     struct {
  3415       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3416       ptrdiff_t nelts;
  3417       Lisp_Object *array;
  3418     } unwind_array;
  3419     struct {
  3420       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3421       void (*func) (void *);    /* Unwind function.  */
  3422       void *arg;
  3423       void (*mark) (void *);    /* GC mark function (if non-null).  */
  3424     } unwind_ptr;
  3425     struct {
  3426       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3427       void (*func) (int);
  3428       int arg;
  3429     } unwind_int;
  3430     struct {
  3431       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3432       void (*func) (intmax_t);
  3433       intmax_t arg;
  3434     } unwind_intmax;
  3435     struct {
  3436       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3437       Lisp_Object marker, window;
  3438     } unwind_excursion;
  3439     struct {
  3440       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3441       void (*func) (void);
  3442     } unwind_void;
  3443     struct {
  3444       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3445       /* `where' is not used in the case of SPECPDL_LET.  */
  3446       Lisp_Object symbol, old_value, where;
  3447     } let;
  3448     struct {
  3449       ENUM_BF (specbind_tag) kind : CHAR_BIT;
  3450       bool_bf debug_on_exit : 1;
  3451       Lisp_Object function;
  3452       Lisp_Object *args;
  3453       ptrdiff_t nargs;
  3454     } bt;
  3455   };
  3456 
  3457 /* We use 64-bit platforms as a proxy for ones with ABIs that treat
  3458    small structs efficiently.  */
  3459 #if SIZE_MAX > 0xffffffff
  3460 #define WRAP_SPECPDL_REF 1
  3461 #endif
  3462 
  3463 /* Abstract reference to a specpdl entry.
  3464    The number is always a multiple of sizeof (union specbinding).  */
  3465 #ifdef WRAP_SPECPDL_REF
  3466 /* Use a proper type for specpdl_ref if it does not make the code slower,
  3467    since the type checking is quite useful.  */
  3468 typedef struct { ptrdiff_t bytes; } specpdl_ref;
  3469 #else
  3470 typedef ptrdiff_t specpdl_ref;
  3471 #endif
  3472 
  3473 /* Internal use only.  */
  3474 INLINE specpdl_ref
  3475 wrap_specpdl_ref (ptrdiff_t bytes)
  3476 {
  3477 #ifdef WRAP_SPECPDL_REF
  3478   return (specpdl_ref){.bytes = bytes};
  3479 #else
  3480   return bytes;
  3481 #endif
  3482 }
  3483 
  3484 /* Internal use only.  */
  3485 INLINE ptrdiff_t
  3486 unwrap_specpdl_ref (specpdl_ref ref)
  3487 {
  3488 #ifdef WRAP_SPECPDL_REF
  3489   return ref.bytes;
  3490 #else
  3491   return ref;
  3492 #endif
  3493 }
  3494 
  3495 INLINE specpdl_ref
  3496 specpdl_count_to_ref (ptrdiff_t count)
  3497 {
  3498   return wrap_specpdl_ref (count * sizeof (union specbinding));
  3499 }
  3500 
  3501 INLINE ptrdiff_t
  3502 specpdl_ref_to_count (specpdl_ref ref)
  3503 {
  3504   return unwrap_specpdl_ref (ref) / sizeof (union specbinding);
  3505 }
  3506 
  3507 /* Whether two `specpdl_ref' refer to the same entry.  */
  3508 INLINE bool
  3509 specpdl_ref_eq (specpdl_ref a, specpdl_ref b)
  3510 {
  3511   return unwrap_specpdl_ref (a) == unwrap_specpdl_ref (b);
  3512 }
  3513 
  3514 /* Whether `a' refers to an earlier entry than `b'.  */
  3515 INLINE bool
  3516 specpdl_ref_lt (specpdl_ref a, specpdl_ref b)
  3517 {
  3518   return unwrap_specpdl_ref (a) < unwrap_specpdl_ref (b);
  3519 }
  3520 
  3521 INLINE bool
  3522 specpdl_ref_valid_p (specpdl_ref ref)
  3523 {
  3524   return unwrap_specpdl_ref (ref) >= 0;
  3525 }
  3526 
  3527 INLINE specpdl_ref
  3528 make_invalid_specpdl_ref (void)
  3529 {
  3530   return wrap_specpdl_ref (-1);
  3531 }
  3532 
  3533 /* Return a reference that is `delta' steps more recent than `ref'.
  3534    `delta' may be negative or zero.  */
  3535 INLINE specpdl_ref
  3536 specpdl_ref_add (specpdl_ref ref, ptrdiff_t delta)
  3537 {
  3538   return wrap_specpdl_ref (unwrap_specpdl_ref (ref)
  3539                            + delta * sizeof (union specbinding));
  3540 }
  3541 
  3542 INLINE union specbinding *
  3543 specpdl_ref_to_ptr (specpdl_ref ref)
  3544 {
  3545   return (union specbinding *)((char *)specpdl + unwrap_specpdl_ref (ref));
  3546 }
  3547 
  3548 /* Return a reference to the most recent specpdl entry.  */
  3549 INLINE specpdl_ref
  3550 SPECPDL_INDEX (void)
  3551 {
  3552   return wrap_specpdl_ref ((char *)specpdl_ptr - (char *)specpdl);
  3553 }
  3554 
  3555 INLINE bool
  3556 backtrace_debug_on_exit (union specbinding *pdl)
  3557 {
  3558   eassert (pdl->kind == SPECPDL_BACKTRACE);
  3559   return pdl->bt.debug_on_exit;
  3560 }
  3561 
  3562 void grow_specpdl_allocation (void);
  3563 
  3564 /* Grow the specpdl stack by one entry.
  3565    The caller should have already initialized the entry.
  3566    Signal an error on stack overflow.
  3567 
  3568    Make sure that there is always one unused entry past the top of the
  3569    stack, so that the just-initialized entry is safely unwound if
  3570    memory exhausted and an error is signaled here.  Also, allocate a
  3571    never-used entry just before the bottom of the stack; sometimes its
  3572    address is taken.  */
  3573 INLINE void
  3574 grow_specpdl (void)
  3575 {
  3576   specpdl_ptr++;
  3577   if (specpdl_ptr == specpdl_end)
  3578     grow_specpdl_allocation ();
  3579 }
  3580 
  3581 INLINE specpdl_ref
  3582 record_in_backtrace (Lisp_Object function, Lisp_Object *args, ptrdiff_t nargs)
  3583 {
  3584   specpdl_ref count = SPECPDL_INDEX ();
  3585 
  3586   eassert (nargs >= UNEVALLED);
  3587   specpdl_ptr->bt.kind = SPECPDL_BACKTRACE;
  3588   specpdl_ptr->bt.debug_on_exit = false;
  3589   specpdl_ptr->bt.function = function;
  3590   current_thread->stack_top = specpdl_ptr->bt.args = args;
  3591   specpdl_ptr->bt.nargs = nargs;
  3592   grow_specpdl ();
  3593 
  3594   return count;
  3595 }
  3596 
  3597 /* This structure helps implement the `catch/throw' and `condition-case/signal'
  3598    control structures.  A struct handler contains all the information needed to
  3599    restore the state of the interpreter after a non-local jump.
  3600 
  3601    Handler structures are chained together in a doubly linked list; the `next'
  3602    member points to the next outer catchtag and the `nextfree' member points in
  3603    the other direction to the next inner element (which is typically the next
  3604    free element since we mostly use it on the deepest handler).
  3605 
  3606    A call like (throw TAG VAL) searches for a catchtag whose `tag_or_ch'
  3607    member is TAG, and then unbinds to it.  The `val' member is used to
  3608    hold VAL while the stack is unwound; `val' is returned as the value
  3609    of the catch form.  If there is a handler of type CATCHER_ALL, it will
  3610    be treated as a handler for all invocations of `signal' and `throw';
  3611    in this case `val' will be set to (ERROR-SYMBOL . DATA) or (TAG . VAL),
  3612    respectively.  During stack unwinding, `nonlocal_exit' is set to
  3613    specify the type of nonlocal exit that caused the stack unwinding.
  3614 
  3615    All the other members are concerned with restoring the interpreter
  3616    state.
  3617 
  3618    Members are volatile if their values need to survive _longjmp when
  3619    a 'struct handler' is a local variable.  */
  3620 
  3621 enum handlertype { CATCHER, CONDITION_CASE, CATCHER_ALL };
  3622 
  3623 enum nonlocal_exit
  3624 {
  3625   NONLOCAL_EXIT_SIGNAL,
  3626   NONLOCAL_EXIT_THROW,
  3627 };
  3628 
  3629 struct handler
  3630 {
  3631   enum handlertype type;
  3632   Lisp_Object tag_or_ch;
  3633 
  3634   /* The next two are set by unwind_to_catch.  */
  3635   enum nonlocal_exit nonlocal_exit;
  3636   Lisp_Object val;
  3637 
  3638   struct handler *next;
  3639   struct handler *nextfree;
  3640 
  3641   /* The bytecode interpreter can have several handlers active at the same
  3642      time, so when we longjmp to one of them, it needs to know which handler
  3643      this was and what was the corresponding internal state.  This is stored
  3644      here, and when we longjmp we make sure that handlerlist points to the
  3645      proper handler.  */
  3646   Lisp_Object *bytecode_top;
  3647   int bytecode_dest;
  3648 
  3649   /* Most global vars are reset to their value via the specpdl mechanism,
  3650      but a few others are handled by storing their value here.  */
  3651   sys_jmp_buf jmp;
  3652   EMACS_INT f_lisp_eval_depth;
  3653   specpdl_ref pdlcount;
  3654   struct bc_frame *act_rec;
  3655   int poll_suppress_count;
  3656   int interrupt_input_blocked;
  3657 
  3658 #ifdef HAVE_X_WINDOWS
  3659   int x_error_handler_depth;
  3660 #endif
  3661 };
  3662 
  3663 extern Lisp_Object memory_signal_data;
  3664 
  3665 /* True if ought to quit now.  */
  3666 
  3667 #define QUITP (!NILP (Vquit_flag) && NILP (Vinhibit_quit))
  3668 
  3669 extern bool volatile pending_signals;
  3670 extern void process_pending_signals (void);
  3671 extern void probably_quit (void);
  3672 
  3673 /* Check quit-flag and quit if it is non-nil.  Typing C-g does not
  3674    directly cause a quit; it only sets Vquit_flag.  So the program
  3675    needs to call maybe_quit at times when it is safe to quit.  Every
  3676    loop that might run for a long time or might not exit ought to call
  3677    maybe_quit at least once, at a safe place.  Unless that is
  3678    impossible, of course.  But it is very desirable to avoid creating
  3679    loops where maybe_quit is impossible.
  3680 
  3681    If quit-flag is set to `kill-emacs' the SIGINT handler has received
  3682    a request to exit Emacs when it is safe to do.
  3683 
  3684    When not quitting, process any pending signals.  */
  3685 
  3686 INLINE void
  3687 maybe_quit (void)
  3688 {
  3689   if (!NILP (Vquit_flag) || pending_signals)
  3690     probably_quit ();
  3691 }
  3692 
  3693 /* Process a quit rarely, based on a counter COUNT, for efficiency.
  3694    "Rarely" means once per USHRT_MAX + 1 times; this is somewhat
  3695    arbitrary, but efficient.  */
  3696 
  3697 INLINE void
  3698 rarely_quit (unsigned short int count)
  3699 {
  3700   if (! count)
  3701     maybe_quit ();
  3702 }
  3703 
  3704 extern Lisp_Object Vascii_downcase_table;
  3705 extern Lisp_Object Vascii_canon_table;
  3706 
  3707 /* Call staticpro (&var) to protect static variable `var'.  */
  3708 
  3709 void staticpro (Lisp_Object const *);
  3710 
  3711 enum { NSTATICS = 2048 };
  3712 extern Lisp_Object const *staticvec[NSTATICS];
  3713 extern int staticidx;
  3714 
  3715 
  3716 /* Forward declarations for prototypes.  */
  3717 struct window;
  3718 struct frame;
  3719 
  3720 /* Define if the windowing system provides a menu bar.  */
  3721 #if defined (USE_X_TOOLKIT) || defined (HAVE_NTGUI) \
  3722   || defined (HAVE_NS) || defined (USE_GTK) || defined (HAVE_HAIKU)
  3723 #define HAVE_EXT_MENU_BAR true
  3724 #endif
  3725 
  3726 /* Define if the windowing system provides a tool-bar.  */
  3727 #if defined (USE_GTK) || defined (HAVE_NS)
  3728 #define HAVE_EXT_TOOL_BAR true
  3729 #endif
  3730 
  3731 /* Return the address of vector A's element at index I.  */
  3732 
  3733 INLINE Lisp_Object *
  3734 xvector_contents_addr (Lisp_Object a, ptrdiff_t i)
  3735 {
  3736   /* This should return &XVECTOR (a)->contents[i], but that would run
  3737      afoul of GCC bug 95072.  */
  3738   void *v = XVECTOR (a);
  3739   char *p = v;
  3740   void *w = p + header_size + i * word_size;
  3741   return w;
  3742 }
  3743 
  3744 /* Return the address of vector A's elements.  */
  3745 
  3746 INLINE Lisp_Object *
  3747 xvector_contents (Lisp_Object a)
  3748 {
  3749   return xvector_contents_addr (a, 0);
  3750 }
  3751 
  3752 /* Copy COUNT Lisp_Objects from ARGS to contents of V starting from OFFSET.  */
  3753 
  3754 INLINE void
  3755 vcopy (Lisp_Object v, ptrdiff_t offset, Lisp_Object const *args,
  3756        ptrdiff_t count)
  3757 {
  3758   eassert (0 <= offset && 0 <= count && offset + count <= ASIZE (v));
  3759   memcpy (xvector_contents_addr (v, offset), args, count * sizeof *args);
  3760 }
  3761 
  3762 /* Functions to modify hash tables.  */
  3763 
  3764 INLINE void
  3765 set_hash_key_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
  3766 {
  3767   gc_aset (h->key_and_value, 2 * idx, val);
  3768 }
  3769 
  3770 INLINE void
  3771 set_hash_value_slot (struct Lisp_Hash_Table *h, ptrdiff_t idx, Lisp_Object val)
  3772 {
  3773   gc_aset (h->key_and_value, 2 * idx + 1, val);
  3774 }
  3775 
  3776 /* Use these functions to set Lisp_Object
  3777    or pointer slots of struct Lisp_Symbol.  */
  3778 
  3779 INLINE void
  3780 set_symbol_function (Lisp_Object sym, Lisp_Object function)
  3781 {
  3782   XSYMBOL (sym)->u.s.function = function;
  3783 }
  3784 
  3785 INLINE void
  3786 set_symbol_plist (Lisp_Object sym, Lisp_Object plist)
  3787 {
  3788   XSYMBOL (sym)->u.s.plist = plist;
  3789 }
  3790 
  3791 INLINE void
  3792 set_symbol_next (Lisp_Object sym, struct Lisp_Symbol *next)
  3793 {
  3794   XSYMBOL (sym)->u.s.next = next;
  3795 }
  3796 
  3797 INLINE void
  3798 make_symbol_constant (Lisp_Object sym)
  3799 {
  3800   XSYMBOL (sym)->u.s.trapped_write = SYMBOL_NOWRITE;
  3801 }
  3802 
  3803 /* Buffer-local variable access functions.  */
  3804 
  3805 INLINE bool
  3806 blv_found (struct Lisp_Buffer_Local_Value *blv)
  3807 {
  3808   eassert (blv->found == !BASE_EQ (blv->defcell, blv->valcell));
  3809   return blv->found;
  3810 }
  3811 
  3812 /* Set overlay's property list.  */
  3813 
  3814 INLINE void
  3815 set_overlay_plist (Lisp_Object overlay, Lisp_Object plist)
  3816 {
  3817   XOVERLAY (overlay)->plist = plist;
  3818 }
  3819 
  3820 /* Get text properties of S.  */
  3821 
  3822 INLINE INTERVAL
  3823 string_intervals (Lisp_Object s)
  3824 {
  3825   return XSTRING (s)->u.s.intervals;
  3826 }
  3827 
  3828 /* Set text properties of S to I.  */
  3829 
  3830 INLINE void
  3831 set_string_intervals (Lisp_Object s, INTERVAL i)
  3832 {
  3833   XSTRING (s)->u.s.intervals = i;
  3834 }
  3835 
  3836 /* Set a Lisp slot in TABLE to VAL.  Most code should use this instead
  3837    of setting slots directly.  */
  3838 
  3839 INLINE void
  3840 set_char_table_defalt (Lisp_Object table, Lisp_Object val)
  3841 {
  3842   XCHAR_TABLE (table)->defalt = val;
  3843 }
  3844 INLINE void
  3845 set_char_table_purpose (Lisp_Object table, Lisp_Object val)
  3846 {
  3847   XCHAR_TABLE (table)->purpose = val;
  3848 }
  3849 
  3850 /* Set different slots in (sub)character tables.  */
  3851 
  3852 INLINE void
  3853 set_char_table_extras (Lisp_Object table, ptrdiff_t idx, Lisp_Object val)
  3854 {
  3855   eassert (0 <= idx && idx < CHAR_TABLE_EXTRA_SLOTS (XCHAR_TABLE (table)));
  3856   XCHAR_TABLE (table)->extras[idx] = val;
  3857 }
  3858 
  3859 INLINE void
  3860 set_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val)
  3861 {
  3862   eassert (0 <= idx && idx < (1 << CHARTAB_SIZE_BITS_0));
  3863   XCHAR_TABLE (table)->contents[idx] = val;
  3864 }
  3865 
  3866 INLINE void
  3867 set_sub_char_table_contents (Lisp_Object table, ptrdiff_t idx, Lisp_Object val)
  3868 {
  3869   XSUB_CHAR_TABLE (table)->contents[idx] = val;
  3870 }
  3871 
  3872 /* Defined in bignum.c.  This part of bignum.c's API does not require
  3873    the caller to access bignum internals; see bignum.h for that.  */
  3874 extern intmax_t bignum_to_intmax (Lisp_Object) ATTRIBUTE_CONST;
  3875 extern uintmax_t bignum_to_uintmax (Lisp_Object) ATTRIBUTE_CONST;
  3876 extern ptrdiff_t bignum_bufsize (Lisp_Object, int) ATTRIBUTE_CONST;
  3877 extern ptrdiff_t bignum_to_c_string (char *, ptrdiff_t, Lisp_Object, int);
  3878 extern Lisp_Object bignum_to_string (Lisp_Object, int);
  3879 extern Lisp_Object make_bignum_str (char const *, int);
  3880 extern Lisp_Object make_neg_biguint (uintmax_t);
  3881 extern Lisp_Object double_to_integer (double);
  3882 
  3883 /* Convert the integer NUM to *N.  Return true if successful, false
  3884    (possibly setting *N) otherwise.  */
  3885 INLINE bool
  3886 integer_to_intmax (Lisp_Object num, intmax_t *n)
  3887 {
  3888   if (FIXNUMP (num))
  3889     {
  3890       *n = XFIXNUM (num);
  3891       return true;
  3892     }
  3893   else
  3894     {
  3895       intmax_t i = bignum_to_intmax (num);
  3896       *n = i;
  3897       return i != 0;
  3898     }
  3899 }
  3900 INLINE bool
  3901 integer_to_uintmax (Lisp_Object num, uintmax_t *n)
  3902 {
  3903   if (FIXNUMP (num))
  3904     {
  3905       *n = XFIXNUM (num);
  3906       return 0 <= XFIXNUM (num);
  3907     }
  3908   else
  3909     {
  3910       uintmax_t i = bignum_to_uintmax (num);
  3911       *n = i;
  3912       return i != 0;
  3913     }
  3914 }
  3915 
  3916 /* A modification count.  These are wide enough, and incremented
  3917    rarely enough, so that they should never overflow a 60-bit counter
  3918    in practice, and the code below assumes this so a compiler can
  3919    generate better code if EMACS_INT is 64 bits.  */
  3920 typedef intmax_t modiff_count;
  3921 
  3922 INLINE modiff_count
  3923 modiff_incr (modiff_count *a, ptrdiff_t len)
  3924 {
  3925   modiff_count a0 = *a; int incr = len ? 1 : 0;
  3926   /* Increase the counter more for a large modification and less for a
  3927      small modification.  Increase it logarithmically to avoid
  3928      increasing it too much.  */
  3929   while (len >>= 1) incr++;
  3930   bool modiff_overflow = INT_ADD_WRAPV (a0, incr, a);
  3931   eassert (!modiff_overflow && *a >> 30 >> 30 == 0);
  3932   return a0;
  3933 }
  3934 
  3935 INLINE Lisp_Object
  3936 modiff_to_integer (modiff_count a)
  3937 {
  3938   eassume (0 <= a && a >> 30 >> 30 == 0);
  3939   return make_int (a);
  3940 }
  3941 
  3942 /* Defined in data.c.  */
  3943 extern AVOID wrong_choice (Lisp_Object, Lisp_Object);
  3944 extern void notify_variable_watchers (Lisp_Object, Lisp_Object,
  3945                                       Lisp_Object, Lisp_Object);
  3946 extern Lisp_Object indirect_function (Lisp_Object);
  3947 extern Lisp_Object find_symbol_value (Lisp_Object);
  3948 enum Arith_Comparison {
  3949   ARITH_EQUAL,
  3950   ARITH_NOTEQUAL,
  3951   ARITH_LESS,
  3952   ARITH_GRTR,
  3953   ARITH_LESS_OR_EQUAL,
  3954   ARITH_GRTR_OR_EQUAL
  3955 };
  3956 extern Lisp_Object arithcompare (Lisp_Object num1, Lisp_Object num2,
  3957                                  enum Arith_Comparison comparison);
  3958 
  3959 /* Convert the Emacs representation CONS back to an integer of type
  3960    TYPE, storing the result the variable VAR.  Signal an error if CONS
  3961    is not a valid representation or is out of range for TYPE.  */
  3962 #define CONS_TO_INTEGER(cons, type, var)                                \
  3963  (TYPE_SIGNED (type)                                                    \
  3964   ? ((var) = cons_to_signed (cons, TYPE_MINIMUM (type), TYPE_MAXIMUM (type))) \
  3965   : ((var) = cons_to_unsigned (cons, TYPE_MAXIMUM (type))))
  3966 extern intmax_t cons_to_signed (Lisp_Object, intmax_t, intmax_t);
  3967 extern uintmax_t cons_to_unsigned (Lisp_Object, uintmax_t);
  3968 
  3969 extern struct Lisp_Symbol *indirect_variable (struct Lisp_Symbol *);
  3970 extern AVOID args_out_of_range (Lisp_Object, Lisp_Object);
  3971 extern AVOID circular_list (Lisp_Object);
  3972 extern Lisp_Object do_symval_forwarding (lispfwd);
  3973 enum Set_Internal_Bind {
  3974   SET_INTERNAL_SET,
  3975   SET_INTERNAL_BIND,
  3976   SET_INTERNAL_UNBIND,
  3977   SET_INTERNAL_THREAD_SWITCH
  3978 };
  3979 extern void set_internal (Lisp_Object, Lisp_Object, Lisp_Object,
  3980                           enum Set_Internal_Bind);
  3981 extern void set_default_internal (Lisp_Object, Lisp_Object,
  3982                                   enum Set_Internal_Bind bindflag);
  3983 extern Lisp_Object expt_integer (Lisp_Object, Lisp_Object);
  3984 extern void syms_of_data (void);
  3985 extern void swap_in_global_binding (struct Lisp_Symbol *);
  3986 
  3987 /* Defined in cmds.c */
  3988 extern void syms_of_cmds (void);
  3989 
  3990 /* Defined in coding.c.  */
  3991 extern Lisp_Object detect_coding_system (const unsigned char *, ptrdiff_t,
  3992                                          ptrdiff_t, bool, bool, Lisp_Object);
  3993 extern void init_coding (void);
  3994 extern void init_coding_once (void);
  3995 extern void syms_of_coding (void);
  3996 extern bool string_ascii_p (Lisp_Object);
  3997 
  3998 /* Defined in character.c.  */
  3999 extern ptrdiff_t chars_in_text (const unsigned char *, ptrdiff_t);
  4000 extern ptrdiff_t multibyte_chars_in_text (const unsigned char *, ptrdiff_t);
  4001 extern void syms_of_character (void);
  4002 
  4003 /* Defined in charset.c.  */
  4004 extern void init_charset (void);
  4005 extern void init_charset_once (void);
  4006 extern void syms_of_charset (void);
  4007 /* Structure forward declarations.  */
  4008 struct charset;
  4009 
  4010 /* Defined in syntax.c.  */
  4011 extern void init_syntax_once (void);
  4012 extern void syms_of_syntax (void);
  4013 
  4014 /* Defined in fns.c.  */
  4015 enum { NEXT_ALMOST_PRIME_LIMIT = 11 };
  4016 extern ptrdiff_t list_length (Lisp_Object);
  4017 extern EMACS_INT next_almost_prime (EMACS_INT) ATTRIBUTE_CONST;
  4018 extern Lisp_Object larger_vector (Lisp_Object, ptrdiff_t, ptrdiff_t);
  4019 extern bool sweep_weak_table (struct Lisp_Hash_Table *, bool);
  4020 extern void hexbuf_digest (char *, void const *, int);
  4021 extern char *extract_data_from_object (Lisp_Object, ptrdiff_t *, ptrdiff_t *);
  4022 EMACS_UINT hash_string (char const *, ptrdiff_t);
  4023 EMACS_UINT sxhash (Lisp_Object);
  4024 Lisp_Object hashfn_user_defined (Lisp_Object, struct Lisp_Hash_Table *);
  4025 Lisp_Object make_hash_table (struct hash_table_test, EMACS_INT, float, float,
  4026                              Lisp_Object, bool);
  4027 ptrdiff_t hash_lookup (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object *);
  4028 ptrdiff_t hash_put (struct Lisp_Hash_Table *, Lisp_Object, Lisp_Object,
  4029                     Lisp_Object);
  4030 void hash_remove_from_table (struct Lisp_Hash_Table *, Lisp_Object);
  4031 extern struct hash_table_test const hashtest_eq, hashtest_eql, hashtest_equal;
  4032 extern void validate_subarray (Lisp_Object, Lisp_Object, Lisp_Object,
  4033                                ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
  4034 extern Lisp_Object substring_both (Lisp_Object, ptrdiff_t, ptrdiff_t,
  4035                                    ptrdiff_t, ptrdiff_t);
  4036 extern Lisp_Object merge (Lisp_Object, Lisp_Object, Lisp_Object);
  4037 extern Lisp_Object merge_c (Lisp_Object, Lisp_Object, bool (*) (Lisp_Object, Lisp_Object));
  4038 extern Lisp_Object do_yes_or_no_p (Lisp_Object);
  4039 extern Lisp_Object concat2 (Lisp_Object, Lisp_Object);
  4040 extern Lisp_Object concat3 (Lisp_Object, Lisp_Object, Lisp_Object);
  4041 extern bool equal_no_quit (Lisp_Object, Lisp_Object);
  4042 extern Lisp_Object nconc2 (Lisp_Object, Lisp_Object);
  4043 extern Lisp_Object assq_no_quit (Lisp_Object, Lisp_Object);
  4044 extern Lisp_Object assoc_no_quit (Lisp_Object, Lisp_Object);
  4045 extern void clear_string_char_byte_cache (void);
  4046 extern ptrdiff_t string_char_to_byte (Lisp_Object, ptrdiff_t);
  4047 extern ptrdiff_t string_byte_to_char (Lisp_Object, ptrdiff_t);
  4048 extern Lisp_Object string_to_multibyte (Lisp_Object);
  4049 extern Lisp_Object string_make_unibyte (Lisp_Object);
  4050 extern Lisp_Object plist_get (Lisp_Object plist, Lisp_Object prop);
  4051 extern Lisp_Object plist_put (Lisp_Object plist, Lisp_Object prop,
  4052                               Lisp_Object val);
  4053 extern Lisp_Object plist_member (Lisp_Object plist, Lisp_Object prop);
  4054 extern void syms_of_fns (void);
  4055 
  4056 /* Defined in sort.c  */
  4057 extern void tim_sort (Lisp_Object, Lisp_Object *, const ptrdiff_t);
  4058 
  4059 /* Defined in floatfns.c.  */
  4060 verify (FLT_RADIX == 2 || FLT_RADIX == 16);
  4061 enum { LOG2_FLT_RADIX = FLT_RADIX == 2 ? 1 : 4 };
  4062 int double_integer_scale (double);
  4063 #ifndef HAVE_TRUNC
  4064 extern double trunc (double);
  4065 #endif
  4066 extern Lisp_Object fmod_float (Lisp_Object x, Lisp_Object y);
  4067 extern void syms_of_floatfns (void);
  4068 
  4069 /* Defined in fringe.c.  */
  4070 extern void syms_of_fringe (void);
  4071 extern void init_fringe (void);
  4072 #ifdef HAVE_WINDOW_SYSTEM
  4073 extern void mark_fringe_data (void);
  4074 extern void init_fringe_once (void);
  4075 #endif /* HAVE_WINDOW_SYSTEM */
  4076 
  4077 /* Defined in image.c.  */
  4078 extern int x_bitmap_mask (struct frame *, ptrdiff_t);
  4079 extern void syms_of_image (void);
  4080 
  4081 #ifdef HAVE_JSON
  4082 /* Defined in json.c.  */
  4083 extern void init_json (void);
  4084 extern void syms_of_json (void);
  4085 #endif
  4086 
  4087 /* Defined in insdel.c.  */
  4088 extern void move_gap_both (ptrdiff_t, ptrdiff_t);
  4089 extern AVOID buffer_overflow (void);
  4090 extern void make_gap (ptrdiff_t);
  4091 extern void make_gap_1 (struct buffer *, ptrdiff_t);
  4092 extern ptrdiff_t copy_text (const unsigned char *, unsigned char *,
  4093                             ptrdiff_t, bool, bool);
  4094 extern int count_combining_before (const unsigned char *,
  4095                                    ptrdiff_t, ptrdiff_t, ptrdiff_t);
  4096 extern int count_combining_after (const unsigned char *,
  4097                                   ptrdiff_t, ptrdiff_t, ptrdiff_t);
  4098 extern void insert (const char *, ptrdiff_t);
  4099 extern void insert_and_inherit (const char *, ptrdiff_t);
  4100 extern void insert_1_both (const char *, ptrdiff_t, ptrdiff_t,
  4101                            bool, bool, bool);
  4102 extern void insert_from_gap_1 (ptrdiff_t, ptrdiff_t, bool text_at_gap_tail);
  4103 extern void insert_from_gap (ptrdiff_t, ptrdiff_t, bool text_at_gap_tail);
  4104 extern void insert_from_string (Lisp_Object, ptrdiff_t, ptrdiff_t,
  4105                                 ptrdiff_t, ptrdiff_t, bool);
  4106 extern void insert_from_buffer (struct buffer *, ptrdiff_t, ptrdiff_t, bool);
  4107 extern void insert_char (int);
  4108 extern void insert_string (const char *);
  4109 extern void insert_before_markers (const char *, ptrdiff_t);
  4110 extern void insert_before_markers_and_inherit (const char *, ptrdiff_t);
  4111 extern void insert_from_string_before_markers (Lisp_Object, ptrdiff_t,
  4112                                                ptrdiff_t, ptrdiff_t,
  4113                                                ptrdiff_t, bool);
  4114 extern void del_range (ptrdiff_t, ptrdiff_t);
  4115 extern Lisp_Object del_range_1 (ptrdiff_t, ptrdiff_t, bool, bool);
  4116 extern void del_range_byte (ptrdiff_t, ptrdiff_t);
  4117 extern void del_range_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t, bool);
  4118 extern Lisp_Object del_range_2 (ptrdiff_t, ptrdiff_t,
  4119                                 ptrdiff_t, ptrdiff_t, bool);
  4120 extern void modify_text (ptrdiff_t, ptrdiff_t);
  4121 extern void prepare_to_modify_buffer (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
  4122 extern void prepare_to_modify_buffer_1 (ptrdiff_t, ptrdiff_t, ptrdiff_t *);
  4123 extern void invalidate_buffer_caches (struct buffer *, ptrdiff_t, ptrdiff_t);
  4124 extern void signal_after_change (ptrdiff_t, ptrdiff_t, ptrdiff_t);
  4125 extern void adjust_after_insert (ptrdiff_t, ptrdiff_t, ptrdiff_t,
  4126                                  ptrdiff_t, ptrdiff_t);
  4127 extern void adjust_markers_for_delete (ptrdiff_t, ptrdiff_t,
  4128                                        ptrdiff_t, ptrdiff_t);
  4129 extern void adjust_markers_bytepos (ptrdiff_t, ptrdiff_t,
  4130                                     ptrdiff_t, ptrdiff_t, int);
  4131 extern void replace_range (ptrdiff_t, ptrdiff_t, Lisp_Object, bool, bool,
  4132                            bool, bool, bool);
  4133 extern void replace_range_2 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
  4134                              const char *, ptrdiff_t, ptrdiff_t, bool);
  4135 extern void syms_of_insdel (void);
  4136 
  4137 /* Defined in dispnew.c.  */
  4138 #ifdef PROFILING
  4139 _Noreturn void __executable_start (void);
  4140 #endif
  4141 extern Lisp_Object Vwindow_system;
  4142 extern Lisp_Object sit_for (Lisp_Object, bool, int);
  4143 
  4144 /* Defined in xdisp.c.  */
  4145 extern bool noninteractive_need_newline;
  4146 extern Lisp_Object echo_area_buffer[2];
  4147 extern void add_to_log (char const *, ...);
  4148 extern void vadd_to_log (char const *, va_list);
  4149 extern void check_message_stack (void);
  4150 extern void clear_message_stack (void);
  4151 extern void setup_echo_area_for_printing (bool);
  4152 extern bool push_message (void);
  4153 extern void pop_message_unwind (void);
  4154 extern Lisp_Object restore_message_unwind (Lisp_Object);
  4155 extern void restore_message (void);
  4156 extern Lisp_Object current_message (void);
  4157 extern void clear_message (bool, bool);
  4158 extern void message (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
  4159 extern void message1 (const char *);
  4160 extern void message1_nolog (const char *);
  4161 extern void message3 (Lisp_Object);
  4162 extern void message3_nolog (Lisp_Object);
  4163 extern void message_dolog (const char *, ptrdiff_t, bool, bool);
  4164 extern void message_with_string (const char *, Lisp_Object, bool);
  4165 extern void message_log_maybe_newline (void);
  4166 extern void update_echo_area (void);
  4167 extern void truncate_echo_area (ptrdiff_t);
  4168 extern void redisplay (void);
  4169 extern ptrdiff_t count_lines (ptrdiff_t start_byte, ptrdiff_t end_byte);
  4170 
  4171 void set_frame_cursor_types (struct frame *, Lisp_Object);
  4172 extern void syms_of_xdisp (void);
  4173 extern void init_xdisp (void);
  4174 extern Lisp_Object safe_eval (Lisp_Object);
  4175 extern bool pos_visible_p (struct window *, ptrdiff_t, int *,
  4176                            int *, int *, int *, int *, int *);
  4177 
  4178 /* Defined in sqlite.c.  */
  4179 extern void syms_of_sqlite (void);
  4180 
  4181 /* Defined in xsettings.c.  */
  4182 extern void syms_of_xsettings (void);
  4183 
  4184 /* Defined in vm-limit.c.  */
  4185 extern void memory_warnings (void *, void (*warnfun) (const char *));
  4186 
  4187 /* Defined in character.c.  */
  4188 extern void parse_str_as_multibyte (const unsigned char *, ptrdiff_t,
  4189                                     ptrdiff_t *, ptrdiff_t *);
  4190 
  4191 /* Defined in alloc.c.  */
  4192 extern void *my_heap_start (void);
  4193 extern void check_pure_size (void);
  4194 unsigned char *resize_string_data (Lisp_Object, ptrdiff_t, int, int);
  4195 extern void malloc_warning (const char *);
  4196 extern AVOID memory_full (size_t);
  4197 extern AVOID buffer_memory_full (ptrdiff_t);
  4198 extern bool survives_gc_p (Lisp_Object);
  4199 extern void mark_object (Lisp_Object);
  4200 extern void mark_objects (Lisp_Object *, ptrdiff_t);
  4201 #if defined REL_ALLOC && !defined SYSTEM_MALLOC && !defined HYBRID_MALLOC
  4202 extern void refill_memory_reserve (void);
  4203 #endif
  4204 extern void alloc_unexec_pre (void);
  4205 extern void alloc_unexec_post (void);
  4206 extern void mark_c_stack (char const *, char const *);
  4207 extern void flush_stack_call_func1 (void (*func) (void *arg), void *arg);
  4208 extern void mark_memory (void const *start, void const *end);
  4209 
  4210 /* Force callee-saved registers and register windows onto the stack,
  4211    so that conservative garbage collection can see their values.  */
  4212 #ifndef HAVE___BUILTIN_UNWIND_INIT
  4213 # ifdef __sparc__
  4214    /* This trick flushes the register windows so that all the state of
  4215       the process is contained in the stack.
  4216       FreeBSD does not have a ta 3 handler, so handle it specially.
  4217       FIXME: Code in the Boehm GC suggests flushing (with 'flushrs') is
  4218       needed on ia64 too.  See mach_dep.c, where it also says inline
  4219       assembler doesn't work with relevant proprietary compilers.  */
  4220 #  if defined __sparc64__ && defined __FreeBSD__
  4221 #   define __builtin_unwind_init() asm ("flushw")
  4222 #  else
  4223 #   define __builtin_unwind_init() asm ("ta 3")
  4224 #  endif
  4225 # else
  4226 #  define __builtin_unwind_init() ((void) 0)
  4227 # endif
  4228 #endif
  4229 INLINE void
  4230 flush_stack_call_func (void (*func) (void *arg), void *arg)
  4231 {
  4232   __builtin_unwind_init ();
  4233   flush_stack_call_func1 (func, arg);
  4234 }
  4235 
  4236 extern void garbage_collect (void);
  4237 extern void maybe_garbage_collect (void);
  4238 extern bool maybe_garbage_collect_eagerly (EMACS_INT factor);
  4239 extern const char *pending_malloc_warning;
  4240 extern Lisp_Object zero_vector;
  4241 extern EMACS_INT consing_until_gc;
  4242 #ifdef HAVE_PDUMPER
  4243 extern int number_finalizers_run;
  4244 #endif
  4245 extern Lisp_Object list1 (Lisp_Object);
  4246 extern Lisp_Object list2 (Lisp_Object, Lisp_Object);
  4247 extern Lisp_Object list3 (Lisp_Object, Lisp_Object, Lisp_Object);
  4248 extern Lisp_Object list4 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  4249 extern Lisp_Object list5 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object,
  4250                           Lisp_Object);
  4251 extern Lisp_Object listn (ptrdiff_t, Lisp_Object, ...);
  4252 extern Lisp_Object pure_listn (ptrdiff_t, Lisp_Object, ...);
  4253 #define list(...) \
  4254   listn (ARRAYELTS (((Lisp_Object []) {__VA_ARGS__})), __VA_ARGS__)
  4255 #define pure_list(...) \
  4256   pure_listn (ARRAYELTS (((Lisp_Object []) {__VA_ARGS__})), __VA_ARGS__)
  4257 
  4258 enum gc_root_type
  4259 {
  4260   GC_ROOT_STATICPRO,
  4261   GC_ROOT_BUFFER_LOCAL_DEFAULT,
  4262   GC_ROOT_BUFFER_LOCAL_NAME,
  4263   GC_ROOT_C_SYMBOL
  4264 };
  4265 
  4266 struct gc_root_visitor
  4267 {
  4268   void (*visit) (Lisp_Object const *, enum gc_root_type, void *);
  4269   void *data;
  4270 };
  4271 extern void visit_static_gc_roots (struct gc_root_visitor visitor);
  4272 
  4273 /* Build a frequently used 1/2/3/4-integer lists.  */
  4274 
  4275 INLINE Lisp_Object
  4276 list1i (intmax_t a)
  4277 {
  4278   return list1 (make_int (a));
  4279 }
  4280 
  4281 INLINE Lisp_Object
  4282 list2i (intmax_t a, intmax_t b)
  4283 {
  4284   return list2 (make_int (a), make_int (b));
  4285 }
  4286 
  4287 INLINE Lisp_Object
  4288 list3i (intmax_t a, intmax_t b, intmax_t c)
  4289 {
  4290   return list3 (make_int (a), make_int (b), make_int (c));
  4291 }
  4292 
  4293 INLINE Lisp_Object
  4294 list4i (intmax_t a, intmax_t b, intmax_t c, intmax_t d)
  4295 {
  4296   return list4 (make_int (a), make_int (b), make_int (c), make_int (d));
  4297 }
  4298 
  4299 extern Lisp_Object make_uninit_bool_vector (EMACS_INT);
  4300 extern Lisp_Object bool_vector_fill (Lisp_Object, Lisp_Object);
  4301 extern AVOID string_overflow (void);
  4302 extern Lisp_Object make_string (const char *, ptrdiff_t);
  4303 extern Lisp_Object make_formatted_string (char *, const char *, ...)
  4304   ATTRIBUTE_FORMAT_PRINTF (2, 3);
  4305 extern Lisp_Object make_unibyte_string (const char *, ptrdiff_t);
  4306 extern ptrdiff_t vectorlike_nbytes (const union vectorlike_header *hdr);
  4307 
  4308 INLINE ptrdiff_t
  4309 vector_nbytes (const struct Lisp_Vector *v)
  4310 {
  4311   return vectorlike_nbytes (&v->header);
  4312 }
  4313 
  4314 /* Make unibyte string from C string when the length isn't known.  */
  4315 
  4316 INLINE Lisp_Object
  4317 build_unibyte_string (const char *str)
  4318 {
  4319   return make_unibyte_string (str, strlen (str));
  4320 }
  4321 
  4322 extern Lisp_Object make_multibyte_string (const char *, ptrdiff_t, ptrdiff_t);
  4323 extern Lisp_Object make_event_array (ptrdiff_t, Lisp_Object *);
  4324 extern Lisp_Object make_uninit_string (EMACS_INT);
  4325 extern Lisp_Object make_uninit_multibyte_string (EMACS_INT, EMACS_INT);
  4326 extern Lisp_Object make_string_from_bytes (const char *, ptrdiff_t, ptrdiff_t);
  4327 extern Lisp_Object make_specified_string (const char *,
  4328                                           ptrdiff_t, ptrdiff_t, bool);
  4329 extern Lisp_Object make_pure_string (const char *, ptrdiff_t, ptrdiff_t, bool);
  4330 extern Lisp_Object make_pure_c_string (const char *, ptrdiff_t);
  4331 extern void pin_string (Lisp_Object string);
  4332 
  4333 /* Make a string allocated in pure space, use STR as string data.  */
  4334 
  4335 INLINE Lisp_Object
  4336 build_pure_c_string (const char *str)
  4337 {
  4338   return make_pure_c_string (str, strlen (str));
  4339 }
  4340 
  4341 /* Make a string from the data at STR, treating it as multibyte if the
  4342    data warrants.  */
  4343 
  4344 INLINE Lisp_Object
  4345 build_string (const char *str)
  4346 {
  4347   return make_string (str, strlen (str));
  4348 }
  4349 
  4350 extern Lisp_Object pure_cons (Lisp_Object, Lisp_Object);
  4351 extern Lisp_Object make_vector (ptrdiff_t, Lisp_Object);
  4352 extern struct Lisp_Vector *allocate_nil_vector (ptrdiff_t)
  4353   ATTRIBUTE_RETURNS_NONNULL;
  4354 
  4355 /* Make an uninitialized vector for SIZE objects.  NOTE: you must
  4356    be sure that GC cannot happen until the vector is completely
  4357    initialized.  E.g. the following code is likely to crash:
  4358 
  4359    v = make_uninit_vector (3);
  4360    ASET (v, 0, obj0);
  4361    ASET (v, 1, Ffunction_can_gc ());
  4362    ASET (v, 2, obj1);
  4363 
  4364    allocate_vector has a similar problem.  */
  4365 
  4366 extern struct Lisp_Vector *allocate_vector (ptrdiff_t)
  4367   ATTRIBUTE_RETURNS_NONNULL;
  4368 
  4369 INLINE Lisp_Object
  4370 make_uninit_vector (ptrdiff_t size)
  4371 {
  4372   return make_lisp_ptr (allocate_vector (size), Lisp_Vectorlike);
  4373 }
  4374 
  4375 /* Like above, but special for sub char-tables.  */
  4376 
  4377 INLINE Lisp_Object
  4378 make_uninit_sub_char_table (int depth, int min_char)
  4379 {
  4380   int slots = SUB_CHAR_TABLE_OFFSET + chartab_size[depth];
  4381   Lisp_Object v = make_uninit_vector (slots);
  4382 
  4383   XSETPVECTYPE (XVECTOR (v), PVEC_SUB_CHAR_TABLE);
  4384   XSUB_CHAR_TABLE (v)->depth = depth;
  4385   XSUB_CHAR_TABLE (v)->min_char = min_char;
  4386   return v;
  4387 }
  4388 
  4389 /* Make a vector of SIZE nils - faster than make_vector (size, Qnil)
  4390    if the OS already cleared the new memory.  */
  4391 
  4392 INLINE Lisp_Object
  4393 make_nil_vector (ptrdiff_t size)
  4394 {
  4395   return make_lisp_ptr (allocate_nil_vector (size), Lisp_Vectorlike);
  4396 }
  4397 
  4398 extern struct Lisp_Vector *allocate_pseudovector (int, int, int,
  4399                                                   enum pvec_type)
  4400   ATTRIBUTE_RETURNS_NONNULL;
  4401 
  4402 /* Allocate uninitialized pseudovector with no Lisp_Object slots.  */
  4403 
  4404 #define ALLOCATE_PLAIN_PSEUDOVECTOR(type, tag) \
  4405   ((type *) allocate_pseudovector (VECSIZE (type), 0, 0, tag))
  4406 
  4407 /* Allocate partially initialized pseudovector where all Lisp_Object
  4408    slots are set to Qnil but the rest (if any) is left uninitialized.  */
  4409 
  4410 #define ALLOCATE_PSEUDOVECTOR(type, field, tag)                        \
  4411   ((type *) allocate_pseudovector (VECSIZE (type),                     \
  4412                                    PSEUDOVECSIZE (type, field),        \
  4413                                    PSEUDOVECSIZE (type, field), tag))
  4414 
  4415 /* Allocate fully initialized pseudovector where all Lisp_Object
  4416    slots are set to Qnil and the rest (if any) is zeroed.  */
  4417 
  4418 #define ALLOCATE_ZEROED_PSEUDOVECTOR(type, field, tag)                 \
  4419   ((type *) allocate_pseudovector (VECSIZE (type),                     \
  4420                                    PSEUDOVECSIZE (type, field),        \
  4421                                    VECSIZE (type), tag))
  4422 
  4423 extern bool gc_in_progress;
  4424 extern Lisp_Object make_float (double);
  4425 extern void display_malloc_warning (void);
  4426 extern specpdl_ref inhibit_garbage_collection (void);
  4427 extern Lisp_Object build_symbol_with_pos (Lisp_Object, Lisp_Object);
  4428 extern void free_cons (struct Lisp_Cons *);
  4429 extern void init_alloc_once (void);
  4430 extern void init_alloc (void);
  4431 extern void syms_of_alloc (void);
  4432 extern struct buffer *allocate_buffer (void) ATTRIBUTE_RETURNS_NONNULL;
  4433 extern int valid_lisp_object_p (Lisp_Object);
  4434 
  4435 /* Defined in gmalloc.c.  */
  4436 #if !defined DOUG_LEA_MALLOC && !defined HYBRID_MALLOC && !defined SYSTEM_MALLOC
  4437 extern size_t __malloc_extra_blocks;
  4438 #endif
  4439 #if !HAVE_DECL_ALIGNED_ALLOC
  4440 extern void *aligned_alloc (size_t, size_t) ATTRIBUTE_MALLOC_SIZE ((2));
  4441 #endif
  4442 extern void malloc_enable_thread (void);
  4443 
  4444 #ifdef REL_ALLOC
  4445 /* Defined in ralloc.c.  */
  4446 extern void *r_alloc (void **, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
  4447 extern void r_alloc_free (void **);
  4448 extern void *r_re_alloc (void **, size_t) ATTRIBUTE_ALLOC_SIZE ((2));
  4449 extern void r_alloc_reset_variable (void **, void **);
  4450 extern void r_alloc_inhibit_buffer_relocation (int);
  4451 #endif
  4452 
  4453 /* Defined in chartab.c.  */
  4454 extern Lisp_Object copy_char_table (Lisp_Object);
  4455 extern Lisp_Object char_table_ref_and_range (Lisp_Object, int,
  4456                                              int *, int *);
  4457 extern void char_table_set_range (Lisp_Object, int, int, Lisp_Object);
  4458 extern void map_char_table (void (*) (Lisp_Object, Lisp_Object,
  4459                             Lisp_Object),
  4460                             Lisp_Object, Lisp_Object, Lisp_Object);
  4461 extern void map_char_table_for_charset (void (*c_function) (Lisp_Object, Lisp_Object),
  4462                                         Lisp_Object, Lisp_Object,
  4463                                         Lisp_Object, struct charset *,
  4464                                         unsigned, unsigned);
  4465 extern Lisp_Object uniprop_table (Lisp_Object);
  4466 extern Lisp_Object get_unicode_property (Lisp_Object, int);
  4467 extern void syms_of_chartab (void);
  4468 
  4469 /* Defined in print.c.  */
  4470 extern Lisp_Object Vprin1_to_string_buffer;
  4471 extern void debug_print (Lisp_Object) EXTERNALLY_VISIBLE;
  4472 extern void temp_output_buffer_setup (const char *);
  4473 extern int print_level;
  4474 extern void print_error_message (Lisp_Object, Lisp_Object, const char *,
  4475                                  Lisp_Object);
  4476 extern Lisp_Object internal_with_output_to_temp_buffer
  4477         (const char *, Lisp_Object (*) (Lisp_Object), Lisp_Object);
  4478 #define FLOAT_TO_STRING_BUFSIZE 350
  4479 extern int float_to_string (char *, double);
  4480 extern void init_print_once (void);
  4481 extern void syms_of_print (void);
  4482 
  4483 /* Defined in doprnt.c.  */
  4484 extern ptrdiff_t doprnt (char *, ptrdiff_t, const char *, const char *,
  4485                          va_list);
  4486 extern ptrdiff_t esprintf (char *, char const *, ...)
  4487   ATTRIBUTE_FORMAT_PRINTF (2, 3);
  4488 extern ptrdiff_t exprintf (char **, ptrdiff_t *, char *, ptrdiff_t,
  4489                            char const *, ...)
  4490   ATTRIBUTE_FORMAT_PRINTF (5, 6);
  4491 extern ptrdiff_t evxprintf (char **, ptrdiff_t *, char *, ptrdiff_t,
  4492                             char const *, va_list)
  4493   ATTRIBUTE_FORMAT_PRINTF (5, 0);
  4494 
  4495 /* Defined in lread.c.  */
  4496 extern Lisp_Object check_obarray (Lisp_Object);
  4497 extern Lisp_Object intern_1 (const char *, ptrdiff_t);
  4498 extern Lisp_Object intern_c_string_1 (const char *, ptrdiff_t);
  4499 extern Lisp_Object intern_driver (Lisp_Object, Lisp_Object, Lisp_Object);
  4500 extern void init_symbol (Lisp_Object, Lisp_Object);
  4501 extern Lisp_Object oblookup (Lisp_Object, const char *, ptrdiff_t, ptrdiff_t);
  4502 INLINE void
  4503 LOADHIST_ATTACH (Lisp_Object x)
  4504 {
  4505   if (initialized)
  4506     Vcurrent_load_list = Fcons (x, Vcurrent_load_list);
  4507 }
  4508 extern bool suffix_p (Lisp_Object, const char *);
  4509 extern Lisp_Object save_match_data_load (Lisp_Object, Lisp_Object, Lisp_Object,
  4510                                          Lisp_Object, Lisp_Object);
  4511 extern int openp (Lisp_Object, Lisp_Object, Lisp_Object,
  4512                   Lisp_Object *, Lisp_Object, bool, bool);
  4513 enum { S2N_IGNORE_TRAILING = 1 };
  4514 extern Lisp_Object string_to_number (char const *, int, ptrdiff_t *);
  4515 extern void map_obarray (Lisp_Object, void (*) (Lisp_Object, Lisp_Object),
  4516                          Lisp_Object);
  4517 extern void dir_warning (const char *, Lisp_Object);
  4518 extern void init_obarray_once (void);
  4519 extern void init_lread (void);
  4520 extern void syms_of_lread (void);
  4521 extern void mark_lread (void);
  4522 
  4523 INLINE Lisp_Object
  4524 intern (const char *str)
  4525 {
  4526   return intern_1 (str, strlen (str));
  4527 }
  4528 
  4529 INLINE Lisp_Object
  4530 intern_c_string (const char *str)
  4531 {
  4532   return intern_c_string_1 (str, strlen (str));
  4533 }
  4534 
  4535 /* Defined in eval.c.  */
  4536 extern Lisp_Object Vautoload_queue;
  4537 extern Lisp_Object Vrun_hooks;
  4538 extern Lisp_Object Vsignaling_function;
  4539 extern Lisp_Object inhibit_lisp_code;
  4540 extern bool signal_quit_p (Lisp_Object);
  4541 extern bool backtrace_yet;
  4542 
  4543 /* To run a normal hook, use the appropriate function from the list below.
  4544    The calling convention:
  4545 
  4546    if (!NILP (Vrun_hooks))
  4547      call1 (Vrun_hooks, Qmy_funny_hook);
  4548 
  4549    should no longer be used.  */
  4550 extern void run_hook (Lisp_Object);
  4551 extern void run_hook_with_args_2 (Lisp_Object, Lisp_Object, Lisp_Object);
  4552 extern Lisp_Object run_hook_with_args (ptrdiff_t nargs, Lisp_Object *args,
  4553                                        Lisp_Object (*funcall)
  4554                                        (ptrdiff_t nargs, Lisp_Object *args));
  4555 extern Lisp_Object quit (void);
  4556 INLINE AVOID
  4557 xsignal (Lisp_Object error_symbol, Lisp_Object data)
  4558 {
  4559   Fsignal (error_symbol, data);
  4560 }
  4561 extern AVOID xsignal0 (Lisp_Object);
  4562 extern AVOID xsignal1 (Lisp_Object, Lisp_Object);
  4563 extern AVOID xsignal2 (Lisp_Object, Lisp_Object, Lisp_Object);
  4564 extern AVOID xsignal3 (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  4565 extern AVOID signal_error (const char *, Lisp_Object);
  4566 extern AVOID overflow_error (void);
  4567 extern bool FUNCTIONP (Lisp_Object);
  4568 extern Lisp_Object funcall_subr (struct Lisp_Subr *subr, ptrdiff_t numargs, Lisp_Object *arg_vector);
  4569 extern Lisp_Object eval_sub (Lisp_Object form);
  4570 extern Lisp_Object apply1 (Lisp_Object, Lisp_Object);
  4571 extern Lisp_Object internal_catch (Lisp_Object, Lisp_Object (*) (Lisp_Object), Lisp_Object);
  4572 extern Lisp_Object internal_lisp_condition_case (Lisp_Object, Lisp_Object, Lisp_Object);
  4573 extern Lisp_Object internal_condition_case (Lisp_Object (*) (void), Lisp_Object, Lisp_Object (*) (Lisp_Object));
  4574 extern Lisp_Object internal_condition_case_1 (Lisp_Object (*) (Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object));
  4575 extern Lisp_Object internal_condition_case_2 (Lisp_Object (*) (Lisp_Object, Lisp_Object), Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object (*) (Lisp_Object));
  4576 extern Lisp_Object internal_condition_case_n
  4577     (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *,
  4578      Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *));
  4579 extern Lisp_Object internal_catch_all (Lisp_Object (*) (void *), void *, Lisp_Object (*) (enum nonlocal_exit, Lisp_Object));
  4580 extern struct handler *push_handler (Lisp_Object, enum handlertype)
  4581   ATTRIBUTE_RETURNS_NONNULL;
  4582 extern struct handler *push_handler_nosignal (Lisp_Object, enum handlertype);
  4583 extern void specbind (Lisp_Object, Lisp_Object);
  4584 extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object);
  4585 extern void record_unwind_protect_array (Lisp_Object *, ptrdiff_t);
  4586 extern void record_unwind_protect_ptr (void (*) (void *), void *);
  4587 extern void record_unwind_protect_ptr_mark (void (*function) (void *),
  4588                                             void *arg, void (*mark) (void *));
  4589 extern void record_unwind_protect_int (void (*) (int), int);
  4590 extern void record_unwind_protect_intmax (void (*) (intmax_t), intmax_t);
  4591 extern void record_unwind_protect_void (void (*) (void));
  4592 extern void record_unwind_protect_excursion (void);
  4593 extern void record_unwind_protect_nothing (void);
  4594 extern void record_unwind_protect_module (enum specbind_tag, void *);
  4595 extern void clear_unwind_protect (specpdl_ref);
  4596 extern void set_unwind_protect (specpdl_ref, void (*) (Lisp_Object),
  4597                                 Lisp_Object);
  4598 extern void set_unwind_protect_ptr (specpdl_ref, void (*) (void *), void *);
  4599 extern Lisp_Object unbind_to (specpdl_ref, Lisp_Object);
  4600 void specpdl_unrewind (union specbinding *pdl, int distance, bool vars_only);
  4601 extern AVOID error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
  4602 extern AVOID verror (const char *, va_list)
  4603   ATTRIBUTE_FORMAT_PRINTF (1, 0);
  4604 extern Lisp_Object vformat_string (const char *, va_list)
  4605   ATTRIBUTE_FORMAT_PRINTF (1, 0);
  4606 extern Lisp_Object load_with_autoload_queue
  4607            (Lisp_Object file, Lisp_Object noerror, Lisp_Object nomessage,
  4608             Lisp_Object nosuffix, Lisp_Object must_suffix);
  4609 extern Lisp_Object call_debugger (Lisp_Object arg);
  4610 extern void init_eval_once (void);
  4611 extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
  4612 extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
  4613 extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
  4614 extern void init_eval (void);
  4615 extern void syms_of_eval (void);
  4616 extern void prog_ignore (Lisp_Object);
  4617 extern void mark_specpdl (union specbinding *first, union specbinding *ptr);
  4618 extern void get_backtrace (Lisp_Object array);
  4619 Lisp_Object backtrace_top_function (void);
  4620 extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol);
  4621 void do_debug_on_call (Lisp_Object code, specpdl_ref count);
  4622 Lisp_Object funcall_general (Lisp_Object fun,
  4623                              ptrdiff_t numargs, Lisp_Object *args);
  4624 
  4625 /* Defined in unexmacosx.c.  */
  4626 #if defined DARWIN_OS && defined HAVE_UNEXEC
  4627 extern void unexec_init_emacs_zone (void);
  4628 extern void *unexec_malloc (size_t);
  4629 extern void *unexec_realloc (void *, size_t);
  4630 extern void unexec_free (void *);
  4631 #endif
  4632 
  4633 /* The definition of Lisp_Module_Function depends on emacs-module.h,
  4634    so we don't define it here.  It's defined in emacs-module.c.  */
  4635 
  4636 INLINE bool
  4637 MODULE_FUNCTIONP (Lisp_Object o)
  4638 {
  4639   return PSEUDOVECTORP (o, PVEC_MODULE_FUNCTION);
  4640 }
  4641 
  4642 INLINE struct Lisp_Module_Function *
  4643 XMODULE_FUNCTION (Lisp_Object o)
  4644 {
  4645   eassert (MODULE_FUNCTIONP (o));
  4646   return XUNTAG (o, Lisp_Vectorlike, struct Lisp_Module_Function);
  4647 }
  4648 
  4649 #ifdef HAVE_MODULES
  4650 /* A function pointer type good enough for lisp.h.  Actual module
  4651    function pointers are of a different type that relies on details
  4652    internal to emacs-module.c.  */
  4653 typedef void (*module_funcptr) (void);
  4654 
  4655 /* Defined in alloc.c.  */
  4656 extern Lisp_Object make_user_ptr (void (*finalizer) (void *), void *p);
  4657 
  4658 /* Defined in emacs-module.c.  */
  4659 extern Lisp_Object funcall_module (Lisp_Object, ptrdiff_t, Lisp_Object *);
  4660 extern Lisp_Object module_function_arity (const struct Lisp_Module_Function *);
  4661 extern Lisp_Object module_function_documentation
  4662   (struct Lisp_Module_Function const *);
  4663 extern Lisp_Object module_function_interactive_form
  4664   (const struct Lisp_Module_Function *);
  4665 extern Lisp_Object module_function_command_modes
  4666   (const struct Lisp_Module_Function *);
  4667 extern module_funcptr module_function_address
  4668   (struct Lisp_Module_Function const *);
  4669 extern void *module_function_data (const struct Lisp_Module_Function *);
  4670 extern void module_finalize_function (const struct Lisp_Module_Function *);
  4671 extern void mark_module_environment (void *);
  4672 extern void finalize_runtime_unwind (void *);
  4673 extern void finalize_environment_unwind (void *);
  4674 extern void init_module_assertions (bool);
  4675 extern void syms_of_module (void);
  4676 #endif
  4677 
  4678 /* Defined in thread.c.  */
  4679 extern void mark_threads (void);
  4680 extern void unmark_main_thread (void);
  4681 
  4682 /* Defined in editfns.c.  */
  4683 extern void insert1 (Lisp_Object);
  4684 extern void save_excursion_save (union specbinding *);
  4685 extern void save_excursion_restore (Lisp_Object, Lisp_Object);
  4686 extern Lisp_Object save_restriction_save (void);
  4687 extern void save_restriction_restore (Lisp_Object);
  4688 extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
  4689 extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
  4690                                             ptrdiff_t, bool);
  4691 extern void labeled_narrow_to_region (Lisp_Object, Lisp_Object, Lisp_Object);
  4692 extern void reset_outermost_restrictions (void);
  4693 extern void labeled_restrictions_remove_in_current_buffer (void);
  4694 extern void init_editfns (void);
  4695 extern void syms_of_editfns (void);
  4696 
  4697 /* Defined in buffer.c.  */
  4698 extern bool mouse_face_overlay_overlaps (Lisp_Object);
  4699 extern Lisp_Object disable_line_numbers_overlay_at_eob (void);
  4700 extern AVOID nsberror (Lisp_Object);
  4701 extern void adjust_overlays_for_insert (ptrdiff_t, ptrdiff_t, bool);
  4702 extern void adjust_overlays_for_delete (ptrdiff_t, ptrdiff_t);
  4703 extern void fix_start_end_in_overlays (ptrdiff_t, ptrdiff_t);
  4704 extern void report_overlay_modification (Lisp_Object, Lisp_Object, bool,
  4705                                          Lisp_Object, Lisp_Object, Lisp_Object);
  4706 extern bool overlay_touches_p (ptrdiff_t);
  4707 extern Lisp_Object other_buffer_safely (Lisp_Object);
  4708 extern Lisp_Object get_truename_buffer (Lisp_Object);
  4709 extern void init_buffer_once (void);
  4710 extern void init_buffer (void);
  4711 extern void syms_of_buffer (void);
  4712 
  4713 /* Defined in marker.c.  */
  4714 
  4715 extern ptrdiff_t marker_position (Lisp_Object);
  4716 extern ptrdiff_t marker_byte_position (Lisp_Object);
  4717 extern void clear_charpos_cache (struct buffer *);
  4718 extern ptrdiff_t buf_charpos_to_bytepos (struct buffer *, ptrdiff_t);
  4719 extern ptrdiff_t buf_bytepos_to_charpos (struct buffer *, ptrdiff_t);
  4720 extern void detach_marker (Lisp_Object);
  4721 extern void unchain_marker (struct Lisp_Marker *);
  4722 extern Lisp_Object set_marker_restricted (Lisp_Object, Lisp_Object, Lisp_Object);
  4723 extern Lisp_Object set_marker_both (Lisp_Object, Lisp_Object, ptrdiff_t, ptrdiff_t);
  4724 extern Lisp_Object set_marker_restricted_both (Lisp_Object, Lisp_Object,
  4725                                                ptrdiff_t, ptrdiff_t);
  4726 extern Lisp_Object build_marker (struct buffer *, ptrdiff_t, ptrdiff_t);
  4727 extern void syms_of_marker (void);
  4728 
  4729 /* Defined in fileio.c.  */
  4730 
  4731 extern char *splice_dir_file (char *, char const *, char const *)
  4732   ATTRIBUTE_RETURNS_NONNULL;
  4733 extern bool file_name_absolute_p (const char *);
  4734 extern char const *get_homedir (void) ATTRIBUTE_RETURNS_NONNULL;
  4735 extern Lisp_Object expand_and_dir_to_file (Lisp_Object);
  4736 extern Lisp_Object write_region (Lisp_Object, Lisp_Object, Lisp_Object,
  4737                                  Lisp_Object, Lisp_Object, Lisp_Object,
  4738                                  Lisp_Object, int);
  4739 extern void close_file_unwind (int);
  4740 extern void fclose_unwind (void *);
  4741 extern void restore_point_unwind (Lisp_Object);
  4742 extern bool file_access_p (char const *, int);
  4743 extern Lisp_Object get_file_errno_data (const char *, Lisp_Object, int);
  4744 extern AVOID report_file_errno (const char *, Lisp_Object, int);
  4745 extern AVOID report_file_error (const char *, Lisp_Object);
  4746 extern AVOID report_file_notify_error (const char *, Lisp_Object);
  4747 extern Lisp_Object file_attribute_errno (Lisp_Object, int);
  4748 extern bool internal_delete_file (Lisp_Object);
  4749 extern Lisp_Object check_emacs_readlinkat (int, Lisp_Object, char const *);
  4750 extern bool file_directory_p (Lisp_Object);
  4751 extern bool file_accessible_directory_p (Lisp_Object);
  4752 extern Lisp_Object buffer_visited_file_modtime (struct buffer *);
  4753 extern void init_fileio (void);
  4754 extern void syms_of_fileio (void);
  4755 
  4756 /* Defined in search.c.  */
  4757 extern void shrink_regexp_cache (void);
  4758 extern void restore_search_regs (void);
  4759 extern void update_search_regs (ptrdiff_t oldstart,
  4760                                 ptrdiff_t oldend, ptrdiff_t newend);
  4761 extern void record_unwind_save_match_data (void);
  4762 extern ptrdiff_t fast_string_match_internal (Lisp_Object, Lisp_Object,
  4763                                              Lisp_Object);
  4764 extern ptrdiff_t fast_c_string_match_internal (Lisp_Object, const char *,
  4765                                                ptrdiff_t, Lisp_Object);
  4766 
  4767 INLINE ptrdiff_t
  4768 fast_string_match (Lisp_Object regexp, Lisp_Object string)
  4769 {
  4770   return fast_string_match_internal (regexp, string, Qnil);
  4771 }
  4772 
  4773 INLINE ptrdiff_t
  4774 fast_string_match_ignore_case (Lisp_Object regexp, Lisp_Object string)
  4775 {
  4776   return fast_string_match_internal (regexp, string, Vascii_canon_table);
  4777 }
  4778 
  4779 INLINE ptrdiff_t
  4780 fast_c_string_match (Lisp_Object regexp,
  4781                      const char *string, ptrdiff_t len)
  4782 {
  4783   return fast_c_string_match_internal (regexp, string, len, Qnil);
  4784 }
  4785 
  4786 INLINE ptrdiff_t
  4787 fast_c_string_match_ignore_case (Lisp_Object regexp,
  4788                                  const char *string, ptrdiff_t len)
  4789 {
  4790   return fast_c_string_match_internal (regexp, string, len,
  4791                                        Vascii_canon_table);
  4792 }
  4793 
  4794 extern ptrdiff_t fast_looking_at (Lisp_Object, ptrdiff_t, ptrdiff_t,
  4795                                   ptrdiff_t, ptrdiff_t, Lisp_Object);
  4796 extern ptrdiff_t find_newline1 (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
  4797                                ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool);
  4798 extern ptrdiff_t find_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
  4799                                ptrdiff_t, ptrdiff_t *, ptrdiff_t *, bool);
  4800 extern void scan_newline (ptrdiff_t, ptrdiff_t, ptrdiff_t, ptrdiff_t,
  4801                           ptrdiff_t, bool);
  4802 extern ptrdiff_t scan_newline_from_point (ptrdiff_t, ptrdiff_t *, ptrdiff_t *);
  4803 extern ptrdiff_t find_newline_no_quit (ptrdiff_t, ptrdiff_t,
  4804                                        ptrdiff_t, ptrdiff_t *);
  4805 extern ptrdiff_t find_before_next_newline (ptrdiff_t, ptrdiff_t,
  4806                                            ptrdiff_t, ptrdiff_t *);
  4807 extern EMACS_INT search_buffer (Lisp_Object, ptrdiff_t, ptrdiff_t,
  4808                                 ptrdiff_t, ptrdiff_t, EMACS_INT,
  4809                                 int, Lisp_Object, Lisp_Object, bool);
  4810 extern void syms_of_search (void);
  4811 extern void clear_regexp_cache (void);
  4812 
  4813 /* Defined in minibuf.c.  */
  4814 
  4815 extern Lisp_Object Vminibuffer_list;
  4816 extern Lisp_Object last_minibuf_string;
  4817 extern void move_minibuffers_onto_frame (struct frame *, Lisp_Object, bool);
  4818 extern bool is_minibuffer (EMACS_INT, Lisp_Object);
  4819 extern EMACS_INT this_minibuffer_depth (Lisp_Object);
  4820 extern EMACS_INT minibuf_level;
  4821 extern Lisp_Object get_minibuffer (EMACS_INT);
  4822 extern void init_minibuf_once (void);
  4823 extern void set_initial_minibuffer_mode (void);
  4824 extern void syms_of_minibuf (void);
  4825 extern void barf_if_interaction_inhibited (void);
  4826 
  4827 /* Defined in callint.c.  */
  4828 
  4829 extern void syms_of_callint (void);
  4830 
  4831 /* Defined in casefiddle.c.  */
  4832 
  4833 extern void syms_of_casefiddle (void);
  4834 
  4835 /* Defined in casetab.c.  */
  4836 
  4837 extern void init_casetab_once (void);
  4838 extern void syms_of_casetab (void);
  4839 
  4840 /* Defined in keyboard.c.  */
  4841 
  4842 extern EMACS_INT command_loop_level;
  4843 extern Lisp_Object echo_message_buffer;
  4844 extern struct kboard *echo_kboard;
  4845 extern void cancel_echoing (void);
  4846 extern bool input_pending;
  4847 #ifdef HAVE_STACK_OVERFLOW_HANDLING
  4848 extern sigjmp_buf return_to_command_loop;
  4849 #endif
  4850 extern Lisp_Object menu_bar_items (Lisp_Object);
  4851 extern Lisp_Object tab_bar_items (Lisp_Object, int *);
  4852 extern Lisp_Object tool_bar_items (Lisp_Object, int *);
  4853 extern void discard_mouse_events (void);
  4854 #if defined (USABLE_SIGIO) || defined (USABLE_SIGPOLL)
  4855 void handle_input_available_signal (int);
  4856 #endif
  4857 extern Lisp_Object pending_funcalls;
  4858 extern bool detect_input_pending (void);
  4859 extern bool detect_input_pending_ignore_squeezables (void);
  4860 extern bool detect_input_pending_run_timers (bool);
  4861 extern void safe_run_hooks (Lisp_Object);
  4862 extern void safe_run_hooks_2 (Lisp_Object, Lisp_Object, Lisp_Object);
  4863 extern void cmd_error_internal (Lisp_Object, const char *);
  4864 extern Lisp_Object command_loop_2 (Lisp_Object);
  4865 extern Lisp_Object read_menu_command (void);
  4866 extern Lisp_Object recursive_edit_1 (void);
  4867 extern void record_auto_save (void);
  4868 extern void force_auto_save_soon (void);
  4869 extern void init_keyboard (void);
  4870 extern void syms_of_keyboard (void);
  4871 extern void keys_of_keyboard (void);
  4872 
  4873 /* Defined in indent.c.  */
  4874 extern ptrdiff_t current_column (void);
  4875 extern void invalidate_current_column (void);
  4876 extern bool indented_beyond_p (ptrdiff_t, ptrdiff_t, EMACS_INT);
  4877 extern void syms_of_indent (void);
  4878 
  4879 /* Defined in frame.c.  */
  4880 extern void store_frame_param (struct frame *, Lisp_Object, Lisp_Object);
  4881 extern void store_in_alist (Lisp_Object *, Lisp_Object, Lisp_Object);
  4882 extern Lisp_Object do_switch_frame (Lisp_Object, int, int, Lisp_Object);
  4883 extern Lisp_Object get_frame_param (struct frame *, Lisp_Object);
  4884 extern void frames_discard_buffer (Lisp_Object);
  4885 extern void init_frame_once (void);
  4886 extern void syms_of_frame (void);
  4887 
  4888 /* Defined in emacs.c.  */
  4889 extern char **initial_argv;
  4890 extern int initial_argc;
  4891 extern char const *emacs_wd;
  4892 #if defined (HAVE_X_WINDOWS) || defined (HAVE_NS)
  4893 extern bool display_arg;
  4894 #endif
  4895 extern Lisp_Object decode_env_path (const char *, const char *, bool);
  4896 extern Lisp_Object empty_unibyte_string, empty_multibyte_string;
  4897 extern AVOID terminate_due_to_signal (int, int);
  4898 #ifdef WINDOWSNT
  4899 extern Lisp_Object Vlibrary_cache;
  4900 #endif
  4901 #if HAVE_SETLOCALE
  4902 void fixup_locale (void);
  4903 void synchronize_system_messages_locale (void);
  4904 void synchronize_system_time_locale (void);
  4905 #else
  4906 INLINE void fixup_locale (void) {}
  4907 INLINE void synchronize_system_messages_locale (void) {}
  4908 INLINE void synchronize_system_time_locale (void) {}
  4909 #endif
  4910 extern char *emacs_strerror (int) ATTRIBUTE_RETURNS_NONNULL;
  4911 extern void shut_down_emacs (int, Lisp_Object);
  4912 
  4913 /* True means don't do interactive redisplay and don't change tty modes.  */
  4914 extern bool noninteractive;
  4915 
  4916 /* True means remove site-lisp directories from load-path.  */
  4917 extern bool no_site_lisp;
  4918 
  4919 /* True means put details like time stamps into builds.  */
  4920 extern bool build_details;
  4921 
  4922 #ifndef WINDOWSNT
  4923 /* 0 not a daemon, 1 foreground daemon, 2 background daemon.  */
  4924 extern int daemon_type;
  4925 #define IS_DAEMON (daemon_type != 0)
  4926 #define DAEMON_RUNNING (daemon_type >= 0)
  4927 #else  /* WINDOWSNT */
  4928 extern void *w32_daemon_event;
  4929 #define IS_DAEMON (w32_daemon_event != NULL)
  4930 #define DAEMON_RUNNING (w32_daemon_event != INVALID_HANDLE_VALUE)
  4931 #endif
  4932 
  4933 /* True if handling a fatal error already.  */
  4934 extern bool fatal_error_in_progress;
  4935 
  4936 /* True means don't do use window-system-specific display code.  */
  4937 extern bool inhibit_window_system;
  4938 /* True means that a filter or a sentinel is running.  */
  4939 extern bool running_asynch_code;
  4940 
  4941 /* Defined in process.c.  */
  4942 struct Lisp_Process;
  4943 extern void child_signal_init (void);
  4944 extern void kill_buffer_processes (Lisp_Object);
  4945 extern int wait_reading_process_output (intmax_t, int, int, bool, Lisp_Object,
  4946                                         struct Lisp_Process *, int);
  4947 /* Max value for the first argument of wait_reading_process_output.  */
  4948 #if GNUC_PREREQ (3, 0, 0) && ! GNUC_PREREQ (4, 6, 0)
  4949 /* Work around a bug in GCC 3.4.2, known to be fixed in GCC 4.6.0.
  4950    The bug merely causes a bogus warning, but the warning is annoying.  */
  4951 # define WAIT_READING_MAX min (TYPE_MAXIMUM (time_t), INTMAX_MAX)
  4952 #else
  4953 # define WAIT_READING_MAX INTMAX_MAX
  4954 #endif
  4955 #ifdef HAVE_TIMERFD
  4956 extern void add_timer_wait_descriptor (int);
  4957 #endif
  4958 extern void add_keyboard_wait_descriptor (int);
  4959 extern void delete_keyboard_wait_descriptor (int);
  4960 #ifdef HAVE_GPM
  4961 extern void add_gpm_wait_descriptor (int);
  4962 extern void delete_gpm_wait_descriptor (int);
  4963 #endif
  4964 extern void init_process_emacs (int);
  4965 extern void syms_of_process (void);
  4966 extern void setup_process_coding_systems (Lisp_Object);
  4967 
  4968 /* Defined in callproc.c.  */
  4969 #ifdef DOS_NT
  4970 # define CHILD_SETUP_ERROR_DESC "Spawning child process"
  4971 #else
  4972 # define CHILD_SETUP_ERROR_DESC "Doing vfork"
  4973 #endif
  4974 
  4975 extern int emacs_spawn (pid_t *, int, int, int, char **, char **,
  4976                         const char *, const char *, bool, bool,
  4977                         const sigset_t *);
  4978 extern char **make_environment_block (Lisp_Object) ATTRIBUTE_RETURNS_NONNULL;
  4979 extern void init_callproc_1 (void);
  4980 extern void init_callproc (void);
  4981 extern void set_initial_environment (void);
  4982 extern void syms_of_callproc (void);
  4983 
  4984 /* Defined in doc.c.  */
  4985 extern Lisp_Object read_doc_string (Lisp_Object);
  4986 extern Lisp_Object get_doc_string (Lisp_Object, bool, bool);
  4987 extern void syms_of_doc (void);
  4988 extern int read_bytecode_char (bool);
  4989 
  4990 /* Defined in bytecode.c.  */
  4991 extern void syms_of_bytecode (void);
  4992 extern Lisp_Object exec_byte_code (Lisp_Object, ptrdiff_t,
  4993                                    ptrdiff_t, Lisp_Object *);
  4994 extern Lisp_Object get_byte_code_arity (Lisp_Object);
  4995 extern void init_bc_thread (struct bc_thread_state *bc);
  4996 extern void free_bc_thread (struct bc_thread_state *bc);
  4997 extern void mark_bytecode (struct bc_thread_state *bc);
  4998 
  4999 INLINE struct bc_frame *
  5000 get_act_rec (struct thread_state *th)
  5001 {
  5002   return th->bc.fp;
  5003 }
  5004 
  5005 INLINE void
  5006 set_act_rec (struct thread_state *th, struct bc_frame *act_rec)
  5007 {
  5008   th->bc.fp = act_rec;
  5009 }
  5010 
  5011 /* Defined in macros.c.  */
  5012 extern void init_macros (void);
  5013 extern void syms_of_macros (void);
  5014 
  5015 /* Defined in undo.c.  */
  5016 extern void truncate_undo_list (struct buffer *);
  5017 extern void record_insert (ptrdiff_t, ptrdiff_t);
  5018 extern void record_delete (ptrdiff_t, Lisp_Object, bool);
  5019 extern void record_first_change (void);
  5020 extern void record_change (ptrdiff_t, ptrdiff_t);
  5021 extern void record_property_change (ptrdiff_t, ptrdiff_t,
  5022                                     Lisp_Object, Lisp_Object,
  5023                                     Lisp_Object);
  5024 extern void syms_of_undo (void);
  5025 
  5026 /* Defined in textprop.c.  */
  5027 extern void report_interval_modification (Lisp_Object, Lisp_Object);
  5028 
  5029 /* Defined in menu.c.  */
  5030 extern void syms_of_menu (void);
  5031 
  5032 /* Defined in xmenu.c.  */
  5033 extern void syms_of_xmenu (void);
  5034 
  5035 /* Defined in termchar.h.  */
  5036 struct tty_display_info;
  5037 
  5038 /* Defined in sysdep.c.  */
  5039 #ifdef HAVE_PERSONALITY_ADDR_NO_RANDOMIZE
  5040 extern int maybe_disable_address_randomization (int, char **);
  5041 #else
  5042 INLINE int
  5043 maybe_disable_address_randomization (int argc, char **argv)
  5044 {
  5045   return argc;
  5046 }
  5047 #endif
  5048 extern int emacs_exec_file (char const *, char *const *, char *const *);
  5049 extern void init_standard_fds (void);
  5050 extern char *emacs_get_current_dir_name (void);
  5051 extern void stuff_char (char c);
  5052 extern void init_foreground_group (void);
  5053 extern void sys_subshell (void);
  5054 extern void sys_suspend (void);
  5055 extern void discard_tty_input (void);
  5056 extern void init_sys_modes (struct tty_display_info *);
  5057 extern void reset_sys_modes (struct tty_display_info *);
  5058 extern void init_all_sys_modes (void);
  5059 extern void reset_all_sys_modes (void);
  5060 extern void child_setup_tty (int);
  5061 extern void setup_pty (int);
  5062 extern int set_window_size (int, int, int);
  5063 extern EMACS_INT get_random (void);
  5064 extern unsigned long int get_random_ulong (void);
  5065 extern void seed_random (void *, ptrdiff_t);
  5066 extern void init_random (void);
  5067 extern void emacs_backtrace (int);
  5068 extern AVOID emacs_abort (void) NO_INLINE;
  5069 extern int emacs_fstatat (int, char const *, void *, int);
  5070 extern int emacs_openat (int, char const *, int, int);
  5071 extern int emacs_open (const char *, int, int);
  5072 extern int emacs_open_noquit (const char *, int, int);
  5073 extern int emacs_pipe (int[2]);
  5074 extern int emacs_close (int);
  5075 extern ptrdiff_t emacs_read (int, void *, ptrdiff_t);
  5076 extern ptrdiff_t emacs_read_quit (int, void *, ptrdiff_t);
  5077 extern ptrdiff_t emacs_write (int, void const *, ptrdiff_t);
  5078 extern ptrdiff_t emacs_write_sig (int, void const *, ptrdiff_t);
  5079 extern ptrdiff_t emacs_write_quit (int, void const *, ptrdiff_t);
  5080 extern void emacs_perror (char const *);
  5081 extern int renameat_noreplace (int, char const *, int, char const *);
  5082 extern int str_collate (Lisp_Object, Lisp_Object, Lisp_Object, Lisp_Object);
  5083 extern void syms_of_sysdep (void);
  5084 
  5085 /* Defined in filelock.c.  */
  5086 extern void unlock_all_files (void);
  5087 extern void unlock_buffer (struct buffer *);
  5088 extern void syms_of_filelock (void);
  5089 
  5090 /* Defined in sound.c.  */
  5091 extern void syms_of_sound (void);
  5092 
  5093 /* Defined in category.c.  */
  5094 extern void init_category_once (void);
  5095 extern Lisp_Object char_category_set (int);
  5096 extern void syms_of_category (void);
  5097 
  5098 /* Defined in ccl.c.  */
  5099 extern void syms_of_ccl (void);
  5100 
  5101 /* Defined in dired.c.  */
  5102 extern void syms_of_dired (void);
  5103 extern Lisp_Object directory_files_internal (Lisp_Object, Lisp_Object,
  5104                                              Lisp_Object, Lisp_Object,
  5105                                              bool, Lisp_Object, Lisp_Object);
  5106 
  5107 /* Defined in term.c.  */
  5108 extern int *char_ins_del_vector;
  5109 extern void syms_of_term (void);
  5110 extern AVOID fatal (const char *msgid, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
  5111 
  5112 /* Defined in terminal.c.  */
  5113 extern void syms_of_terminal (void);
  5114 extern char * tty_type_name (Lisp_Object);
  5115 
  5116 /* Defined in font.c.  */
  5117 extern void syms_of_font (void);
  5118 extern void init_font (void);
  5119 
  5120 #ifdef HAVE_WINDOW_SYSTEM
  5121 /* Defined in fontset.c.  */
  5122 extern void syms_of_fontset (void);
  5123 #endif
  5124 
  5125 /* Defined in inotify.c */
  5126 #ifdef HAVE_INOTIFY
  5127 extern void syms_of_inotify (void);
  5128 #endif
  5129 
  5130 /* Defined in kqueue.c */
  5131 #ifdef HAVE_KQUEUE
  5132 extern void globals_of_kqueue (void);
  5133 extern void syms_of_kqueue (void);
  5134 #endif
  5135 
  5136 /* Defined in gfilenotify.c */
  5137 #ifdef HAVE_GFILENOTIFY
  5138 extern void globals_of_gfilenotify (void);
  5139 extern void syms_of_gfilenotify (void);
  5140 #endif
  5141 
  5142 #ifdef HAVE_W32NOTIFY
  5143 /* Defined on w32notify.c.  */
  5144 extern void syms_of_w32notify (void);
  5145 #endif
  5146 
  5147 #if defined HAVE_NTGUI || defined CYGWIN
  5148 /* Defined in w32cygwinx.c.  */
  5149 extern void syms_of_w32cygwinx (void);
  5150 #endif
  5151 
  5152 /* Defined in xfaces.c.  */
  5153 extern Lisp_Object Vface_alternative_font_family_alist;
  5154 extern Lisp_Object Vface_alternative_font_registry_alist;
  5155 extern void syms_of_xfaces (void);
  5156 extern void init_xfaces (void);
  5157 
  5158 #ifdef HAVE_X_WINDOWS
  5159 /* Defined in xfns.c.  */
  5160 extern void syms_of_xfns (void);
  5161 
  5162 /* Defined in xsmfns.c.  */
  5163 extern void syms_of_xsmfns (void);
  5164 
  5165 /* Defined in xselect.c.  */
  5166 extern void syms_of_xselect (void);
  5167 
  5168 /* Defined in xterm.c.  */
  5169 extern void init_xterm (void);
  5170 extern void syms_of_xterm (void);
  5171 #endif /* HAVE_X_WINDOWS */
  5172 
  5173 #ifdef HAVE_WINDOW_SYSTEM
  5174 /* Defined in xterm.c, nsterm.m, w32term.c.  */
  5175 extern char *get_keysym_name (int);
  5176 #endif /* HAVE_WINDOW_SYSTEM */
  5177 
  5178 /* Defined in xml.c.  */
  5179 extern void syms_of_xml (void);
  5180 #ifdef HAVE_LIBXML2
  5181 extern void xml_cleanup_parser (void);
  5182 #endif
  5183 
  5184 #ifdef HAVE_LCMS2
  5185 /* Defined in lcms.c.  */
  5186 extern void syms_of_lcms2 (void);
  5187 #endif
  5188 
  5189 #ifdef HAVE_ZLIB
  5190 
  5191 #include <stdio.h>
  5192 
  5193 /* Defined in decompress.c.  */
  5194 extern int md5_gz_stream (FILE *, void *);
  5195 extern void syms_of_decompress (void);
  5196 #endif
  5197 
  5198 #ifdef HAVE_DBUS
  5199 /* Defined in dbusbind.c.  */
  5200 void init_dbusbind (void);
  5201 void syms_of_dbusbind (void);
  5202 #endif
  5203 
  5204 
  5205 /* Defined in profiler.c.  */
  5206 extern bool profiler_memory_running;
  5207 extern void malloc_probe (size_t);
  5208 extern void syms_of_profiler (void);
  5209 
  5210 
  5211 #ifdef DOS_NT
  5212 /* Defined in msdos.c, w32.c.  */
  5213 extern char *emacs_root_dir (void);
  5214 #endif /* DOS_NT */
  5215 
  5216 #ifdef HAVE_NATIVE_COMP
  5217 INLINE bool
  5218 SUBR_NATIVE_COMPILEDP (Lisp_Object a)
  5219 {
  5220   return SUBRP (a) && !NILP (XSUBR (a)->native_comp_u);
  5221 }
  5222 
  5223 INLINE bool
  5224 SUBR_NATIVE_COMPILED_DYNP (Lisp_Object a)
  5225 {
  5226   return SUBR_NATIVE_COMPILEDP (a) && !NILP (XSUBR (a)->lambda_list);
  5227 }
  5228 
  5229 INLINE Lisp_Object
  5230 SUBR_TYPE (Lisp_Object a)
  5231 {
  5232   return XSUBR (a)->type;
  5233 }
  5234 
  5235 INLINE struct Lisp_Native_Comp_Unit *
  5236 allocate_native_comp_unit (void)
  5237 {
  5238   return ALLOCATE_ZEROED_PSEUDOVECTOR (struct Lisp_Native_Comp_Unit,
  5239                                        data_impure_vec, PVEC_NATIVE_COMP_UNIT);
  5240 }
  5241 #else
  5242 INLINE bool
  5243 SUBR_NATIVE_COMPILEDP (Lisp_Object a)
  5244 {
  5245   return false;
  5246 }
  5247 
  5248 INLINE bool
  5249 SUBR_NATIVE_COMPILED_DYNP (Lisp_Object a)
  5250 {
  5251   return false;
  5252 }
  5253 
  5254 #endif
  5255 
  5256 /* Defined in lastfile.c.  */
  5257 extern char my_edata[];
  5258 extern char my_endbss[];
  5259 extern char *my_endbss_static;
  5260 
  5261 extern void *xmalloc (size_t)
  5262   ATTRIBUTE_MALLOC_SIZE ((1)) ATTRIBUTE_RETURNS_NONNULL;
  5263 extern void *xzalloc (size_t)
  5264   ATTRIBUTE_MALLOC_SIZE ((1)) ATTRIBUTE_RETURNS_NONNULL;
  5265 extern void *xrealloc (void *, size_t)
  5266   ATTRIBUTE_ALLOC_SIZE ((2)) ATTRIBUTE_RETURNS_NONNULL;
  5267 extern void xfree (void *);
  5268 extern void *xnmalloc (ptrdiff_t, ptrdiff_t)
  5269   ATTRIBUTE_MALLOC_SIZE ((1,2)) ATTRIBUTE_RETURNS_NONNULL;
  5270 extern void *xnrealloc (void *, ptrdiff_t, ptrdiff_t)
  5271   ATTRIBUTE_ALLOC_SIZE ((2,3)) ATTRIBUTE_RETURNS_NONNULL;
  5272 extern void *xpalloc (void *, ptrdiff_t *, ptrdiff_t, ptrdiff_t, ptrdiff_t)
  5273   ATTRIBUTE_RETURNS_NONNULL;
  5274 
  5275 extern char *xstrdup (char const *)
  5276   ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
  5277 extern char *xlispstrdup (Lisp_Object)
  5278   ATTRIBUTE_MALLOC ATTRIBUTE_RETURNS_NONNULL;
  5279 extern void dupstring (char **, char const *);
  5280 
  5281 /* Make DEST a copy of STRING's data.  Return a pointer to DEST's terminating
  5282    null byte.  This is like stpcpy, except the source is a Lisp string.  */
  5283 
  5284 INLINE char *
  5285 lispstpcpy (char *dest, Lisp_Object string)
  5286 {
  5287   ptrdiff_t len = SBYTES (string);
  5288   memcpy (dest, SDATA (string), len + 1);
  5289   return dest + len;
  5290 }
  5291 
  5292 #if (defined HAVE___LSAN_IGNORE_OBJECT \
  5293      && defined HAVE_SANITIZER_LSAN_INTERFACE_H)
  5294 # include <sanitizer/lsan_interface.h>
  5295 #else
  5296 /* Treat *P as a non-leak.  */
  5297 INLINE void
  5298 __lsan_ignore_object (void const *p)
  5299 {
  5300 }
  5301 #endif
  5302 
  5303 extern void xputenv (const char *);
  5304 
  5305 extern char *egetenv_internal (const char *, ptrdiff_t);
  5306 
  5307 INLINE char *
  5308 egetenv (const char *var)
  5309 {
  5310   /* When VAR is a string literal, strlen can be optimized away.  */
  5311   return egetenv_internal (var, strlen (var));
  5312 }
  5313 
  5314 /* Set up the name of the machine we're running on.  */
  5315 extern void init_system_name (void);
  5316 
  5317 /* Return the absolute value of X.  X should be a signed integer
  5318    expression without side effects, and X's absolute value should not
  5319    exceed the maximum for its promoted type.  This is called 'eabs'
  5320    because 'abs' is reserved by the C standard.  */
  5321 #define eabs(x)         ((x) < 0 ? -(x) : (x))
  5322 
  5323 /* SAFE_ALLOCA normally allocates memory on the stack, but if size is
  5324    larger than MAX_ALLOCA, use xmalloc to avoid overflowing the stack.  */
  5325 
  5326 enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
  5327 
  5328 extern void *record_xmalloc (size_t)
  5329   ATTRIBUTE_ALLOC_SIZE ((1)) ATTRIBUTE_RETURNS_NONNULL;
  5330 
  5331 #define USE_SAFE_ALLOCA                 \
  5332   ptrdiff_t sa_avail = MAX_ALLOCA;      \
  5333   specpdl_ref sa_count = SPECPDL_INDEX ()
  5334 
  5335 #define AVAIL_ALLOCA(size) (sa_avail -= (size), alloca (size))
  5336 
  5337 /* SAFE_ALLOCA allocates a simple buffer.  */
  5338 
  5339 #define SAFE_ALLOCA(size) ((size) <= sa_avail                           \
  5340                            ? AVAIL_ALLOCA (size)                        \
  5341                            : record_xmalloc (size))
  5342 
  5343 /* SAFE_NALLOCA sets BUF to a newly allocated array of MULTIPLIER *
  5344    NITEMS items, each of the same type as *BUF.  MULTIPLIER must
  5345    positive.  The code is tuned for MULTIPLIER being a constant.  */
  5346 
  5347 #define SAFE_NALLOCA(buf, multiplier, nitems)                    \
  5348   do {                                                           \
  5349     if ((nitems) <= sa_avail / sizeof *(buf) / (multiplier))     \
  5350       (buf) = AVAIL_ALLOCA (sizeof *(buf) * (multiplier) * (nitems)); \
  5351     else                                                         \
  5352       {                                                          \
  5353         (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \
  5354         record_unwind_protect_ptr (xfree, buf);                  \
  5355       }                                                          \
  5356   } while (false)
  5357 
  5358 /* SAFE_ALLOCA_STRING allocates a C copy of a Lisp string.  */
  5359 
  5360 #define SAFE_ALLOCA_STRING(ptr, string)                 \
  5361   do {                                                  \
  5362     (ptr) = SAFE_ALLOCA (SBYTES (string) + 1);          \
  5363     memcpy (ptr, SDATA (string), SBYTES (string) + 1);  \
  5364   } while (false)
  5365 
  5366 /* Free xmalloced memory and enable GC as needed.  */
  5367 
  5368 #define SAFE_FREE() safe_free (sa_count)
  5369 
  5370 INLINE void
  5371 safe_free (specpdl_ref sa_count)
  5372 {
  5373   while (specpdl_ptr != specpdl_ref_to_ptr (sa_count))
  5374     {
  5375       specpdl_ptr--;
  5376       if (specpdl_ptr->kind == SPECPDL_UNWIND_PTR)
  5377         {
  5378           eassert (specpdl_ptr->unwind_ptr.func == xfree);
  5379           xfree (specpdl_ptr->unwind_ptr.arg);
  5380         }
  5381       else
  5382         {
  5383           eassert (specpdl_ptr->kind == SPECPDL_UNWIND_ARRAY);
  5384           xfree (specpdl_ptr->unwind_array.array);
  5385         }
  5386     }
  5387 }
  5388 
  5389 /* Pop the specpdl stack back to COUNT, and return VAL.
  5390    Prefer this to { SAFE_FREE (); unbind_to (COUNT, VAL); }
  5391    when COUNT predates USE_SAFE_ALLOCA, as it is a bit more efficient
  5392    and also lets callers intermix SAFE_ALLOCA calls with other calls
  5393    that grow the specpdl stack.  */
  5394 
  5395 #define SAFE_FREE_UNBIND_TO(count, val) \
  5396   safe_free_unbind_to (count, sa_count, val)
  5397 
  5398 INLINE Lisp_Object
  5399 safe_free_unbind_to (specpdl_ref count, specpdl_ref sa_count, Lisp_Object val)
  5400 {
  5401   eassert (!specpdl_ref_lt (sa_count, count));
  5402   return unbind_to (count, val);
  5403 }
  5404 
  5405 /* Set BUF to point to an allocated array of NELT Lisp_Objects,
  5406    immediately followed by EXTRA spare bytes.  */
  5407 
  5408 #define SAFE_ALLOCA_LISP_EXTRA(buf, nelt, extra)               \
  5409   do {                                                         \
  5410     ptrdiff_t alloca_nbytes;                                   \
  5411     if (INT_MULTIPLY_WRAPV (nelt, word_size, &alloca_nbytes)   \
  5412         || INT_ADD_WRAPV (alloca_nbytes, extra, &alloca_nbytes) \
  5413         || SIZE_MAX < alloca_nbytes)                           \
  5414       memory_full (SIZE_MAX);                                  \
  5415     else if (alloca_nbytes <= sa_avail)                        \
  5416       (buf) = AVAIL_ALLOCA (alloca_nbytes);                    \
  5417     else                                                       \
  5418       {                                                        \
  5419         /* Although only the first nelt words need clearing,   \
  5420            typically EXTRA is 0 or small so just use xzalloc;  \
  5421            this is simpler and often faster.  */               \
  5422         (buf) = xzalloc (alloca_nbytes);                       \
  5423         record_unwind_protect_array (buf, nelt);               \
  5424       }                                                        \
  5425   } while (false)
  5426 
  5427 /* Set BUF to point to an allocated array of NELT Lisp_Objects.  */
  5428 
  5429 #define SAFE_ALLOCA_LISP(buf, nelt) SAFE_ALLOCA_LISP_EXTRA (buf, nelt, 0)
  5430 
  5431 
  5432 /* If USE_STACK_LISP_OBJECTS, define macros and functions that
  5433    allocate some Lisp objects on the C stack.  As the storage is not
  5434    managed by the garbage collector, these objects are dangerous:
  5435    passing them to user code could result in undefined behavior if the
  5436    objects are in use after the C function returns.  Conversely, these
  5437    objects have better performance because GC is not involved.
  5438 
  5439    While debugging you may want to disable allocation on the C stack.
  5440    Build with CPPFLAGS='-DUSE_STACK_LISP_OBJECTS=0' to disable it.  */
  5441 
  5442 #if (!defined USE_STACK_LISP_OBJECTS \
  5443      && defined __GNUC__ && !defined __clang__ && ! GNUC_PREREQ (4, 3, 2))
  5444   /* Work around GCC bugs 36584 and 35271, which were fixed in GCC 4.3.2.  */
  5445 # define USE_STACK_LISP_OBJECTS false
  5446 #endif
  5447 #ifndef USE_STACK_LISP_OBJECTS
  5448 # define USE_STACK_LISP_OBJECTS true
  5449 #endif
  5450 
  5451 #ifdef GC_CHECK_STRING_BYTES
  5452 enum { defined_GC_CHECK_STRING_BYTES = true };
  5453 #else
  5454 enum { defined_GC_CHECK_STRING_BYTES = false };
  5455 #endif
  5456 
  5457 /* True for stack-based cons and string implementations, respectively.
  5458    Use stack-based strings only if stack-based cons also works.
  5459    Otherwise, STACK_CONS would create heap-based cons cells that
  5460    could point to stack-based strings, which is a no-no.  */
  5461 
  5462 enum
  5463   {
  5464     USE_STACK_CONS = USE_STACK_LISP_OBJECTS,
  5465     USE_STACK_STRING = (USE_STACK_CONS
  5466                         && !defined_GC_CHECK_STRING_BYTES)
  5467   };
  5468 
  5469 /* Auxiliary macros used for auto allocation of Lisp objects.  Please
  5470    use these only in macros like AUTO_CONS that declare a local
  5471    variable whose lifetime will be clear to the programmer.  */
  5472 #define STACK_CONS(a, b) \
  5473   make_lisp_ptr (&((struct Lisp_Cons) {{{a, {b}}}}), Lisp_Cons)
  5474 #define AUTO_CONS_EXPR(a, b) \
  5475   (USE_STACK_CONS ? STACK_CONS (a, b) : Fcons (a, b))
  5476 
  5477 /* Declare NAME as an auto Lisp cons or short list if possible, a
  5478    GC-based one otherwise.  This is in the sense of the C keyword
  5479    'auto'; i.e., the object has the lifetime of the containing block.
  5480    The resulting object should not be made visible to user Lisp code.  */
  5481 
  5482 #define AUTO_CONS(name, a, b) Lisp_Object name = AUTO_CONS_EXPR (a, b)
  5483 #define AUTO_LIST1(name, a)                                             \
  5484   Lisp_Object name = (USE_STACK_CONS ? STACK_CONS (a, Qnil) : list1 (a))
  5485 #define AUTO_LIST2(name, a, b)                                          \
  5486   Lisp_Object name = (USE_STACK_CONS                                    \
  5487                       ? STACK_CONS (a, STACK_CONS (b, Qnil))            \
  5488                       : list2 (a, b))
  5489 #define AUTO_LIST3(name, a, b, c)                                       \
  5490   Lisp_Object name = (USE_STACK_CONS                                    \
  5491                       ? STACK_CONS (a, STACK_CONS (b, STACK_CONS (c, Qnil))) \
  5492                       : list3 (a, b, c))
  5493 #define AUTO_LIST4(name, a, b, c, d)                                    \
  5494     Lisp_Object name                                                    \
  5495       = (USE_STACK_CONS                                                 \
  5496          ? STACK_CONS (a, STACK_CONS (b, STACK_CONS (c,                 \
  5497                                                      STACK_CONS (d, Qnil)))) \
  5498          : list4 (a, b, c, d))
  5499 
  5500 /* Declare NAME as an auto Lisp string if possible, a GC-based one if not.
  5501    Take its unibyte value from the null-terminated string STR,
  5502    an expression that should not have side effects.
  5503    STR's value is not necessarily copied.  The resulting Lisp string
  5504    should not be modified or given text properties or made visible to
  5505    user code.  */
  5506 
  5507 #define AUTO_STRING(name, str) \
  5508   AUTO_STRING_WITH_LEN (name, str, strlen (str))
  5509 
  5510 /* Declare NAME as an auto Lisp string if possible, a GC-based one if not.
  5511    Take its unibyte value from the null-terminated string STR with length LEN.
  5512    STR may have side effects and may contain null bytes.
  5513    STR's value is not necessarily copied.  The resulting Lisp string
  5514    should not be modified or given text properties or made visible to
  5515    user code.  */
  5516 
  5517 #define AUTO_STRING_WITH_LEN(name, str, len)                            \
  5518   Lisp_Object name =                                                    \
  5519     (USE_STACK_STRING                                                   \
  5520      ? (make_lisp_ptr                                                   \
  5521         ((&(struct Lisp_String) {{{len, -1, 0, (unsigned char *) (str)}}}), \
  5522          Lisp_String))                                                  \
  5523      : make_unibyte_string (str, len))
  5524 
  5525 /* The maximum length of "small" lists, as a heuristic.  These lists
  5526    are so short that code need not check for cycles or quits while
  5527    traversing.  */
  5528 enum { SMALL_LIST_LEN_MAX = 127 };
  5529 
  5530 /* Loop over conses of the list TAIL, signaling if a cycle is found,
  5531    and possibly quitting after each loop iteration.  In the loop body,
  5532    set TAIL to the current cons.  If the loop exits normally,
  5533    set TAIL to the terminating non-cons, typically nil.  The loop body
  5534    should not modify the list’s top level structure other than by
  5535    perhaps deleting the current cons.  */
  5536 
  5537 #define FOR_EACH_TAIL(tail) \
  5538   FOR_EACH_TAIL_INTERNAL (tail, circular_list (tail), true)
  5539 
  5540 /* Like FOR_EACH_TAIL (TAIL), except do not signal or quit.
  5541    If the loop exits due to a cycle, TAIL’s value is undefined.  */
  5542 
  5543 #define FOR_EACH_TAIL_SAFE(tail) \
  5544   FOR_EACH_TAIL_INTERNAL (tail, (void) ((tail) = Qnil), false)
  5545 
  5546 /* Iterator intended for use only within FOR_EACH_TAIL_INTERNAL.  */
  5547 struct for_each_tail_internal
  5548 {
  5549   Lisp_Object tortoise;
  5550   intptr_t max, n;
  5551   unsigned short int q;
  5552 };
  5553 
  5554 /* Like FOR_EACH_TAIL (LIST), except evaluate CYCLE if a cycle is
  5555    found, and check for quit if CHECK_QUIT.  This is an internal macro
  5556    intended for use only by the above macros.
  5557 
  5558    Use Brent’s teleporting tortoise-hare algorithm.  See:
  5559    Brent RP. BIT. 1980;20(2):176-184. doi:10.1007/BF01933190
  5560    https://maths-people.anu.edu.au/~brent/pd/rpb051i.pdf
  5561 
  5562    This macro uses maybe_quit because of an excess of caution.  The
  5563    call to maybe_quit should not be needed in practice, as a very long
  5564    list, whether circular or not, will cause Emacs to be so slow in
  5565    other uninterruptible areas (e.g., garbage collection) that there
  5566    is little point to calling maybe_quit here.  */
  5567 
  5568 #define FOR_EACH_TAIL_INTERNAL(tail, cycle, check_quit)                 \
  5569   for (struct for_each_tail_internal li = { tail, 2, 0, 2 };            \
  5570        CONSP (tail);                                                    \
  5571        ((tail) = XCDR (tail),                                           \
  5572         ((--li.q != 0                                                   \
  5573           || ((check_quit) ? maybe_quit () : (void) 0, 0 < --li.n)      \
  5574           || (li.q = li.n = li.max <<= 1, li.n >>= USHRT_WIDTH,         \
  5575               li.tortoise = (tail), false))                             \
  5576          && BASE_EQ (tail, li.tortoise))                                \
  5577         ? (cycle) : (void) 0))
  5578 
  5579 /* Do a `for' loop over alist values.  */
  5580 
  5581 #define FOR_EACH_ALIST_VALUE(head_var, list_var, value_var)             \
  5582   for ((list_var) = (head_var);                                         \
  5583        (CONSP (list_var) && ((value_var) = XCDR (XCAR (list_var)), true)); \
  5584        (list_var) = XCDR (list_var))
  5585 
  5586 /* Check whether it's time for GC, and run it if so.  */
  5587 
  5588 INLINE void
  5589 maybe_gc (void)
  5590 {
  5591   if (consing_until_gc < 0)
  5592     maybe_garbage_collect ();
  5593 }
  5594 
  5595 /* Simplified version of 'define-error' that works with pure
  5596    objects.  */
  5597 void
  5598 define_error (Lisp_Object name, const char *message, Lisp_Object parent);
  5599 
  5600 INLINE_HEADER_END
  5601 
  5602 #endif /* EMACS_LISP_H */

/* [<][>][^][v][top][bottom][index][help] */