diff options
| author | Helmut Eller | 2024-06-23 17:25:21 +0200 |
|---|---|---|
| committer | Helmut Eller | 2026-02-12 18:51:51 +0100 |
| commit | 3442fdd2a2d9702bf9ed856b9bf0a0b1d0992747 (patch) | |
| tree | 90340ebf9863356a779c96dd6ef810cd3aabd5c9 /src | |
| parent | 163dd21e7305bbd91aecb87cb4968970d1e1e873 (diff) | |
| download | emacs-3442fdd2a2d9702bf9ed856b9bf0a0b1d0992747.tar.gz emacs-3442fdd2a2d9702bf9ed856b9bf0a0b1d0992747.zip | |
Remove struct Lisp_Buffer_Objfwd
* src/lisp.h (struct Lisp_Buffer_Objfwd): Deleted.
(struct Lisp_Fwd): Add the fields bufoffset and bufpredicate.
Make the type a 1-byte bitfield so that the entire struct still
fits in two words.
(XBUFFER_OFFSET): Renamed from XBUFFER_OBJFWD.
* src/buffer.c (DEFVAR_PER_BUFFER, defvar_per_buffer)
(buffer_local_value): Update accordingly.
* src/data.c (do_symval_forwarding, store_symval_forwarding)
(set_internal, default_value, set_default_internal)
(Fmake_local_variable, Fkill_local_variable, Flocal_variable_): Use
XBUFFER_OFFSET.
Diffstat (limited to 'src')
| -rw-r--r-- | src/buffer.c | 29 | ||||
| -rw-r--r-- | src/data.c | 19 | ||||
| -rw-r--r-- | src/lisp.h | 30 |
3 files changed, 39 insertions, 39 deletions
diff --git a/src/buffer.c b/src/buffer.c index 9abce241897..cc559ad0ad6 100644 --- a/src/buffer.c +++ b/src/buffer.c | |||
| @@ -1402,7 +1402,7 @@ buffer_local_value (Lisp_Object variable, Lisp_Object buffer) | |||
| 1402 | { | 1402 | { |
| 1403 | lispfwd fwd = SYMBOL_FWD (sym); | 1403 | lispfwd fwd = SYMBOL_FWD (sym); |
| 1404 | if (BUFFER_OBJFWDP (fwd)) | 1404 | if (BUFFER_OBJFWDP (fwd)) |
| 1405 | result = per_buffer_value (buf, XBUFFER_OBJFWD (fwd)->offset); | 1405 | result = per_buffer_value (buf, XBUFFER_OFFSET (fwd)); |
| 1406 | else | 1406 | else |
| 1407 | result = Fdefault_value (variable); | 1407 | result = Fdefault_value (variable); |
| 1408 | break; | 1408 | break; |
| @@ -4982,32 +4982,31 @@ init_buffer (void) | |||
| 4982 | 4982 | ||
| 4983 | /* FIXME: use LISPSYM_INITIALLY instead of TAG_PTR_INITIALLY */ | 4983 | /* FIXME: use LISPSYM_INITIALLY instead of TAG_PTR_INITIALLY */ |
| 4984 | #define DEFVAR_PER_BUFFER(lname, vname, predicate_, doc) \ | 4984 | #define DEFVAR_PER_BUFFER(lname, vname, predicate_, doc) \ |
| 4985 | do \ | 4985 | do { \ |
| 4986 | { \ | 4986 | const Lisp_Object sym \ |
| 4987 | const Lisp_Object sym = TAG_PTR_INITIALLY ( \ | 4987 | = TAG_PTR_INITIALLY (Lisp_Symbol, (intptr_t)((i##predicate_) \ |
| 4988 | Lisp_Symbol, (intptr_t)((i##predicate_) * sizeof *lispsym)); \ | 4988 | * sizeof *lispsym)); \ |
| 4989 | static const struct Lisp_Fwd bo_fwd = { \ | 4989 | static const struct Lisp_Fwd bo_fwd \ |
| 4990 | .type = Lisp_Fwd_Buffer_Obj, \ | 4990 | = { .type = Lisp_Fwd_Buffer_Obj, \ |
| 4991 | .u.bufobjfwd = { .offset = offsetof (struct buffer, vname##_), \ | 4991 | .bufoffset = offsetof (struct buffer, vname##_), \ |
| 4992 | .predicate = sym }, \ | 4992 | .u.bufpredicate = sym }; \ |
| 4993 | }; \ | 4993 | static_assert (offsetof (struct buffer, vname##_) \ |
| 4994 | < (1 << 8 * sizeof bo_fwd.bufoffset)); \ | ||
| 4994 | defvar_per_buffer (&bo_fwd, lname); \ | 4995 | defvar_per_buffer (&bo_fwd, lname); \ |
| 4995 | } \ | 4996 | } while (0) |
| 4996 | while (0) | ||
| 4997 | 4997 | ||
| 4998 | static void | 4998 | static void |
| 4999 | defvar_per_buffer (const struct Lisp_Fwd *fwd, const char *namestring) | 4999 | defvar_per_buffer (const struct Lisp_Fwd *fwd, const char *namestring) |
| 5000 | { | 5000 | { |
| 5001 | eassert (fwd->type == Lisp_Fwd_Buffer_Obj); | 5001 | eassert (fwd->type == Lisp_Fwd_Buffer_Obj); |
| 5002 | const struct Lisp_Buffer_Objfwd *bo_fwd = XBUFFER_OBJFWD (fwd); | ||
| 5003 | struct Lisp_Symbol *sym = XSYMBOL (intern (namestring)); | 5002 | struct Lisp_Symbol *sym = XSYMBOL (intern (namestring)); |
| 5004 | 5003 | ||
| 5005 | sym->u.s.declared_special = true; | 5004 | sym->u.s.declared_special = true; |
| 5006 | sym->u.s.redirect = SYMBOL_FORWARDED; | 5005 | sym->u.s.redirect = SYMBOL_FORWARDED; |
| 5007 | SET_SYMBOL_FWD (sym, fwd); | 5006 | SET_SYMBOL_FWD (sym, fwd); |
| 5008 | XSETSYMBOL (PER_BUFFER_SYMBOL (bo_fwd->offset), sym); | 5007 | XSETSYMBOL (PER_BUFFER_SYMBOL (XBUFFER_OFFSET (fwd)), sym); |
| 5009 | 5008 | ||
| 5010 | if (PER_BUFFER_IDX (bo_fwd->offset) == 0) | 5009 | if (PER_BUFFER_IDX (XBUFFER_OFFSET (fwd)) == 0) |
| 5011 | /* Did a DEFVAR_PER_BUFFER without initializing the corresponding | 5010 | /* Did a DEFVAR_PER_BUFFER without initializing the corresponding |
| 5012 | slot of buffer_local_flags. */ | 5011 | slot of buffer_local_flags. */ |
| 5013 | emacs_abort (); | 5012 | emacs_abort (); |
diff --git a/src/data.c b/src/data.c index 6b46a771ba8..5eda4f2f599 100644 --- a/src/data.c +++ b/src/data.c | |||
| @@ -1342,7 +1342,7 @@ do_symval_forwarding (lispfwd valcontents) | |||
| 1342 | 1342 | ||
| 1343 | case Lisp_Fwd_Buffer_Obj: | 1343 | case Lisp_Fwd_Buffer_Obj: |
| 1344 | return per_buffer_value (current_buffer, | 1344 | return per_buffer_value (current_buffer, |
| 1345 | XBUFFER_OBJFWD (valcontents)->offset); | 1345 | XBUFFER_OFFSET (valcontents)); |
| 1346 | 1346 | ||
| 1347 | case Lisp_Fwd_Kboard_Obj: | 1347 | case Lisp_Fwd_Kboard_Obj: |
| 1348 | return *(Lisp_Object *) (XKBOARD_OFFSET (valcontents) | 1348 | return *(Lisp_Object *) (XKBOARD_OFFSET (valcontents) |
| @@ -1457,9 +1457,8 @@ store_symval_forwarding (lispfwd valcontents, Lisp_Object newval, | |||
| 1457 | 1457 | ||
| 1458 | case Lisp_Fwd_Buffer_Obj: | 1458 | case Lisp_Fwd_Buffer_Obj: |
| 1459 | { | 1459 | { |
| 1460 | const struct Lisp_Buffer_Objfwd *fwd = XBUFFER_OBJFWD (valcontents); | 1460 | int offset = XBUFFER_OFFSET (valcontents); |
| 1461 | int offset = fwd->offset; | 1461 | Lisp_Object predicate = valcontents->u.bufpredicate; |
| 1462 | Lisp_Object predicate = fwd->predicate; | ||
| 1463 | 1462 | ||
| 1464 | if (!NILP (newval) && !NILP (predicate)) | 1463 | if (!NILP (newval) && !NILP (predicate)) |
| 1465 | { | 1464 | { |
| @@ -1774,7 +1773,7 @@ set_internal (Lisp_Object symbol, Lisp_Object newval, Lisp_Object where, | |||
| 1774 | 1773 | ||
| 1775 | if (BUFFER_OBJFWDP (innercontents)) | 1774 | if (BUFFER_OBJFWDP (innercontents)) |
| 1776 | { | 1775 | { |
| 1777 | int offset = XBUFFER_OBJFWD (innercontents)->offset; | 1776 | int offset = XBUFFER_OFFSET (innercontents); |
| 1778 | int idx = PER_BUFFER_IDX (offset); | 1777 | int idx = PER_BUFFER_IDX (offset); |
| 1779 | if (idx > 0 && bindflag == SET_INTERNAL_SET | 1778 | if (idx > 0 && bindflag == SET_INTERNAL_SET |
| 1780 | && !PER_BUFFER_VALUE_P (buf, idx)) | 1779 | && !PER_BUFFER_VALUE_P (buf, idx)) |
| @@ -1956,7 +1955,7 @@ default_value (Lisp_Object symbol) | |||
| 1956 | rather than letting do_symval_forwarding get the current value. */ | 1955 | rather than letting do_symval_forwarding get the current value. */ |
| 1957 | if (BUFFER_OBJFWDP (valcontents)) | 1956 | if (BUFFER_OBJFWDP (valcontents)) |
| 1958 | { | 1957 | { |
| 1959 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 1958 | int offset = XBUFFER_OFFSET (valcontents); |
| 1960 | if (PER_BUFFER_IDX (offset) != 0) | 1959 | if (PER_BUFFER_IDX (offset) != 0) |
| 1961 | return per_buffer_default (offset); | 1960 | return per_buffer_default (offset); |
| 1962 | } | 1961 | } |
| @@ -2051,7 +2050,7 @@ set_default_internal (Lisp_Object symbol, Lisp_Object value, | |||
| 2051 | Make them work apparently like Lisp_Buffer_Local_Value variables. */ | 2050 | Make them work apparently like Lisp_Buffer_Local_Value variables. */ |
| 2052 | if (BUFFER_OBJFWDP (valcontents)) | 2051 | if (BUFFER_OBJFWDP (valcontents)) |
| 2053 | { | 2052 | { |
| 2054 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 2053 | int offset = XBUFFER_OFFSET (valcontents); |
| 2055 | int idx = PER_BUFFER_IDX (offset); | 2054 | int idx = PER_BUFFER_IDX (offset); |
| 2056 | 2055 | ||
| 2057 | set_per_buffer_default (offset, value); | 2056 | set_per_buffer_default (offset, value); |
| @@ -2263,7 +2262,7 @@ Instead, use `add-hook' and specify t for the LOCAL argument. */) | |||
| 2263 | { | 2262 | { |
| 2264 | if (forwarded && BUFFER_OBJFWDP (valcontents.fwd)) | 2263 | if (forwarded && BUFFER_OBJFWDP (valcontents.fwd)) |
| 2265 | { | 2264 | { |
| 2266 | int offset = XBUFFER_OBJFWD (valcontents.fwd)->offset; | 2265 | int offset = XBUFFER_OFFSET (valcontents.fwd); |
| 2267 | int idx = PER_BUFFER_IDX (offset); | 2266 | int idx = PER_BUFFER_IDX (offset); |
| 2268 | eassert (idx); | 2267 | eassert (idx); |
| 2269 | if (idx > 0) | 2268 | if (idx > 0) |
| @@ -2335,7 +2334,7 @@ From now on the default value will apply in this buffer. Return VARIABLE. */) | |||
| 2335 | lispfwd valcontents = SYMBOL_FWD (sym); | 2334 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 2336 | if (BUFFER_OBJFWDP (valcontents)) | 2335 | if (BUFFER_OBJFWDP (valcontents)) |
| 2337 | { | 2336 | { |
| 2338 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 2337 | int offset = XBUFFER_OFFSET (valcontents); |
| 2339 | int idx = PER_BUFFER_IDX (offset); | 2338 | int idx = PER_BUFFER_IDX (offset); |
| 2340 | 2339 | ||
| 2341 | if (idx > 0) | 2340 | if (idx > 0) |
| @@ -2416,7 +2415,7 @@ Also see `buffer-local-boundp'.*/) | |||
| 2416 | lispfwd valcontents = SYMBOL_FWD (sym); | 2415 | lispfwd valcontents = SYMBOL_FWD (sym); |
| 2417 | if (BUFFER_OBJFWDP (valcontents)) | 2416 | if (BUFFER_OBJFWDP (valcontents)) |
| 2418 | { | 2417 | { |
| 2419 | int offset = XBUFFER_OBJFWD (valcontents)->offset; | 2418 | int offset = XBUFFER_OFFSET (valcontents); |
| 2420 | int idx = PER_BUFFER_IDX (offset); | 2419 | int idx = PER_BUFFER_IDX (offset); |
| 2421 | if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) | 2420 | if (idx == -1 || PER_BUFFER_VALUE_P (buf, idx)) |
| 2422 | return Qt; | 2421 | return Qt; |
diff --git a/src/lisp.h b/src/lisp.h index bf446256774..8a8f27b0271 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -3053,15 +3053,6 @@ make_uint (uintmax_t n) | |||
| 3053 | (EXPR_SIGNED (expr) ? make_int (expr) : make_uint (expr)) | 3053 | (EXPR_SIGNED (expr) ? make_int (expr) : make_uint (expr)) |
| 3054 | 3054 | ||
| 3055 | 3055 | ||
| 3056 | /* Like Lisp_Objfwd except that value lives in a slot in the | ||
| 3057 | current buffer. Value is byte index of slot within buffer. */ | ||
| 3058 | struct Lisp_Buffer_Objfwd | ||
| 3059 | { | ||
| 3060 | int offset; | ||
| 3061 | /* One of Qnil, Qintegerp, Qsymbolp, Qstringp, Qfloatp or Qnumberp. */ | ||
| 3062 | Lisp_Object predicate; | ||
| 3063 | }; | ||
| 3064 | |||
| 3065 | /* struct Lisp_Buffer_Local_Value is used in a symbol value cell when | 3056 | /* struct Lisp_Buffer_Local_Value is used in a symbol value cell when |
| 3066 | the symbol has buffer-local bindings. (Exception: | 3057 | the symbol has buffer-local bindings. (Exception: |
| 3067 | some buffer-local variables are built-in, with their values stored | 3058 | some buffer-local variables are built-in, with their values stored |
| @@ -3105,15 +3096,26 @@ struct Lisp_Buffer_Local_Value | |||
| 3105 | Lisp_Object valcell; | 3096 | Lisp_Object valcell; |
| 3106 | }; | 3097 | }; |
| 3107 | 3098 | ||
| 3099 | /* A struct Lisp_Fwd is used to locate a variable. See Lisp_Fwd_Type | ||
| 3100 | for the various types of variables. | ||
| 3101 | |||
| 3102 | Lisp_Fwd structs are created by macros like DEFVAR_INT, DEFVAR_BOOL etc. | ||
| 3103 | and are always kept in static variables. They are never allocated | ||
| 3104 | dynamically. */ | ||
| 3105 | |||
| 3108 | struct Lisp_Fwd | 3106 | struct Lisp_Fwd |
| 3109 | { | 3107 | { |
| 3110 | enum Lisp_Fwd_Type type; | 3108 | enum Lisp_Fwd_Type type : 8; |
| 3109 | uint16_t bufoffset; /* used if type == Lisp_Fwd_Buffer_Obj */ | ||
| 3111 | union | 3110 | union |
| 3112 | { | 3111 | { |
| 3113 | intmax_t *intvar; | 3112 | intmax_t *intvar; |
| 3114 | bool *boolvar; | 3113 | bool *boolvar; |
| 3115 | Lisp_Object *objvar; | 3114 | Lisp_Object *objvar; |
| 3116 | struct Lisp_Buffer_Objfwd bufobjfwd; | 3115 | /* One of Qnil, Qintegerp, Qsymbolp, Qstringp, Qfloatp, Qnumberp, |
| 3116 | Qfraction, Qvertical_scroll_bar, or Qoverwrite_mode. | ||
| 3117 | */ | ||
| 3118 | Lisp_Object bufpredicate; | ||
| 3117 | int kbdoffset; | 3119 | int kbdoffset; |
| 3118 | } u; | 3120 | } u; |
| 3119 | }; | 3121 | }; |
| @@ -3130,11 +3132,11 @@ BUFFER_OBJFWDP (lispfwd a) | |||
| 3130 | return XFWDTYPE (a) == Lisp_Fwd_Buffer_Obj; | 3132 | return XFWDTYPE (a) == Lisp_Fwd_Buffer_Obj; |
| 3131 | } | 3133 | } |
| 3132 | 3134 | ||
| 3133 | INLINE struct Lisp_Buffer_Objfwd const * | 3135 | INLINE int |
| 3134 | XBUFFER_OBJFWD (lispfwd a) | 3136 | XBUFFER_OFFSET (lispfwd a) |
| 3135 | { | 3137 | { |
| 3136 | eassert (BUFFER_OBJFWDP (a)); | 3138 | eassert (BUFFER_OBJFWDP (a)); |
| 3137 | return &a->u.bufobjfwd; | 3139 | return a->bufoffset; |
| 3138 | } | 3140 | } |
| 3139 | 3141 | ||
| 3140 | INLINE bool | 3142 | INLINE bool |