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;
|
|
68 #endif /* USE_MINIMAL_TAGBITS */
|
|
69 EMACS_UINT ui;
|
185
|
70 EMACS_INT i;
|
|
71 /* GCC bites yet again. I fart in the general direction of
|
|
72 the GCC authors.
|
|
73
|
|
74 This was formerly declared 'void *v' etc. but that causes
|
|
75 GCC to accept any (yes, any) pointer as the argument of
|
|
76 a function declared to accept a Lisp_Object. */
|
|
77 struct __nosuchstruct__ *v;
|
|
78 CONST struct __nosuchstruct__ *cv; /* C wanks */
|
|
79 }
|
0
|
80 Lisp_Object;
|
|
81
|
207
|
82 #ifndef USE_MINIMAL_TAGBITS
|
0
|
83 #ifndef XMAKE_LISP
|
|
84 #if (__GNUC__ > 1)
|
|
85 /* Use GCC's struct initializers feature */
|
185
|
86 #define XMAKE_LISP(vartype,value) \
|
0
|
87 ((union Lisp_Object) { gu: { markbit: 0, \
|
|
88 type: (vartype), \
|
185
|
89 val: ((unsigned EMACS_INT) value) } })
|
0
|
90 #endif /* __GNUC__ */
|
|
91 #endif /* !XMAKE_LISP */
|
207
|
92 #endif /* ! USE_MINIMAL_TAGBITS */
|
0
|
93
|
|
94 #ifdef XMAKE_LISP
|
185
|
95 #define Qzero (XMAKE_LISP (Lisp_Type_Int, 0))
|
|
96 #define make_int(a) (XMAKE_LISP (Lisp_Type_Int, (a)))
|
207
|
97 #define make_char(a) (XMAKE_LISP (Lisp_Type_Char, (a)))
|
0
|
98 #else
|
|
99 extern Lisp_Object Qzero;
|
|
100 #endif
|
|
101
|
207
|
102 extern Lisp_Object Qnull_pointer;
|
0
|
103
|
|
104 #define EQ(x,y) ((x).v == (y).v)
|
|
105 #define GC_EQ(x,y) ((x).gu.val == (y).gu.val && (x).gu.type == (y).gu.type)
|
|
106
|
|
107 #define XTYPE(a) ((enum Lisp_Type) (a).gu.type)
|
|
108 #define XGCTYPE(a) XTYPE (a)
|
|
109
|
|
110 /* This was commented out a long time ago. I uncommented it, but it
|
|
111 makes the Alpha crash, and that's the only system that would use
|
|
112 this, so it stays commented out. */
|
|
113 #if 0 /* EXPLICIT_SIGN_EXTEND */
|
|
114 /* Make sure we sign-extend; compilers have been known to fail to do so. */
|
|
115 #define XREALINT(a) (((a).i << ((LONGBITS) - (VALBITS))) >> ((LONGBITS) - (VALBITS)))
|
|
116 #else
|
207
|
117 #ifdef USE_MINIMAL_TAGBITS
|
|
118 # define XREALINT(a) ((a).si.val)
|
|
119 #else
|
|
120 # define XREALINT(a) ((a).s.val)
|
|
121 #endif
|
0
|
122 #endif /* EXPLICIT_SIGN_EXTEND */
|
|
123
|
207
|
124 #ifdef USE_MINIMAL_TAGBITS
|
|
125 # define XPNTRVAL(a) ((a).ui)
|
|
126 # define XCHARVAL(a) ((a).gu.val)
|
|
127 #else
|
|
128 # define XPNTRVAL(a) ((a).gu.val)
|
|
129 # define XCHARVAL(a) XPNTRVAL(a)
|
|
130 #endif
|
|
131
|
0
|
132 #ifdef HAVE_SHM
|
|
133 /* In this representation, data is found in two widely separated segments. */
|
|
134 extern int pure_size;
|
|
135 # define XPNTR(a) \
|
207
|
136 ((void *)(XPNTRVAL(a)) | (XPNTRVAL(a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)))
|
0
|
137 #else /* not HAVE_SHM */
|
|
138 # ifdef DATA_SEG_BITS
|
|
139 /* This case is used for the rt-pc and hp-pa.
|
|
140 In the diffs I was given, it checked for ptr = 0
|
|
141 and did not adjust it in that case.
|
|
142 But I don't think that zero should ever be found
|
|
143 in a Lisp object whose data type says it points to something.
|
|
144 */
|
207
|
145 # define XPNTR(a) ((void *)((XPNTRVAL(a)) | DATA_SEG_BITS))
|
0
|
146 # else /* not DATA_SEG_BITS */
|
207
|
147 # define XPNTR(a) ((void *) (XPNTRVAL(a)))
|
0
|
148 # endif /* not DATA_SEG_BITS */
|
185
|
149 #endif /* not HAVE_SHM */
|
0
|
150
|
207
|
151 #ifdef USE_MINIMAL_TAGBITS
|
|
152 # define XSETINT(a, b) \
|
|
153 do { Lisp_Object *_xzx = &(a) ; \
|
|
154 (*_xzx).si.val = (b) ; \
|
|
155 (*_xzx).si.bit = 1; \
|
|
156 } while (0)
|
|
157 # define XSETCHAR(a, b) \
|
|
158 do { Lisp_Object *_xzx = &(a) ; \
|
|
159 (*_xzx).gu.val = (b) ; \
|
|
160 (*_xzx).gu.type = Lisp_Type_Char; \
|
|
161 } while (0)
|
|
162 #else
|
|
163 # define XSETINT(a, b) ((void) ((a) = make_int (b)))
|
|
164 # define XSETCHAR(a, b) ((void) ((a) = make_char (b)))
|
|
165 #endif
|
0
|
166
|
|
167 /* XSETOBJ was formerly named XSET. The name change was made to catch
|
|
168 C code that attempts to use this macro. You should always use the
|
|
169 individual settor macros (XSETCONS, XSETBUFFER, etc.) instead. */
|
|
170
|
207
|
171 #ifdef USE_MINIMAL_TAGBITS
|
|
172 # define XSETOBJ(var, vartype, value) \
|
|
173 ((void) ((var).ui = (EMACS_UINT)(value)))
|
0
|
174 #else
|
207
|
175 # ifdef XMAKE_LISP
|
|
176 # define XSETOBJ(a, type, b) ((void) ((a) = XMAKE_LISP (type, b)))
|
|
177 # else
|
0
|
178 /* This is haired up to avoid evaluating var twice...
|
|
179 This is necessary only in the "union" version.
|
|
180 The "int" version has never done double evaluation.
|
|
181 */
|
|
182 /* XEmacs change: put the assignment to val first; otherwise you
|
|
183 can trip up the error_check_*() stuff */
|
207
|
184 # define XSETOBJ(var, vartype, value) \
|
185
|
185 do { \
|
|
186 Lisp_Object *tmp_xset_var = &(var); \
|
|
187 (*tmp_xset_var).s.val = ((EMACS_INT) (value)); \
|
|
188 (*tmp_xset_var).gu.markbit = 0; \
|
|
189 (*tmp_xset_var).gu.type = (vartype); \
|
0
|
190 } while (0)
|
207
|
191 # endif /* ! XMAKE_LISP */
|
|
192 #endif /* ! USE_MINIMAL_TAGBITS */
|
0
|
193
|
207
|
194 #if GCMARKBITS > 0
|
|
195 /*
|
|
196 * XMARKBIT access the markbit. Markbits are used only in particular
|
|
197 * slots of particular structure types. Other markbits are always
|
|
198 * zero. Outside of garbage collection, all mark bits are always
|
|
199 * zero.
|
|
200 */
|
|
201 # define XMARKBIT(a) ((a).gu.markbit)
|
|
202 # define XMARK(a) ((void) (XMARKBIT (a) = 1))
|
|
203 # define XUNMARK(a) ((void) (XMARKBIT (a) = 0))
|
213
|
204 #else
|
|
205 # define XUNMARK(a) DO_NOTHING
|
207
|
206 #endif
|
0
|
207
|
|
208 /* Use this for turning a (void *) into a Lisp_Object, as when the
|
|
209 Lisp_Object is passed into a toolkit callback function */
|
|
210 #define VOID_TO_LISP(larg,varg) \
|
185
|
211 ((void) ((larg).v = (struct __nosuchstruct__ *) (varg)))
|
0
|
212 #define CVOID_TO_LISP(larg,varg) \
|
185
|
213 ((void) ((larg).cv = (CONST struct __nosuchstruct__ *) (varg)))
|
0
|
214
|
|
215 /* Use this for turning a Lisp_Object into a (void *), as when the
|
|
216 Lisp_Object is passed into a toolkit callback function */
|
|
217 #define LISP_TO_VOID(larg) ((void *) ((larg).v))
|
|
218 #define LISP_TO_CVOID(larg) ((CONST void *) ((larg).cv))
|
|
219
|
|
220 /* Convert a Lisp_Object into something that can't be used as an
|
|
221 lvalue. Useful for type-checking. */
|
|
222 #if (__GNUC__ > 1)
|
|
223 #define NON_LVALUE(larg) ({ (larg); })
|
|
224 #else
|
|
225 /* Well, you can't really do it without using a function call, and
|
|
226 there's no real point in that; no-union-type is the rule, and that
|
|
227 will catch errors. */
|
|
228 #define NON_LVALUE(larg) (larg)
|
|
229 #endif
|