annotate src/lisp-disunion.h @ 412:697ef44129c6 r21-2-14

Import from CVS: tag r21-2-14
author cvs
date Mon, 13 Aug 2007 11:20:41 +0200
parents 74fd4e045ea6
children 11054d720c21
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. */
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
22 /* This file has diverged greatly from FSF Emacs. Syncing is no
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
23 longer desirable or possible */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24
207
e45d5e7c476e Import from CVS: tag r20-4b2
cvs
parents: 201
diff changeset
25 /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
26 Format of a non-union-type Lisp Object
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
27
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
28 3 2 1 0
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
29 bit 10987654321098765432109876543210
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
30 --------------------------------
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
31 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTT
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
32
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
33 Integers are treated specially, and look like this:
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
34
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
35 3 2 1 0
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
36 bit 10987654321098765432109876543210
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
37 --------------------------------
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
38 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVT
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
39
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
40 For integral Lisp types, i.e. integers and characters, the value
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
41 bits are the Lisp object.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
42
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
43 The object is obtained by masking off the type and mark bits.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
44 Bit 1 is used as a value bit by splitting the Lisp integer type
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
45 into two subtypes, Lisp_Type_Int_Even and Lisp_Type_Int_Odd. By
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
46 this trickery we get 31 bits for integers instead of 30.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
47
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
48 For non-integral types, the value bits of a Lisp_Object contain
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
49 a pointer to a structure containing the object. The pointer is
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
50 obtained by masking off the type and mark bits.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
51
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
52 All pointer-based types are coalesced under a single type called
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
53 Lisp_Type_Record. The type bits for this type are required
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
54 by the implementation to be 00, just like the least
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
55 significant bits of word-aligned struct pointers on 32-bit
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
56 hardware. Because of this, Lisp_Object pointers don't have
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
57 to be masked and are full-sized.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
58
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
59 There are no mark bits.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
60 Integers and characters don't need to be marked. All other types
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
61 are lrecord-based, which means they get marked by incrementing
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
62 their ->implementation pointer.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
63
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
64 Here is a brief description of the following macros:
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
65
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
66 XTYPE The type bits of a Lisp_Object
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
67 XPNTRVAL The value bits of a Lisp_Object storing a pointer
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
68 XCHARVAL The value bits of a Lisp_Object storing a Emchar
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
69 XREALINT The value bits of a Lisp_Object storing an integer, signed
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
70 XUINT The value bits of a Lisp_Object storing an integer, unsigned
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
71 INTP Non-zero if this Lisp_Object an integer?
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
72 Qzero Lisp Integer 0
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
73 EQ Non-zero if two Lisp_Objects are identical
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
74 GC_EQ Version of EQ used during garbage collection */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
75
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
76 typedef EMACS_INT Lisp_Object;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
77
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
78 #define Lisp_Type_Int_Bit (Lisp_Type_Int_Even & Lisp_Type_Int_Odd)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
79 #define make_obj(vartype, x) ((Lisp_Object) (x))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
80 #define make_int(x) ((Lisp_Object) (((x) << INT_GCBITS) | Lisp_Type_Int_Bit))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
81 #define make_char(x) ((Lisp_Object) (((x) << GCBITS) | Lisp_Type_Char))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
82 #define VALMASK (((1UL << VALBITS) - 1UL) << GCTYPEBITS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
83 #define XTYPE(x) ((enum Lisp_Type) (((EMACS_UINT)(x)) & ~VALMASK))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
84 #define XPNTRVAL(x) (x) /* This depends on Lisp_Type_Record == 0 */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
85 #define XCHARVAL(x) ((x) >> GCBITS)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
86 #define GC_EQ(x,y) EQ (x,y)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
87 #define XREALINT(x) ((x) >> INT_GCBITS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
88 #define XUINT(x) ((EMACS_UINT)(x) >> INT_GCBITS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
89 #define INTP(x) ((EMACS_UINT)(x) & Lisp_Type_Int_Bit)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
90
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 296
diff changeset
91 #define Qzero make_int (0)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 296
diff changeset
92 #define Qnull_pointer ((Lisp_Object) 0)
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
93 #define XGCTYPE(x) XTYPE(x)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
94 #define EQ(x,y) ((x) == (y))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
95 #define XSETINT(var, value) ((void) ((var) = make_int (value)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
96 #define XSETCHAR(var, value) ((void) ((var) = make_char (value)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
97 #define XSETOBJ(var, vartype, value) ((void) ((var) = make_obj (vartype, value)))
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
98
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
99 /* Convert between a (void *) and a Lisp_Object, as when the
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
100 Lisp_Object is passed to a toolkit callback function */
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 0
diff changeset
101 #define VOID_TO_LISP(larg,varg) ((void) ((larg) = ((Lisp_Object) (varg))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 #define CVOID_TO_LISP VOID_TO_LISP
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103 #define LISP_TO_VOID(larg) ((void *) (larg))
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 398
diff changeset
104 #define LISP_TO_CVOID(varg) ((CONST void *) (larg))
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 /* Convert a Lisp_Object into something that can't be used as an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 lvalue. Useful for type-checking. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 #define NON_LVALUE(larg) ((larg) + 0)