aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias EngdegÄrd2023-04-16 11:20:05 +0200
committerMattias EngdegÄrd2023-04-16 14:07:36 +0200
commit3c8167ec0f9647e6fc33e65b0a0324f96cb795ee (patch)
tree7178b4c017cc59c77e0c9d7e573243964716fd21
parentbc61a1afdd6c3ba8a605ed46ae97b1e36b40f951 (diff)
downloademacs-3c8167ec0f9647e6fc33e65b0a0324f96cb795ee.tar.gz
emacs-3c8167ec0f9647e6fc33e65b0a0324f96cb795ee.zip
Fit symbol_redirect snugly in two bits
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.
-rw-r--r--src/lisp.h36
-rw-r--r--src/pdumper.c4
2 files changed, 16 insertions, 24 deletions
diff --git a/src/lisp.h b/src/lisp.h
index 78b68880702..4e17e369312 100644
--- a/src/lisp.h
+++ b/src/lisp.h
@@ -810,24 +810,24 @@ typedef struct { void const *fwdptr; } lispfwd;
810 810
811enum symbol_interned 811enum symbol_interned
812{ 812{
813 SYMBOL_UNINTERNED = 0, 813 SYMBOL_UNINTERNED, /* not interned anywhere */
814 SYMBOL_INTERNED = 1, 814 SYMBOL_INTERNED, /* interned but not in initial obarray */
815 SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2 815 SYMBOL_INTERNED_IN_INITIAL_OBARRAY /* interned in initial obarray */
816}; 816};
817 817
818enum symbol_redirect 818enum symbol_redirect
819{ 819{
820 SYMBOL_PLAINVAL = 4, 820 SYMBOL_PLAINVAL, /* plain var, value is in the `value' field */
821 SYMBOL_VARALIAS = 1, 821 SYMBOL_VARALIAS, /* var alias, value is really in the `alias' symbol */
822 SYMBOL_LOCALIZED = 2, 822 SYMBOL_LOCALIZED, /* localized var, value is in the `blv' object */
823 SYMBOL_FORWARDED = 3 823 SYMBOL_FORWARDED /* forwarding var, value is in `forward' */
824}; 824};
825 825
826enum symbol_trapped_write 826enum symbol_trapped_write
827{ 827{
828 SYMBOL_UNTRAPPED_WRITE = 0, 828 SYMBOL_UNTRAPPED_WRITE, /* normal case, just set the value */
829 SYMBOL_NOWRITE = 1, 829 SYMBOL_NOWRITE, /* constant, cannot set, e.g. nil, t, :keyword */
830 SYMBOL_TRAPPED_WRITE = 2 830 SYMBOL_TRAPPED_WRITE /* trap the write, call watcher functions */
831}; 831};
832 832
833struct Lisp_Symbol 833struct Lisp_Symbol
@@ -838,21 +838,13 @@ struct Lisp_Symbol
838 { 838 {
839 bool_bf gcmarkbit : 1; 839 bool_bf gcmarkbit : 1;
840 840
841 /* Indicates where the value can be found: 841 /* Indicates where the value can be found. */
842 0 : it's a plain var, the value is in the `value' field. 842 ENUM_BF (symbol_redirect) redirect : 2;
843 1 : it's a varalias, the value is really in the `alias' symbol.
844 2 : it's a localized var, the value is in the `blv' object.
845 3 : it's a forwarding variable, the value is in `forward'. */
846 ENUM_BF (symbol_redirect) redirect : 3;
847 843
848 /* 0 : normal case, just set the value
849 1 : constant, cannot set, e.g. nil, t, :keywords.
850 2 : trap the write, call watcher functions. */
851 ENUM_BF (symbol_trapped_write) trapped_write : 2; 844 ENUM_BF (symbol_trapped_write) trapped_write : 2;
852 845
853 /* Interned state of the symbol. This is an enumerator from 846 /* Interned state of the symbol. */
854 enum symbol_interned. */ 847 ENUM_BF (symbol_interned) interned : 2;
855 unsigned interned : 2;
856 848
857 /* True means that this variable has been explicitly declared 849 /* True means that this variable has been explicitly declared
858 special (with `defvar' etc), and shouldn't be lexically bound. */ 850 special (with `defvar' etc), and shouldn't be lexically bound. */
diff --git a/src/pdumper.c b/src/pdumper.c
index 2c3828081fa..339aed1f657 100644
--- a/src/pdumper.c
+++ b/src/pdumper.c
@@ -2459,10 +2459,10 @@ dump_symbol (struct dump_context *ctx,
2459 Lisp_Object object, 2459 Lisp_Object object,
2460 dump_off offset) 2460 dump_off offset)
2461{ 2461{
2462#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_999DC26DEC 2462#if CHECK_STRUCTS && !defined HASH_Lisp_Symbol_61B174C9F4
2463# error "Lisp_Symbol changed. See CHECK_STRUCTS comment in config.h." 2463# error "Lisp_Symbol changed. See CHECK_STRUCTS comment in config.h."
2464#endif 2464#endif
2465#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_ADB4F5B113) 2465#if CHECK_STRUCTS && !defined (HASH_symbol_redirect_EA72E4BFF5)
2466# error "symbol_redirect changed. See CHECK_STRUCTS comment in config.h." 2466# error "symbol_redirect changed. See CHECK_STRUCTS comment in config.h."
2467#endif 2467#endif
2468 2468