annotate src/lisp-disunion.h @ 5936:574f0cded429 cygwin

try to replace all nnnL or nnnUL constants with EMACS_[U]INT
author Henry Thompson <ht@markup.co.uk>
date Sun, 13 Dec 2015 13:22:58 +0000
parents f5dfcf2323bc
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 /* Fundamental definitions for XEmacs Lisp interpreter -- non-union objects.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc.
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
3 Copyright (C) 2001, 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
4
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5 This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5013
diff changeset
7 XEmacs is free software: you can redistribute it and/or modify it
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5013
diff changeset
9 Free Software Foundation, either version 3 of the License, or (at your
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5013
diff changeset
10 option) any later version.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15 for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
5402
308d34e9f07d Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents: 5013
diff changeset
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20 /* Synched up with: FSF 19.30. Split out from lisp.h. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 /* This file has diverged greatly from FSF Emacs. Syncing is no
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 longer desirable or possible */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 /*
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25 Format of a non-union-type Lisp Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27 3 2 1 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 bit 10987654321098765432109876543210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29 --------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 Integers are treated specially, and look like this:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 3 2 1 0
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 bit 10987654321098765432109876543210
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
36 --------------------------------
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
37 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVT
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
38
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 For integral Lisp types, i.e. integers and characters, the value
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
40 bits are the Lisp object. Some people call such Lisp_Objects "immediate".
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
42 The object is obtained by masking off the type bits.
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
43 Bit 1 is used as a value bit by splitting the Lisp integer type
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
44 into two subtypes, Lisp_Type_Fixnum_Even and Lisp_Type_Fixnum_Odd.
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
45 By this trickery we get 31 bits for integers instead of 30.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 For non-integral types, the value bits of a Lisp_Object contain
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
48 a pointer to a structure containing the object. The pointer is
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
49 obtained by masking off the type and mark bits.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
50
462
0784d089fdc9 Import from CVS: tag r21-2-46
cvs
parents: 458
diff changeset
51 All pointer-based types are coalesced under a single type called
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
52 Lisp_Type_Record. The type bits for this type are required by the
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
53 implementation to be 00, just like the least significant bits of
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
54 word-aligned struct pointers on 32-bit hardware. This requires that
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
55 all structs implementing Lisp_Objects have an alignment of at least 4
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
56 bytes. Because of this, Lisp_Object pointers don't have to be masked
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
57 and are full-sized.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
59 There are no mark bits in the Lisp_Object itself (there used to be).
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
60
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
61 Integers and characters don't need to be marked. All other types are
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
62 lrecord-based, which means they get marked by setting the mark bit in
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
63 the struct lrecord_header.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
64
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
65 Here is a brief description of the following macros:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
66
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
67 XTYPE The type bits of a Lisp_Object
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 XPNTRVAL The value bits of a Lisp_Object storing a pointer
867
804517e16990 [xemacs-hg @ 2002-06-05 09:54:39 by ben]
ben
parents: 853
diff changeset
69 XCHARVAL The value bits of a Lisp_Object storing a Ichar
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
70 XREALFIXNUM The value bits of a Lisp_Object storing an integer, signed
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
71 XUINT The value bits of a Lisp_Object storing an integer, unsigned
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
72 FIXNUMP Non-zero if this Lisp_Object is an integer
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
73 Qzero Lisp Integer 0
458
c33ae14dd6d0 Import from CVS: tag r21-2-44
cvs
parents: 452
diff changeset
74 EQ Non-zero if two Lisp_Objects are identical, not merely equal. */
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
75
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
76
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
77 typedef EMACS_INT Lisp_Object;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
78
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
79 #define Lisp_Type_Fixnum_Bit (Lisp_Type_Fixnum_Even & Lisp_Type_Fixnum_Odd)
5936
574f0cded429 try to replace all nnnL or nnnUL constants with EMACS_[U]INT
Henry Thompson <ht@markup.co.uk>
parents: 5929
diff changeset
80 #define VALMASK ((((uintptr_t)UE1 << VALBITS) - 1UL) << GCTYPEBITS)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81 #define XTYPE(x) ((enum Lisp_Type) (((EMACS_UINT)(x)) & ~VALMASK))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 #define XPNTRVAL(x) (x) /* This depends on Lisp_Type_Record == 0 */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 #define XCHARVAL(x) ((x) >> GCBITS)
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
84 #define XREALFIXNUM(x) ((x) >> FIXNUM_GCBITS)
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
85 #define XUINT(x) ((EMACS_UINT)(x) >> FIXNUM_GCBITS)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
86
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
87 #define wrap_pointer_1(ptr) ((Lisp_Object) (ptr))
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
88
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
89 DECLARE_INLINE_HEADER (
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
90 Lisp_Object
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
91 make_fixnum_verify (EMACS_INT val)
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
92 )
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
93 {
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
94 Lisp_Object obj = (Lisp_Object) ((val << FIXNUM_GCBITS) | Lisp_Type_Fixnum_Bit);
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
95 type_checking_assert (XREALFIXNUM (obj) == val);
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
96 return obj;
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
97 }
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
98
5629
0d05accafc63 Don't lose bits in make_fixnum / make_char_1.
Jerry James <james@xemacs.org>
parents: 5581
diff changeset
99 #define make_fixnum(x) ((Lisp_Object) ((((EMACS_INT)(x)) << FIXNUM_GCBITS) | Lisp_Type_Fixnum_Bit))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
100
5629
0d05accafc63 Don't lose bits in make_fixnum / make_char_1.
Jerry James <james@xemacs.org>
parents: 5581
diff changeset
101 #define make_char_1(x) ((Lisp_Object) ((((EMACS_UINT)(x)) << GCBITS) | Lisp_Type_Char))
826
6728e641994e [xemacs-hg @ 2002-05-05 11:30:15 by ben]
ben
parents: 800
diff changeset
102
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
103 #define FIXNUMP(x) ((EMACS_UINT)(x) & Lisp_Type_Fixnum_Bit)
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
104 #define FIXNUM_PLUS(x,y) ((x)+(y)-Lisp_Type_Fixnum_Bit)
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
105 #define FIXNUM_MINUS(x,y) ((x)-(y)+Lisp_Type_Fixnum_Bit)
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
106 #define FIXNUM_PLUS1(x) FIXNUM_PLUS (x, make_fixnum (1))
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
107 #define FIXNUM_MINUS1(x) FIXNUM_MINUS (x, make_fixnum (1))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108
5581
56144c8593a8 Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents: 5402
diff changeset
109 #define Qzero make_fixnum (0)
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 #define Qnull_pointer ((Lisp_Object) 0)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 #define EQ(x,y) ((x) == (y))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 831
diff changeset
113 /* WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 831
diff changeset
114
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
115 You can only GET_LISP_FROM_VOID something that had previously been
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
116 STORE_LISP_IN_VOID'd. If you want to go the other way, use
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
117 STORE_VOID_IN_LISP and GET_VOID_FROM_LISP, or use make_opaque_ptr(). */
853
2b6fa2618f76 [xemacs-hg @ 2002-05-28 08:44:22 by ben]
ben
parents: 831
diff changeset
118
5013
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
119 /* Convert a Lisp object to a void * pointer, as when it needs to be passed
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
120 to a toolkit callback function */
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
121 #define STORE_LISP_IN_VOID(larg) ((void *) (larg))
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
122
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
123 /* Convert a void * pointer back into a Lisp object, assuming that the
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
124 pointer was generated by STORE_LISP_IN_VOID. */
ae48681c47fa changes to VOID_TO_LISP et al.
Ben Wing <ben@xemacs.org>
parents: 1111
diff changeset
125 #define GET_LISP_FROM_VOID(varg) ((Lisp_Object) (varg))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 /* Convert a Lisp_Object into something that can't be used as an
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128 lvalue. Useful for type-checking. */
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 #define NON_LVALUE(larg) ((larg) + 0)