From 770aaffe0ae52fb9305f9e2b646803ab2c4c0f84 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Mon, 24 Jun 2024 10:06:54 +0200 Subject: [PATCH 1/2] Move the Lisp_Fwd.bufoffset field back to the union * src/lisp.h (struct Lisp_Fwd): With the predicate enum, we can now pack the offset and the predicate into a one-word struct. (XBUFFER_OFFSET): Use the new field name. * src/buffer.c (DEFVAR_PER_BUFFER): Create the one-word struct. * src/data.c (store_symval_forwarding): Use the new field name. --- src/buffer.c | 15 +++++++++------ src/data.c | 2 +- src/lisp.h | 9 ++++++--- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/buffer.c b/src/buffer.c index 39b5e29067a..a69a9a3bbd8 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -5017,14 +5017,17 @@ init_buffer (void) that nil is allowed too). DOC is a dummy where you write the doc string as a comment. */ -#define DEFVAR_PER_BUFFER(lname, vname, predicate, doc) \ +#define DEFVAR_PER_BUFFER(lname, vname, predicate_, doc) \ do { \ - static const struct Lisp_Fwd bo_fwd \ - = { .type = Lisp_Fwd_Buffer_Obj, \ - .bufoffset = offsetof (struct buffer, vname##_), \ - .u.bufpredicate = FWDPRED_##predicate }; \ + static const struct Lisp_Fwd bo_fwd = { \ + .type = Lisp_Fwd_Buffer_Obj, \ + .u.buf = { \ + .offset = offsetof (struct buffer, vname##_), \ + .predicate = FWDPRED_##predicate_ \ + } \ + }; \ static_assert (offsetof (struct buffer, vname##_) \ - < (1 << 8 * sizeof bo_fwd.bufoffset)); \ + < (1 << 8 * sizeof bo_fwd.u.buf.offset)); \ defvar_per_buffer (&bo_fwd, lname); \ } while (0) diff --git a/src/data.c b/src/data.c index 9fd439e07b5..dcf869c1a0e 100644 --- a/src/data.c +++ b/src/data.c @@ -1513,7 +1513,7 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, { int offset = XBUFFER_OFFSET (valcontents); if (!NILP (newval)) - check_fwd_predicate (valcontents->u.bufpredicate, newval); + check_fwd_predicate (valcontents->u.buf.predicate, newval); if (buf == NULL) buf = current_buffer; set_per_buffer_value (buf, offset, newval); diff --git a/src/lisp.h b/src/lisp.h index e3c2dce7df0..912b208a213 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3180,13 +3180,16 @@ #define INT_TO_INTEGER(expr) \ struct Lisp_Fwd { enum Lisp_Fwd_Type type : 8; - uint16_t bufoffset; /* used if type == Lisp_Fwd_Buffer_Obj */ union { intmax_t *intvar; bool *boolvar; Lisp_Object *objvar; - enum Lisp_Fwd_Predicate bufpredicate; + struct + { + uint16_t offset; + enum Lisp_Fwd_Predicate predicate : 8; + } buf; int kbdoffset; } u; }; @@ -3207,7 +3210,7 @@ BUFFER_OBJFWDP (lispfwd a) XBUFFER_OFFSET (lispfwd a) { eassert (BUFFER_OBJFWDP (a)); - return a->bufoffset; + return a->u.buf.offset; } INLINE bool -- 2.39.2