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