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. */
|
|
22
|
|
23 /* If union type is not wanted, define Lisp_Object as just a number
|
|
24 and define the macros below to extract fields by shifting */
|
|
25
|
|
26 #define Qzero 0
|
|
27
|
|
28 typedef EMACS_INT Lisp_Object;
|
|
29
|
185
|
30 #define VALMASK ((1L << (VALBITS)) - 1L)
|
0
|
31 #define GCTYPEMASK ((1L << (GCTYPEBITS)) - 1L)
|
|
32
|
|
33 /* comment from FSFmacs (perhaps not accurate here):
|
|
34
|
|
35 This is set in the car of a cons and in the plist slot of a symbol
|
|
36 to indicate it is marked. Likewise in the plist slot of an interval,
|
|
37 the chain slot of a marker, the type slot of a float, and the name
|
|
38 slot of a buffer.
|
|
39
|
|
40 In strings, this bit in the size field indicates that the string
|
|
41 is a "large" one, one which was separately malloc'd
|
|
42 rather than being part of a string block. */
|
|
43
|
201
|
44 #define MARKBIT (1UL << (VALBITS))
|
0
|
45
|
|
46
|
|
47 /* These macros extract various sorts of values from a Lisp_Object.
|
185
|
48 For example, if tem is a Lisp_Object whose type is Lisp_Type_Cons,
|
|
49 XCONS (tem) is the struct Lisp_Cons * pointing to the memory for that cons. */
|
0
|
50
|
185
|
51 /* One needs to override this if there must be high bits set in data space
|
0
|
52 (doing the result of the below & ((1 << (GCTYPE + 1)) - 1) would work
|
185
|
53 on all machines, but would penalize machines which don't need it) */
|
201
|
54 #define XTYPE(a) ((enum Lisp_Type) (((EMACS_UINT)(a)) >> ((VALBITS) + 1)))
|
0
|
55
|
|
56 #define EQ(x,y) ((x) == (y))
|
|
57 #define GC_EQ(x,y) (XGCTYPE (x) == XGCTYPE (y) && XPNTR (x) == XPNTR (y))
|
|
58
|
|
59 /* Extract the value of a Lisp_Object as a signed integer. */
|
|
60
|
|
61 #ifndef XREALINT /* Some machines need to do this differently. */
|
|
62 # define XREALINT(a) (((a) << (LONGBITS-VALBITS)) >> (LONGBITS-VALBITS))
|
|
63 #endif
|
|
64
|
|
65 /* Extract the value as an unsigned integer. This is a basis
|
|
66 for extracting it as a pointer to a structure in storage. */
|
|
67
|
185
|
68 #define XUINT(a) ((a) & VALMASK)
|
0
|
69
|
185
|
70 #ifdef HAVE_SHM
|
0
|
71 /* In this representation, data is found in two widely separated segments. */
|
|
72 extern int pure_size;
|
|
73 # define XPNTR(a) \
|
|
74 (XUINT (a) | (XUINT (a) > pure_size ? DATA_SEG_BITS : PURE_SEG_BITS))
|
|
75 # else /* not HAVE_SHM */
|
|
76 # ifdef DATA_SEG_BITS
|
|
77 /* This case is used for the rt-pc.
|
|
78 In the diffs I was given, it checked for ptr = 0
|
|
79 and did not adjust it in that case.
|
|
80 But I don't think that zero should ever be found
|
185
|
81 in a Lisp object whose data type says it points to something. */
|
0
|
82 # define XPNTR(a) (XUINT (a) | DATA_SEG_BITS)
|
|
83 # else
|
|
84 # define XPNTR(a) XUINT (a)
|
|
85 # endif
|
185
|
86 #endif /* not HAVE_SHM */
|
0
|
87
|
185
|
88 #define XSETINT(a, b) XSETOBJ (a, Lisp_Type_Int, b)
|
0
|
89
|
185
|
90 #define XSETCHAR(var, value) XSETOBJ (var, Lisp_Type_Char, value)
|
0
|
91
|
|
92 /* XSETOBJ was formerly named XSET. The name change was made to catch
|
|
93 C code that attempts to use this macro. You should always use the
|
|
94 individual settor macros (XSETCONS, XSETBUFFER, etc.) instead. */
|
|
95
|
185
|
96 #define XSETOBJ(var, type_tag, value) \
|
201
|
97 ((void) ((var) = (((EMACS_INT) (type_tag) << ((VALBITS) + 1)) \
|
185
|
98 + ((EMACS_INT) (value) & VALMASK))))
|
0
|
99
|
|
100 /* During garbage collection, XGCTYPE must be used for extracting types
|
185
|
101 so that the mark bit is ignored. XMARKBIT accesses the markbit.
|
|
102 Markbits are used only in particular slots of particular structure types.
|
|
103 Other markbits are always zero.
|
|
104 Outside of garbage collection, all mark bits are always zero. */
|
0
|
105
|
|
106 #ifndef XGCTYPE
|
201
|
107 # define XGCTYPE(a) XTYPE(a)
|
0
|
108 #endif
|
|
109
|
185
|
110 # define XMARKBIT(a) ((a) & (MARKBIT))
|
0
|
111
|
185
|
112 # define XMARK(a) ((void) ((a) |= (MARKBIT)))
|
|
113 # define XUNMARK(a) ((void) ((a) &= (~(MARKBIT))))
|
0
|
114
|
|
115 /* Use this for turning a (void *) into a Lisp_Object, as when the
|
|
116 Lisp_Object is passed into a toolkit callback function */
|
185
|
117 #define VOID_TO_LISP(larg,varg) ((void) ((larg) = ((Lisp_Object) (varg))))
|
0
|
118 #define CVOID_TO_LISP VOID_TO_LISP
|
|
119
|
185
|
120 /* Use this for turning a Lisp_Object into a (void *), as when the
|
0
|
121 Lisp_Object is passed into a toolkit callback function */
|
|
122 #define LISP_TO_VOID(larg) ((void *) (larg))
|
|
123 #define LISP_TO_CVOID(varg) ((CONST void *) (larg))
|
|
124
|
|
125 /* Convert a Lisp_Object into something that can't be used as an
|
|
126 lvalue. Useful for type-checking. */
|
|
127 #define NON_LVALUE(larg) ((larg) + 0)
|