From 67cb8dd5e597e3725f7adfccadc14ac18f2ec241 Mon Sep 17 00:00:00 2001 From: Helmut Eller Date: Sun, 23 Jun 2024 11:25:35 +0200 Subject: [PATCH 2/6] Remove struct Lisp_Intfwd It was a struct with a single field. * src/lisp.h (struct Lisp_Intfwd): Deleted. (struct Lisp_Fwd): Add an intvar field instead. (DEFVAR_INT): Update accordingly. * src/data.c (XINTVAR): Updated and renamed from XFIXNUMFWD. (do_symval_forwarding, store_symval_forwarding): Use it. --- src/data.c | 10 +++++----- src/lisp.h | 22 ++++++---------------- src/pdumper.c | 4 ++-- 3 files changed, 13 insertions(+), 23 deletions(-) diff --git a/src/data.c b/src/data.c index 4a6a247e89e..9b3984d80e6 100644 --- a/src/data.c +++ b/src/data.c @@ -67,11 +67,11 @@ XKBOARD_OBJFWD (lispfwd a) eassert (KBOARD_OBJFWDP (a)); return &a->u.kboardobjfwd; } -static struct Lisp_Intfwd const * -XFIXNUMFWD (lispfwd a) +static intmax_t * +XINTVAR (lispfwd a) { eassert (INTFWDP (a)); - return &a->u.intfwd; + return a->u.intvar; } static struct Lisp_Objfwd const * XOBJFWD (lispfwd a) @@ -1333,7 +1333,7 @@ do_symval_forwarding (lispfwd valcontents) switch (XFWDTYPE (valcontents)) { case Lisp_Fwd_Int: - return make_int (*XFIXNUMFWD (valcontents)->intvar); + return make_int (*XINTVAR (valcontents)); case Lisp_Fwd_Bool: return (*XBOOLFWD (valcontents)->boolvar ? Qt : Qnil); @@ -1419,7 +1419,7 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, CHECK_INTEGER (newval); if (! integer_to_intmax (newval, &i)) xsignal1 (Qoverflow_error, newval); - *XFIXNUMFWD (valcontents)->intvar = i; + *XINTVAR (valcontents) = i; } break; diff --git a/src/lisp.h b/src/lisp.h index 3ce5e2b4d66..bfbf2447635 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -3115,15 +3115,6 @@ #define INT_TO_INTEGER(expr) \ (EXPR_SIGNED (expr) ? make_int (expr) : make_uint (expr)) -/* Forwarding pointer to an int variable. - This is allowed only in the value cell of a symbol, - and it means that the symbol's value really lives in the - specified int variable. */ -struct Lisp_Intfwd - { - intmax_t *intvar; - }; - /* Boolean forwarding pointer to an int variable. This is like Lisp_Intfwd except that the ostensible "value" of the symbol is t if the bool variable is true, @@ -3206,7 +3197,7 @@ #define INT_TO_INTEGER(expr) \ enum Lisp_Fwd_Type type; union { - struct Lisp_Intfwd intfwd; + intmax_t *intvar; struct Lisp_Boolfwd boolfwd; struct Lisp_Objfwd objfwd; struct Lisp_Buffer_Objfwd bufobjfwd; @@ -3628,13 +3619,12 @@ #define DEFVAR_BOOL(lname, vname, doc) \ = {Lisp_Fwd_Bool, .u.boolfwd = {&globals.f_##vname}}; \ defvar_bool (&b_fwd, lname); \ } while (false) -#define DEFVAR_INT(lname, vname, doc) \ - do { \ - static struct Lisp_Fwd const i_fwd \ - = {Lisp_Fwd_Int, .u.intfwd = {&globals.f_##vname}}; \ - defvar_int (&i_fwd, lname); \ +#define DEFVAR_INT(lname, vname, doc) \ + do { \ + static struct Lisp_Fwd const i_fwd \ + = {Lisp_Fwd_Int, .u.intvar = &globals.f_##vname}; \ + defvar_int (&i_fwd, lname); \ } while (false) - #define DEFVAR_KBOARD(lname, vname, doc) \ do \ { \ diff --git a/src/pdumper.c b/src/pdumper.c index d8e21b569f1..84175ea9a2c 100644 --- a/src/pdumper.c +++ b/src/pdumper.c @@ -2367,8 +2367,8 @@ dump_field_fwd (struct dump_context *ctx, void *out, const void *in_start, { case Lisp_Fwd_Int: { - const struct Lisp_Intfwd *fwd = &(*in_field)->u.intfwd; - dump_emacs_reloc_immediate_intmax_t (ctx, fwd->intvar, *fwd->intvar); + const intmax_t *intvar = (*in_field)->u.intvar; + dump_emacs_reloc_immediate_intmax_t (ctx, intvar, *intvar); } return; case Lisp_Fwd_Bool: -- 2.39.2