aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2018-06-07 19:12:29 -0700
committerPaul Eggert2018-06-14 17:13:40 -0700
commit4139c98eb5f9003fefe62187e6a60644e38389e9 (patch)
tree44e4c501b2f1d9dbf6da0a4bca086bd9d315cf29 /src
parentf8ad6b311bf142defe4c203b64713c5a5051c4a7 (diff)
downloademacs-4139c98eb5f9003fefe62187e6a60644e38389e9.tar.gz
emacs-4139c98eb5f9003fefe62187e6a60644e38389e9.zip
Remove Lisp_Misc_Save_Value
This type and its associated routines are no longer used. * src/alloc.c (voidfuncptr): Move here from src/lisp.h. (free_misc, make_save_int_int_int) (make_save_obj_obj_obj_obj, make_save_ptr) (make_save_ptr_int, make_save_ptr_ptr) (make_save_funcptr_ptr_obj, make_save_memory) (free_save_value, mark_save_value): Remove. (mark_object): Remove mention of Lisp_Misc_Save_Value. * src/lisp.h (Lisp_Misc_Save_Value, SAVE_SLOT_BITS) (SAVE_VALUE_SLOTS, SAVE_TYPE_BITS, enum Lisp_Save_Type) (struct Lisp_Save_Value, SAVE_VALUEP, XSAVE_VALUE) (save_type, XSAVE_POINTER, set_save_pointer) (XSAVE_FUNCPOINTER, XSAVE_INTEGER, set_save_integer) (XSAVE_OBJECT): Remove. (union Lisp_Misc): Remove u_save_value. (voidfuncptr): Move from here to src/alloc.c. * src/print.c (print_object): Remove support for printing Lisp_Misc_Save_Value.
Diffstat (limited to 'src')
-rw-r--r--src/alloc.c153
-rw-r--r--src/lisp.h176
-rw-r--r--src/print.c83
3 files changed, 5 insertions, 407 deletions
diff --git a/src/alloc.c b/src/alloc.c
index 6b57c83cc2e..7b2140501ec 100644
--- a/src/alloc.c
+++ b/src/alloc.c
@@ -172,6 +172,7 @@ malloc_initialize_hook (void)
172 172
173/* Declare the malloc initialization hook, which runs before 'main' starts. 173/* Declare the malloc initialization hook, which runs before 'main' starts.
174 EXTERNALLY_VISIBLE works around Bug#22522. */ 174 EXTERNALLY_VISIBLE works around Bug#22522. */
175typedef void (*voidfuncptr) (void);
175# ifndef __MALLOC_HOOK_VOLATILE 176# ifndef __MALLOC_HOOK_VOLATILE
176# define __MALLOC_HOOK_VOLATILE 177# define __MALLOC_HOOK_VOLATILE
177# endif 178# endif
@@ -3710,123 +3711,6 @@ allocate_misc (enum Lisp_Misc_Type type)
3710 return val; 3711 return val;
3711} 3712}
3712 3713
3713/* Free a Lisp_Misc object. */
3714
3715void
3716free_misc (Lisp_Object misc)
3717{
3718 XMISCANY (misc)->type = Lisp_Misc_Free;
3719 XMISC (misc)->u_free.chain = misc_free_list;
3720 misc_free_list = XMISC (misc);
3721 consing_since_gc -= sizeof (union Lisp_Misc);
3722 total_free_markers++;
3723}
3724
3725/* Verify properties of Lisp_Save_Value's representation
3726 that are assumed here and elsewhere. */
3727
3728verify (SAVE_UNUSED == 0);
3729verify (((SAVE_INTEGER | SAVE_POINTER | SAVE_FUNCPOINTER | SAVE_OBJECT)
3730 >> SAVE_SLOT_BITS)
3731 == 0);
3732
3733/* Return Lisp_Save_Value objects for the various combinations
3734 that callers need. */
3735
3736Lisp_Object
3737make_save_int_int_int (ptrdiff_t a, ptrdiff_t b, ptrdiff_t c)
3738{
3739 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3740 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3741 p->save_type = SAVE_TYPE_INT_INT_INT;
3742 p->data[0].integer = a;
3743 p->data[1].integer = b;
3744 p->data[2].integer = c;
3745 return val;
3746}
3747
3748Lisp_Object
3749make_save_obj_obj_obj_obj (Lisp_Object a, Lisp_Object b, Lisp_Object c,
3750 Lisp_Object d)
3751{
3752 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3753 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3754 p->save_type = SAVE_TYPE_OBJ_OBJ_OBJ_OBJ;
3755 p->data[0].object = a;
3756 p->data[1].object = b;
3757 p->data[2].object = c;
3758 p->data[3].object = d;
3759 return val;
3760}
3761
3762Lisp_Object
3763make_save_ptr (void *a)
3764{
3765 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3766 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3767 p->save_type = SAVE_POINTER;
3768 p->data[0].pointer = a;
3769 return val;
3770}
3771
3772Lisp_Object
3773make_save_ptr_int (void *a, ptrdiff_t b)
3774{
3775 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3776 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3777 p->save_type = SAVE_TYPE_PTR_INT;
3778 p->data[0].pointer = a;
3779 p->data[1].integer = b;
3780 return val;
3781}
3782
3783Lisp_Object
3784make_save_ptr_ptr (void *a, void *b)
3785{
3786 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3787 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3788 p->save_type = SAVE_TYPE_PTR_PTR;
3789 p->data[0].pointer = a;
3790 p->data[1].pointer = b;
3791 return val;
3792}
3793
3794Lisp_Object
3795make_save_funcptr_ptr_obj (void (*a) (void), void *b, Lisp_Object c)
3796{
3797 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3798 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3799 p->save_type = SAVE_TYPE_FUNCPTR_PTR_OBJ;
3800 p->data[0].funcpointer = a;
3801 p->data[1].pointer = b;
3802 p->data[2].object = c;
3803 return val;
3804}
3805
3806/* Return a Lisp_Save_Value object that represents an array A
3807 of N Lisp objects. */
3808
3809Lisp_Object
3810make_save_memory (Lisp_Object *a, ptrdiff_t n)
3811{
3812 Lisp_Object val = allocate_misc (Lisp_Misc_Save_Value);
3813 struct Lisp_Save_Value *p = XSAVE_VALUE (val);
3814 p->save_type = SAVE_TYPE_MEMORY;
3815 p->data[0].pointer = a;
3816 p->data[1].integer = n;
3817 return val;
3818}
3819
3820/* Free a Lisp_Save_Value object. Do not use this function
3821 if SAVE contains pointer other than returned by xmalloc. */
3822
3823void
3824free_save_value (Lisp_Object save)
3825{
3826 xfree (XSAVE_POINTER (save, 0));
3827 free_misc (save);
3828}
3829
3830Lisp_Object 3714Lisp_Object
3831make_misc_ptr (void *a) 3715make_misc_ptr (void *a)
3832{ 3716{
@@ -5281,10 +5165,8 @@ valid_pointer_p (void *p)
5281 5165
5282/* Return 2 if OBJ is a killed or special buffer object, 1 if OBJ is a 5166/* Return 2 if OBJ is a killed or special buffer object, 1 if OBJ is a
5283 valid lisp object, 0 if OBJ is NOT a valid lisp object, or -1 if we 5167 valid lisp object, 0 if OBJ is NOT a valid lisp object, or -1 if we
5284 cannot validate OBJ. This function can be quite slow, so its primary 5168 cannot validate OBJ. This function can be quite slow, and is used
5285 use is the manual debugging. The only exception is print_object, where 5169 only in debugging. */
5286 we use it to check whether the memory referenced by the pointer of
5287 Lisp_Save_Value object contains valid objects. */
5288 5170
5289int 5171int
5290valid_lisp_object_p (Lisp_Object obj) 5172valid_lisp_object_p (Lisp_Object obj)
@@ -6363,30 +6245,6 @@ mark_localized_symbol (struct Lisp_Symbol *ptr)
6363 mark_object (blv->defcell); 6245 mark_object (blv->defcell);
6364} 6246}
6365 6247
6366NO_INLINE /* To reduce stack depth in mark_object. */
6367static void
6368mark_save_value (struct Lisp_Save_Value *ptr)
6369{
6370 /* If `save_type' is zero, `data[0].pointer' is the address
6371 of a memory area containing `data[1].integer' potential
6372 Lisp_Objects. */
6373 if (ptr->save_type == SAVE_TYPE_MEMORY)
6374 {
6375 Lisp_Object *p = ptr->data[0].pointer;
6376 ptrdiff_t nelt;
6377 for (nelt = ptr->data[1].integer; nelt > 0; nelt--, p++)
6378 mark_maybe_object (*p);
6379 }
6380 else
6381 {
6382 /* Find Lisp_Objects in `data[N]' slots and mark them. */
6383 int i;
6384 for (i = 0; i < SAVE_VALUE_SLOTS; i++)
6385 if (save_type (ptr, i) == SAVE_OBJECT)
6386 mark_object (ptr->data[i].object);
6387 }
6388}
6389
6390/* Remove killed buffers or items whose car is a killed buffer from 6248/* Remove killed buffers or items whose car is a killed buffer from
6391 LIST, and mark other items. Return changed LIST, which is marked. */ 6249 LIST, and mark other items. Return changed LIST, which is marked. */
6392 6250
@@ -6695,11 +6553,6 @@ mark_object (Lisp_Object arg)
6695 XMISCANY (obj)->gcmarkbit = 1; 6553 XMISCANY (obj)->gcmarkbit = 1;
6696 break; 6554 break;
6697 6555
6698 case Lisp_Misc_Save_Value:
6699 XMISCANY (obj)->gcmarkbit = 1;
6700 mark_save_value (XSAVE_VALUE (obj));
6701 break;
6702
6703 case Lisp_Misc_Ptr: 6556 case Lisp_Misc_Ptr:
6704 XMISCANY (obj)->gcmarkbit = true; 6557 XMISCANY (obj)->gcmarkbit = true;
6705 break; 6558 break;
diff --git a/src/lisp.h b/src/lisp.h
index 12f326f6a63..ff708ebf60e 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -511,7 +511,6 @@ enum Lisp_Misc_Type
511 Lisp_Misc_Free = 0x5eab, 511 Lisp_Misc_Free = 0x5eab,
512 Lisp_Misc_Marker, 512 Lisp_Misc_Marker,
513 Lisp_Misc_Overlay, 513 Lisp_Misc_Overlay,
514 Lisp_Misc_Save_Value,
515 Lisp_Misc_Finalizer, 514 Lisp_Misc_Finalizer,
516 Lisp_Misc_Ptr, 515 Lisp_Misc_Ptr,
517#ifdef HAVE_MODULES 516#ifdef HAVE_MODULES
@@ -560,9 +559,8 @@ enum Lisp_Fwd_Type
560 members that are accessible only from C. A Lisp_Misc object is a 559 members that are accessible only from C. A Lisp_Misc object is a
561 wrapper for a C struct that can contain anything you like. 560 wrapper for a C struct that can contain anything you like.
562 561
563 Explicit freeing is discouraged for Lisp objects in general. But if 562 There is no way to explicitly free a Lisp Object; only the garbage
564 you really need to exploit this, use Lisp_Misc (check free_misc in 563 collector frees them.
565 alloc.c to see why). There is no way to free a vectorlike object.
566 564
567 To add a new pseudovector type, extend the pvec_type enumeration; 565 To add a new pseudovector type, extend the pvec_type enumeration;
568 to add a new Lisp_Misc, extend the Lisp_Misc_Type enumeration. 566 to add a new Lisp_Misc, extend the Lisp_Misc_Type enumeration.
@@ -2362,140 +2360,6 @@ struct Lisp_Overlay
2362 Lisp_Object plist; 2360 Lisp_Object plist;
2363 }; 2361 };
2364 2362
2365/* Number of bits needed to store one of the values
2366 SAVE_UNUSED..SAVE_OBJECT. */
2367enum { SAVE_SLOT_BITS = 3 };
2368
2369/* Number of slots in a save value where save_type is nonzero. */
2370enum { SAVE_VALUE_SLOTS = 4 };
2371
2372/* Bit-width and values for struct Lisp_Save_Value's save_type member. */
2373
2374enum { SAVE_TYPE_BITS = SAVE_VALUE_SLOTS * SAVE_SLOT_BITS + 1 };
2375
2376/* Types of data which may be saved in a Lisp_Save_Value. */
2377
2378enum Lisp_Save_Type
2379 {
2380 SAVE_UNUSED,
2381 SAVE_INTEGER,
2382 SAVE_FUNCPOINTER,
2383 SAVE_POINTER,
2384 SAVE_OBJECT,
2385 SAVE_TYPE_INT_INT = SAVE_INTEGER + (SAVE_INTEGER << SAVE_SLOT_BITS),
2386 SAVE_TYPE_INT_INT_INT
2387 = (SAVE_INTEGER + (SAVE_TYPE_INT_INT << SAVE_SLOT_BITS)),
2388 SAVE_TYPE_OBJ_OBJ = SAVE_OBJECT + (SAVE_OBJECT << SAVE_SLOT_BITS),
2389 SAVE_TYPE_OBJ_OBJ_OBJ = SAVE_OBJECT + (SAVE_TYPE_OBJ_OBJ << SAVE_SLOT_BITS),
2390 SAVE_TYPE_OBJ_OBJ_OBJ_OBJ
2391 = SAVE_OBJECT + (SAVE_TYPE_OBJ_OBJ_OBJ << SAVE_SLOT_BITS),
2392 SAVE_TYPE_PTR_INT = SAVE_POINTER + (SAVE_INTEGER << SAVE_SLOT_BITS),
2393 SAVE_TYPE_PTR_OBJ = SAVE_POINTER + (SAVE_OBJECT << SAVE_SLOT_BITS),
2394 SAVE_TYPE_PTR_PTR = SAVE_POINTER + (SAVE_POINTER << SAVE_SLOT_BITS),
2395 SAVE_TYPE_FUNCPTR_PTR_OBJ
2396 = SAVE_FUNCPOINTER + (SAVE_TYPE_PTR_OBJ << SAVE_SLOT_BITS),
2397
2398 /* This has an extra bit indicating it's raw memory. */
2399 SAVE_TYPE_MEMORY = SAVE_TYPE_PTR_INT + (1 << (SAVE_TYPE_BITS - 1))
2400 };
2401
2402/* SAVE_SLOT_BITS must be large enough to represent these values. */
2403verify (((SAVE_UNUSED | SAVE_INTEGER | SAVE_FUNCPOINTER
2404 | SAVE_POINTER | SAVE_OBJECT)
2405 >> SAVE_SLOT_BITS)
2406 == 0);
2407
2408/* Special object used to hold a different values for later use.
2409
2410 This is mostly used to package C integers and pointers to call
2411 record_unwind_protect when two or more values need to be saved.
2412 For example:
2413
2414 ...
2415 struct my_data *md = get_my_data ();
2416 ptrdiff_t mi = get_my_integer ();
2417 record_unwind_protect (my_unwind, make_save_ptr_int (md, mi));
2418 ...
2419
2420 Lisp_Object my_unwind (Lisp_Object arg)
2421 {
2422 struct my_data *md = XSAVE_POINTER (arg, 0);
2423 ptrdiff_t mi = XSAVE_INTEGER (arg, 1);
2424 ...
2425 }
2426
2427 If ENABLE_CHECKING is in effect, XSAVE_xxx macros do type checking of the
2428 saved objects and raise eassert if type of the saved object doesn't match
2429 the type which is extracted. In the example above, XSAVE_INTEGER (arg, 2)
2430 and XSAVE_OBJECT (arg, 0) are wrong because nothing was saved in slot 2 and
2431 slot 0 is a pointer. */
2432
2433typedef void (*voidfuncptr) (void);
2434
2435struct Lisp_Save_Value
2436 {
2437 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Save_Value */
2438 bool_bf gcmarkbit : 1;
2439 unsigned spacer : 32 - (16 + 1 + SAVE_TYPE_BITS);
2440
2441 /* V->data may hold up to SAVE_VALUE_SLOTS entries. The type of
2442 V's data entries are determined by V->save_type. E.g., if
2443 V->save_type == SAVE_TYPE_PTR_OBJ, V->data[0] is a pointer,
2444 V->data[1] is an integer, and V's other data entries are unused.
2445
2446 If V->save_type == SAVE_TYPE_MEMORY, V->data[0].pointer is the address of
2447 a memory area containing V->data[1].integer potential Lisp_Objects. */
2448 ENUM_BF (Lisp_Save_Type) save_type : SAVE_TYPE_BITS;
2449 union {
2450 void *pointer;
2451 voidfuncptr funcpointer;
2452 ptrdiff_t integer;
2453 Lisp_Object object;
2454 } data[SAVE_VALUE_SLOTS];
2455 };
2456
2457INLINE bool
2458SAVE_VALUEP (Lisp_Object x)
2459{
2460 return MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Save_Value;
2461}
2462
2463INLINE struct Lisp_Save_Value *
2464XSAVE_VALUE (Lisp_Object a)
2465{
2466 eassert (SAVE_VALUEP (a));
2467 return XUNTAG (a, Lisp_Misc, struct Lisp_Save_Value);
2468}
2469
2470/* Return the type of V's Nth saved value. */
2471INLINE int
2472save_type (struct Lisp_Save_Value *v, int n)
2473{
2474 eassert (0 <= n && n < SAVE_VALUE_SLOTS);
2475 return (v->save_type >> (SAVE_SLOT_BITS * n) & ((1 << SAVE_SLOT_BITS) - 1));
2476}
2477
2478/* Get and set the Nth saved pointer. */
2479
2480INLINE void *
2481XSAVE_POINTER (Lisp_Object obj, int n)
2482{
2483 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_POINTER);
2484 return XSAVE_VALUE (obj)->data[n].pointer;
2485}
2486INLINE void
2487set_save_pointer (Lisp_Object obj, int n, void *val)
2488{
2489 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_POINTER);
2490 XSAVE_VALUE (obj)->data[n].pointer = val;
2491}
2492INLINE voidfuncptr
2493XSAVE_FUNCPOINTER (Lisp_Object obj, int n)
2494{
2495 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_FUNCPOINTER);
2496 return XSAVE_VALUE (obj)->data[n].funcpointer;
2497}
2498
2499struct Lisp_Misc_Ptr 2363struct Lisp_Misc_Ptr
2500 { 2364 {
2501 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Ptr */ 2365 ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Ptr */
@@ -2543,30 +2407,6 @@ xmint_pointer (Lisp_Object a)
2543 return XUNTAG (a, Lisp_Misc, struct Lisp_Misc_Ptr)->pointer; 2407 return XUNTAG (a, Lisp_Misc, struct Lisp_Misc_Ptr)->pointer;
2544} 2408}
2545 2409
2546/* Get and set the Nth saved integer. */
2547
2548INLINE ptrdiff_t
2549XSAVE_INTEGER (Lisp_Object obj, int n)
2550{
2551 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_INTEGER);
2552 return XSAVE_VALUE (obj)->data[n].integer;
2553}
2554INLINE void
2555set_save_integer (Lisp_Object obj, int n, ptrdiff_t val)
2556{
2557 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_INTEGER);
2558 XSAVE_VALUE (obj)->data[n].integer = val;
2559}
2560
2561/* Extract Nth saved object. */
2562
2563INLINE Lisp_Object
2564XSAVE_OBJECT (Lisp_Object obj, int n)
2565{
2566 eassert (save_type (XSAVE_VALUE (obj), n) == SAVE_OBJECT);
2567 return XSAVE_VALUE (obj)->data[n].object;
2568}
2569
2570#ifdef HAVE_MODULES 2410#ifdef HAVE_MODULES
2571struct Lisp_User_Ptr 2411struct Lisp_User_Ptr
2572{ 2412{
@@ -2625,7 +2465,6 @@ union Lisp_Misc
2625 struct Lisp_Free u_free; 2465 struct Lisp_Free u_free;
2626 struct Lisp_Marker u_marker; 2466 struct Lisp_Marker u_marker;
2627 struct Lisp_Overlay u_overlay; 2467 struct Lisp_Overlay u_overlay;
2628 struct Lisp_Save_Value u_save_value;
2629 struct Lisp_Finalizer u_finalizer; 2468 struct Lisp_Finalizer u_finalizer;
2630 struct Lisp_Misc_Ptr u_misc_ptr; 2469 struct Lisp_Misc_Ptr u_misc_ptr;
2631#ifdef HAVE_MODULES 2470#ifdef HAVE_MODULES
@@ -3708,7 +3547,6 @@ extern void parse_str_as_multibyte (const unsigned char *, ptrdiff_t,
3708/* Defined in alloc.c. */ 3547/* Defined in alloc.c. */
3709extern void *my_heap_start (void); 3548extern void *my_heap_start (void);
3710extern void check_pure_size (void); 3549extern void check_pure_size (void);
3711extern void free_misc (Lisp_Object);
3712extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT); 3550extern void allocate_string_data (struct Lisp_String *, EMACS_INT, EMACS_INT);
3713extern void malloc_warning (const char *); 3551extern void malloc_warning (const char *);
3714extern _Noreturn void memory_full (size_t); 3552extern _Noreturn void memory_full (size_t);
@@ -3862,16 +3700,6 @@ extern bool gc_in_progress;
3862extern Lisp_Object make_float (double); 3700extern Lisp_Object make_float (double);
3863extern void display_malloc_warning (void); 3701extern void display_malloc_warning (void);
3864extern ptrdiff_t inhibit_garbage_collection (void); 3702extern ptrdiff_t inhibit_garbage_collection (void);
3865extern Lisp_Object make_save_int_int_int (ptrdiff_t, ptrdiff_t, ptrdiff_t);
3866extern Lisp_Object make_save_obj_obj_obj_obj (Lisp_Object, Lisp_Object,
3867 Lisp_Object, Lisp_Object);
3868extern Lisp_Object make_save_ptr (void *);
3869extern Lisp_Object make_save_ptr_int (void *, ptrdiff_t);
3870extern Lisp_Object make_save_ptr_ptr (void *, void *);
3871extern Lisp_Object make_save_funcptr_ptr_obj (void (*) (void), void *,
3872 Lisp_Object);
3873extern Lisp_Object make_save_memory (Lisp_Object *, ptrdiff_t);
3874extern void free_save_value (Lisp_Object);
3875extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object); 3703extern Lisp_Object build_overlay (Lisp_Object, Lisp_Object, Lisp_Object);
3876extern void free_cons (struct Lisp_Cons *); 3704extern void free_cons (struct Lisp_Cons *);
3877extern void init_alloc_once (void); 3705extern void init_alloc_once (void);
diff --git a/src/print.c b/src/print.c
index 741d1cc5fd2..71591952a23 100644
--- a/src/print.c
+++ b/src/print.c
@@ -2185,89 +2185,6 @@ print_object (Lisp_Object obj, Lisp_Object printcharfun, bool escapeflag)
2185 } 2185 }
2186 break; 2186 break;
2187 2187
2188 case Lisp_Misc_Save_Value:
2189 {
2190 int i;
2191 struct Lisp_Save_Value *v = XSAVE_VALUE (obj);
2192
2193 print_c_string ("#<save-value ", printcharfun);
2194
2195 if (v->save_type == SAVE_TYPE_MEMORY)
2196 {
2197 ptrdiff_t amount = v->data[1].integer;
2198
2199 /* valid_lisp_object_p is reliable, so try to print up
2200 to 8 saved objects. This code is rarely used, so
2201 it's OK that valid_lisp_object_p is slow. */
2202
2203 int limit = min (amount, 8);
2204 Lisp_Object *area = v->data[0].pointer;
2205
2206 i = sprintf (buf, "with %"pD"d objects", amount);
2207 strout (buf, i, i, printcharfun);
2208
2209 for (i = 0; i < limit; i++)
2210 {
2211 Lisp_Object maybe = area[i];
2212 int valid = valid_lisp_object_p (maybe);
2213
2214 printchar (' ', printcharfun);
2215 if (0 < valid)
2216 print_object (maybe, printcharfun, escapeflag);
2217 else
2218 print_c_string (valid < 0 ? "<some>" : "<invalid>",
2219 printcharfun);
2220 }
2221 if (i == limit && i < amount)
2222 print_c_string (" ...", printcharfun);
2223 }
2224 else
2225 {
2226 /* Print each slot according to its type. */
2227 int index;
2228 for (index = 0; index < SAVE_VALUE_SLOTS; index++)
2229 {
2230 if (index)
2231 printchar (' ', printcharfun);
2232
2233 switch (save_type (v, index))
2234 {
2235 case SAVE_UNUSED:
2236 i = sprintf (buf, "<unused>");
2237 break;
2238
2239 case SAVE_POINTER:
2240 i = sprintf (buf, "<pointer %p>",
2241 v->data[index].pointer);
2242 break;
2243
2244 case SAVE_FUNCPOINTER:
2245 i = sprintf (buf, "<funcpointer %p>",
2246 ((void *) (intptr_t)
2247 v->data[index].funcpointer));
2248 break;
2249
2250 case SAVE_INTEGER:
2251 i = sprintf (buf, "<integer %"pD"d>",
2252 v->data[index].integer);
2253 break;
2254
2255 case SAVE_OBJECT:
2256 print_object (v->data[index].object, printcharfun,
2257 escapeflag);
2258 continue;
2259
2260 default:
2261 emacs_abort ();
2262 }
2263
2264 strout (buf, i, i, printcharfun);
2265 }
2266 }
2267 printchar ('>', printcharfun);
2268 }
2269 break;
2270
2271 default: 2188 default:
2272 goto badtype; 2189 goto badtype;
2273 } 2190 }