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