annotate src/lisp-disunion.h @ 201:eb5470882647 r20-3b27

Import from CVS: tag r20-3b27
author cvs
date Mon, 13 Aug 2007 10:01:22 +0200
parents 3d6bfa290dbd
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 -- non-union objects.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 /* Synched up with: FSF 19.30. Split out from lisp.h. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23 /* If union type is not wanted, define Lisp_Object as just a number
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 and define the macros below to extract fields by shifting */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #define Qzero 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 typedef EMACS_INT Lisp_Object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
30 #define VALMASK ((1L << (VALBITS)) - 1L)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #define GCTYPEMASK ((1L << (GCTYPEBITS)) - 1L)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 /* comment from FSFmacs (perhaps not accurate here):
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 This is set in the car of a cons and in the plist slot of a symbol
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 to indicate it is marked. Likewise in the plist slot of an interval,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 the chain slot of a marker, the type slot of a float, and the name
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
38 slot of a buffer.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
39
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
40 In strings, this bit in the size field indicates that the string
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 is a "large" one, one which was separately malloc'd
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42 rather than being part of a string block. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 185
diff changeset
44 #define MARKBIT (1UL << (VALBITS))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47 /* These macros extract various sorts of values from a Lisp_Object.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
48 For example, if tem is a Lisp_Object whose type is Lisp_Type_Cons,
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
49 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
51 /* One needs to override this if there must be high bits set in data space
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
53 on all machines, but would penalize machines which don't need it) */
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 185
diff changeset
54 #define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT)(a)) >> ((VALBITS) + 1)))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 #define EQ(x,y) ((x) == (y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 #define GC_EQ(x,y) (XGCTYPE (x) == XGCTYPE (y) && XPNTR (x) == XPNTR (y))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 /* Extract the value of a Lisp_Object as a signed integer. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61 #ifndef XREALINT /* Some machines need to do this differently. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62 # define XREALINT(a) (((a) << (LONGBITS-VALBITS)) >> (LONGBITS-VALBITS))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 /* Extract the value as an unsigned integer. This is a basis
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 for extracting it as a pointer to a structure in storage. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
68 #define XUINT(a) ((a) & VALMASK)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
70 #ifdef HAVE_SHM
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 /* In this representation, data is found in two widely separated segments. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72 extern int pure_size;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
73 # define XPNTR(a) \
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
74 (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75 # else /* not HAVE_SHM */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 # ifdef DATA_SEG_BITS
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77 /* This case is used for the rt-pc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 In the diffs I was given, it checked for ptr = 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 and did not adjust it in that case.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80 But I don't think that zero should ever be found
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
81 in a Lisp object whose data type says it points to something. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
82 # define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 # else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 # define XPNTR(a) XUINT (a)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 # endif
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
86 #endif /* not HAVE_SHM */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
88 #define XSETINT(a, b) XSETOBJ (a, Lisp_Type_Int, b)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
90 #define XSETCHAR(var, value) XSETOBJ (var, Lisp_Type_Char, value)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
91
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
92 /* XSETOBJ was formerly named XSET. The name change was made to catch
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 C code that attempts to use this macro. You should always use the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94 individual settor macros (XSETCONS, XSETBUFFER, etc.) instead. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
95
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
96 #define XSETOBJ(var, type_tag, value) \
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 185
diff changeset
97 ((void) ((var) = (((EMACS_INT) (type_tag) << ((VALBITS) + 1)) \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
98 + ((EMACS_INT) (value) & VALMASK))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 /* During garbage collection, XGCTYPE must be used for extracting types
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
101 so that the mark bit is ignored. XMARKBIT accesses the markbit.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
102 Markbits are used only in particular slots of particular structure types.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
103 Other markbits are always zero.
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
104 Outside of garbage collection, all mark bits are always zero. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 #ifndef XGCTYPE
201
eb5470882647 Import from CVS: tag r20-3b27
cvs
parents: 185
diff changeset
107 # define XGCTYPE(a) XTYPE(a)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
109
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
110 # define XMARKBIT(a) ((a) & (MARKBIT))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
112 # define XMARK(a) ((void) ((a) |= (MARKBIT)))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
113 # define XUNMARK(a) ((void) ((a) &= (~(MARKBIT))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 /* Use this for turning a (void *) into a Lisp_Object, as when the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 Lisp_Object is passed into a toolkit callback function */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
117 #define VOID_TO_LISP(larg,varg) ((void) ((larg) = ((Lisp_Object) (varg))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 #define CVOID_TO_LISP VOID_TO_LISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
120 /* Use this for turning a Lisp_Object into a (void *), as when the
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 Lisp_Object is passed into a toolkit callback function */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 #define LISP_TO_VOID(larg) ((void *) (larg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 #define LISP_TO_CVOID(varg) ((CONST void *) (larg))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 /* Convert a Lisp_Object into something that can't be used as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 lvalue. Useful for type-checking. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 #define NON_LVALUE(larg) ((larg) + 0)