diff options
Diffstat (limited to 'src/lisp.h')
| -rw-r--r-- | src/lisp.h | 114 |
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 | ||
| 1863 | typedef void (*voidfuncptr) (void); | 1843 | typedef 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 | ||
| 2709 | typedef Lisp_Object (*specbinding_func) (Lisp_Object); | ||
| 2710 | |||
| 2711 | enum specbind_tag { | 2690 | enum 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); | |||
| 3423 | extern void check_message_stack (void); | 3419 | extern void check_message_stack (void); |
| 3424 | extern void setup_echo_area_for_printing (int); | 3420 | extern void setup_echo_area_for_printing (int); |
| 3425 | extern bool push_message (void); | 3421 | extern bool push_message (void); |
| 3426 | extern Lisp_Object pop_message_unwind (Lisp_Object); | 3422 | extern void pop_message_unwind (void); |
| 3427 | extern Lisp_Object restore_message_unwind (Lisp_Object); | 3423 | extern Lisp_Object restore_message_unwind (Lisp_Object); |
| 3428 | extern void restore_message (void); | 3424 | extern void restore_message (void); |
| 3429 | extern Lisp_Object current_message (void); | 3425 | extern Lisp_Object current_message (void); |
| @@ -3585,8 +3581,16 @@ extern bool abort_on_gc; | |||
| 3585 | extern Lisp_Object make_float (double); | 3581 | extern Lisp_Object make_float (double); |
| 3586 | extern void display_malloc_warning (void); | 3582 | extern void display_malloc_warning (void); |
| 3587 | extern ptrdiff_t inhibit_garbage_collection (void); | 3583 | extern ptrdiff_t inhibit_garbage_collection (void); |
| 3588 | extern Lisp_Object make_save_value (enum Lisp_Save_Type, ...); | 3584 | extern Lisp_Object make_save_int_int_int (ptrdiff_t, ptrdiff_t, ptrdiff_t); |
| 3589 | extern Lisp_Object make_save_pointer (void *); | 3585 | extern Lisp_Object make_save_obj_obj_obj_obj (Lisp_Object, Lisp_Object, |
| 3586 | Lisp_Object, Lisp_Object); | ||
| 3587 | extern Lisp_Object make_save_ptr (void *); | ||
| 3588 | extern Lisp_Object make_save_ptr_int (void *, ptrdiff_t); | ||
| 3589 | extern Lisp_Object make_save_ptr_ptr (void *, void *); | ||
| 3590 | extern Lisp_Object make_save_funcptr_ptr_obj (void (*) (void), void *, | ||
| 3591 | Lisp_Object); | ||
| 3592 | extern Lisp_Object make_save_memory (Lisp_Object *, ptrdiff_t); | ||
| 3593 | extern void free_save_value (Lisp_Object); | ||
| 3590 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); | 3594 | extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3591 | extern void free_marker (Lisp_Object); | 3595 | extern void free_marker (Lisp_Object); |
| 3592 | extern void free_cons (struct Lisp_Cons *); | 3596 | extern 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 *)); |
| 3745 | extern void specbind (Lisp_Object, Lisp_Object); | 3749 | extern void specbind (Lisp_Object, Lisp_Object); |
| 3746 | extern void record_unwind_protect (Lisp_Object (*) (Lisp_Object), Lisp_Object); | 3750 | extern void record_unwind_protect (void (*) (Lisp_Object), Lisp_Object); |
| 3751 | extern void record_unwind_protect_int (void (*) (int), int); | ||
| 3752 | extern void record_unwind_protect_ptr (void (*) (void *), void *); | ||
| 3753 | extern void record_unwind_protect_void (void (*) (void)); | ||
| 3754 | extern void record_unwind_protect_nothing (void); | ||
| 3755 | extern void clear_unwind_protect (ptrdiff_t); | ||
| 3756 | extern void set_unwind_protect_ptr (ptrdiff_t, void (*) (void *), void *); | ||
| 3747 | extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object); | 3757 | extern Lisp_Object unbind_to (ptrdiff_t, Lisp_Object); |
| 3748 | extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); | 3758 | extern _Noreturn void error (const char *, ...) ATTRIBUTE_FORMAT_PRINTF (1, 2); |
| 3749 | extern _Noreturn void verror (const char *, va_list) | 3759 | extern _Noreturn void verror (const char *, va_list) |
| 3750 | ATTRIBUTE_FORMAT_PRINTF (1, 0); | 3760 | ATTRIBUTE_FORMAT_PRINTF (1, 0); |
| 3751 | extern Lisp_Object un_autoload (Lisp_Object); | 3761 | extern void un_autoload (Lisp_Object); |
| 3752 | extern Lisp_Object call_debugger (Lisp_Object arg); | 3762 | extern Lisp_Object call_debugger (Lisp_Object arg); |
| 3753 | extern void init_eval_once (void); | 3763 | extern void init_eval_once (void); |
| 3754 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); | 3764 | extern Lisp_Object safe_call (ptrdiff_t, Lisp_Object, ...); |
| @@ -3756,6 +3766,7 @@ extern Lisp_Object safe_call1 (Lisp_Object, Lisp_Object); | |||
| 3756 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); | 3766 | extern Lisp_Object safe_call2 (Lisp_Object, Lisp_Object, Lisp_Object); |
| 3757 | extern void init_eval (void); | 3767 | extern void init_eval (void); |
| 3758 | extern void syms_of_eval (void); | 3768 | extern void syms_of_eval (void); |
| 3769 | extern void unwind_body (Lisp_Object); | ||
| 3759 | extern void record_in_backtrace (Lisp_Object function, | 3770 | extern void record_in_backtrace (Lisp_Object function, |
| 3760 | Lisp_Object *args, ptrdiff_t nargs); | 3771 | Lisp_Object *args, ptrdiff_t nargs); |
| 3761 | extern void mark_specpdl (void); | 3772 | extern void mark_specpdl (void); |
| @@ -3771,8 +3782,8 @@ extern void insert1 (Lisp_Object); | |||
| 3771 | extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); | 3782 | extern Lisp_Object format2 (const char *, Lisp_Object, Lisp_Object); |
| 3772 | extern Lisp_Object save_excursion_save (void); | 3783 | extern Lisp_Object save_excursion_save (void); |
| 3773 | extern Lisp_Object save_restriction_save (void); | 3784 | extern Lisp_Object save_restriction_save (void); |
| 3774 | extern Lisp_Object save_excursion_restore (Lisp_Object); | 3785 | extern void save_excursion_restore (Lisp_Object); |
| 3775 | extern Lisp_Object save_restriction_restore (Lisp_Object); | 3786 | extern void save_restriction_restore (Lisp_Object); |
| 3776 | extern _Noreturn void time_overflow (void); | 3787 | extern _Noreturn void time_overflow (void); |
| 3777 | extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); | 3788 | extern Lisp_Object make_buffer_string (ptrdiff_t, ptrdiff_t, bool); |
| 3778 | extern Lisp_Object make_buffer_string_both (ptrdiff_t, ptrdiff_t, ptrdiff_t, | 3789 | extern 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); |
| 3792 | extern bool overlay_touches_p (ptrdiff_t); | 3803 | extern bool overlay_touches_p (ptrdiff_t); |
| 3793 | extern Lisp_Object Vbuffer_alist; | 3804 | extern Lisp_Object Vbuffer_alist; |
| 3794 | extern Lisp_Object set_buffer_if_live (Lisp_Object); | ||
| 3795 | extern Lisp_Object other_buffer_safely (Lisp_Object); | 3805 | extern Lisp_Object other_buffer_safely (Lisp_Object); |
| 3796 | extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string; | 3806 | extern Lisp_Object Qpriority, Qwindow, Qbefore_string, Qafter_string; |
| 3797 | extern Lisp_Object get_truename_buffer (Lisp_Object); | 3807 | extern Lisp_Object get_truename_buffer (Lisp_Object); |
| @@ -3825,8 +3835,9 @@ extern Lisp_Object Qinsert_file_contents; | |||
| 3825 | extern Lisp_Object Qfile_name_history; | 3835 | extern Lisp_Object Qfile_name_history; |
| 3826 | extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); | 3836 | extern Lisp_Object expand_and_dir_to_file (Lisp_Object, Lisp_Object); |
| 3827 | EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ | 3837 | EXFUN (Fread_file_name, 6); /* Not a normal DEFUN. */ |
| 3828 | extern Lisp_Object close_file_unwind (Lisp_Object); | 3838 | extern void close_file_unwind (int); |
| 3829 | extern Lisp_Object restore_point_unwind (Lisp_Object); | 3839 | extern void fclose_unwind (void *); |
| 3840 | extern void restore_point_unwind (Lisp_Object); | ||
| 3830 | extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); | 3841 | extern _Noreturn void report_file_errno (const char *, Lisp_Object, int); |
| 3831 | extern _Noreturn void report_file_error (const char *, Lisp_Object); | 3842 | extern _Noreturn void report_file_error (const char *, Lisp_Object); |
| 3832 | extern bool internal_delete_file (Lisp_Object); | 3843 | extern bool internal_delete_file (Lisp_Object); |
| @@ -4099,6 +4110,7 @@ extern void init_random (void); | |||
| 4099 | extern void emacs_backtrace (int); | 4110 | extern void emacs_backtrace (int); |
| 4100 | extern _Noreturn void emacs_abort (void) NO_INLINE; | 4111 | extern _Noreturn void emacs_abort (void) NO_INLINE; |
| 4101 | extern int emacs_open (const char *, int, int); | 4112 | extern int emacs_open (const char *, int, int); |
| 4113 | extern int emacs_pipe (int[2]); | ||
| 4102 | extern int emacs_close (int); | 4114 | extern int emacs_close (int); |
| 4103 | extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); | 4115 | extern ptrdiff_t emacs_read (int, char *, ptrdiff_t); |
| 4104 | extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t); | 4116 | extern ptrdiff_t emacs_write (int, const char *, ptrdiff_t); |
| @@ -4262,7 +4274,6 @@ extern void init_system_name (void); | |||
| 4262 | 4274 | ||
| 4263 | enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; | 4275 | enum MAX_ALLOCA { MAX_ALLOCA = 16 * 1024 }; |
| 4264 | 4276 | ||
| 4265 | extern Lisp_Object safe_alloca_unwind (Lisp_Object); | ||
| 4266 | extern void *record_xmalloc (size_t); | 4277 | extern 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); \ |