annotate src/lrecord.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 de805c49cfc1
children 41dbb7a9d5f2
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 /* The "lrecord" structure (header of a compound lisp object).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
5 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
24 #ifndef _XEMACS_LRECORD_H_
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
25 #define _XEMACS_LRECORD_H_
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 /* The "lrecord" type of Lisp object is used for all object types
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28 other than a few simple ones. This allows many types to be
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
29 implemented but only a few bits required in a Lisp object for
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
30 type information. (The tradeoff is that each object has its
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
31 type marked in it, thereby increasing its size.) The first
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
32 four bytes of all lrecords is either a pointer to a struct
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
33 lrecord_implementation, which contains methods describing how
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
34 to process this object, or an index into an array of pointers
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
35 to struct lrecord_implementations plus some other data bits.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
37 Lrecords are of two types: straight lrecords, and lcrecords.
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
38 Straight lrecords are used for those types of objects that have
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
39 their own allocation routines (typically allocated out of 2K chunks
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
40 of memory called `frob blocks'). These objects have a `struct
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
41 lrecord_header' at the top, containing only the bits needed to find
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
42 the lrecord_implementation for the object. There are special
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
43 routines in alloc.c to deal with each such object type.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
45 Lcrecords are used for less common sorts of objects that don't
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
46 do their own allocation. Each such object is malloc()ed
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
47 individually, and the objects are chained together through
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
48 a `next' pointer. Lcrecords have a `struct lcrecord_header'
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
49 at the top, which contains a `struct lrecord_header' and
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
50 a `next' pointer, and are allocated using alloc_lcrecord().
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 Creating a new lcrecord type is fairly easy; just follow the
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
53 lead of some existing type (e.g. hash tables). Note that you
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 do not need to supply all the methods (see below); reasonable
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 defaults are provided for many of them. Alternatively, if you're
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 just looking for a way of encapsulating data (which possibly
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 could contain Lisp_Objects in it), you may well be able to use
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 the opaque type. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 struct lrecord_header
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
61 {
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
62 /* index into lrecord_implementations_table[] */
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
63 unsigned char type;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
64 struct {
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
65 /* 1 if the object is marked during GC. */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
66 unsigned mark :1;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
67 /* 1 if the object resides in read-only space */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
68 unsigned c_readonly : 1;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
69 /* 1 if the object is readonly from lisp */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
70 unsigned lisp_readonly : 1;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
71 } flags;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
72 };
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
73
243
f220cc83d72e Import from CVS: tag r20-5b20
cvs
parents: 213
diff changeset
74 struct lrecord_implementation;
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
75 int lrecord_type_index (CONST struct lrecord_implementation *implementation);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
76
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
77 # define set_lheader_implementation(header,imp) do { \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
78 struct lrecord_header* SLI_header = (header); \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
79 (SLI_header)->type = lrecord_type_index (imp); \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
80 (SLI_header)->flags.mark = 0; \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
81 (SLI_header)->flags.c_readonly = 0; \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
82 (SLI_header)->flags.lisp_readonly = 0; \
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
83 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85 struct lcrecord_header
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
86 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
87 struct lrecord_header lheader;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
88
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
89 /* The `next' field is normally used to chain all lrecords together
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
90 so that the GC can find (and free) all of them.
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
91 `alloc_lcrecord' threads records together.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
92
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
93 The `next' field may be used for other purposes as long as some
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
94 other mechanism is provided for letting the GC do its work.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
95
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
96 For example, the event and marker object types allocate members
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
97 out of memory chunks, and are able to find all unmarked members
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
98 by sweeping through the elements of the list of chunks. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
99 struct lcrecord_header *next;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
100
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
101 /* The `uid' field is just for debugging/printing convenience.
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
102 Having this slot doesn't hurt us much spacewise, since an
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
103 lcrecord already has the above slots plus malloc overhead. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
104 unsigned int uid :31;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
105
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
106 /* The `free' field is a flag that indicates whether this lcrecord
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
107 is on a "free list". Free lists are used to minimize the number
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
108 of calls to malloc() when we're repeatedly allocating and freeing
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
109 a number of the same sort of lcrecord. Lcrecords on a free list
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
110 always get marked in a different fashion, so we can use this flag
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
111 as a sanity check to make sure that free lists only have freed
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
112 lcrecords and there are no freed lcrecords elsewhere. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
113 unsigned int free :1;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
114 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 /* Used for lcrecords in an lcrecord-list. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 struct free_lcrecord_header
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
118 {
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
119 struct lcrecord_header lcheader;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
120 Lisp_Object chain;
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
121 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
123 /* see alloc.c for an explanation */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
124 Lisp_Object this_one_is_unmarkable (Lisp_Object obj,
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
125 void (*markobj) (Lisp_Object));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 struct lrecord_implementation
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
128 {
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
129 CONST char *name;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
130 /* This function is called at GC time, to make sure that all Lisp_Objects
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
131 pointed to by this object get properly marked. It should call
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
132 the mark_object function on all Lisp_Objects in the object. If
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
133 the return value is non-nil, it should be a Lisp_Object to be
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
134 marked (don't call the mark_object function explicitly on it,
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
135 because the GC routines will do this). Doing it this way reduces
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
136 recursion, so the object returned should preferably be the one
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
137 with the deepest level of Lisp_Object pointers. This function
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
138 can be NULL, meaning no GC marking is necessary. */
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
139 Lisp_Object (*marker) (Lisp_Object, void (*mark_object) (Lisp_Object));
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
140 /* This can be NULL if the object is an lcrecord; the
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
141 default_object_printer() in print.c will be used. */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
142 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
143 /* This function is called at GC time when the object is about to
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
144 be freed, and at dump time (FOR_DISKSAVE will be non-zero in this
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
145 case). It should perform any necessary cleanup (e.g. freeing
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
146 malloc()ed memory. This can be NULL, meaning no special
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
147 finalization is necessary.
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
148
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
149 WARNING: remember that the finalizer is called at dump time even
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
150 though the object is not being freed. */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
151 void (*finalizer) (void *header, int for_disksave);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
152 /* This can be NULL, meaning compare objects with EQ(). */
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
153 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
154 /* This can be NULL, meaning use the Lisp_Object itself as the hash;
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
155 but *only* if the `equal' function is EQ (if two objects are
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
156 `equal', they *must* hash to the same value or the hashing won't
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
157 work). */
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
158 unsigned long (*hash) (Lisp_Object, int);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
159 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
160 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
161 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
162 Lisp_Object (*plist) (Lisp_Object obj);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
164 /* Only one of these is non-0. If both are 0, it means that this type
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
165 is not instantiable by alloc_lcrecord(). */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
166 size_t static_size;
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
167 size_t (*size_in_bytes_method) (CONST void *header);
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
168 /* A unique subtag-code (dynamically) assigned to this datatype. */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
169 /* (This is a pointer so the rest of this structure can be read-only.) */
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
170 int *lrecord_type_index;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
171 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
172 one that does not have an lcrecord_header at the front and which
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
173 is (usually) allocated in frob blocks. We only use this flag for
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
174 some consistency checking, and that only when error-checking is
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
175 enabled. */
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
176 int basic_p;
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
177 };
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
179 extern CONST struct lrecord_implementation *lrecord_implementations_table[];
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
180
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
181 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
182 (lrecord_implementations_table[XRECORD_LHEADER (obj)->type])
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
183 #define LHEADER_IMPLEMENTATION(lh) (lrecord_implementations_table[(lh)->type])
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
184
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 extern int gc_in_progress;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
187 #define MARKED_RECORD_P(obj) (gc_in_progress && XRECORD_LHEADER (obj)->flags.mark)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
188 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->flags.mark)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
189 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->flags.mark = 1))
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
190 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->flags.mark = 0))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
191
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
192 #define UNMARKABLE_RECORD_HEADER_P(lheader) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
193 (LHEADER_IMPLEMENTATION (lheader)->marker == this_one_is_unmarkable)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
194
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
195 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->flags.c_readonly)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
196 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->flags.lisp_readonly)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
197 #define SET_C_READONLY_RECORD_HEADER(lheader) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
198 ((void) ((lheader)->flags.c_readonly = (lheader)->flags.lisp_readonly = 1))
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
199 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
200 ((void) ((lheader)->flags.lisp_readonly = 1))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
201
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
202 /* Declaring the following structures as const puts them in the
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
203 text (read-only) segment, which makes debugging inconvenient
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
204 because this segment is not mapped when processing a core-
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
205 dump file */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
206
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
207 #ifdef DEBUG_XEMACS
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
208 #define CONST_IF_NOT_DEBUG
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
209 #else
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
210 #define CONST_IF_NOT_DEBUG CONST
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
211 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
212
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
215 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
216
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
217 #if defined (ERROR_CHECK_TYPECHECK)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
221 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
222
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
223 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
224 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,0,0,0,0,structtype)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
226 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
227 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,sizeof(structtype),0,1,structtype)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
229 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
230 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,0,0,0,0,structtype)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
231
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
232 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
233 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,sizeof (structtype),0,0,structtype)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
234
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
235 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,sizer,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
236 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,0,0,0,0,sizer,structtype)
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 243
diff changeset
237
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
238 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,sizer,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
239 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,0,sizer,0,structtype) \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
240
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
241 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,getprop,putprop,remprop,props,size,sizer,basic_p,structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
242 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
243 static int lrecord_##c_name##_lrecord_type_index; \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
244 CONST_IF_NOT_DEBUG struct lrecord_implementation lrecord_##c_name = \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
245 { name, marker, printer, nuker, equal, hash, \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
246 getprop, putprop, remprop, props, size, sizer, \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
247 &(lrecord_##c_name##_lrecord_type_index), basic_p } \
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
248
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
249 #define LRECORDP(a) (XTYPE ((a)) == Lisp_Type_Record)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
250 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
211
78478c60bfcd Import from CVS: tag r20-4b4
cvs
parents: 207
diff changeset
251
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
252 #define RECORD_TYPEP(x, ty) \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
253 (LRECORDP (x) && \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
254 lrecord_implementations_table[XRECORD_LHEADER (x)->type] == (ty))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 /* NOTE: the DECLARE_LRECORD() must come before the associated
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
257 DEFINE_LRECORD_*() or you will get compile errors.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
258
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
259 Furthermore, you always need to put the DECLARE_LRECORD() in a header
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
260 file, and make sure the header file is included in inline.c, even
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
261 if the type is private to a particular file. Otherwise, you will
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
262 get undefined references for the error_check_foo() inline function
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
263 under GCC. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
264
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
265 #ifdef ERROR_CHECK_TYPECHECK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
266
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
267 # define DECLARE_LRECORD(c_name, structtype) \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
268 extern CONST_IF_NOT_DEBUG struct lrecord_implementation \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
269 lrecord_##c_name; \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
270 INLINE structtype *error_check_##c_name (Lisp_Object obj); \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
271 INLINE structtype * \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
272 error_check_##c_name (Lisp_Object obj) \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
273 { \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
274 assert (RECORD_TYPEP (obj, &lrecord_##c_name) || \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
275 MARKED_RECORD_P (obj)); \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
276 return (structtype *) XPNTR (obj); \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
277 } \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
278 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
279
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
280 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
281 INLINE structtype *error_check_##c_name (Lisp_Object obj); \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
282 INLINE structtype * \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
283 error_check_##c_name (Lisp_Object obj) \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
284 { \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
285 assert (XGCTYPE (obj) == type_enum); \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 272
diff changeset
286 return (structtype *) XPNTR (obj); \
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
287 } \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
289
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
290 # define XRECORD(x, c_name, structtype) error_check_##c_name (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
291 # define XNONRECORD(x, c_name, type_enum, structtype) error_check_##c_name (x)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
292
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
293 # define XSETRECORD(var, p, c_name) do \
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
294 { \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
295 XSETOBJ (var, Lisp_Type_Record, p); \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
296 assert (RECORD_TYPEP (var, &lrecord_##c_name) || \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
297 MARKED_RECORD_P (var)); \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
298 } while (0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
299
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
300 #else /* not ERROR_CHECK_TYPECHECK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
301
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
302 # define DECLARE_LRECORD(c_name, structtype) \
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
303 extern Lisp_Object Q##c_name##p; \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
304 extern CONST_IF_NOT_DEBUG struct lrecord_implementation \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
305 lrecord_##c_name
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
306 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 extern Lisp_Object Q##c_name##p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
309 # define XNONRECORD(x, c_name, type_enum, structtype) \
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 ((structtype *) XPNTR (x))
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
311 # define XSETRECORD(var, p, c_name) XSETOBJ (var, Lisp_Type_Record, p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
312
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
313 #endif /* not ERROR_CHECK_TYPECHECK */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
314
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
315 #define RECORDP(x, c_name) RECORD_TYPEP (x, &lrecord_##c_name)
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
316 #define GC_RECORDP(x, c_name) gc_record_type_p (x, &lrecord_##c_name)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 /* Note: we now have two different kinds of type-checking macros.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 The "old" kind has now been renamed CONCHECK_foo. The reason for
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
320 this is that the CONCHECK_foo macros signal a continuable error,
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
321 allowing the user (through debug-on-error) to substitute a different
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322 value and return from the signal, which causes the lvalue argument
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 to get changed. Quite a lot of code would crash if that happened,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
324 because it did things like
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
326 foo = XCAR (list);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 CHECK_STRING (foo);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 and later on did XSTRING (XCAR (list)), assuming that the type
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 is correct (when it might be wrong, if the user substituted a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 correct value in the debugger).
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 To get around this, I made all the CHECK_foo macros signal a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
334 non-continuable error. Places where a continuable error is OK
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
335 (generally only when called directly on the argument of a Lisp
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336 primitive) should be changed to use CONCHECK().
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 FSF Emacs does not have this problem because RMS took the cheesy
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 way out and disabled returning from a signal entirely. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
341 #define CONCHECK_RECORD(x, c_name) do { \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
342 if (!RECORD_TYPEP (x, &lrecord_##c_name)) \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
343 x = wrong_type_argument (Q##c_name##p, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
344 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
345 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
346 if (XTYPE (x) != lisp_enum) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
347 x = wrong_type_argument (predicate, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
348 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
349 #define CHECK_RECORD(x, c_name) do { \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
350 if (!RECORD_TYPEP (x, &lrecord_##c_name)) \
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
351 dead_wrong_type_argument (Q##c_name##p, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
352 } while (0)
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
353 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
354 if (XTYPE (x) != lisp_enum) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
355 dead_wrong_type_argument (predicate, x); \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
356 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
357
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
358 void *alloc_lcrecord (size_t size, CONST struct lrecord_implementation *);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
359
185
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
360 #define alloc_lcrecord_type(type, lrecord_implementation) \
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
361 ((type *) alloc_lcrecord (sizeof (type), lrecord_implementation))
3d6bfa290dbd Import from CVS: tag r20-3b19
cvs
parents: 2
diff changeset
362
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
363 int gc_record_type_p (Lisp_Object frob,
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
364 CONST struct lrecord_implementation *type);
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
365
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
366 /* Copy the data from one lcrecord structure into another, but don't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
367 overwrite the header information. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
368
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
369 #define copy_lcrecord(dst, src) \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
370 memcpy ((char *) dst + sizeof (struct lcrecord_header), \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
371 (char *) src + sizeof (struct lcrecord_header), \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
372 sizeof (*dst) - sizeof (struct lcrecord_header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
373
2
ac2d302a0011 Import from CVS: tag r19-15b2
cvs
parents: 0
diff changeset
374 #define zero_lcrecord(lcr) \
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
375 memset ((char *) lcr + sizeof (struct lcrecord_header), 0, \
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
376 sizeof (*lcr) - sizeof (struct lcrecord_header))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377
412
697ef44129c6 Import from CVS: tag r21-2-14
cvs
parents: 410
diff changeset
378 #endif /* _XEMACS_LRECORD_H_ */