comparison src/lisp-union.h @ 398:74fd4e045ea6 r21-2-29

Import from CVS: tag r21-2-29
author cvs
date Mon, 13 Aug 2007 11:13:30 +0200
parents 8626e4521993
children 2f8bb876ab1d
comparison
equal deleted inserted replaced
397:f4aeb21a5bad 398:74fd4e045ea6
21 21
22 /* Divergent from FSF. */ 22 /* Divergent from FSF. */
23 23
24 /* Definition of Lisp_Object type as a union. 24 /* Definition of Lisp_Object type as a union.
25 The declaration order of the objects within the struct members 25 The declaration order of the objects within the struct members
26 of the union is dependent on ENDIAN-ness and USE_MINIMAL_TAGBITS. 26 of the union is dependent on ENDIAN-ness.
27 See lisp-disunion.h for more details. */ 27 See lisp-disunion.h for more details. */
28 28
29 typedef 29 typedef
30 union Lisp_Object 30 union Lisp_Object
31 { 31 {
32 /* if non-valbits are at lower addresses */ 32 /* if non-valbits are at lower addresses */
33 #if defined(WORDS_BIGENDIAN) == defined(USE_MINIMAL_TAGBITS) 33 #if defined(WORDS_BIGENDIAN)
34 struct 34 struct
35 { 35 {
36 EMACS_UINT val : VALBITS; 36 EMACS_UINT val : VALBITS;
37 #if GCMARKBITS > 0
38 unsigned int markbit: GCMARKBITS;
39 #endif
40 enum_field (Lisp_Type) type : GCTYPEBITS; 37 enum_field (Lisp_Type) type : GCTYPEBITS;
41 } gu; 38 } gu;
42 39
43 struct 40 struct
44 { 41 {
53 } u; 50 } u;
54 #else /* non-valbits are at higher addresses */ 51 #else /* non-valbits are at higher addresses */
55 struct 52 struct
56 { 53 {
57 enum_field (Lisp_Type) type : GCTYPEBITS; 54 enum_field (Lisp_Type) type : GCTYPEBITS;
58 #if GCMARKBITS > 0
59 unsigned int markbit: GCMARKBITS;
60 #endif
61 EMACS_UINT val : VALBITS; 55 EMACS_UINT val : VALBITS;
62 } gu; 56 } gu;
63 57
64 struct 58 struct
65 { 59 {
80 74
81 /* This was formerly declared 'void *v' etc. but that causes 75 /* This was formerly declared 'void *v' etc. but that causes
82 GCC to accept any (yes, any) pointer as the argument of 76 GCC to accept any (yes, any) pointer as the argument of
83 a function declared to accept a Lisp_Object. */ 77 a function declared to accept a Lisp_Object. */
84 struct nosuchstruct *v; 78 struct nosuchstruct *v;
85 CONST struct nosuchstruct *cv; 79 const struct nosuchstruct *cv;
86 } 80 }
87 Lisp_Object; 81 Lisp_Object;
88 82
89 #define XCHARVAL(x) ((x).gu.val) 83 #define XCHARVAL(x) ((x).gu.val)
90
91 #ifdef USE_MINIMAL_TAGBITS
92 84
93 # define XSETINT(var, value) do { \ 85 # define XSETINT(var, value) do { \
94 EMACS_INT xset_value = (value); \ 86 EMACS_INT xset_value = (value); \
95 Lisp_Object *xset_var = &(var); \ 87 Lisp_Object *xset_var = &(var); \
96 xset_var->s.bits = 1; \ 88 xset_var->s.bits = 1; \
105 # define XSETOBJ(var, vartype, value) do { \ 97 # define XSETOBJ(var, vartype, value) do { \
106 EMACS_UINT xset_value = (EMACS_UINT) (value); \ 98 EMACS_UINT xset_value = (EMACS_UINT) (value); \
107 (var).ui = xset_value; \ 99 (var).ui = xset_value; \
108 } while (0) 100 } while (0)
109 # define XPNTRVAL(x) ((x).ui) 101 # define XPNTRVAL(x) ((x).ui)
110
111 #else /* ! USE_MINIMAL_TAGBITS */
112
113 # define XSETOBJ(var, vartype, value) do { \
114 EMACS_UINT xset_value = (EMACS_UINT) (value); \
115 Lisp_Object *xset_var = &(var); \
116 xset_var->gu.type = (vartype); \
117 xset_var->gu.markbit = 0; \
118 xset_var->gu.val = xset_value; \
119 } while (0)
120 # define XSETINT(var, value) XSETOBJ (var, Lisp_Type_Int, value)
121 # define XSETCHAR(var, value) XSETOBJ (var, Lisp_Type_Char, value)
122 # define XPNTRVAL(x) ((x).gu.val)
123
124 #endif /* ! USE_MINIMAL_TAGBITS */
125 102
126 INLINE Lisp_Object make_int (EMACS_INT val); 103 INLINE Lisp_Object make_int (EMACS_INT val);
127 INLINE Lisp_Object 104 INLINE Lisp_Object
128 make_int (EMACS_INT val) 105 make_int (EMACS_INT val)
129 { 106 {
144 extern Lisp_Object Qnull_pointer, Qzero; 121 extern Lisp_Object Qnull_pointer, Qzero;
145 122
146 #define XREALINT(x) ((x).s.val) 123 #define XREALINT(x) ((x).s.val)
147 #define XUINT(x) ((x).u.val) 124 #define XUINT(x) ((x).u.val)
148 #define XTYPE(x) ((x).gu.type) 125 #define XTYPE(x) ((x).gu.type)
149 #define XGCTYPE(x) XTYPE (x)
150 #define EQ(x,y) ((x).v == (y).v) 126 #define EQ(x,y) ((x).v == (y).v)
151 127
152 #ifdef USE_MINIMAL_TAGBITS
153 #define INTP(x) ((x).s.bits) 128 #define INTP(x) ((x).s.bits)
154 #define GC_EQ(x,y) EQ (x, y) 129 #define INT_PLUS(x,y) make_int (XINT (x) + XINT (y))
155 #else 130 #define INT_MINUS(x,y) make_int (XINT (x) - XINT (y))
156 #define INTP(x) (XTYPE(x) == Lisp_Type_Int) 131 #define INT_PLUS1(x) make_int (XINT (x) + 1)
157 #define GC_EQ(x,y) ((x).gu.val == (y).gu.val && XTYPE (x) == XTYPE (y)) 132 #define INT_MINUS1(x) make_int (XINT (x) - 1)
158 #endif
159
160 #if GCMARKBITS > 0
161 /* XMARKBIT accesses the markbit. Markbits are used only in
162 particular slots of particular structure types. Other markbits are
163 always zero. Outside of garbage collection, all mark bits are
164 always zero. */
165 # define XMARKBIT(x) ((x).gu.markbit)
166 # define XMARK(x) ((void) (XMARKBIT (x) = 1))
167 # define XUNMARK(x) ((void) (XMARKBIT (x) = 0))
168 #else
169 # define XUNMARK(x) DO_NOTHING
170 #endif
171 133
172 /* Convert between a (void *) and a Lisp_Object, as when the 134 /* Convert between a (void *) and a Lisp_Object, as when the
173 Lisp_Object is passed to a toolkit callback function */ 135 Lisp_Object is passed to a toolkit callback function */
174 #define VOID_TO_LISP(larg,varg) \ 136 #define VOID_TO_LISP(larg,varg) \
175 ((void) ((larg).v = (struct nosuchstruct *) (varg))) 137 ((void) ((larg).v = (struct nosuchstruct *) (varg)))
176 #define CVOID_TO_LISP(larg,varg) \ 138 #define CVOID_TO_LISP(larg,varg) \
177 ((void) ((larg).cv = (CONST struct nosuchstruct *) (varg))) 139 ((void) ((larg).cv = (const struct nosuchstruct *) (varg)))
178 #define LISP_TO_VOID(larg) ((void *) ((larg).v)) 140 #define LISP_TO_VOID(larg) ((void *) ((larg).v))
179 #define LISP_TO_CVOID(larg) ((CONST void *) ((larg).cv)) 141 #define LISP_TO_CVOID(larg) ((const void *) ((larg).cv))
180 142
181 /* Convert a Lisp_Object into something that can't be used as an 143 /* Convert a Lisp_Object into something that can't be used as an
182 lvalue. Useful for type-checking. */ 144 lvalue. Useful for type-checking. */
183 #if (__GNUC__ > 1) 145 #if (__GNUC__ > 1)
184 #define NON_LVALUE(larg) ({ (larg); }) 146 #define NON_LVALUE(larg) ({ (larg); })