]> git.eshelyaron.com Git - emacs.git/commitdiff
Fit symbol_redirect snugly in two bits
authorMattias Engdegård <mattiase@acm.org>
Sun, 16 Apr 2023 09:20:05 +0000 (11:20 +0200)
committerMattias Engdegård <mattiase@acm.org>
Sun, 16 Apr 2023 12:07:36 +0000 (14:07 +0200)
This allows the C compiler to do away with all default clauses when
switching on the `redirect` field.

* src/lisp.h (enum symbol_redirect): Use values in the 0..3 range,
which also matches the old comment in struct Lisp_Symbol.
(enum symbol_interned, enum symbol_redirect)
(enum symbol_trapped_write): Comment members.  Remove explicit values.
(struct Lisp_Symbol): Shrink the `redirect` member to 2 bits.
Use the correct type for the `interned` field.
Move value comments to their types.
* src/pdumper.c (dump_symbol): Update hashes.

src/lisp.h
src/pdumper.c

index 78b68880702004941ff21ba7668b38c7573ae2bf..4e17e36931284b1966e12aecd37c3a59ef32517b 100644 (file)
@@ -810,24 +810,24 @@ typedef struct { void const *fwdptr; } lispfwd;
 
 enum symbol_interned
 {
-  SYMBOL_UNINTERNED = 0,
-  SYMBOL_INTERNED = 1,
-  SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2
+  SYMBOL_UNINTERNED,                 /* not interned anywhere */
+  SYMBOL_INTERNED,                   /* interned but not in initial obarray */
+  SYMBOL_INTERNED_IN_INITIAL_OBARRAY  /* interned in initial obarray */
 };
 
 enum symbol_redirect
 {
-  SYMBOL_PLAINVAL  = 4,
-  SYMBOL_VARALIAS  = 1,
-  SYMBOL_LOCALIZED = 2,
-  SYMBOL_FORWARDED = 3
+  SYMBOL_PLAINVAL,   /* plain var, value is in the `value' field */
+  SYMBOL_VARALIAS,   /* var alias, value is really in the `alias' symbol */
+  SYMBOL_LOCALIZED,  /* localized var, value is in the `blv' object */
+  SYMBOL_FORWARDED   /* forwarding var, value is in `forward' */
 };
 
 enum symbol_trapped_write
 {
-  SYMBOL_UNTRAPPED_WRITE = 0,
-  SYMBOL_NOWRITE = 1,
-  SYMBOL_TRAPPED_WRITE = 2
+  SYMBOL_UNTRAPPED_WRITE,  /* normal case, just set the value */
+  SYMBOL_NOWRITE,          /* constant, cannot set, e.g. nil, t, :keyword */
+  SYMBOL_TRAPPED_WRITE     /* trap the write, call watcher functions */
 };
 
 struct Lisp_Symbol
@@ -838,21 +838,13 @@ struct Lisp_Symbol
     {
       bool_bf gcmarkbit : 1;
 
-      /* Indicates where the value can be found:
-        0 : it's a plain var, the value is in the `value' field.
-        1 : it's a varalias, the value is really in the `alias' symbol.
-        2 : it's a localized var, the value is in the `blv' object.
-        3 : it's a forwarding variable, the value is in `forward'.  */
-      ENUM_BF (symbol_redirect) redirect : 3;
+      /* Indicates where the value can be found.  */
+      ENUM_BF (symbol_redirect) redirect : 2;
 
-      /* 0 : normal case, just set the value
-        1 : constant, cannot set, e.g. nil, t, :keywords.
-        2 : trap the write, call watcher functions.  */
       ENUM_BF (symbol_trapped_write) trapped_write : 2;
 
-      /* Interned state of the symbol.  This is an enumerator from
-        enum symbol_interned.  */
-      unsigned interned : 2;
+      /* Interned state of the symbol.  */
+      ENUM_BF (symbol_interned) interned : 2;
 
       /* True means that this variable has been explicitly declared
         special (with `defvar' etc), and shouldn't be lexically bound.  */
index 2c3828081fa0bf5cd64e4b5d5a11c6fb09d2fad3..339aed1f657c8d39099c495cb26b028f669c2245 100644 (file)
@@ -2459,10 +2459,10 @@ dump_symbol (struct dump_context *ctx,
              Lisp_Object object,
              dump_off offset)
 {
-#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_999DC26DEC
+#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_61B174C9F4
 # error "Lisp_Symbol changed. See CHECK_STRUCTS comment in config.h."
 #endif
-#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_ADB4F5B113)
+#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_EA72E4BFF5)
 # error "symbol_redirect changed. See CHECK_STRUCTS comment in config.h."
 #endif