0
|
1 /* Fundamental definitions for XEmacs Lisp interpreter -- non-union objects.
|
|
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
|
|
3
|
|
4 This file is part of XEmacs.
|
|
5
|
|
6 XEmacs is free software; you can redistribute it and/or modify it
|
|
7 under the terms of the GNU General Public License as published by the
|
|
8 Free Software Foundation; either version 2, or (at your option) any
|
|
9 later version.
|
|
10
|
|
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
|
|
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
14 for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with XEmacs; see the file COPYING. If not, write to
|
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
19 Boston, MA 02111-1307, USA. */
|
|
20
|
|
21 /* Synched up with: FSF 19.30. Split out from lisp.h. */
|
207
|
22 /* This file has diverged greatly from FSF Emacs. Syncing is no
|
|
23 longer desired or possible */
|
0
|
24
|
207
|
25 /*
|
|
26 * Format of a non-union-type Lisp Object
|
|
27 *
|
|
28 * For the USE_MINIMAL_TAGBITS implementation:
|
|
29 *
|
|
30 * 3 2 1 0
|
|
31 * bit 10987654321098765432109876543210
|
|
32 * --------------------------------
|
|
33 * VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTT
|
|
34 *
|
|
35 * For the non-USE_MINIMAL_TAGBITS implementation:
|
|
36 *
|
|
37 * 3 2 1 0
|
|
38 * bit 10987654321098765432109876543210
|
|
39 * --------------------------------
|
|
40 * TTTMVVVVVVVVVVVVVVVVVVVVVVVVVVVV
|
|
41 *
|
|
42 * V = value bits
|
|
43 * T = type bits
|
|
44 * M = mark bits
|
|
45 *
|
|
46 * For integral Lisp types, i.e. integers and characters, the value
|
|
47 * bits are the Lisp object.
|
|
48 *
|
|
49 * The object is obtained by masking off the type and mark
|
|
50 * bits. In the USE_MINIMAL_TAGBITS implementation, bit 1 is
|
|
51 * used as a value bit by splitting the Lisp integer type into
|
|
52 * two subtypes, Lisp_Type_Int_Even and Lisp_Type_Int_Odd. By
|
|
53 * this trickery we get 31 bits for integers instead of 30.
|
|
54 *
|
|
55 * In the non-USE_MINIMAL_TAGBITS world, Lisp integers are 28
|
|
56 * bits, or more properly (LONGBITS - GCTYPEBITS - 1) bits.
|
|
57 *
|
|
58 * For non-integral types, the value bits of Lisp_Object contain a
|
|
59 * pointer to structure containing the object. The pointer is
|
|
60 * obtained by masking off the type and mark bits.
|
|
61 *
|
|
62 * In the USE_MINIMAL_TAGBITS implementation, all
|
|
63 * pointer-based types are coalesced under a single type called
|
|
64 * Lisp_Type_Record. The type bits for this type are required
|
|
65 * by the implementation to be 00, just like the least
|
|
66 * significant bits of word-aligned struct pointers on 32-bit
|
|
67 * hardware. Because of this, Lisp_Object pointers don't have
|
|
68 * to be masked and are full-sized.
|
|
69 *
|
|
70 * In the non-USE_MINIMAL_TAGBITS implementation, the type and
|
|
71 * mark bits must be masked off and pointers are limited to 28
|
|
72 * bits (really LONGBITS - GCTYPEBITS - 1 bits).
|
|
73 */
|
0
|
74
|
207
|
75 #ifdef USE_MINIMAL_TAGBITS
|
|
76 # define Qzero Lisp_Type_Int_Even
|
217
|
77 # define VALMASK (((1UL << (VALBITS)) - 1L) << (GCTYPEBITS))
|
207
|
78 #else
|
|
79 # define Qzero Lisp_Type_Int
|
|
80 # define VALMASK ((1L << (VALBITS)) - 1L)
|
|
81 # define GCTYPEMASK ((1L << (GCTYPEBITS)) - 1L)
|
|
82 #endif
|
0
|
83
|
|
84 typedef EMACS_INT Lisp_Object;
|
|
85
|
207
|
86 #define Qnull_pointer 0
|
0
|
87
|
207
|
88 /*
|
|
89 * There are no mark bits in the USE_MINIMAL_TAGBITS implementation.
|
|
90 * Integers and characters don't need to be marked. All other types
|
|
91 * are lrecord-based, which means they get marked by incrementing
|
|
92 * their ->implementation pointer.
|
|
93 */
|
|
94 #if GCMARKBITS > 0
|
|
95 /*
|
|
96 * XMARKBIT accesses the markbit. Markbits are used only in particular
|
|
97 * slots of particular structure types. Other markbits are always
|
|
98 * zero. Outside of garbage collection, all mark bits are always zero.
|
|
99 */
|
|
100 # define MARKBIT (1UL << (VALBITS))
|
|
101 # define XMARKBIT(a) ((a) & (MARKBIT))
|
|
102
|
|
103 # define XMARK(a) ((void) ((a) |= (MARKBIT)))
|
|
104 # define XUNMARK(a) ((void) ((a) &= (~(MARKBIT))))
|
213
|
105 #else
|
|
106 # define XUNMARK(a) DO_NOTHING
|
207
|
107 #endif
|
0
|
108
|
207
|
109 /*
|
|
110 * Extract the type bits from a Lisp_Object. If using USE_MINIMAL_TAGBITS,
|
|
111 * the least significant two bits are the type bits. Otherwise the
|
|
112 * most significant GCTYPEBITS bits are the type bits.
|
|
113 *
|
|
114 * In the non-USE_MINIMAL_TAGBITS case, one needs to override this
|
|
115 * if there must be high bits set in data space. Masking the bits
|
|
116 * (doing the result of the below & ((1 << (GCTYPEBITS)) - 1) would
|
|
117 * work on all machines, but would penalize machines which don't
|
|
118 * need it)
|
|
119 */
|
|
120 #ifdef USE_MINIMAL_TAGBITS
|
|
121 # define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT)(a)) & ~(VALMASK)))
|
|
122 #else
|
|
123 # define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT)(a)) >> ((VALBITS) + 1)))
|
|
124 #endif
|
0
|
125
|
207
|
126 /*
|
|
127 * This applies only to the non-USE_MINIMAL_TAGBITS Lisp_Object.
|
|
128 *
|
|
129 * In the past, during garbage collection, XGCTYPE needed to be used
|
|
130 * for extracting types so that the mark bit was ignored. XGCTYPE
|
|
131 * did and exatr & operation to remove the mark bit. But the mark
|
|
132 * bit has been since moved so that the type bits could be extracted
|
|
133 * with a single shift operation, making XGCTYPE no more expensive
|
|
134 * than XTYPE, so the two operations are now equivalent.
|
|
135 */
|
|
136 #ifndef XGCTYPE
|
|
137 # define XGCTYPE(a) XTYPE(a)
|
|
138 #endif
|
0
|
139
|
|
140 #define EQ(x,y) ((x) == (y))
|
|
141
|
207
|
142 #ifdef USE_MINIMAL_TAGBITS
|
|
143 # define GC_EQ(x,y) EQ(x,y)
|
|
144 #else
|
|
145 # define GC_EQ(x,y) (XGCTYPE (x) == XGCTYPE (y) && XPNTR (x) == XPNTR (y))
|
0
|
146 #endif
|
|
147
|
207
|
148 /*
|
|
149 * Extract the value of a Lisp_Object as a signed integer.
|
|
150 *
|
|
151 * The right shifts below are non-portable because >> is allowed to
|
|
152 * sign extend or not signed extend signed integers depending on the
|
|
153 * compiler implementors preference. But this right-shifting of
|
|
154 * signed ints has been here forever, so the apparently reality is
|
|
155 * that all compilers of any consequence do sign extension, which is
|
|
156 * what is needed here.
|
|
157 */
|
|
158 #ifndef XREALINT /* Some machines need to do this differently. */
|
|
159 # ifdef USE_MINIMAL_TAGBITS
|
|
160 # define XREALINT(a) ((a) >> (LONGBITS-VALBITS-1))
|
|
161 # else
|
|
162 # define XREALINT(a) (((a) << (LONGBITS-VALBITS)) >> (LONGBITS-VALBITS))
|
|
163 # endif
|
|
164 #endif
|
0
|
165
|
259
|
166 /* Extract the value of a Lisp integer as an unsigned integer. */
|
|
167 #ifdef USE_MINIMAL_TAGBITS
|
|
168 # define XUINT(a) ((EMACS_UINT)(a) >> (LONGBITS-VALBITS-1))
|
|
169 #else
|
|
170 # define XUINT(a) XPNTRVAL(a)
|
|
171 #endif
|
|
172
|
207
|
173 /*
|
|
174 * Extract the pointer value bits of a pointer based type.
|
|
175 */
|
|
176 #ifdef USE_MINIMAL_TAGBITS
|
|
177 # define XPNTRVAL(a) (a) /* This depends on Lisp_Type_Record == 0 */
|
|
178 # define XCHARVAL(a) ((a) >> (LONGBITS-VALBITS))
|
|
179 #else
|
|
180 # define XPNTRVAL(a) ((a) & VALMASK)
|
|
181 # define XCHARVAL(a) XPNTRVAL(a)
|
|
182 #endif
|
0
|
183
|
185
|
184 #ifdef HAVE_SHM
|
0
|
185 /* In this representation, data is found in two widely separated segments. */
|
|
186 extern int pure_size;
|
|
187 # define XPNTR(a) \
|
207
|
188 (XPNTRVAL (a) | (XPNTRVAL (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
|
0
|
189 # else /* not HAVE_SHM */
|
|
190 # ifdef DATA_SEG_BITS
|
|
191 /* This case is used for the rt-pc.
|
|
192 In the diffs I was given, it checked for ptr = 0
|
|
193 and did not adjust it in that case.
|
|
194 But I don't think that zero should ever be found
|
185
|
195 in a Lisp object whose data type says it points to something. */
|
207
|
196 # define XPNTR(a) (XPNTRVAL (a) | DATA_SEG_BITS)
|
0
|
197 # else
|
207
|
198 # define XPNTR(a) XPNTRVAL (a)
|
0
|
199 # endif
|
185
|
200 #endif /* not HAVE_SHM */
|
0
|
201
|
207
|
202 #ifdef USE_MINIMAL_TAGBITS
|
0
|
203
|
207
|
204 /* XSETINT depends on Lisp_Type_Int_Even == 1 and Lisp_Type_Int_Odd == 3 */
|
|
205 # define XSETINT(var, value) \
|
|
206 ((void) ((var) = ((value) << (LONGBITS-VALBITS-1)) + 1))
|
|
207 # define XSETCHAR(var, value) \
|
|
208 ((void) ((var) = ((value) << (LONGBITS-VALBITS)) + Lisp_Type_Char))
|
|
209 # define XSETOBJ(var, type_tag, value) \
|
|
210 ((void) ((var) = ((EMACS_UINT) (value))))
|
0
|
211
|
207
|
212 #else
|
0
|
213
|
207
|
214 # define XSETINT(a, b) XSETOBJ (a, Lisp_Type_Int, b)
|
|
215 # define XSETCHAR(var, value) XSETOBJ (var, Lisp_Type_Char, value)
|
|
216 # define XSETOBJ(var, type_tag, value) \
|
|
217 ((void) ((var) = (((EMACS_UINT) (type_tag) << ((VALBITS) + 1)) \
|
|
218 + ((EMACS_INT) (value) & VALMASK))))
|
|
219 #endif
|
0
|
220
|
|
221 /* Use this for turning a (void *) into a Lisp_Object, as when the
|
|
222 Lisp_Object is passed into a toolkit callback function */
|
185
|
223 #define VOID_TO_LISP(larg,varg) ((void) ((larg) = ((Lisp_Object) (varg))))
|
0
|
224 #define CVOID_TO_LISP VOID_TO_LISP
|
|
225
|
185
|
226 /* Use this for turning a Lisp_Object into a (void *), as when the
|
0
|
227 Lisp_Object is passed into a toolkit callback function */
|
|
228 #define LISP_TO_VOID(larg) ((void *) (larg))
|
|
229 #define LISP_TO_CVOID(varg) ((CONST void *) (larg))
|
|
230
|
|
231 /* Convert a Lisp_Object into something that can't be used as an
|
|
232 lvalue. Useful for type-checking. */
|
|
233 #define NON_LVALUE(larg) ((larg) + 0)
|