aboutsummaryrefslogtreecommitdiffstats
path: root/src/lisp.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lisp.h')
-rw-r--r--src/lisp.h114
1 files changed, 62 insertions, 52 deletions
diff --git a/src/lisp.h b/src/lisp.h
index e194a1ef765..26238113173 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -441,8 +441,7 @@ enum Lisp_Fwd_Type
441 displayed to users. These are Lisp_Save_Value, a Lisp_Misc 441 displayed to users. These are Lisp_Save_Value, a Lisp_Misc
442 subtype; and PVEC_OTHER, a kind of vectorlike object. The former 442 subtype; and PVEC_OTHER, a kind of vectorlike object. The former
443 is suitable for temporarily stashing away pointers and integers in 443 is suitable for temporarily stashing away pointers and integers in
444 a Lisp object (see the existing uses of make_save_value and 444 a Lisp object. The latter is useful for vector-like Lisp objects
445 XSAVE_VALUE). The latter is useful for vector-like Lisp objects
446 that need to be used as part of other objects, but which are never 445 that need to be used as part of other objects, but which are never
447 shown to users or Lisp code (search for PVEC_OTHER in xterm.c for 446 shown to users or Lisp code (search for PVEC_OTHER in xterm.c for
448 an example). 447 an example).
@@ -1819,46 +1818,27 @@ enum Lisp_Save_Type
1819/* Special object used to hold a different values for later use. 1818/* Special object used to hold a different values for later use.
1820 1819
1821 This is mostly used to package C integers and pointers to call 1820 This is mostly used to package C integers and pointers to call
1822 record_unwind_protect. A typical task is to pass just one C object 1821 record_unwind_protect when two or more values need to be saved.
1823 pointer to the unwind function. You should pack an object pointer with 1822 For example:
1824 make_save_pointer and then get it back with XSAVE_POINTER, e.g.:
1825 1823
1826 ... 1824 ...
1827 struct my_data *md = get_my_data (); 1825 struct my_data *md = get_my_data ();
1828 record_unwind_protect (my_unwind, make_save_pointer (md)); 1826 ptrdiff_t mi = get_my_integer ();
1827 record_unwind_protect (my_unwind, make_save_ptr_int (md, mi));
1829 ... 1828 ...
1830 1829
1831 Lisp_Object my_unwind (Lisp_Object arg) 1830 Lisp_Object my_unwind (Lisp_Object arg)
1832 { 1831 {
1833 struct my_data *md = XSAVE_POINTER (arg, 0); 1832 struct my_data *md = XSAVE_POINTER (arg, 0);
1834 ... 1833 ptrdiff_t mi = XSAVE_INTEGER (arg, 1);
1835 }
1836
1837 If you need to pass something else you can use make_save_value,
1838 which allows you to pack up to SAVE_VALUE_SLOTS integers, pointers,
1839 function pointers or Lisp_Objects and conveniently get them back
1840 with XSAVE_INTEGER, XSAVE_POINTER, XSAVE_FUNCPOINTER, and
1841 XSAVE_OBJECT macros:
1842
1843 ...
1844 struct my_data *md = get_my_data ();
1845 Lisp_Object my_object = get_my_object ();
1846 record_unwind_protect
1847 (my_unwind, make_save_value (SAVE_TYPE_PTR_OBJ, md, my_object));
1848 ...
1849
1850 Lisp_Object my_unwind (Lisp_Object arg)
1851 {
1852 struct my_data *md = XSAVE_POINTER (arg, 0);
1853 Lisp_Object my_object = XSAVE_OBJECT (arg, 1);
1854 ... 1834 ...
1855 } 1835 }
1856 1836
1857 If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the 1837 If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the
1858 saved objects and raise eassert if type of the saved object doesn't match 1838 saved objects and raise eassert if type of the saved object doesn't match
1859 the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2) 1839 the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2)
1860 or XSAVE_OBJECT (arg, 0) are wrong because nothing was saved in slot 2 and 1840 and XSAVE_OBJECT (arg, 0) are wrong because nothing was saved in slot 2 and
1861 Lisp_Object was saved in slot 1 of ARG. */ 1841 slot 0 is a pointer. */
1862 1842
1863typedef void (*voidfuncptr) (void); 1843typedef void (*voidfuncptr) (void);
1864 1844
@@ -1868,12 +1848,13 @@ struct Lisp_Save_Value
1868 unsigned gcmarkbit : 1; 1848 unsigned gcmarkbit : 1;
1869 int spacer : 32 - (16 + 1 + SAVE_TYPE_BITS); 1849 int spacer : 32 - (16 + 1 + SAVE_TYPE_BITS);
1870 1850
1871 /* DATA[N] may hold up to SAVE_VALUE_SLOTS entries. The type of 1851 /* V->data may hold up to SAVE_VALUE_SLOTS entries. The type of
1872 V's Ith entry is given by save_type (V, I). E.g., if save_type 1852 V's data entries are determined by V->save_type. E.g., if
1873 (V, 3) == SAVE_INTEGER, V->data[3].integer is in use. 1853 V->save_type == SAVE_TYPE_PTR_OBJ, V->data[0] is a pointer,
1854 V->data[1] is an integer, and V's other data entries are unused.
1874 1855
1875 If SAVE_TYPE == SAVE_TYPE_MEMORY, DATA[0].pointer is the address of 1856 If V->save_type == SAVE_TYPE_MEMORY, V->data[0].pointer is the address of
1876 a memory area containing DATA[1].integer potential Lisp_Objects. */ 1857 a memory area containing V->data[1].integer potential Lisp_Objects. */
1877 ENUM_BF (Lisp_Save_Type) save_type : SAVE_TYPE_BITS; 1858 ENUM_BF (Lisp_Save_Type) save_type : SAVE_TYPE_BITS;
1878 union { 1859 union {
1879 void *pointer; 1860 void *pointer;
@@ -2706,10 +2687,11 @@ typedef jmp_buf sys_jmp_buf;
2706 used all over the place, needs to be fast, and needs to know the size of 2687 used all over the place, needs to be fast, and needs to know the size of
2707 union specbinding. But only eval.c should access it. */ 2688 union specbinding. But only eval.c should access it. */
2708 2689
2709typedef Lisp_Object (*specbinding_func) (Lisp_Object);
2710
2711enum specbind_tag { 2690enum specbind_tag {
2712 SPECPDL_UNWIND, /* An unwind_protect function. */ 2691 SPECPDL_UNWIND, /* An unwind_protect function on Lisp_Object. */
2692 SPECPDL_UNWIND_PTR, /* Likewise, on void *. */
2693 SPECPDL_UNWIND_INT, /* Likewise, on int. */
2694 SPECPDL_UNWIND_VOID, /* Likewise, with no arg. */
2713 SPECPDL_BACKTRACE, /* An element of the backtrace. */ 2695 SPECPDL_BACKTRACE, /* An element of the backtrace. */
2714 SPECPDL_LET, /* A plain and simple dynamic let-binding. */ 2696 SPECPDL_LET, /* A plain and simple dynamic let-binding. */
2715 /* Tags greater than SPECPDL_LET must be "subkinds" of LET. */ 2697 /* Tags greater than SPECPDL_LET must be "subkinds" of LET. */
@@ -2722,11 +2704,25 @@ union specbinding
2722 ENUM_BF (specbind_tag) kind : CHAR_BIT; 2704 ENUM_BF (specbind_tag) kind : CHAR_BIT;
2723 struct { 2705 struct {
2724 ENUM_BF (specbind_tag) kind : CHAR_BIT; 2706 ENUM_BF (specbind_tag) kind : CHAR_BIT;
2707 void (*func) (Lisp_Object);
2725 Lisp_Object arg; 2708 Lisp_Object arg;
2726 specbinding_func func;
2727 } unwind; 2709 } unwind;
2728 struct { 2710 struct {
2729 ENUM_BF (specbind_tag) kind : CHAR_BIT; 2711 ENUM_BF (specbind_tag) kind : CHAR_BIT;
2712 void (*func) (void *);
2713 void *arg;
2714 } unwind_ptr;
2715 struct {
2716 ENUM_BF (specbind_tag) kind : CHAR_BIT;
2717 void (*func) (int);
2718 int arg;
2719 } unwind_int;
2720 struct {
2721 ENUM_BF (specbind_tag) kind : CHAR_BIT;
2722 void (*func) (void);
2723 } unwind_void;
2724 struct {
2725 ENUM_BF (specbind_tag) kind : CHAR_BIT;
2730 /* `where' is not used in the case of SPECPDL_LET. */ 2726 /* `where' is not used in the case of SPECPDL_LET. */
2731 Lisp_Object symbol, old_value, where; 2727 Lisp_Object symbol, old_value, where;
2732 } let; 2728 } let;
@@ -3423,7 +3419,7 @@ extern void add_to_log (const char *, Lisp_Object, Lisp_Object);
3423extern void check_message_stack (void); 3419extern void check_message_stack (void);
3424extern void setup_echo_area_for_printing (int); 3420extern void setup_echo_area_for_printing (int);
3425extern bool push_message (void); 3421extern bool push_message (void);
3426extern Lisp_Object pop_message_unwind (Lisp_Object); 3422extern void pop_message_unwind (void);
3427extern Lisp_Object restore_message_unwind (Lisp_Object); 3423extern Lisp_Object restore_message_unwind (Lisp_Object);
3428extern void restore_message (void); 3424extern void restore_message (void);
3429extern Lisp_Object current_message (void); 3425extern Lisp_Object current_message (void);
@@ -3585,8 +3581,16 @@ extern bool abort_on_gc;
3585extern Lisp_Object make_float (double); 3581extern Lisp_Object make_float (double);
3586extern void display_malloc_warning (void); 3582extern void display_malloc_warning (void);
3587extern ptrdiff_t inhibit_garbage_collection (void); 3583extern ptrdiff_t inhibit_garbage_collection (void);
3588extern Lisp_Object make_save_value (enum Lisp_Save_Type, ...); 3584extern Lisp_Object make_save_int_int_int (ptrdiff_t, ptrdiff_t, ptrdiff_t);
3589extern Lisp_Object make_save_pointer (void *); 3585extern Lisp_Object make_save_obj_obj_obj_obj (Lisp_Object, Lisp_Object,
3586 Lisp_Object, Lisp_Object);
3587extern Lisp_Object make_save_ptr (void *);
3588extern Lisp_Object make_save_ptr_int (void *, ptrdiff_t);
3589extern Lisp_Object make_save_ptr_ptr (void *, void *);
3590extern Lisp_Object make_save_funcptr_ptr_obj (void (*) (void), void *,
3591 Lisp_Object);
3592extern Lisp_Object make_save_memory (Lisp_Object *, ptrdiff_t);
3593extern void free_save_value (Lisp_Object);
3590extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); 3594extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object);
3591extern void free_marker (Lisp_Object); 3595extern void free_marker (Lisp_Object);
3592extern void free_cons (struct Lisp_Cons *); 3596extern void free_cons (struct Lisp_Cons *);
@@ -3743,12 +3747,18 @@ extern Lisp_Object internal_condition_case_n
3743 (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *, 3747 (Lisp_Object (*) (ptrdiff_t, Lisp_Object *), ptrdiff_t, Lisp_Object *,
3744 Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *)); 3748 Lisp_Object, Lisp_Object (*) (Lisp_Object, ptrdiff_t, Lisp_Object *));
3745extern void specbind (Lisp_Object, Lisp_Object); 3749extern void specbind (Lisp_Object, Lisp_Object);
3746extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); 3750extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object);
3751extern void record_unwind_protect_int (void (*) (int), int);
3752extern void record_unwind_protect_ptr (void (*) (void *), void *);
3753extern void record_unwind_protect_void (void (*) (void));
3754extern void record_unwind_protect_nothing (void);
3755extern void clear_unwind_protect (ptrdiff_t);
3756extern void set_unwind_protect_ptr (ptrdiff_t, void (*) (void *), void *);
3747extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object); 3757extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object);
3748extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); 3758extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2);
3749extern _Noreturn void verror (const char *, va_list) 3759extern _Noreturn void verror (const char *, va_list)
3750 ATTRIBUTE_FORMAT_PRINTF (1, 0); 3760 ATTRIBUTE_FORMAT_PRINTF (1, 0);
3751extern Lisp_Object un_autoload (Lisp_Object); 3761extern void un_autoload (Lisp_Object);
3752extern Lisp_Object call_debugger (Lisp_Object arg); 3762extern Lisp_Object call_debugger (Lisp_Object arg);
3753extern void init_eval_once (void); 3763extern void init_eval_once (void);
3754extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); 3764extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...);
@@ -3756,6 +3766,7 @@ extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object);
3756extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); 3766extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object);
3757extern void init_eval (void); 3767extern void init_eval (void);
3758extern void syms_of_eval (void); 3768extern void syms_of_eval (void);
3769extern void unwind_body (Lisp_Object);
3759extern void record_in_backtrace (Lisp_Object function, 3770extern void record_in_backtrace (Lisp_Object function,
3760 Lisp_Object *args, ptrdiff_t nargs); 3771 Lisp_Object *args, ptrdiff_t nargs);
3761extern void mark_specpdl (void); 3772extern void mark_specpdl (void);
@@ -3771,8 +3782,8 @@ extern void insert1 (Lisp_Object);
3771extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); 3782extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object);
3772extern Lisp_Object save_excursion_save (void); 3783extern Lisp_Object save_excursion_save (void);
3773extern Lisp_Object save_restriction_save (void); 3784extern Lisp_Object save_restriction_save (void);
3774extern Lisp_Object save_excursion_restore (Lisp_Object); 3785extern void save_excursion_restore (Lisp_Object);
3775extern Lisp_Object save_restriction_restore (Lisp_Object); 3786extern void save_restriction_restore (Lisp_Object);
3776extern _Noreturn void time_overflow (void); 3787extern _Noreturn void time_overflow (void);
3777extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); 3788extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool);
3778extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, 3789extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t,
@@ -3791,7 +3802,6 @@ extern void report_overlay_modification (Lisp_Object, Lisp_Object, bool,
3791 Lisp_Object, Lisp_Object, Lisp_Object); 3802 Lisp_Object, Lisp_Object, Lisp_Object);
3792extern bool overlay_touches_p (ptrdiff_t); 3803extern bool overlay_touches_p (ptrdiff_t);
3793extern Lisp_Object Vbuffer_alist; 3804extern Lisp_Object Vbuffer_alist;
3794extern Lisp_Object set_buffer_if_live (Lisp_Object);
3795extern Lisp_Object other_buffer_safely (Lisp_Object); 3805extern Lisp_Object other_buffer_safely (Lisp_Object);
3796extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string; 3806extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string;
3797extern Lisp_Object get_truename_buffer (Lisp_Object); 3807extern Lisp_Object get_truename_buffer (Lisp_Object);
@@ -3825,8 +3835,9 @@ extern Lisp_Object Qinsert_file_contents;
3825extern Lisp_Object Qfile_name_history; 3835extern Lisp_Object Qfile_name_history;
3826extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); 3836extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object);
3827EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ 3837EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */
3828extern Lisp_Object close_file_unwind (Lisp_Object); 3838extern void close_file_unwind (int);
3829extern Lisp_Object restore_point_unwind (Lisp_Object); 3839extern void fclose_unwind (void *);
3840extern void restore_point_unwind (Lisp_Object);
3830extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); 3841extern _Noreturn void report_file_errno (const char *, Lisp_Object, int);
3831extern _Noreturn void report_file_error (const char *, Lisp_Object); 3842extern _Noreturn void report_file_error (const char *, Lisp_Object);
3832extern bool internal_delete_file (Lisp_Object); 3843extern bool internal_delete_file (Lisp_Object);
@@ -4099,6 +4110,7 @@ extern void init_random (void);
4099extern void emacs_backtrace (int); 4110extern void emacs_backtrace (int);
4100extern _Noreturn void emacs_abort (void) NO_INLINE; 4111extern _Noreturn void emacs_abort (void) NO_INLINE;
4101extern int emacs_open (const char *, int, int); 4112extern int emacs_open (const char *, int, int);
4113extern int emacs_pipe (int[2]);
4102extern int emacs_close (int); 4114extern int emacs_close (int);
4103extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); 4115extern ptrdiff_t emacs_read (int, char *, ptrdiff_t);
4104extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t); 4116extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t);
@@ -4262,7 +4274,6 @@ extern void init_system_name (void);
4262 4274
4263enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; 4275enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 };
4264 4276
4265extern Lisp_Object safe_alloca_unwind (Lisp_Object);
4266extern void *record_xmalloc (size_t); 4277extern void *record_xmalloc (size_t);
4267 4278
4268#define USE_SAFE_ALLOCA \ 4279#define USE_SAFE_ALLOCA \
@@ -4286,8 +4297,7 @@ extern void *record_xmalloc (size_t);
4286 { \ 4297 { \
4287 (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \ 4298 (buf) = xnmalloc (nitems, sizeof *(buf) * (multiplier)); \
4288 sa_must_free = 1; \ 4299 sa_must_free = 1; \
4289 record_unwind_protect (safe_alloca_unwind, \ 4300 record_unwind_protect_ptr (xfree, buf); \
4290 make_save_pointer (buf)); \
4291 } \ 4301 } \
4292 } while (0) 4302 } while (0)
4293 4303
@@ -4312,9 +4322,9 @@ extern void *record_xmalloc (size_t);
4312 { \ 4322 { \
4313 Lisp_Object arg_; \ 4323 Lisp_Object arg_; \
4314 buf = xmalloc ((nelt) * word_size); \ 4324 buf = xmalloc ((nelt) * word_size); \
4315 arg_ = make_save_value (SAVE_TYPE_MEMORY, buf, nelt); \ 4325 arg_ = make_save_memory (buf, nelt); \
4316 sa_must_free = 1; \ 4326 sa_must_free = 1; \
4317 record_unwind_protect (safe_alloca_unwind, arg_); \ 4327 record_unwind_protect (free_save_value, arg_); \
4318 } \ 4328 } \
4319 else \ 4329 else \
4320 memory_full (SIZE_MAX); \ 4330 memory_full (SIZE_MAX); \