0
|
1 /* Fundamental definitions for XEmacs Lisp interpreter -- union objects.
|
|
2 Copyright (C) 1985, 1986, 1987, 1992, 1993, 1994
|
|
3 Free Software Foundation, Inc.
|
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
11
|
|
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
15 for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: FSF 19.30. Split out from lisp.h. */
|
|
23
|
|
24 typedef
|
|
25 union Lisp_Object
|
185
|
26 {
|
|
27 struct
|
0
|
28 {
|
185
|
29 #if (!!defined (WORDS_BIGENDIAN) != !!defined (LOWTAGS))
|
|
30 /* Big-endian lowtags, little-endian hightags */
|
207
|
31 unsigned EMACS_INT type_mark: GCTYPEBITS + GCMARKBITS;
|
185
|
32 signed EMACS_INT val: VALBITS;
|
0
|
33 #else /* If WORDS_BIGENDIAN, or little-endian hightags */
|
185
|
34 signed EMACS_INT val: VALBITS;
|
207
|
35 unsigned EMACS_INT mark_type: GCTYPEBITS + GCMARKBITS;
|
185
|
36 #endif /* BIG/LITTLE_ENDIAN vs HIGH/LOWTAGS */
|
|
37 } s;
|
|
38 struct
|
0
|
39 {
|
185
|
40 #if (!!defined (WORDS_BIGENDIAN) == !!defined (LOWTAGS))
|
|
41 unsigned EMACS_INT val: VALBITS;
|
|
42 #endif
|
0
|
43 #ifdef __GNUC__ /* Non-ANSI extension */
|
185
|
44 enum Lisp_Type type: GCTYPEBITS;
|
0
|
45 #else
|
185
|
46 unsigned EMACS_INT type: GCTYPEBITS;
|
0
|
47 #endif /* __GNUC__ */
|
185
|
48 /* The markbit is not really part of the value of a Lisp_Object,
|
|
49 and is always zero except during garbage collection. */
|
207
|
50 #if GCMARKBITS > 0
|
|
51 unsigned EMACS_INT markbit: GCMARKBITS;
|
|
52 #endif
|
185
|
53 #if (!!defined (WORDS_BIGENDIAN) != !!defined (LOWTAGS))
|
|
54 unsigned EMACS_INT val: VALBITS;
|
|
55 #endif
|
|
56 } gu;
|
207
|
57 #ifdef USE_MINIMAL_TAGBITS
|
|
58 struct
|
|
59 {
|
|
60 #if (!!defined (WORDS_BIGENDIAN) != !!defined (LOWTAGS))
|
|
61 unsigned bit: GCTYPEBITS - 1;
|
|
62 #endif
|
|
63 signed EMACS_INT val: VALBITS + 1;
|
|
64 #if (!!defined (WORDS_BIGENDIAN) == !!defined (LOWTAGS))
|
|
65 unsigned bit: GCTYPEBITS - 1;
|
|
66 #endif
|
|
67 } si;
|
259
|
68 struct
|
|
69 {
|
|
70 #if (!!defined (WORDS_BIGENDIAN) != !!defined (LOWTAGS))
|
|
71 unsigned bit: GCTYPEBITS - 1;
|
|
72 #endif
|
|
73 unsigned EMACS_INT val: VALBITS + 1;
|
|
74 #if (!!defined (WORDS_BIGENDIAN) == !!defined (LOWTAGS))
|
|
75 unsigned bit: GCTYPEBITS - 1;
|
|
76 #endif
|
|
77 } u_i;
|
207
|
78 #endif /* USE_MINIMAL_TAGBITS */
|
|
79 EMACS_UINT ui;
|
185
|
80 EMACS_INT i;
|
|
81 /* GCC bites yet again. I fart in the general direction of
|
|
82 the GCC authors.
|
|
83
|
|
84 This was formerly declared 'void *v' etc. but that causes
|
|
85 GCC to accept any (yes, any) pointer as the argument of
|
|
86 a function declared to accept a Lisp_Object. */
|
|
87 struct __nosuchstruct__ *v;
|
|
88 CONST struct __nosuchstruct__ *cv; /* C wanks */
|
|
89 }
|
0
|
90 Lisp_Object;
|
|
91
|
207
|
92 #ifndef USE_MINIMAL_TAGBITS
|
0
|
93 #ifndef XMAKE_LISP
|
|
94 #if (__GNUC__ > 1)
|
|
95 /* Use GCC's struct initializers feature */
|
185
|
96 #define XMAKE_LISP(vartype,value) \
|
0
|
97 ((union Lisp_Object) { gu: { markbit: 0, \
|
|
98 type: (vartype), \
|
185
|
99 val: ((unsigned EMACS_INT) value) } })
|
0
|
100 #endif /* __GNUC__ */
|
|
101 #endif /* !XMAKE_LISP */
|
207
|
102 #endif /* ! USE_MINIMAL_TAGBITS */
|
0
|
103
|
|
104 #ifdef XMAKE_LISP
|
185
|
105 #define Qzero (XMAKE_LISP (Lisp_Type_Int, 0))
|
|
106 #define make_int(a) (XMAKE_LISP (Lisp_Type_Int, (a)))
|
207
|
107 #define make_char(a) (XMAKE_LISP (Lisp_Type_Char, (a)))
|
0
|
108 #else
|
|
109 extern Lisp_Object Qzero;
|
|
110 #endif
|
|
111
|
207
|
112 extern Lisp_Object Qnull_pointer;
|
0
|
113
|
|
114 #define EQ(x,y) ((x).v == (y).v)
|
|
115 #define GC_EQ(x,y) ((x).gu.val == (y).gu.val && (x).gu.type == (y).gu.type)
|
|
116
|
|
117 #define XTYPE(a) ((enum Lisp_Type) (a).gu.type)
|
|
118 #define XGCTYPE(a) XTYPE (a)
|
|
119
|
|
120 /* This was commented out a long time ago. I uncommented it, but it
|
|
121 makes the Alpha crash, and that's the only system that would use
|
|
122 this, so it stays commented out. */
|
|
123 #if 0 /* EXPLICIT_SIGN_EXTEND */
|
|
124 /* Make sure we sign-extend; compilers have been known to fail to do so. */
|
|
125 #define XREALINT(a) (((a).i << ((LONGBITS) - (VALBITS))) >> ((LONGBITS) - (VALBITS)))
|
|
126 #else
|
207
|
127 #ifdef USE_MINIMAL_TAGBITS
|
|
128 # define XREALINT(a) ((a).si.val)
|
|
129 #else
|
|
130 # define XREALINT(a) ((a).s.val)
|
|
131 #endif
|
0
|
132 #endif /* EXPLICIT_SIGN_EXTEND */
|
|
133
|
207
|
134 #ifdef USE_MINIMAL_TAGBITS
|
259
|
135 # define XUINT(a) ((a).u_i.val)
|
|
136 #else
|
|
137 # define XUINT(a) XPNTRVAL(a)
|
|
138 #endif
|
|
139
|
|
140 #ifdef USE_MINIMAL_TAGBITS
|
207
|
141 # define XPNTRVAL(a) ((a).ui)
|
|
142 # define XCHARVAL(a) ((a).gu.val)
|
|
143 #else
|
|
144 # define XPNTRVAL(a) ((a).gu.val)
|
|
145 # define XCHARVAL(a) XPNTRVAL(a)
|
|
146 #endif
|
|
147
|
0
|
148 #ifdef HAVE_SHM
|
|
149 /* In this representation, data is found in two widely separated segments. */
|
|
150 extern int pure_size;
|
|
151 # define XPNTR(a) \
|
207
|
152 ((void *)(XPNTRVAL(a)) | (XPNTRVAL(a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)))
|
0
|
153 #else /* not HAVE_SHM */
|
|
154 # ifdef DATA_SEG_BITS
|
|
155 /* This case is used for the rt-pc and hp-pa.
|
|
156 In the diffs I was given, it checked for ptr = 0
|
|
157 and did not adjust it in that case.
|
|
158 But I don't think that zero should ever be found
|
|
159 in a Lisp object whose data type says it points to something.
|
|
160 */
|
207
|
161 # define XPNTR(a) ((void *)((XPNTRVAL(a)) | DATA_SEG_BITS))
|
0
|
162 # else /* not DATA_SEG_BITS */
|
207
|
163 # define XPNTR(a) ((void *) (XPNTRVAL(a)))
|
0
|
164 # endif /* not DATA_SEG_BITS */
|
185
|
165 #endif /* not HAVE_SHM */
|
0
|
166
|
207
|
167 #ifdef USE_MINIMAL_TAGBITS
|
|
168 # define XSETINT(a, b) \
|
|
169 do { Lisp_Object *_xzx = &(a) ; \
|
|
170 (*_xzx).si.val = (b) ; \
|
|
171 (*_xzx).si.bit = 1; \
|
|
172 } while (0)
|
|
173 # define XSETCHAR(a, b) \
|
|
174 do { Lisp_Object *_xzx = &(a) ; \
|
|
175 (*_xzx).gu.val = (b) ; \
|
|
176 (*_xzx).gu.type = Lisp_Type_Char; \
|
|
177 } while (0)
|
|
178 #else
|
|
179 # define XSETINT(a, b) ((void) ((a) = make_int (b)))
|
|
180 # define XSETCHAR(a, b) ((void) ((a) = make_char (b)))
|
|
181 #endif
|
0
|
182
|
|
183 /* XSETOBJ was formerly named XSET. The name change was made to catch
|
|
184 C code that attempts to use this macro. You should always use the
|
|
185 individual settor macros (XSETCONS, XSETBUFFER, etc.) instead. */
|
|
186
|
207
|
187 #ifdef USE_MINIMAL_TAGBITS
|
|
188 # define XSETOBJ(var, vartype, value) \
|
|
189 ((void) ((var).ui = (EMACS_UINT)(value)))
|
0
|
190 #else
|
207
|
191 # ifdef XMAKE_LISP
|
|
192 # define XSETOBJ(a, type, b) ((void) ((a) = XMAKE_LISP (type, b)))
|
|
193 # else
|
0
|
194 /* This is haired up to avoid evaluating var twice...
|
|
195 This is necessary only in the "union" version.
|
|
196 The "int" version has never done double evaluation.
|
|
197 */
|
|
198 /* XEmacs change: put the assignment to val first; otherwise you
|
|
199 can trip up the error_check_*() stuff */
|
207
|
200 # define XSETOBJ(var, vartype, value) \
|
185
|
201 do { \
|
|
202 Lisp_Object *tmp_xset_var = &(var); \
|
|
203 (*tmp_xset_var).s.val = ((EMACS_INT) (value)); \
|
|
204 (*tmp_xset_var).gu.markbit = 0; \
|
|
205 (*tmp_xset_var).gu.type = (vartype); \
|
0
|
206 } while (0)
|
207
|
207 # endif /* ! XMAKE_LISP */
|
|
208 #endif /* ! USE_MINIMAL_TAGBITS */
|
0
|
209
|
207
|
210 #if GCMARKBITS > 0
|
|
211 /*
|
|
212 * XMARKBIT access the markbit. Markbits are used only in particular
|
|
213 * slots of particular structure types. Other markbits are always
|
|
214 * zero. Outside of garbage collection, all mark bits are always
|
|
215 * zero.
|
|
216 */
|
|
217 # define XMARKBIT(a) ((a).gu.markbit)
|
|
218 # define XMARK(a) ((void) (XMARKBIT (a) = 1))
|
|
219 # define XUNMARK(a) ((void) (XMARKBIT (a) = 0))
|
213
|
220 #else
|
|
221 # define XUNMARK(a) DO_NOTHING
|
207
|
222 #endif
|
0
|
223
|
|
224 /* Use this for turning a (void *) into a Lisp_Object, as when the
|
|
225 Lisp_Object is passed into a toolkit callback function */
|
|
226 #define VOID_TO_LISP(larg,varg) \
|
185
|
227 ((void) ((larg).v = (struct __nosuchstruct__ *) (varg)))
|
0
|
228 #define CVOID_TO_LISP(larg,varg) \
|
185
|
229 ((void) ((larg).cv = (CONST struct __nosuchstruct__ *) (varg)))
|
0
|
230
|
|
231 /* Use this for turning a Lisp_Object into a (void *), as when the
|
|
232 Lisp_Object is passed into a toolkit callback function */
|
|
233 #define LISP_TO_VOID(larg) ((void *) ((larg).v))
|
|
234 #define LISP_TO_CVOID(larg) ((CONST void *) ((larg).cv))
|
|
235
|
|
236 /* Convert a Lisp_Object into something that can't be used as an
|
|
237 lvalue. Useful for type-checking. */
|
|
238 #if (__GNUC__ > 1)
|
|
239 #define NON_LVALUE(larg) ({ (larg); })
|
|
240 #else
|
|
241 /* Well, you can't really do it without using a function call, and
|
|
242 there's no real point in that; no-union-type is the rule, and that
|
|
243 will catch errors. */
|
|
244 #define NON_LVALUE(larg) (larg)
|
|
245 #endif
|