diff options
| author | Gerd Moellmann | 2001-10-05 09:48:47 +0000 |
|---|---|---|
| committer | Gerd Moellmann | 2001-10-05 09:48:47 +0000 |
| commit | a32fa736966d35fbcfbc149f5923052b183aeec0 (patch) | |
| tree | 3cac6aeb0251fbe79df0a45ba3fc7429749a806d | |
| parent | 656280a67eef9dc13c0a01118cc7bb1f014bbcea (diff) | |
| download | emacs-a32fa736966d35fbcfbc149f5923052b183aeec0.tar.gz emacs-a32fa736966d35fbcfbc149f5923052b183aeec0.zip | |
(LIST_END_P, FOREACH): New macros.
(pure_size) [HAVE_SHM]: Declare extern size_t.
(check_pure_size): Add prototype.
(enum symbol_interned): New enumeration.
(struct Lisp_Symbol): Remove member `obarray', add
`indirect_variable', `constant', and `interned'.
(SYMBOL_INTERNED_P, SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P)
(SYMBOL_CONSTANT_P, SYMBOL_VALUE, SET_SYMBOL_VALUE): New macros.
(indirect_variable): Add prototype.
| -rw-r--r-- | src/lisp.h | 132 |
1 files changed, 117 insertions, 15 deletions
diff --git a/src/lisp.h b/src/lisp.h index e0830b934b3..e7de504f464 100644 --- a/src/lisp.h +++ b/src/lisp.h | |||
| @@ -129,7 +129,7 @@ enum Lisp_Type | |||
| 129 | Lisp_Type_Limit | 129 | Lisp_Type_Limit |
| 130 | }; | 130 | }; |
| 131 | 131 | ||
| 132 | /* This is the set of datatypes that share a common structure. | 132 | /* This is the set of data types that share a common structure. |
| 133 | The first member of the structure is a type code from this set. | 133 | The first member of the structure is a type code from this set. |
| 134 | The enum values are arbitrary, but we'll use large numbers to make it | 134 | The enum values are arbitrary, but we'll use large numbers to make it |
| 135 | more likely that we'll spot the error if a random word in memory is | 135 | more likely that we'll spot the error if a random word in memory is |
| @@ -327,7 +327,7 @@ enum pvec_type | |||
| 327 | 327 | ||
| 328 | /* One need to override this if there must be high bits set in data space | 328 | /* One need to override this if there must be high bits set in data space |
| 329 | (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work | 329 | (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work |
| 330 | on all machines, but would penalise machines which don't need it) | 330 | on all machines, but would penalize machines which don't need it) |
| 331 | */ | 331 | */ |
| 332 | #ifndef XTYPE | 332 | #ifndef XTYPE |
| 333 | #define XTYPE(a) ((enum Lisp_Type) ((a) >> VALBITS)) | 333 | #define XTYPE(a) ((enum Lisp_Type) ((a) >> VALBITS)) |
| @@ -360,7 +360,7 @@ enum pvec_type | |||
| 360 | #ifndef XPNTR | 360 | #ifndef XPNTR |
| 361 | #ifdef HAVE_SHM | 361 | #ifdef HAVE_SHM |
| 362 | /* In this representation, data is found in two widely separated segments. */ | 362 | /* In this representation, data is found in two widely separated segments. */ |
| 363 | extern int pure_size; | 363 | extern size_t pure_size; |
| 364 | #define XPNTR(a) \ | 364 | #define XPNTR(a) \ |
| 365 | (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)) | 365 | (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)) |
| 366 | #else /* not HAVE_SHM */ | 366 | #else /* not HAVE_SHM */ |
| @@ -788,18 +788,6 @@ struct Lisp_Bool_Vector | |||
| 788 | unsigned char data[1]; | 788 | unsigned char data[1]; |
| 789 | }; | 789 | }; |
| 790 | 790 | ||
| 791 | /* In a symbol, the markbit of the plist is used as the gc mark bit */ | ||
| 792 | |||
| 793 | struct Lisp_Symbol | ||
| 794 | { | ||
| 795 | struct Lisp_String *name; | ||
| 796 | Lisp_Object value; | ||
| 797 | Lisp_Object function; | ||
| 798 | Lisp_Object plist; | ||
| 799 | Lisp_Object obarray; | ||
| 800 | struct Lisp_Symbol *next; /* -> next symbol in this obarray bucket */ | ||
| 801 | }; | ||
| 802 | |||
| 803 | /* This structure describes a built-in function. | 791 | /* This structure describes a built-in function. |
| 804 | It is generated by the DEFUN macro only. | 792 | It is generated by the DEFUN macro only. |
| 805 | defsubr makes it into a Lisp object. | 793 | defsubr makes it into a Lisp object. |
| @@ -820,6 +808,90 @@ struct Lisp_Subr | |||
| 820 | 808 | ||
| 821 | 809 | ||
| 822 | /*********************************************************************** | 810 | /*********************************************************************** |
| 811 | Symbols | ||
| 812 | ***********************************************************************/ | ||
| 813 | |||
| 814 | /* Interned state of a symbol. */ | ||
| 815 | |||
| 816 | enum symbol_interned | ||
| 817 | { | ||
| 818 | SYMBOL_UNINTERNED = 0, | ||
| 819 | SYMBOL_INTERNED = 1, | ||
| 820 | SYMBOL_INTERNED_IN_INITIAL_OBARRAY = 2 | ||
| 821 | }; | ||
| 822 | |||
| 823 | /* In a symbol, the markbit of the plist is used as the gc mark bit */ | ||
| 824 | |||
| 825 | struct Lisp_Symbol | ||
| 826 | { | ||
| 827 | /* Non-zero means symbol serves as a variable alias. The symbol | ||
| 828 | holding the real value is found in the value slot. */ | ||
| 829 | unsigned indirect_variable : 1; | ||
| 830 | |||
| 831 | /* Non-zero means symbol is constant, i.e. changing its value | ||
| 832 | should signal an error. */ | ||
| 833 | unsigned constant : 1; | ||
| 834 | |||
| 835 | /* Interned state of the symbol. This is an enumerator from | ||
| 836 | enum symbol_interned. */ | ||
| 837 | unsigned interned : 2; | ||
| 838 | |||
| 839 | /* The symbol's name. This should become a Lisp_Object | ||
| 840 | some day; there's no need for the Lisp_String pointer nowadays. */ | ||
| 841 | struct Lisp_String *name; | ||
| 842 | |||
| 843 | /* Value of the symbol or Qunbound if unbound. If this symbol is a | ||
| 844 | defvaralias, `value' contains the symbol for which it is an | ||
| 845 | alias. Use the SYMBOL_VALUE and SET_SYMBOL_VALUE macros to get | ||
| 846 | and set a symbol's value, to take defvaralias into account. */ | ||
| 847 | Lisp_Object value; | ||
| 848 | |||
| 849 | /* Function value of the symbol or Qunbound if not fcoundp. */ | ||
| 850 | Lisp_Object function; | ||
| 851 | |||
| 852 | /* The symbol's property list. */ | ||
| 853 | Lisp_Object plist; | ||
| 854 | |||
| 855 | /* Next symbol in obarray bucket, if the symbol is interned. */ | ||
| 856 | struct Lisp_Symbol *next; | ||
| 857 | }; | ||
| 858 | |||
| 859 | /* Value is non-zero if SYM is an interned symbol. */ | ||
| 860 | |||
| 861 | #define SYMBOL_INTERNED_P(sym) \ | ||
| 862 | (XSYMBOL (sym)->interned != SYMBOL_UNINTERNED) | ||
| 863 | |||
| 864 | /* Value is non-zero if SYM is interned in initial_obarray. */ | ||
| 865 | |||
| 866 | #define SYMBOL_INTERNED_IN_INITIAL_OBARRAY_P(sym) \ | ||
| 867 | (XSYMBOL (sym)->interned == SYMBOL_INTERNED_IN_INITIAL_OBARRAY) | ||
| 868 | |||
| 869 | /* Value is non-zero if symbol is considered a constant, i.e. its | ||
| 870 | value cannot be changed (there is an exception for keyword symbols, | ||
| 871 | whose value can be set to the keyword symbol itself). */ | ||
| 872 | |||
| 873 | #define SYMBOL_CONSTANT_P(sym) XSYMBOL (sym)->constant | ||
| 874 | |||
| 875 | /* Value is the value of SYM, with defvaralias taken into | ||
| 876 | account. */ | ||
| 877 | |||
| 878 | #define SYMBOL_VALUE(sym) \ | ||
| 879 | (XSYMBOL (sym)->indirect_variable \ | ||
| 880 | ? XSYMBOL (indirect_variable (sym))->value \ | ||
| 881 | : XSYMBOL (sym)->value) | ||
| 882 | |||
| 883 | /* Set SYM's value to VAL, taking defvaralias into account. */ | ||
| 884 | |||
| 885 | #define SET_SYMBOL_VALUE(sym, val) \ | ||
| 886 | do { \ | ||
| 887 | if (XSYMBOL (sym)->indirect_variable) \ | ||
| 888 | XSYMBOL (indirect_variable ((sym)))->value = (val); \ | ||
| 889 | else \ | ||
| 890 | XSYMBOL (sym)->value = (val); \ | ||
| 891 | } while (0) | ||
| 892 | |||
| 893 | |||
| 894 | /*********************************************************************** | ||
| 823 | Hash Tables | 895 | Hash Tables |
| 824 | ***********************************************************************/ | 896 | ***********************************************************************/ |
| 825 | 897 | ||
| @@ -1923,6 +1995,7 @@ EXFUN (Fadd1, 1); | |||
| 1923 | EXFUN (Fsub1, 1); | 1995 | EXFUN (Fsub1, 1); |
| 1924 | EXFUN (Fmake_variable_buffer_local, 1); | 1996 | EXFUN (Fmake_variable_buffer_local, 1); |
| 1925 | 1997 | ||
| 1998 | extern Lisp_Object indirect_variable P_ ((Lisp_Object)); | ||
| 1926 | extern Lisp_Object long_to_cons P_ ((unsigned long)); | 1999 | extern Lisp_Object long_to_cons P_ ((unsigned long)); |
| 1927 | extern unsigned long cons_to_long P_ ((Lisp_Object)); | 2000 | extern unsigned long cons_to_long P_ ((Lisp_Object)); |
| 1928 | extern void args_out_of_range P_ ((Lisp_Object, Lisp_Object)); | 2001 | extern void args_out_of_range P_ ((Lisp_Object, Lisp_Object)); |
| @@ -2186,6 +2259,7 @@ extern int pos_visible_p P_ ((struct window *, int, int *, int)); | |||
| 2186 | extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ())); | 2259 | extern void memory_warnings P_ ((POINTER_TYPE *, void (*warnfun) ())); |
| 2187 | 2260 | ||
| 2188 | /* Defined in alloc.c */ | 2261 | /* Defined in alloc.c */ |
| 2262 | extern void check_pure_size P_ ((void)); | ||
| 2189 | extern void allocate_string_data P_ ((struct Lisp_String *, int, int)); | 2263 | extern void allocate_string_data P_ ((struct Lisp_String *, int, int)); |
| 2190 | extern void uninterrupt_malloc P_ ((void)); | 2264 | extern void uninterrupt_malloc P_ ((void)); |
| 2191 | extern void malloc_warning P_ ((char *)); | 2265 | extern void malloc_warning P_ ((char *)); |
| @@ -2986,3 +3060,31 @@ extern Lisp_Object Vdirectory_sep_char; | |||
| 2986 | #else | 3060 | #else |
| 2987 | #define SWITCH_ENUM_CAST(x) (x) | 3061 | #define SWITCH_ENUM_CAST(x) (x) |
| 2988 | #endif | 3062 | #endif |
| 3063 | |||
| 3064 | /* Loop over Lisp list LIST. Signal an error if LIST is not a proper | ||
| 3065 | list, or if it contains circles. | ||
| 3066 | |||
| 3067 | HARE and TORTOISE should be the names of Lisp_Object variables, and | ||
| 3068 | N should be the name of an EMACS_INT variable declared in the | ||
| 3069 | function where the macro is used. Each nested loop should use | ||
| 3070 | its own variables. | ||
| 3071 | |||
| 3072 | In the loop body, HARE is set to each cons of LIST, and N is the | ||
| 3073 | length of the list processed so far. */ | ||
| 3074 | |||
| 3075 | #define LIST_END_P(list, obj) \ | ||
| 3076 | (NILP (obj) \ | ||
| 3077 | ? 1 \ | ||
| 3078 | : (CONSP (obj) \ | ||
| 3079 | ? 0 \ | ||
| 3080 | : (wrong_type_argument (Qlistp, (list), 0)), 1)) | ||
| 3081 | |||
| 3082 | #define FOREACH(hare, list, tortoise, n) \ | ||
| 3083 | for (tortoise = hare = (list), n = 0; \ | ||
| 3084 | !LIST_END_P (list, hare); \ | ||
| 3085 | (hare = XCDR (hare), ++n, \ | ||
| 3086 | ((n & 1) != 0 \ | ||
| 3087 | ? (tortoise = XCDR (tortoise), \ | ||
| 3088 | (EQ (hare, tortoise) \ | ||
| 3089 | && (circular_list_error ((list)), 1))) \ | ||
| 3090 | : 0))) | ||