doc: /* Create a new cons, give it CAR and CDR as components, and return it. */)
(Lisp_Object car, Lisp_Object cdr)
{
- register Lisp_Object val;
- struct Lisp_Cons *p;
-
- p = xmalloc (sizeof *p);
- SCM_NEWSMOB (p->self, lisp_cons_tag, p);
- XSETCONS (val, p);
- XSETCAR (val, car);
- XSETCDR (val, cdr);
- return val;
+ return scm_cons (car, cdr);
}
/* Make a list of 1, 2, 3, 4 or 5 specified objects. */
lisp_misc_tag = scm_make_smob_type ("elisp-misc", 0);
lisp_string_tag = scm_make_smob_type ("elisp-string", 0);
lisp_vectorlike_tag = scm_make_smob_type ("elisp-vectorlike", 0);
- lisp_cons_tag = scm_make_smob_type ("elisp-cons", 0);
/* Used to do Vpurify_flag = Qt here, but Qt isn't set up yet! */
#define lisp_h_CHECK_SYMBOL(x) CHECK_TYPE (SYMBOLP (x), Qsymbolp, x)
#define lisp_h_CHECK_TYPE(ok, predicate, x) \
((ok) ? (void) 0 : (void) wrong_type_argument (predicate, x))
-#define lisp_h_CONSP(x) (SMOB_TYPEP (x, lisp_cons_tag))
+#define lisp_h_CONSP(x) (x && scm_is_pair (x))
#define lisp_h_EQ(x, y) (scm_is_eq (x, y))
#define lisp_h_FLOATP(x) (x && SCM_INEXACTP (x))
#define lisp_h_INTEGERP(x) (SCM_I_INUMP (x))
(eassert ((sym)->redirect == SYMBOL_PLAINVAL), (sym)->val.value)
#define lisp_h_SYMBOLP(x) (SMOB_TYPEP (x, lisp_symbol_tag))
#define lisp_h_VECTORLIKEP(x) (SMOB_TYPEP (x, lisp_vectorlike_tag))
-#define lisp_h_XCAR(c) XCONS (c)->car
-#define lisp_h_XCDR(c) XCONS (c)->cdr
+#define lisp_h_XCAR(c) (scm_car (c))
+#define lisp_h_XCDR(c) (scm_cdr (c))
#define lisp_h_XHASH(a) (SCM_UNPACK (a))
#define lisp_h_XSYMBOL(a) \
(eassert (SYMBOLP (a)), (struct Lisp_Symbol *) SMOB_PTR (a))
# define VECTORLIKEP(x) lisp_h_VECTORLIKEP (x)
# define XCAR(c) lisp_h_XCAR (c)
# define XCDR(c) lisp_h_XCDR (c)
-# define XCONS(a) lisp_h_XCONS (a)
# define XHASH(a) lisp_h_XHASH (a)
# define XSYMBOL(a) lisp_h_XSYMBOL (a)
#endif
scm_t_bits lisp_misc_tag;
scm_t_bits lisp_string_tag;
scm_t_bits lisp_vectorlike_tag;
-scm_t_bits lisp_cons_tag;
enum Lisp_Type
{
/* Extract a value or address from a Lisp_Object. */
-INLINE struct Lisp_Cons *
-XCONS (Lisp_Object a)
-{
- eassert (CONSP (a));
- return SMOB_PTR (a);
-}
-
INLINE struct Lisp_Vector *
XVECTOR (Lisp_Object a)
{
#define XSETINT(a, b) ((a) = make_number (b))
#define XSETFASTINT(a, b) ((a) = make_natnum (b))
-#define XSETCONS(a, b) ((a) = (b)->self)
#define XSETVECTOR(a, b) ((a) = (b)->header.self)
#define XSETSTRING(a, b) ((a) = (b)->self)
#define XSETSYMBOL(a, b) ((a) = (b)->self)
typedef struct interval *INTERVAL;
-struct Lisp_Cons
- {
- Lisp_Object self;
-
- /* Car of this cons cell. */
- Lisp_Object car;
-
- /* Cdr of this cons cell. */
- Lisp_Object cdr;
- };
-
-/* Take the car or cdr of something known to be a cons cell. */
-/* The _addr functions shouldn't be used outside of the minimal set
- of code that has to know what a cons cell looks like. Other code not
- part of the basic lisp implementation should assume that the car and cdr
- fields are not accessible. (What if we want to switch to
- a copying collector someday? Cached cons cell field addresses may be
- invalidated at arbitrary points.) */
-INLINE Lisp_Object *
-xcar_addr (Lisp_Object c)
-{
- return &XCONS (c)->car;
-}
-INLINE Lisp_Object *
-xcdr_addr (Lisp_Object c)
-{
- return &XCONS (c)->cdr;
-}
-
-/* Use these from normal code. */
LISP_MACRO_DEFUN (XCAR, Lisp_Object, (Lisp_Object c), (c))
LISP_MACRO_DEFUN (XCDR, Lisp_Object, (Lisp_Object c), (c))
INLINE void
XSETCAR (Lisp_Object c, Lisp_Object n)
{
- *xcar_addr (c) = n;
+ scm_set_car_x (c, n);
}
INLINE void
XSETCDR (Lisp_Object c, Lisp_Object n)
{
- *xcdr_addr (c) = n;
+ scm_set_cdr_x (c, n);
}
/* Take the car or cdr of something whose type is not known. */
arguments, so we can catch errors with maxargs at compile-time. */
#ifdef _MSC_VER
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
+ SCM_SNARF_INIT (defsubr (&sname);) \
Lisp_Object fnname DEFUN_ARGS_ ## maxargs ; \
static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
{ { NULL, \
Lisp_Object fnname
#else /* not _MSC_VER */
#define DEFUN(lname, fnname, sname, minargs, maxargs, intspec, doc) \
+ SCM_SNARF_INIT (defsubr (&sname);) \
static struct Lisp_Subr alignas (GCALIGNMENT) sname = \
{ { .self = NULL, \
.size = PVEC_SUBR << PSEUDOVECTOR_AREA_BITS }, \
Lisp_Object prev, next, last_boundary;
EMACS_INT size_so_far = 0;
ptrdiff_t count = SPECPDL_INDEX ();
+ static const size_t sizeof_cons = sizeof (scm_t_cell);
/* Make the buffer current to get its local values of variables such
as undo_limit. Also so that Vundo_outer_limit_function can
if (CONSP (next) && NILP (XCAR (next)))
{
/* Add in the space occupied by this element and its chain link. */
- size_so_far += sizeof (struct Lisp_Cons);
+ size_so_far += sizeof_cons;
/* Advance to next element. */
prev = next;
elt = XCAR (next);
/* Add in the space occupied by this element and its chain link. */
- size_so_far += sizeof (struct Lisp_Cons);
+ size_so_far += sizeof_cons;
if (CONSP (elt))
{
- size_so_far += sizeof (struct Lisp_Cons);
+ size_so_far += sizeof_cons;
if (STRINGP (XCAR (elt)))
size_so_far += (sizeof (struct Lisp_String) - 1
+ SCHARS (XCAR (elt)));
}
/* Add in the space occupied by this element and its chain link. */
- size_so_far += sizeof (struct Lisp_Cons);
+ size_so_far += sizeof_cons;
if (CONSP (elt))
{
- size_so_far += sizeof (struct Lisp_Cons);
+ size_so_far += sizeof_cons;
if (STRINGP (XCAR (elt)))
size_so_far += (sizeof (struct Lisp_String) - 1
+ SCHARS (XCAR (elt)));