emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Benchmarking temporary Lisp objects [Was: Re: [RFC] temporary Lisp_S


From: Dmitry Antipov
Subject: Re: Benchmarking temporary Lisp objects [Was: Re: [RFC] temporary Lisp_Strings]
Date: Thu, 04 Sep 2014 17:37:30 +0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.0

On 09/04/2014 05:11 PM, Stefan Monnier wrote:

Let's not worry about this case, we can/should punt to Fcons for them.

Thanks to Paul, there is a C99-compilant solution:

#if (__GNUC__ || __HP_cc || __HP_aCC || __IBMC__        \
     || __IBMCPP__ || __ICC || 0x5110 <= __SUNPRO_C)

/* have __attribute__ ((aligned (GCALIGNMENT))) for conses */

#define scoped_cons(car, cdr)                                           \
  make_lisp_ptr (&((struct Lisp_Cons) { car, { cdr } }), Lisp_Cons)

#else /* another compiler, need an explicit alignment */

INLINE Lisp_Object
scoped_cons_init (void *ptr, Lisp_Object x, Lisp_Object y)
{
  struct Lisp_Cons *c = (struct Lisp_Cons *)
    (((uintptr_t) ptr + (GCALIGNMENT - 1)) & ~(GCALIGNMENT - 1));
  c->car = x;
  c->u.cdr = y;
  return make_lisp_ptr (c, Lisp_Cons);
}

#define scoped_cons(car, cdr)                                           \
  scoped_cons_init ((char[sizeof (struct Lisp_Cons)                     \
                          + (GCALIGNMENT - 1)]) {}, (car), (cdr))

#endif /* compiler selection */




reply via email to

[Prev in Thread] Current Thread [Next in Thread]