diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/alloc.c | 32 | ||||
| -rw-r--r-- | src/data.c | 24 | ||||
| -rw-r--r-- | src/lisp.h | 47 | ||||
| -rw-r--r-- | src/print.c | 13 |
4 files changed, 115 insertions, 1 deletions
diff --git a/src/alloc.c b/src/alloc.c index bee7cd1758d..48ce3f120f5 100644 --- a/src/alloc.c +++ b/src/alloc.c | |||
| @@ -3711,6 +3711,23 @@ make_event_array (ptrdiff_t nargs, Lisp_Object *args) | |||
| 3711 | } | 3711 | } |
| 3712 | } | 3712 | } |
| 3713 | 3713 | ||
| 3714 | #ifdef HAVE_MODULES | ||
| 3715 | /* Create a new module user ptr object. */ | ||
| 3716 | Lisp_Object | ||
| 3717 | make_user_ptr (void (*finalizer) (void*), void *p) | ||
| 3718 | { | ||
| 3719 | Lisp_Object obj; | ||
| 3720 | struct Lisp_User_Ptr *uptr; | ||
| 3721 | |||
| 3722 | obj = allocate_misc (Lisp_Misc_User_Ptr); | ||
| 3723 | uptr = XUSER_PTR (obj); | ||
| 3724 | uptr->finalizer = finalizer; | ||
| 3725 | uptr->p = p; | ||
| 3726 | return obj; | ||
| 3727 | } | ||
| 3728 | |||
| 3729 | #endif | ||
| 3730 | |||
| 3714 | static void | 3731 | static void |
| 3715 | init_finalizer_list (struct Lisp_Finalizer *head) | 3732 | init_finalizer_list (struct Lisp_Finalizer *head) |
| 3716 | { | 3733 | { |
| @@ -6301,6 +6318,12 @@ mark_object (Lisp_Object arg) | |||
| 6301 | mark_object (XFINALIZER (obj)->function); | 6318 | mark_object (XFINALIZER (obj)->function); |
| 6302 | break; | 6319 | break; |
| 6303 | 6320 | ||
| 6321 | #ifdef HAVE_MODULES | ||
| 6322 | case Lisp_Misc_User_Ptr: | ||
| 6323 | XMISCANY (obj)->gcmarkbit = true; | ||
| 6324 | break; | ||
| 6325 | #endif | ||
| 6326 | |||
| 6304 | default: | 6327 | default: |
| 6305 | emacs_abort (); | 6328 | emacs_abort (); |
| 6306 | } | 6329 | } |
| @@ -6677,8 +6700,15 @@ sweep_misc (void) | |||
| 6677 | { | 6700 | { |
| 6678 | if (mblk->markers[i].m.u_any.type == Lisp_Misc_Marker) | 6701 | if (mblk->markers[i].m.u_any.type == Lisp_Misc_Marker) |
| 6679 | unchain_marker (&mblk->markers[i].m.u_marker); | 6702 | unchain_marker (&mblk->markers[i].m.u_marker); |
| 6680 | if (mblk->markers[i].m.u_any.type == Lisp_Misc_Finalizer) | 6703 | else if (mblk->markers[i].m.u_any.type == Lisp_Misc_Finalizer) |
| 6681 | unchain_finalizer (&mblk->markers[i].m.u_finalizer); | 6704 | unchain_finalizer (&mblk->markers[i].m.u_finalizer); |
| 6705 | #ifdef HAVE_MODULES | ||
| 6706 | else if (mblk->markers[i].m.u_any.type == Lisp_Misc_User_Ptr) | ||
| 6707 | { | ||
| 6708 | struct Lisp_User_Ptr *uptr = &mblk->markers[i].m.u_user_ptr; | ||
| 6709 | uptr->finalizer (uptr->p); | ||
| 6710 | } | ||
| 6711 | #endif | ||
| 6682 | /* Set the type of the freed object to Lisp_Misc_Free. | 6712 | /* Set the type of the freed object to Lisp_Misc_Free. |
| 6683 | We could leave the type alone, since nobody checks it, | 6713 | We could leave the type alone, since nobody checks it, |
| 6684 | but this might catch bugs faster. */ | 6714 | but this might catch bugs faster. */ |
diff --git a/src/data.c b/src/data.c index 51546044c68..1e9cc814f00 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -223,6 +223,10 @@ for example, (type-of 1) returns `integer'. */) | |||
| 223 | return Qfloat; | 223 | return Qfloat; |
| 224 | case Lisp_Misc_Finalizer: | 224 | case Lisp_Misc_Finalizer: |
| 225 | return Qfinalizer; | 225 | return Qfinalizer; |
| 226 | #ifdef HAVE_MODULES | ||
| 227 | case Lisp_Misc_User_Ptr: | ||
| 228 | return Quser_ptr; | ||
| 229 | #endif | ||
| 226 | default: | 230 | default: |
| 227 | emacs_abort (); | 231 | emacs_abort (); |
| 228 | } | 232 | } |
| @@ -424,6 +428,17 @@ DEFUN ("markerp", Fmarkerp, Smarkerp, 1, 1, 0, | |||
| 424 | return Qnil; | 428 | return Qnil; |
| 425 | } | 429 | } |
| 426 | 430 | ||
| 431 | #ifdef HAVE_MODULES | ||
| 432 | DEFUN ("user-ptrp", Fuser_ptrp, Suser_ptrp, 1, 1, 0, | ||
| 433 | doc: /* Return t if OBJECT is a module user pointer. */) | ||
| 434 | (Lisp_Object object) | ||
| 435 | { | ||
| 436 | if (USER_PTRP (object)) | ||
| 437 | return Qt; | ||
| 438 | return Qnil; | ||
| 439 | } | ||
| 440 | #endif | ||
| 441 | |||
| 427 | DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, | 442 | DEFUN ("subrp", Fsubrp, Ssubrp, 1, 1, 0, |
| 428 | doc: /* Return t if OBJECT is a built-in function. */) | 443 | doc: /* Return t if OBJECT is a built-in function. */) |
| 429 | (Lisp_Object object) | 444 | (Lisp_Object object) |
| @@ -3478,6 +3493,9 @@ syms_of_data (void) | |||
| 3478 | DEFSYM (Qbool_vector_p, "bool-vector-p"); | 3493 | DEFSYM (Qbool_vector_p, "bool-vector-p"); |
| 3479 | DEFSYM (Qchar_or_string_p, "char-or-string-p"); | 3494 | DEFSYM (Qchar_or_string_p, "char-or-string-p"); |
| 3480 | DEFSYM (Qmarkerp, "markerp"); | 3495 | DEFSYM (Qmarkerp, "markerp"); |
| 3496 | #ifdef HAVE_MODULES | ||
| 3497 | DEFSYM (Quser_ptrp, "user-ptrp"); | ||
| 3498 | #endif | ||
| 3481 | DEFSYM (Qbuffer_or_string_p, "buffer-or-string-p"); | 3499 | DEFSYM (Qbuffer_or_string_p, "buffer-or-string-p"); |
| 3482 | DEFSYM (Qinteger_or_marker_p, "integer-or-marker-p"); | 3500 | DEFSYM (Qinteger_or_marker_p, "integer-or-marker-p"); |
| 3483 | DEFSYM (Qfboundp, "fboundp"); | 3501 | DEFSYM (Qfboundp, "fboundp"); |
| @@ -3569,6 +3587,9 @@ syms_of_data (void) | |||
| 3569 | DEFSYM (Qmarker, "marker"); | 3587 | DEFSYM (Qmarker, "marker"); |
| 3570 | DEFSYM (Qoverlay, "overlay"); | 3588 | DEFSYM (Qoverlay, "overlay"); |
| 3571 | DEFSYM (Qfinalizer, "finalizer"); | 3589 | DEFSYM (Qfinalizer, "finalizer"); |
| 3590 | #ifdef HAVE_MODULES | ||
| 3591 | DEFSYM (Quser_ptr, "user-ptr"); | ||
| 3592 | #endif | ||
| 3572 | DEFSYM (Qfloat, "float"); | 3593 | DEFSYM (Qfloat, "float"); |
| 3573 | DEFSYM (Qwindow_configuration, "window-configuration"); | 3594 | DEFSYM (Qwindow_configuration, "window-configuration"); |
| 3574 | DEFSYM (Qprocess, "process"); | 3595 | DEFSYM (Qprocess, "process"); |
| @@ -3683,6 +3704,9 @@ syms_of_data (void) | |||
| 3683 | defsubr (&Sbyteorder); | 3704 | defsubr (&Sbyteorder); |
| 3684 | defsubr (&Ssubr_arity); | 3705 | defsubr (&Ssubr_arity); |
| 3685 | defsubr (&Ssubr_name); | 3706 | defsubr (&Ssubr_name); |
| 3707 | #ifdef HAVE_MODULES | ||
| 3708 | defsubr (&Suser_ptrp); | ||
| 3709 | #endif | ||
| 3686 | 3710 | ||
| 3687 | defsubr (&Sbool_vector_exclusive_or); | 3711 | defsubr (&Sbool_vector_exclusive_or); |
| 3688 | defsubr (&Sbool_vector_union); | 3712 | defsubr (&Sbool_vector_union); |
diff --git a/src/lisp.h b/src/lisp.h index cab912e7401..02c19690adf 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -468,6 +468,9 @@ enum Lisp_Misc_Type | |||
| 468 | Lisp_Misc_Overlay, | 468 | Lisp_Misc_Overlay, |
| 469 | Lisp_Misc_Save_Value, | 469 | Lisp_Misc_Save_Value, |
| 470 | Lisp_Misc_Finalizer, | 470 | Lisp_Misc_Finalizer, |
| 471 | #ifdef HAVE_MODULES | ||
| 472 | Lisp_Misc_User_Ptr, | ||
| 473 | #endif | ||
| 471 | /* Currently floats are not a misc type, | 474 | /* Currently floats are not a misc type, |
| 472 | but let's define this in case we want to change that. */ | 475 | but let's define this in case we want to change that. */ |
| 473 | Lisp_Misc_Float, | 476 | Lisp_Misc_Float, |
| @@ -581,6 +584,12 @@ INLINE bool PROCESSP (Lisp_Object); | |||
| 581 | INLINE bool PSEUDOVECTORP (Lisp_Object, int); | 584 | INLINE bool PSEUDOVECTORP (Lisp_Object, int); |
| 582 | INLINE bool SAVE_VALUEP (Lisp_Object); | 585 | INLINE bool SAVE_VALUEP (Lisp_Object); |
| 583 | INLINE bool FINALIZERP (Lisp_Object); | 586 | INLINE bool FINALIZERP (Lisp_Object); |
| 587 | |||
| 588 | #ifdef HAVE_MODULES | ||
| 589 | INLINE bool USER_PTRP (Lisp_Object); | ||
| 590 | INLINE struct Lisp_User_Ptr *(XUSER_PTR) (Lisp_Object); | ||
| 591 | #endif | ||
| 592 | |||
| 584 | INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t, | 593 | INLINE void set_sub_char_table_contents (Lisp_Object, ptrdiff_t, |
| 585 | Lisp_Object); | 594 | Lisp_Object); |
| 586 | INLINE bool STRINGP (Lisp_Object); | 595 | INLINE bool STRINGP (Lisp_Object); |
| @@ -2230,6 +2239,18 @@ XSAVE_OBJECT (Lisp_Object obj, int n) | |||
| 2230 | return XSAVE_VALUE (obj)->data[n].object; | 2239 | return XSAVE_VALUE (obj)->data[n].object; |
| 2231 | } | 2240 | } |
| 2232 | 2241 | ||
| 2242 | #ifdef HAVE_MODULES | ||
| 2243 | struct Lisp_User_Ptr | ||
| 2244 | { | ||
| 2245 | ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_User_Ptr */ | ||
| 2246 | bool_bf gcmarkbit : 1; | ||
| 2247 | unsigned spacer : 15; | ||
| 2248 | |||
| 2249 | void (*finalizer) (void*); | ||
| 2250 | void *p; | ||
| 2251 | }; | ||
| 2252 | #endif | ||
| 2253 | |||
| 2233 | /* A finalizer sentinel. */ | 2254 | /* A finalizer sentinel. */ |
| 2234 | struct Lisp_Finalizer | 2255 | struct Lisp_Finalizer |
| 2235 | { | 2256 | { |
| @@ -2265,6 +2286,9 @@ union Lisp_Misc | |||
| 2265 | struct Lisp_Overlay u_overlay; | 2286 | struct Lisp_Overlay u_overlay; |
| 2266 | struct Lisp_Save_Value u_save_value; | 2287 | struct Lisp_Save_Value u_save_value; |
| 2267 | struct Lisp_Finalizer u_finalizer; | 2288 | struct Lisp_Finalizer u_finalizer; |
| 2289 | #ifdef HAVE_MODULES | ||
| 2290 | struct Lisp_User_Ptr u_user_ptr; | ||
| 2291 | #endif | ||
| 2268 | }; | 2292 | }; |
| 2269 | 2293 | ||
| 2270 | INLINE union Lisp_Misc * | 2294 | INLINE union Lisp_Misc * |
| @@ -2314,6 +2338,16 @@ XFINALIZER (Lisp_Object a) | |||
| 2314 | return & XMISC (a)->u_finalizer; | 2338 | return & XMISC (a)->u_finalizer; |
| 2315 | } | 2339 | } |
| 2316 | 2340 | ||
| 2341 | #ifdef HAVE_MODULES | ||
| 2342 | INLINE struct Lisp_User_Ptr * | ||
| 2343 | XUSER_PTR (Lisp_Object a) | ||
| 2344 | { | ||
| 2345 | eassert (USER_PTRP (a)); | ||
| 2346 | return & XMISC (a)->u_user_ptr; | ||
| 2347 | } | ||
| 2348 | #endif | ||
| 2349 | |||
| 2350 | |||
| 2317 | 2351 | ||
| 2318 | /* Forwarding pointer to an int variable. | 2352 | /* Forwarding pointer to an int variable. |
| 2319 | This is allowed only in the value cell of a symbol, | 2353 | This is allowed only in the value cell of a symbol, |
| @@ -2598,6 +2632,14 @@ FINALIZERP (Lisp_Object x) | |||
| 2598 | return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Finalizer; | 2632 | return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Finalizer; |
| 2599 | } | 2633 | } |
| 2600 | 2634 | ||
| 2635 | #ifdef HAVE_MODULES | ||
| 2636 | INLINE bool | ||
| 2637 | USER_PTRP (Lisp_Object x) | ||
| 2638 | { | ||
| 2639 | return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_User_Ptr; | ||
| 2640 | } | ||
| 2641 | #endif | ||
| 2642 | |||
| 2601 | INLINE bool | 2643 | INLINE bool |
| 2602 | AUTOLOADP (Lisp_Object x) | 2644 | AUTOLOADP (Lisp_Object x) |
| 2603 | { | 2645 | { |
| @@ -3870,6 +3912,11 @@ Lisp_Object backtrace_top_function (void); | |||
| 3870 | extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); | 3912 | extern bool let_shadows_buffer_binding_p (struct Lisp_Symbol *symbol); |
| 3871 | extern bool let_shadows_global_binding_p (Lisp_Object symbol); | 3913 | extern bool let_shadows_global_binding_p (Lisp_Object symbol); |
| 3872 | 3914 | ||
| 3915 | #ifdef HAVE_MODULES | ||
| 3916 | /* Defined in alloc.c. */ | ||
| 3917 | extern Lisp_Object make_user_ptr (void (*finalizer) (void*), void *p); | ||
| 3918 | |||
| 3919 | #endif | ||
| 3873 | 3920 | ||
| 3874 | /* Defined in editfns.c. */ | 3921 | /* Defined in editfns.c. */ |
| 3875 | extern void insert1 (Lisp_Object); | 3922 | extern void insert1 (Lisp_Object); |
diff --git a/src/print.c b/src/print.c index 6f868ceff84..420e6f55b4c 100644 --- a/src/print.c +++ b/src/print.c | |||
| @@ -1990,6 +1990,19 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag) | |||
| 1990 | printchar ('>', printcharfun); | 1990 | printchar ('>', printcharfun); |
| 1991 | break; | 1991 | break; |
| 1992 | 1992 | ||
| 1993 | #ifdef HAVE_MODULES | ||
| 1994 | case Lisp_Misc_User_Ptr: | ||
| 1995 | { | ||
| 1996 | print_c_string ("#<user-ptr ", printcharfun); | ||
| 1997 | int i = sprintf (buf, "ptr=%p finalizer=%p", | ||
| 1998 | XUSER_PTR (obj)->p, | ||
| 1999 | XUSER_PTR (obj)->finalizer); | ||
| 2000 | strout (buf, i, i, printcharfun); | ||
| 2001 | printchar ('>', printcharfun); | ||
| 2002 | break; | ||
| 2003 | } | ||
| 2004 | #endif | ||
| 2005 | |||
| 1993 | case Lisp_Misc_Finalizer: | 2006 | case Lisp_Misc_Finalizer: |
| 1994 | print_c_string ("#<finalizer", printcharfun); | 2007 | print_c_string ("#<finalizer", printcharfun); |
| 1995 | if (NILP (XFINALIZER (obj)->function)) | 2008 | if (NILP (XFINALIZER (obj)->function)) |