[Top][All Lists]

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

Re: [RFC, PATCH] shrink struct vectorlike_header #2

From: Paul Eggert
Subject: Re: [RFC, PATCH] shrink struct vectorlike_header #2
Date: Thu, 08 Nov 2012 08:30:13 -0800
User-agent: Mozilla/5.0 (X11; Linux i686; rv:16.0) Gecko/20121028 Thunderbird/16.0.2

On 11/08/2012 07:08 AM, Dmitry Antipov wrote:
> +#define NEXT_IN_FREE_LIST(v) ((struct Lisp_Vectorlike_Free *) v)->next

This solution is nicer than what we have, but it still
has the problem of casting pointers, which would let
the C compiler do optimizations that we don't want to

Another possibility would be something like this:

  static struct Lisp_Vector *
  next_in_free_list (struct Lisp_Vector *v)
    intptr_t i = XIL (v->contents[0]);
    return (struct Lisp_Vector *) i;
  static void
  set_next_in_free_list (struct Lisp_Vector *v, struct Lisp_Vector *next)
    v->contents[0] = XIL ((intptr_t) (next));

That is, define a setter as well as a getter, and use the setter
when modifying the next field.  This would be simpler and
arguably cleaner than the union and would be just as safe, since we
know that Lisp_Object is at least as wide as intptr_t.

reply via email to

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