Mercurial > hg > xemacs-beta
annotate src/lisp-disunion.h @ 5428:73eef12660cd
Converted gnuserv docs to GPLv3 or later.
| author | Mats Lidell <matsl@xemacs.org> |
|---|---|
| date | Sat, 06 Nov 2010 22:57:08 +0100 |
| parents | 308d34e9f07d |
| children | 56144c8593a8 |
| rev | line source |
|---|---|
| 428 | 1 /* Fundamental definitions for XEmacs Lisp interpreter -- non-union objects. |
| 2 Copyright (C) 1985, 1986, 1987, 1992, 1993 Free Software Foundation, Inc. | |
| 826 | 3 Copyright (C) 2001, 2002 Ben Wing. |
| 428 | 4 |
| 5 This file is part of XEmacs. | |
| 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 | 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 | 11 |
| 12 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
| 13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
| 14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
| 15 for more details. | |
| 16 | |
| 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 | 19 |
| 20 /* Synched up with: FSF 19.30. Split out from lisp.h. */ | |
| 21 /* This file has diverged greatly from FSF Emacs. Syncing is no | |
| 22 longer desirable or possible */ | |
| 23 | |
| 24 /* | |
| 25 Format of a non-union-type Lisp Object | |
| 26 | |
| 27 3 2 1 0 | |
| 28 bit 10987654321098765432109876543210 | |
| 29 -------------------------------- | |
| 30 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVTT | |
| 31 | |
| 32 Integers are treated specially, and look like this: | |
| 33 | |
| 34 3 2 1 0 | |
| 35 bit 10987654321098765432109876543210 | |
| 36 -------------------------------- | |
| 37 VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVT | |
| 38 | |
| 39 For integral Lisp types, i.e. integers and characters, the value | |
| 458 | 40 bits are the Lisp object. Some people call such Lisp_Objects "immediate". |
| 428 | 41 |
| 458 | 42 The object is obtained by masking off the type bits. |
| 462 | 43 Bit 1 is used as a value bit by splitting the Lisp integer type |
| 458 | 44 into two subtypes, Lisp_Type_Int_Even and Lisp_Type_Int_Odd. |
| 45 By this trickery we get 31 bits for integers instead of 30. | |
| 428 | 46 |
| 47 For non-integral types, the value bits of a Lisp_Object contain | |
| 48 a pointer to a structure containing the object. The pointer is | |
| 49 obtained by masking off the type and mark bits. | |
| 50 | |
| 462 | 51 All pointer-based types are coalesced under a single type called |
| 458 | 52 Lisp_Type_Record. The type bits for this type are required by the |
| 53 implementation to be 00, just like the least significant bits of | |
| 54 word-aligned struct pointers on 32-bit hardware. This requires that | |
| 55 all structs implementing Lisp_Objects have an alignment of at least 4 | |
| 56 bytes. Because of this, Lisp_Object pointers don't have to be masked | |
| 57 and are full-sized. | |
| 428 | 58 |
| 458 | 59 There are no mark bits in the Lisp_Object itself (there used to be). |
| 60 | |
| 61 Integers and characters don't need to be marked. All other types are | |
| 62 lrecord-based, which means they get marked by setting the mark bit in | |
| 63 the struct lrecord_header. | |
| 428 | 64 |
| 65 Here is a brief description of the following macros: | |
| 66 | |
| 67 XTYPE The type bits of a Lisp_Object | |
| 68 XPNTRVAL The value bits of a Lisp_Object storing a pointer | |
| 867 | 69 XCHARVAL The value bits of a Lisp_Object storing a Ichar |
| 428 | 70 XREALINT The value bits of a Lisp_Object storing an integer, signed |
| 71 XUINT The value bits of a Lisp_Object storing an integer, unsigned | |
| 458 | 72 INTP Non-zero if this Lisp_Object is an integer |
| 428 | 73 Qzero Lisp Integer 0 |
| 458 | 74 EQ Non-zero if two Lisp_Objects are identical, not merely equal. */ |
| 428 | 75 |
| 76 | |
| 77 typedef EMACS_INT Lisp_Object; | |
| 78 | |
| 79 #define Lisp_Type_Int_Bit (Lisp_Type_Int_Even & Lisp_Type_Int_Odd) | |
| 80 #define VALMASK (((1UL << VALBITS) - 1UL) << GCTYPEBITS) | |
| 81 #define XTYPE(x) ((enum Lisp_Type) (((EMACS_UINT)(x)) & ~VALMASK)) | |
| 82 #define XPNTRVAL(x) (x) /* This depends on Lisp_Type_Record == 0 */ | |
| 83 #define XCHARVAL(x) ((x) >> GCBITS) | |
| 84 #define XREALINT(x) ((x) >> INT_GCBITS) | |
| 85 #define XUINT(x) ((EMACS_UINT)(x) >> INT_GCBITS) | |
| 826 | 86 |
| 87 #define wrap_pointer_1(ptr) ((Lisp_Object) (ptr)) | |
| 88 | |
| 89 DECLARE_INLINE_HEADER ( | |
| 90 Lisp_Object | |
| 91 make_int_verify (EMACS_INT val) | |
| 92 ) | |
| 93 { | |
| 94 Lisp_Object obj = (Lisp_Object) ((val << INT_GCBITS) | Lisp_Type_Int_Bit); | |
| 95 type_checking_assert (XREALINT (obj) == val); | |
| 96 return obj; | |
| 97 } | |
| 98 | |
| 99 #define make_int(x) ((Lisp_Object) (((x) << INT_GCBITS) | Lisp_Type_Int_Bit)) | |
| 100 | |
| 831 | 101 #define make_char_1(x) ((Lisp_Object) (((x) << GCBITS) | Lisp_Type_Char)) |
| 826 | 102 |
| 428 | 103 #define INTP(x) ((EMACS_UINT)(x) & Lisp_Type_Int_Bit) |
| 104 #define INT_PLUS(x,y) ((x)+(y)-Lisp_Type_Int_Bit) | |
| 105 #define INT_MINUS(x,y) ((x)-(y)+Lisp_Type_Int_Bit) | |
| 106 #define INT_PLUS1(x) INT_PLUS (x, make_int (1)) | |
| 107 #define INT_MINUS1(x) INT_MINUS (x, make_int (1)) | |
| 108 | |
| 109 #define Qzero make_int (0) | |
| 110 #define Qnull_pointer ((Lisp_Object) 0) | |
| 111 #define EQ(x,y) ((x) == (y)) | |
| 112 | |
| 853 | 113 /* WARNING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! |
| 114 | |
| 5013 | 115 You can only GET_LISP_FROM_VOID something that had previously been |
| 116 STORE_LISP_IN_VOID'd. If you want to go the other way, use | |
| 117 STORE_VOID_IN_LISP and GET_VOID_FROM_LISP, or use make_opaque_ptr(). */ | |
| 853 | 118 |
| 5013 | 119 /* Convert a Lisp object to a void * pointer, as when it needs to be passed |
| 120 to a toolkit callback function */ | |
| 121 #define STORE_LISP_IN_VOID(larg) ((void *) (larg)) | |
| 122 | |
| 123 /* Convert a void * pointer back into a Lisp object, assuming that the | |
| 124 pointer was generated by STORE_LISP_IN_VOID. */ | |
| 125 #define GET_LISP_FROM_VOID(varg) ((Lisp_Object) (varg)) | |
| 428 | 126 |
| 127 /* Convert a Lisp_Object into something that can't be used as an | |
| 128 lvalue. Useful for type-checking. */ | |
| 129 #define NON_LVALUE(larg) ((larg) + 0) |
