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 */
|
|
31 unsigned EMACS_INT type_mark: GCTYPEBITS + 1;
|
|
32 signed EMACS_INT val: VALBITS;
|
0
|
33 #else /* If WORDS_BIGENDIAN, or little-endian hightags */
|
185
|
34 signed EMACS_INT val: VALBITS;
|
|
35 unsigned EMACS_INT mark_type: GCTYPEBITS + 1;
|
|
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. */
|
|
50 unsigned EMACS_INT markbit: 1;
|
|
51 #if (!!defined (WORDS_BIGENDIAN) != !!defined (LOWTAGS))
|
|
52 unsigned EMACS_INT val: VALBITS;
|
|
53 #endif
|
|
54 } gu;
|
|
55 EMACS_INT i;
|
|
56 /* GCC bites yet again. I fart in the general direction of
|
|
57 the GCC authors.
|
|
58
|
|
59 This was formerly declared 'void *v' etc. but that causes
|
|
60 GCC to accept any (yes, any) pointer as the argument of
|
|
61 a function declared to accept a Lisp_Object. */
|
|
62 struct __nosuchstruct__ *v;
|
|
63 CONST struct __nosuchstruct__ *cv; /* C wanks */
|
|
64 }
|
0
|
65 Lisp_Object;
|
|
66
|
|
67 #ifndef XMAKE_LISP
|
|
68 #if (__GNUC__ > 1)
|
|
69 /* Use GCC's struct initializers feature */
|
185
|
70 #define XMAKE_LISP(vartype,value) \
|
0
|
71 ((union Lisp_Object) { gu: { markbit: 0, \
|
|
72 type: (vartype), \
|
185
|
73 val: ((unsigned EMACS_INT) value) } })
|
0
|
74 #endif /* __GNUC__ */
|
|
75 #endif /* !XMAKE_LISP */
|
|
76
|
|
77
|
|
78 #ifdef XMAKE_LISP
|
185
|
79 #define Qzero (XMAKE_LISP (Lisp_Type_Int, 0))
|
|
80 #define make_int(a) (XMAKE_LISP (Lisp_Type_Int, (a)))
|
0
|
81 #else
|
|
82 extern Lisp_Object Qzero;
|
|
83 #endif
|
|
84
|
|
85
|
|
86 #define EQ(x,y) ((x).v == (y).v)
|
|
87 #define GC_EQ(x,y) ((x).gu.val == (y).gu.val && (x).gu.type == (y).gu.type)
|
|
88
|
|
89 #define XTYPE(a) ((enum Lisp_Type) (a).gu.type)
|
|
90 #define XGCTYPE(a) XTYPE (a)
|
|
91
|
|
92 /* This was commented out a long time ago. I uncommented it, but it
|
|
93 makes the Alpha crash, and that's the only system that would use
|
|
94 this, so it stays commented out. */
|
|
95 #if 0 /* EXPLICIT_SIGN_EXTEND */
|
|
96 /* Make sure we sign-extend; compilers have been known to fail to do so. */
|
|
97 #define XREALINT(a) (((a).i << ((LONGBITS) - (VALBITS))) >> ((LONGBITS) - (VALBITS)))
|
|
98 #else
|
|
99 #define XREALINT(a) ((a).s.val)
|
|
100 #endif /* EXPLICIT_SIGN_EXTEND */
|
|
101
|
|
102 #define XUINT(a) ((a).gu.val)
|
|
103 #ifdef HAVE_SHM
|
|
104 /* In this representation, data is found in two widely separated segments. */
|
|
105 extern int pure_size;
|
|
106 # define XPNTR(a) \
|
|
107 ((void *)(((a).gu.val) | ((a).gu.val > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS)))
|
|
108 #else /* not HAVE_SHM */
|
|
109 # ifdef DATA_SEG_BITS
|
|
110 /* This case is used for the rt-pc and hp-pa.
|
|
111 In the diffs I was given, it checked for ptr = 0
|
|
112 and did not adjust it in that case.
|
|
113 But I don't think that zero should ever be found
|
|
114 in a Lisp object whose data type says it points to something.
|
|
115 */
|
|
116 # define XPNTR(a) ((void *)(((a).gu.val) | DATA_SEG_BITS))
|
|
117 # else /* not DATA_SEG_BITS */
|
|
118 # define XPNTR(a) ((void *) ((a).gu.val))
|
|
119 # endif /* not DATA_SEG_BITS */
|
185
|
120 #endif /* not HAVE_SHM */
|
|
121 #define XSETINT(a, b) ((void) ((a) = make_int (b)))
|
0
|
122
|
185
|
123 #define XSETCHAR(a, b) ((void) ((a) = make_char (b)))
|
0
|
124
|
|
125 /* XSETOBJ was formerly named XSET. The name change was made to catch
|
|
126 C code that attempts to use this macro. You should always use the
|
|
127 individual settor macros (XSETCONS, XSETBUFFER, etc.) instead. */
|
|
128
|
|
129 #ifdef XMAKE_LISP
|
185
|
130 #define XSETOBJ(a, type, b) ((void) ((a) = XMAKE_LISP (type, b)))
|
0
|
131 #else
|
|
132 /* This is haired up to avoid evaluating var twice...
|
|
133 This is necessary only in the "union" version.
|
|
134 The "int" version has never done double evaluation.
|
|
135 */
|
|
136 /* XEmacs change: put the assignment to val first; otherwise you
|
|
137 can trip up the error_check_*() stuff */
|
185
|
138 #define XSETOBJ(var, vartype, value) \
|
|
139 do { \
|
|
140 Lisp_Object *tmp_xset_var = &(var); \
|
|
141 (*tmp_xset_var).s.val = ((EMACS_INT) (value)); \
|
|
142 (*tmp_xset_var).gu.markbit = 0; \
|
|
143 (*tmp_xset_var).gu.type = (vartype); \
|
0
|
144 } while (0)
|
|
145 #endif /* undefined XMAKE_LISP */
|
|
146
|
|
147 /* During garbage collection, XGCTYPE must be used for extracting types
|
185
|
148 so that the mark bit is ignored. XMARKBIT access the markbit.
|
|
149 Markbits are used only in particular slots of particular structure types.
|
|
150 Other markbits are always zero.
|
|
151 Outside of garbage collection, all mark bits are always zero. */
|
0
|
152
|
|
153 #define XMARKBIT(a) ((a).gu.markbit)
|
185
|
154 #define XMARK(a) ((void) (XMARKBIT (a) = 1))
|
|
155 #define XUNMARK(a) ((void) (XMARKBIT (a) = 0))
|
0
|
156
|
|
157 /* Use this for turning a (void *) into a Lisp_Object, as when the
|
|
158 Lisp_Object is passed into a toolkit callback function */
|
|
159 #define VOID_TO_LISP(larg,varg) \
|
185
|
160 ((void) ((larg).v = (struct __nosuchstruct__ *) (varg)))
|
0
|
161 #define CVOID_TO_LISP(larg,varg) \
|
185
|
162 ((void) ((larg).cv = (CONST struct __nosuchstruct__ *) (varg)))
|
0
|
163
|
|
164 /* Use this for turning a Lisp_Object into a (void *), as when the
|
|
165 Lisp_Object is passed into a toolkit callback function */
|
|
166 #define LISP_TO_VOID(larg) ((void *) ((larg).v))
|
|
167 #define LISP_TO_CVOID(larg) ((CONST void *) ((larg).cv))
|
|
168
|
|
169 /* Convert a Lisp_Object into something that can't be used as an
|
|
170 lvalue. Useful for type-checking. */
|
|
171 #if (__GNUC__ > 1)
|
|
172 #define NON_LVALUE(larg) ({ (larg); })
|
|
173 #else
|
|
174 /* Well, you can't really do it without using a function call, and
|
|
175 there's no real point in that; no-union-type is the rule, and that
|
|
176 will catch errors. */
|
|
177 #define NON_LVALUE(larg) (larg)
|
|
178 #endif
|