Lisp_Misc_Overlay,
Lisp_Misc_Save_Value,
Lisp_Misc_Finalizer,
+ Lisp_Misc_Ptr,
#ifdef HAVE_MODULES
Lisp_Misc_User_Ptr,
#endif
First, there are already a couple of Lisp types that can be used if
your new type does not need to be exposed to Lisp programs nor
- displayed to users. These are Lisp_Save_Value, a Lisp_Misc
+ displayed to users. These are Lisp_Misc_Ptr, a Lisp_Misc
subtype; and PVEC_OTHER, a kind of vectorlike object. The former
- is suitable for temporarily stashing away pointers and integers in
- a Lisp object. The latter is useful for vector-like Lisp objects
+ is suitable for stashing a pointer in a Lisp object; the pointer
+ might be to some low-level C object that contains auxiliary
+ information. The latter is useful for vector-like Lisp objects
that need to be used as part of other objects, but which are never
shown to users or Lisp code (search for PVEC_OTHER in xterm.c for
an example).
return XSAVE_VALUE (obj)->data[n].funcpointer;
}
-extern Lisp_Object make_save_ptr (void *);
+struct Lisp_Misc_Ptr
+ {
+ ENUM_BF (Lisp_Misc_Type) type : 16; /* = Lisp_Misc_Ptr */
+ bool_bf gcmarkbit : 1;
+ unsigned spacer : 15;
+ void *pointer;
+ };
+
+extern Lisp_Object make_misc_ptr (void *);
/* A mint_ptr object OBJ represents a C-language pointer P efficiently.
Preferably (and typically), OBJ is a Lisp integer I such that
XINTPTR (I) == P, as this represents P within a single Lisp value
without requiring any auxiliary memory. However, if P would be
damaged by being tagged as an integer and then untagged via
- XINTPTR, then OBJ is a Lisp_Save_Value with pointer component P.
+ XINTPTR, then OBJ is a Lisp_Misc_Ptr with pointer component P.
mint_ptr objects are efficiency hacks intended for C code.
Although xmint_ptr can be given any mint_ptr generated by non-buggy
make_mint_ptr (void *a)
{
Lisp_Object val = TAG_PTR (Lisp_Int0, a);
- return INTEGERP (val) && XINTPTR (val) == a ? val : make_save_ptr (a);
+ return INTEGERP (val) && XINTPTR (val) == a ? val : make_misc_ptr (a);
}
INLINE bool
mint_ptrp (Lisp_Object x)
{
- return (INTEGERP (x)
- || (SAVE_VALUEP (x) && XSAVE_VALUE (x)->save_type == SAVE_POINTER));
+ return INTEGERP (x) || (MISCP (x) && XMISCTYPE (x) == Lisp_Misc_Ptr);
}
INLINE void *
eassert (mint_ptrp (a));
if (INTEGERP (a))
return XINTPTR (a);
- return XSAVE_POINTER (a, 0);
+ return XUNTAG (a, Lisp_Misc, struct Lisp_Misc_Ptr)->pointer;
}
/* Get and set the Nth saved integer. */
struct Lisp_Overlay u_overlay;
struct Lisp_Save_Value u_save_value;
struct Lisp_Finalizer u_finalizer;
+ struct Lisp_Misc_Ptr u_misc_ptr;
#ifdef HAVE_MODULES
struct Lisp_User_Ptr u_user_ptr;
#endif
extern Lisp_Object make_save_int_int_int (ptrdiff_t, ptrdiff_t, ptrdiff_t);
extern Lisp_Object make_save_obj_obj_obj_obj (Lisp_Object, Lisp_Object,
Lisp_Object, Lisp_Object);
+extern Lisp_Object make_save_ptr (void *);
extern Lisp_Object make_save_ptr_int (void *, ptrdiff_t);
extern Lisp_Object make_save_ptr_ptr (void *, void *);
extern Lisp_Object make_save_funcptr_ptr_obj (void (*) (void), void *,