annotate src/lisp-union.h @ 185:3d6bfa290dbd r20-3b19

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