428
|
1 /* The "lrecord" structure (header of a compound lisp object).
|
|
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
|
771
|
3 Copyright (C) 1996, 2001 Ben Wing.
|
428
|
4
|
|
5 This file is part of XEmacs.
|
|
6
|
|
7 XEmacs is free software; you can redistribute it and/or modify it
|
|
8 under the terms of the GNU General Public License as published by the
|
|
9 Free Software Foundation; either version 2, or (at your option) any
|
|
10 later version.
|
|
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
|
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
|
21
|
|
22 /* Synched up with: Not in FSF. */
|
|
23
|
440
|
24 #ifndef INCLUDED_lrecord_h_
|
|
25 #define INCLUDED_lrecord_h_
|
428
|
26
|
|
27 /* The "lrecord" type of Lisp object is used for all object types
|
|
28 other than a few simple ones. This allows many types to be
|
442
|
29 implemented but only a few bits required in a Lisp object for type
|
|
30 information. (The tradeoff is that each object has its type marked
|
|
31 in it, thereby increasing its size.) All lrecords begin with a
|
|
32 `struct lrecord_header', which identifies the lisp object type, by
|
|
33 providing an index into a table of `struct lrecord_implementation',
|
|
34 which describes the behavior of the lisp object. It also contains
|
|
35 some other data bits.
|
428
|
36
|
|
37 Lrecords are of two types: straight lrecords, and lcrecords.
|
|
38 Straight lrecords are used for those types of objects that have
|
|
39 their own allocation routines (typically allocated out of 2K chunks
|
|
40 of memory called `frob blocks'). These objects have a `struct
|
|
41 lrecord_header' at the top, containing only the bits needed to find
|
|
42 the lrecord_implementation for the object. There are special
|
|
43 routines in alloc.c to deal with each such object type.
|
|
44
|
442
|
45 Lcrecords are used for less common sorts of objects that don't do
|
|
46 their own allocation. Each such object is malloc()ed individually,
|
|
47 and the objects are chained together through a `next' pointer.
|
|
48 Lcrecords have a `struct lcrecord_header' at the top, which
|
|
49 contains a `struct lrecord_header' and a `next' pointer, and are
|
|
50 allocated using alloc_lcrecord().
|
428
|
51
|
|
52 Creating a new lcrecord type is fairly easy; just follow the
|
|
53 lead of some existing type (e.g. hash tables). Note that you
|
|
54 do not need to supply all the methods (see below); reasonable
|
|
55 defaults are provided for many of them. Alternatively, if you're
|
|
56 just looking for a way of encapsulating data (which possibly
|
|
57 could contain Lisp_Objects in it), you may well be able to use
|
|
58 the opaque type. */
|
|
59
|
|
60 struct lrecord_header
|
|
61 {
|
|
62 /* index into lrecord_implementations_table[] */
|
442
|
63 unsigned int type :8;
|
|
64
|
|
65 /* If `mark' is 0 after the GC mark phase, the object will be freed
|
|
66 during the GC sweep phase. There are 2 ways that `mark' can be 1:
|
|
67 - by being referenced from other objects during the GC mark phase
|
|
68 - because it is permanently on, for c_readonly objects */
|
|
69 unsigned int mark :1;
|
|
70
|
|
71 /* 1 if the object resides in logically read-only space, and does not
|
|
72 reference other non-c_readonly objects.
|
|
73 Invariant: if (c_readonly == 1), then (mark == 1 && lisp_readonly == 1) */
|
|
74 unsigned int c_readonly :1;
|
|
75
|
428
|
76 /* 1 if the object is readonly from lisp */
|
442
|
77 unsigned int lisp_readonly :1;
|
771
|
78
|
|
79 unsigned int unused :21;
|
428
|
80 };
|
|
81
|
|
82 struct lrecord_implementation;
|
442
|
83 int lrecord_type_index (const struct lrecord_implementation *implementation);
|
428
|
84
|
430
|
85 #define set_lheader_implementation(header,imp) do { \
|
428
|
86 struct lrecord_header* SLI_header = (header); \
|
442
|
87 SLI_header->type = (imp)->lrecord_type_index; \
|
430
|
88 SLI_header->mark = 0; \
|
|
89 SLI_header->c_readonly = 0; \
|
|
90 SLI_header->lisp_readonly = 0; \
|
428
|
91 } while (0)
|
|
92
|
|
93 struct lcrecord_header
|
|
94 {
|
|
95 struct lrecord_header lheader;
|
|
96
|
442
|
97 /* The `next' field is normally used to chain all lcrecords together
|
428
|
98 so that the GC can find (and free) all of them.
|
442
|
99 `alloc_lcrecord' threads lcrecords together.
|
428
|
100
|
|
101 The `next' field may be used for other purposes as long as some
|
|
102 other mechanism is provided for letting the GC do its work.
|
|
103
|
|
104 For example, the event and marker object types allocate members
|
|
105 out of memory chunks, and are able to find all unmarked members
|
|
106 by sweeping through the elements of the list of chunks. */
|
|
107 struct lcrecord_header *next;
|
|
108
|
|
109 /* The `uid' field is just for debugging/printing convenience.
|
|
110 Having this slot doesn't hurt us much spacewise, since an
|
|
111 lcrecord already has the above slots plus malloc overhead. */
|
|
112 unsigned int uid :31;
|
|
113
|
|
114 /* The `free' field is a flag that indicates whether this lcrecord
|
|
115 is on a "free list". Free lists are used to minimize the number
|
|
116 of calls to malloc() when we're repeatedly allocating and freeing
|
|
117 a number of the same sort of lcrecord. Lcrecords on a free list
|
|
118 always get marked in a different fashion, so we can use this flag
|
|
119 as a sanity check to make sure that free lists only have freed
|
|
120 lcrecords and there are no freed lcrecords elsewhere. */
|
|
121 unsigned int free :1;
|
|
122 };
|
|
123
|
|
124 /* Used for lcrecords in an lcrecord-list. */
|
|
125 struct free_lcrecord_header
|
|
126 {
|
|
127 struct lcrecord_header lcheader;
|
|
128 Lisp_Object chain;
|
|
129 };
|
|
130
|
442
|
131 enum lrecord_type
|
|
132 {
|
|
133 /* Symbol value magic types come first to make SYMBOL_VALUE_MAGIC_P fast.
|
|
134 #### This should be replaced by a symbol_value_magic_p flag
|
|
135 in the Lisp_Symbol lrecord_header. */
|
|
136 lrecord_type_symbol_value_forward,
|
|
137 lrecord_type_symbol_value_varalias,
|
|
138 lrecord_type_symbol_value_lisp_magic,
|
|
139 lrecord_type_symbol_value_buffer_local,
|
|
140 lrecord_type_max_symbol_value_magic = lrecord_type_symbol_value_buffer_local,
|
|
141
|
|
142 lrecord_type_symbol,
|
|
143 lrecord_type_subr,
|
|
144 lrecord_type_cons,
|
|
145 lrecord_type_vector,
|
|
146 lrecord_type_string,
|
|
147 lrecord_type_lcrecord_list,
|
|
148 lrecord_type_compiled_function,
|
|
149 lrecord_type_weak_list,
|
|
150 lrecord_type_bit_vector,
|
|
151 lrecord_type_float,
|
|
152 lrecord_type_hash_table,
|
|
153 lrecord_type_lstream,
|
|
154 lrecord_type_process,
|
|
155 lrecord_type_charset,
|
|
156 lrecord_type_coding_system,
|
|
157 lrecord_type_char_table,
|
|
158 lrecord_type_char_table_entry,
|
|
159 lrecord_type_range_table,
|
|
160 lrecord_type_opaque,
|
|
161 lrecord_type_opaque_ptr,
|
|
162 lrecord_type_buffer,
|
|
163 lrecord_type_extent,
|
|
164 lrecord_type_extent_info,
|
|
165 lrecord_type_extent_auxiliary,
|
|
166 lrecord_type_marker,
|
|
167 lrecord_type_event,
|
|
168 lrecord_type_keymap,
|
|
169 lrecord_type_command_builder,
|
|
170 lrecord_type_timeout,
|
|
171 lrecord_type_specifier,
|
|
172 lrecord_type_console,
|
|
173 lrecord_type_device,
|
|
174 lrecord_type_frame,
|
|
175 lrecord_type_window,
|
617
|
176 lrecord_type_window_mirror,
|
442
|
177 lrecord_type_window_configuration,
|
|
178 lrecord_type_gui_item,
|
|
179 lrecord_type_popup_data,
|
|
180 lrecord_type_toolbar_button,
|
617
|
181 lrecord_type_scrollbar_instance,
|
442
|
182 lrecord_type_color_instance,
|
|
183 lrecord_type_font_instance,
|
|
184 lrecord_type_image_instance,
|
|
185 lrecord_type_glyph,
|
|
186 lrecord_type_face,
|
|
187 lrecord_type_database,
|
|
188 lrecord_type_tooltalk_message,
|
|
189 lrecord_type_tooltalk_pattern,
|
|
190 lrecord_type_ldap,
|
|
191 lrecord_type_pgconn,
|
|
192 lrecord_type_pgresult,
|
|
193 lrecord_type_devmode,
|
|
194 lrecord_type_mswindows_dialog_id,
|
446
|
195 lrecord_type_case_table,
|
462
|
196 lrecord_type_emacs_ffi,
|
|
197 lrecord_type_emacs_gtk_object,
|
|
198 lrecord_type_emacs_gtk_boxed,
|
454
|
199 lrecord_type_free, /* only used for "free" lrecords */
|
|
200 lrecord_type_undefined, /* only used for debugging */
|
442
|
201 lrecord_type_last_built_in_type /* must be last */
|
|
202 };
|
|
203
|
647
|
204 extern int lrecord_type_count;
|
428
|
205
|
|
206 struct lrecord_implementation
|
|
207 {
|
442
|
208 const char *name;
|
|
209
|
|
210 /* `marker' is called at GC time, to make sure that all Lisp_Objects
|
428
|
211 pointed to by this object get properly marked. It should call
|
|
212 the mark_object function on all Lisp_Objects in the object. If
|
|
213 the return value is non-nil, it should be a Lisp_Object to be
|
|
214 marked (don't call the mark_object function explicitly on it,
|
|
215 because the GC routines will do this). Doing it this way reduces
|
|
216 recursion, so the object returned should preferably be the one
|
|
217 with the deepest level of Lisp_Object pointers. This function
|
|
218 can be NULL, meaning no GC marking is necessary. */
|
|
219 Lisp_Object (*marker) (Lisp_Object);
|
442
|
220
|
|
221 /* `printer' converts the object to a printed representation.
|
|
222 This can be NULL; in this case default_object_printer() will be
|
|
223 used instead. */
|
428
|
224 void (*printer) (Lisp_Object, Lisp_Object printcharfun, int escapeflag);
|
442
|
225
|
|
226 /* `finalizer' is called at GC time when the object is about to
|
428
|
227 be freed, and at dump time (FOR_DISKSAVE will be non-zero in this
|
|
228 case). It should perform any necessary cleanup (e.g. freeing
|
442
|
229 malloc()ed memory). This can be NULL, meaning no special
|
428
|
230 finalization is necessary.
|
|
231
|
442
|
232 WARNING: remember that `finalizer' is called at dump time even
|
428
|
233 though the object is not being freed. */
|
|
234 void (*finalizer) (void *header, int for_disksave);
|
442
|
235
|
428
|
236 /* This can be NULL, meaning compare objects with EQ(). */
|
|
237 int (*equal) (Lisp_Object obj1, Lisp_Object obj2, int depth);
|
442
|
238
|
|
239 /* `hash' generates hash values for use with hash tables that have
|
|
240 `equal' as their test function. This can be NULL, meaning use
|
|
241 the Lisp_Object itself as the hash. But, you must still satisfy
|
|
242 the constraint that if two objects are `equal', then they *must*
|
|
243 hash to the same value in order for hash tables to work properly.
|
|
244 This means that `hash' can be NULL only if the `equal' method is
|
|
245 also NULL. */
|
428
|
246 unsigned long (*hash) (Lisp_Object, int);
|
|
247
|
|
248 /* External data layout description */
|
|
249 const struct lrecord_description *description;
|
|
250
|
442
|
251 /* These functions allow any object type to have builtin property
|
|
252 lists that can be manipulated from the lisp level with
|
|
253 `get', `put', `remprop', and `object-plist'. */
|
428
|
254 Lisp_Object (*getprop) (Lisp_Object obj, Lisp_Object prop);
|
|
255 int (*putprop) (Lisp_Object obj, Lisp_Object prop, Lisp_Object val);
|
|
256 int (*remprop) (Lisp_Object obj, Lisp_Object prop);
|
|
257 Lisp_Object (*plist) (Lisp_Object obj);
|
|
258
|
442
|
259 /* Only one of `static_size' and `size_in_bytes_method' is non-0.
|
|
260 If both are 0, this type is not instantiable by alloc_lcrecord(). */
|
665
|
261 Bytecount static_size;
|
|
262 Bytecount (*size_in_bytes_method) (const void *header);
|
442
|
263
|
|
264 /* The (constant) index into lrecord_implementations_table */
|
|
265 enum lrecord_type lrecord_type_index;
|
|
266
|
428
|
267 /* A "basic" lrecord is any lrecord that's not an lcrecord, i.e.
|
|
268 one that does not have an lcrecord_header at the front and which
|
|
269 is (usually) allocated in frob blocks. We only use this flag for
|
|
270 some consistency checking, and that only when error-checking is
|
|
271 enabled. */
|
442
|
272 unsigned int basic_p :1;
|
428
|
273 };
|
|
274
|
617
|
275 /* All the built-in lisp object types are enumerated in `enum lrecord_type'.
|
442
|
276 Additional ones may be defined by a module (none yet). We leave some
|
|
277 room in `lrecord_implementations_table' for such new lisp object types. */
|
|
278 #define MODULE_DEFINABLE_TYPE_COUNT 32
|
|
279
|
647
|
280 extern const struct lrecord_implementation *lrecord_implementations_table[lrecord_type_last_built_in_type + MODULE_DEFINABLE_TYPE_COUNT];
|
428
|
281
|
|
282 #define XRECORD_LHEADER_IMPLEMENTATION(obj) \
|
442
|
283 LHEADER_IMPLEMENTATION (XRECORD_LHEADER (obj))
|
|
284 #define LHEADER_IMPLEMENTATION(lh) lrecord_implementations_table[(lh)->type]
|
428
|
285
|
|
286 extern int gc_in_progress;
|
|
287
|
442
|
288 #define MARKED_RECORD_P(obj) (XRECORD_LHEADER (obj)->mark)
|
428
|
289 #define MARKED_RECORD_HEADER_P(lheader) ((lheader)->mark)
|
|
290 #define MARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 1))
|
|
291 #define UNMARK_RECORD_HEADER(lheader) ((void) ((lheader)->mark = 0))
|
|
292
|
|
293 #define C_READONLY_RECORD_HEADER_P(lheader) ((lheader)->c_readonly)
|
|
294 #define LISP_READONLY_RECORD_HEADER_P(lheader) ((lheader)->lisp_readonly)
|
442
|
295 #define SET_C_READONLY_RECORD_HEADER(lheader) do { \
|
|
296 struct lrecord_header *SCRRH_lheader = (lheader); \
|
|
297 SCRRH_lheader->c_readonly = 1; \
|
|
298 SCRRH_lheader->lisp_readonly = 1; \
|
|
299 SCRRH_lheader->mark = 1; \
|
|
300 } while (0)
|
428
|
301 #define SET_LISP_READONLY_RECORD_HEADER(lheader) \
|
|
302 ((void) ((lheader)->lisp_readonly = 1))
|
442
|
303 #define RECORD_MARKER(lheader) lrecord_markers[(lheader)->type]
|
428
|
304
|
|
305 /* External description stuff
|
|
306
|
771
|
307 PLEASE NOTE: Both lrecord_description and struct_description are
|
|
308 badly misnamed. In reality, an lrecord_description is nothing more
|
|
309 than a list of the elements in a block of memory that need
|
|
310 relocating or other special handling, and a struct_description is
|
|
311 no more than an lrecord_description plus the size of the block of
|
|
312 memory. (In fact, a struct_description can now have its size given
|
|
313 as zero, i.e. unspecified, meaning that the last element in the
|
|
314 structure is noted in the list and the size of the block can
|
|
315 therefore be computed from it.) The names stem from the fact
|
|
316 lrecord_descriptions are used to describe lrecords (the size of the
|
|
317 lrecord is elsewhere in its description, attached to its methods,
|
|
318 so it does not need to be given here), while struct_descriptions
|
|
319 are used to describe C structs; but both are used in various
|
|
320 additional ways. Much better terms would be memory_description and
|
|
321 sized_memory_description.
|
428
|
322
|
771
|
323 An lrecord_description is an array of values. (This is actually
|
|
324 misnamed, in that it does not just describe lrecords, but any
|
|
325 blocks of memory.) The first value of each line is a type, the
|
|
326 second the offset in the lrecord structure. The third and
|
|
327 following elements are parameters; their presence, type and number
|
|
328 is type-dependent.
|
|
329
|
|
330 The description ends with a "XD_END", "XD_SPECIFIER_END" or
|
|
331 "XD_CODING_SYSTEM_END" record.
|
|
332
|
|
333 The top-level description of an lrecord or lcrecord does not need
|
|
334 to describe every element, just the ones that need to be relocated,
|
|
335 since the size of the lrecord is known. (The same goes for nested
|
|
336 structures, whenever the structure size is given, rather than being
|
|
337 defaulted by specifying 0 for the size.)
|
|
338
|
|
339 A struct_description is used for describing nested "structures".
|
|
340 (Again a misnomer, since it can be used for any blocks of memory,
|
|
341 not just structures.) It just contains a size for the memory block,
|
|
342 a pointer to an lrecord_description, and (for unions only) a union
|
|
343 constant, described below. The size can be 0 (#### not yet
|
|
344 implemented!), in which case the size will be determined from the
|
|
345 largest offset logically referenced (i.e. last offset mentioned +
|
|
346 size of that object). This is useful for stretchy arrays.
|
428
|
347
|
|
348 Some example descriptions :
|
440
|
349
|
428
|
350 static const struct lrecord_description cons_description[] = {
|
440
|
351 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
|
|
352 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
|
428
|
353 { XD_END }
|
|
354 };
|
|
355
|
440
|
356 Which means "two lisp objects starting at the 'car' and 'cdr' elements"
|
428
|
357
|
|
358 static const struct lrecord_description string_description[] = {
|
440
|
359 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
|
|
360 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT(0, 1) },
|
|
361 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
|
428
|
362 { XD_END }
|
|
363 };
|
|
364 "A pointer to string data at 'data', the size of the pointed array being the value
|
|
365 of the size variable plus 1, and one lisp object at 'plist'"
|
|
366
|
|
367 The existing types :
|
|
368 XD_LISP_OBJECT
|
440
|
369 A Lisp object. This is also the type to use for pointers to other lrecords.
|
428
|
370
|
440
|
371 XD_LISP_OBJECT_ARRAY
|
771
|
372 An array of Lisp objects or (equivalently) pointers to lrecords.
|
|
373 The parameter (i.e. third element) is the count. This would be declared
|
|
374 as Lisp_Object foo[666]. For something declared as Lisp_Object *foo,
|
|
375 use XD_STRUCT_PTR, whose description parameter is a struct_description
|
|
376 consisting of only XD_LISP_OBJECT and XD_END.
|
440
|
377
|
428
|
378 XD_LO_LINK
|
771
|
379 Weak link in a linked list of objects of the same type. This is a
|
|
380 link that does NOT generate a GC reference. Thus the pdumper will
|
|
381 not automatically add the referenced object to the table of all
|
|
382 objects to be dumped, and when storing and loading the dumped data
|
|
383 will automatically prune unreferenced objects in the chain and link
|
|
384 each referenced object to the next referenced object, even if it's
|
|
385 many links away. We also need to special handling of a similar
|
|
386 nature for the root of the chain, which will be a staticpro()ed
|
|
387 object.
|
432
|
388
|
428
|
389 XD_OPAQUE_PTR
|
|
390 Pointer to undumpable data. Must be NULL when dumping.
|
|
391
|
|
392 XD_STRUCT_PTR
|
771
|
393 Pointer to block of described memory. (This is misnamed: It is NOT
|
|
394 necessarily a pointer to a struct foo.) Parameters are number of
|
|
395 contiguous blocks and struct_description.
|
|
396
|
|
397 XD_STRUCT_ARRAY
|
|
398 Array of blocks of described memory. Parameters are number of
|
|
399 structures and struct_description. This differs from XD_STRUCT_PTR
|
|
400 in that the parameter is declared as struct foo[666] instead of
|
|
401 struct *foo. In other words, the block of memory holding the
|
|
402 structures is within the containing structure, rather than being
|
|
403 elsewhere, with a pointer in the containing structure.
|
428
|
404
|
|
405 XD_OPAQUE_DATA_PTR
|
|
406 Pointer to dumpable opaque data. Parameter is the size of the data.
|
|
407 Pointed data must be relocatable without changes.
|
|
408
|
771
|
409 XD_UNION
|
|
410 Union of two or more different types of data. Parameters are a
|
|
411 constant which determines which type the data is (this is usually an
|
|
412 XD_INDIRECT, referring to one of the fields in the structure), and
|
|
413 an array of struct_descriptions, whose values are used as follows,
|
|
414 which is *DIFFERENT* from their usage in XD_STRUCT_PTR: the first
|
|
415 field is a constant, which is compared to the first parameter of the
|
|
416 XD_UNION descriptor to determine if this description applies to the
|
|
417 data at the given offset, and the second is a pointer to a *SINGLE*
|
|
418 lrecord_description structure, describing the data being pointed at
|
|
419 when the associated constant matches. You can go ahead and create
|
|
420 an array of lrecord_description structures and put an XD_END on it,
|
|
421 but only the first one is used. If the data being pointed at is a
|
|
422 structure, you *MAY NOT* substitute an array of lrecord_description
|
|
423 structures describing the structure; instead, use a single
|
|
424 lrecord_description structure with an XD_STRUCT_PTR in it, and point
|
|
425 it in turn to the description of the structure. See charset.h for a
|
|
426 description of how to use XD_UNION. (In other words, if the constant
|
|
427 matches, the lrecord_description pointed at will in essence be
|
|
428 substituted for the XD_UNION declaration.)
|
|
429
|
428
|
430 XD_C_STRING
|
|
431 Pointer to a C string.
|
|
432
|
|
433 XD_DOC_STRING
|
|
434 Pointer to a doc string (C string if positive, opaque value if negative)
|
|
435
|
|
436 XD_INT_RESET
|
|
437 An integer which will be reset to a given value in the dump file.
|
|
438
|
771
|
439
|
665
|
440 XD_ELEMCOUNT
|
|
441 Elemcount value. Used for counts.
|
647
|
442
|
665
|
443 XD_BYTECOUNT
|
|
444 Bytecount value. Used for counts.
|
647
|
445
|
665
|
446 XD_HASHCODE
|
|
447 Hashcode value. Used for the results of hashing functions.
|
428
|
448
|
|
449 XD_INT
|
|
450 int value. Used for counts.
|
|
451
|
|
452 XD_LONG
|
|
453 long value. Used for counts.
|
|
454
|
771
|
455 XD_BYTECOUNT
|
|
456 bytecount value. Used for counts.
|
|
457
|
428
|
458 XD_END
|
|
459 Special type indicating the end of the array.
|
|
460
|
|
461 XD_SPECIFIER_END
|
|
462 Special type indicating the end of the array for a specifier. Extra
|
771
|
463 description, describing the specifier-type-specific data at the end
|
|
464 of the specifier object, is going to be fetched from the specifier
|
|
465 methods. This should occur exactly once, in the description of the
|
|
466 specifier object, and the dump code knows how to special-case this
|
|
467 by fetching the specifier_methods pointer from the appropriate place
|
|
468 in the memory block (which will, of course, be a struct
|
|
469 Lisp_Specifier), fetching the description of the
|
|
470 specifier-type-specific data from this, and continuing processing
|
|
471 the memory block.
|
|
472
|
|
473 XD_CODING_SYSTEM_END
|
|
474 Special type indicating the end of the array for a coding system.
|
|
475 Extra description is going to be fetched from the coding system
|
|
476 methods. Works just like XD_SPECIFIER_END.
|
428
|
477
|
|
478
|
|
479 Special macros:
|
|
480 XD_INDIRECT(line, delta)
|
|
481 Usable where a "count" or "size" is requested. Gives the value of
|
|
482 the element which is at line number 'line' in the description (count
|
|
483 starts at zero) and adds delta to it.
|
|
484 */
|
|
485
|
647
|
486 enum lrecord_description_type
|
|
487 {
|
440
|
488 XD_LISP_OBJECT_ARRAY,
|
428
|
489 XD_LISP_OBJECT,
|
|
490 XD_LO_LINK,
|
|
491 XD_OPAQUE_PTR,
|
|
492 XD_STRUCT_PTR,
|
771
|
493 XD_STRUCT_ARRAY,
|
428
|
494 XD_OPAQUE_DATA_PTR,
|
771
|
495 XD_UNION,
|
428
|
496 XD_C_STRING,
|
|
497 XD_DOC_STRING,
|
|
498 XD_INT_RESET,
|
665
|
499 XD_BYTECOUNT,
|
|
500 XD_ELEMCOUNT,
|
|
501 XD_HASHCODE,
|
428
|
502 XD_INT,
|
|
503 XD_LONG,
|
|
504 XD_END,
|
771
|
505 XD_SPECIFIER_END,
|
|
506 XD_CODING_SYSTEM_END
|
428
|
507 };
|
|
508
|
647
|
509 struct lrecord_description
|
|
510 {
|
428
|
511 enum lrecord_description_type type;
|
|
512 int offset;
|
|
513 EMACS_INT data1;
|
|
514 const struct struct_description *data2;
|
|
515 };
|
|
516
|
647
|
517 struct struct_description
|
|
518 {
|
665
|
519 Bytecount size;
|
428
|
520 const struct lrecord_description *description;
|
|
521 };
|
|
522
|
|
523 #define XD_INDIRECT(val, delta) (-1-((val)|(delta<<8)))
|
|
524
|
|
525 #define XD_IS_INDIRECT(code) (code<0)
|
|
526 #define XD_INDIRECT_VAL(code) ((-1-code) & 255)
|
|
527 #define XD_INDIRECT_DELTA(code) (((-1-code)>>8) & 255)
|
|
528
|
|
529 #define XD_DYNARR_DESC(base_type, sub_desc) \
|
440
|
530 { XD_STRUCT_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \
|
|
531 { XD_INT, offsetof (base_type, cur) }, \
|
|
532 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) }
|
428
|
533
|
|
534 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size.
|
|
535 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies.
|
|
536 */
|
|
537
|
|
538 #if defined (ERROR_CHECK_TYPECHECK)
|
|
539 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
|
|
540 #else
|
|
541 # define DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype)
|
|
542 #endif
|
|
543
|
|
544 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
|
|
545 DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
|
|
546
|
442
|
547 #define DEFINE_BASIC_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
|
|
548 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof(structtype),0,1,structtype)
|
428
|
549
|
|
550 #define DEFINE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
|
|
551 DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
|
|
552
|
442
|
553 #define DEFINE_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
|
|
554 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
|
428
|
555
|
|
556 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
|
|
557 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
|
|
558
|
442
|
559 #define DEFINE_BASIC_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
|
|
560 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,0,sizer,1,structtype)
|
428
|
561
|
442
|
562 #define DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
|
771
|
563 MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
|
442
|
564
|
|
565 #define MAKE_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
|
428
|
566 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
|
442
|
567 const struct lrecord_implementation lrecord_##c_name = \
|
428
|
568 { name, marker, printer, nuker, equal, hash, desc, \
|
442
|
569 getprop, putprop, remprop, plist, size, sizer, \
|
|
570 lrecord_type_##c_name, basic_p }
|
|
571
|
|
572 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,structtype) \
|
|
573 DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,structtype)
|
|
574
|
|
575 #define DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,structtype) \
|
|
576 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizeof (structtype),0,0,structtype)
|
|
577
|
|
578 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,sizer,structtype) \
|
|
579 DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,0,0,0,0,sizer,structtype)
|
|
580
|
|
581 #define DEFINE_EXTERNAL_LRECORD_SEQUENCE_IMPLEMENTATION_WITH_PROPS(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,sizer,structtype) \
|
|
582 MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,0,sizer,0,structtype)
|
|
583
|
|
584 #define MAKE_EXTERNAL_LRECORD_IMPLEMENTATION(name,c_name,marker,printer,nuker,equal,hash,desc,getprop,putprop,remprop,plist,size,sizer,basic_p,structtype) \
|
|
585 DECLARE_ERROR_CHECK_TYPECHECK(c_name, structtype) \
|
647
|
586 int lrecord_type_##c_name; \
|
444
|
587 struct lrecord_implementation lrecord_##c_name = \
|
442
|
588 { name, marker, printer, nuker, equal, hash, desc, \
|
|
589 getprop, putprop, remprop, plist, size, sizer, \
|
444
|
590 lrecord_type_last_built_in_type, basic_p }
|
442
|
591
|
|
592
|
|
593 extern Lisp_Object (*lrecord_markers[]) (Lisp_Object);
|
|
594
|
|
595 #define INIT_LRECORD_IMPLEMENTATION(type) do { \
|
|
596 lrecord_implementations_table[lrecord_type_##type] = &lrecord_##type; \
|
|
597 lrecord_markers[lrecord_type_##type] = \
|
|
598 lrecord_implementations_table[lrecord_type_##type]->marker; \
|
|
599 } while (0)
|
428
|
600
|
444
|
601 #define INIT_EXTERNAL_LRECORD_IMPLEMENTATION(type) do { \
|
|
602 lrecord_type_##type = lrecord_type_count++; \
|
|
603 lrecord_##type.lrecord_type_index = lrecord_type_##type; \
|
|
604 INIT_LRECORD_IMPLEMENTATION(type); \
|
|
605 } while (0)
|
|
606
|
428
|
607 #define LRECORDP(a) (XTYPE (a) == Lisp_Type_Record)
|
|
608 #define XRECORD_LHEADER(a) ((struct lrecord_header *) XPNTR (a))
|
|
609
|
|
610 #define RECORD_TYPEP(x, ty) \
|
647
|
611 (LRECORDP (x) && (XRECORD_LHEADER (x)->type == (unsigned int) (ty)))
|
442
|
612
|
|
613 /* Steps to create a new object:
|
|
614
|
|
615 1. Declare the struct for your object in a header file somewhere.
|
|
616 Remember that it must begin with
|
|
617
|
|
618 struct lcrecord_header header;
|
|
619
|
617
|
620 2. Put the "standard junk" (DECLARE_RECORD()/XFOO/XSETFOO/etc.) below the
|
|
621 struct definition -- see below.
|
442
|
622
|
|
623 3. Add this header file to inline.c.
|
|
624
|
|
625 4. Create the methods for your object. Note that technically you don't
|
|
626 need any, but you will almost always want at least a mark method.
|
|
627
|
|
628 5. Define your object with DEFINE_LRECORD_IMPLEMENTATION() or some
|
|
629 variant.
|
|
630
|
|
631 6. Include the header file in the .c file where you defined the object.
|
|
632
|
|
633 7. Put a call to INIT_LRECORD_IMPLEMENTATION() for the object in the
|
|
634 .c file's syms_of_foo() function.
|
|
635
|
|
636 8. Add a type enum for the object to enum lrecord_type, earlier in this
|
|
637 file.
|
|
638
|
|
639 An example:
|
428
|
640
|
442
|
641 ------------------------------ in toolbar.h -----------------------------
|
|
642
|
|
643 struct toolbar_button
|
|
644 {
|
|
645 struct lcrecord_header header;
|
|
646
|
|
647 Lisp_Object next;
|
|
648 Lisp_Object frame;
|
|
649
|
|
650 Lisp_Object up_glyph;
|
|
651 Lisp_Object down_glyph;
|
|
652 Lisp_Object disabled_glyph;
|
|
653
|
|
654 Lisp_Object cap_up_glyph;
|
|
655 Lisp_Object cap_down_glyph;
|
|
656 Lisp_Object cap_disabled_glyph;
|
|
657
|
|
658 Lisp_Object callback;
|
|
659 Lisp_Object enabled_p;
|
|
660 Lisp_Object help_string;
|
|
661
|
|
662 char enabled;
|
|
663 char down;
|
|
664 char pushright;
|
|
665 char blank;
|
|
666
|
|
667 int x, y;
|
|
668 int width, height;
|
|
669 int dirty;
|
|
670 int vertical;
|
|
671 int border_width;
|
|
672 };
|
428
|
673
|
617
|
674 [[ the standard junk: ]]
|
|
675
|
442
|
676 DECLARE_LRECORD (toolbar_button, struct toolbar_button);
|
|
677 #define XTOOLBAR_BUTTON(x) XRECORD (x, toolbar_button, struct toolbar_button)
|
|
678 #define XSETTOOLBAR_BUTTON(x, p) XSETRECORD (x, p, toolbar_button)
|
617
|
679 #define wrap_toolbar_button(p) wrap_record (p, toolbar_button)
|
442
|
680 #define TOOLBAR_BUTTONP(x) RECORDP (x, toolbar_button)
|
|
681 #define CHECK_TOOLBAR_BUTTON(x) CHECK_RECORD (x, toolbar_button)
|
|
682 #define CONCHECK_TOOLBAR_BUTTON(x) CONCHECK_RECORD (x, toolbar_button)
|
|
683
|
|
684 ------------------------------ in toolbar.c -----------------------------
|
|
685
|
|
686 #include "toolbar.h"
|
|
687
|
|
688 ...
|
|
689
|
|
690 static Lisp_Object
|
|
691 mark_toolbar_button (Lisp_Object obj)
|
|
692 {
|
|
693 struct toolbar_button *data = XTOOLBAR_BUTTON (obj);
|
|
694 mark_object (data->next);
|
|
695 mark_object (data->frame);
|
|
696 mark_object (data->up_glyph);
|
|
697 mark_object (data->down_glyph);
|
|
698 mark_object (data->disabled_glyph);
|
|
699 mark_object (data->cap_up_glyph);
|
|
700 mark_object (data->cap_down_glyph);
|
|
701 mark_object (data->cap_disabled_glyph);
|
|
702 mark_object (data->callback);
|
|
703 mark_object (data->enabled_p);
|
|
704 return data->help_string;
|
|
705 }
|
|
706
|
617
|
707 [[ If your object should never escape to Lisp, declare its print method
|
|
708 as internal_object_printer instead of 0. ]]
|
|
709
|
442
|
710 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
|
617
|
711 mark_toolbar_button, 0,
|
|
712 0, 0, 0, 0, struct toolbar_button);
|
442
|
713
|
|
714 ...
|
|
715
|
|
716 void
|
|
717 syms_of_toolbar (void)
|
|
718 {
|
|
719 INIT_LRECORD_IMPLEMENTATION (toolbar_button);
|
|
720
|
|
721 ...;
|
|
722 }
|
|
723
|
|
724 ------------------------------ in inline.c -----------------------------
|
|
725
|
|
726 #ifdef HAVE_TOOLBARS
|
|
727 #include "toolbar.h"
|
|
728 #endif
|
|
729
|
|
730 ------------------------------ in lrecord.h -----------------------------
|
|
731
|
|
732 enum lrecord_type
|
|
733 {
|
|
734 ...
|
|
735 lrecord_type_toolbar_button,
|
|
736 ...
|
|
737 };
|
|
738
|
|
739 */
|
|
740
|
|
741 /*
|
|
742
|
|
743 Note: Object types defined in external dynamically-loaded modules (not
|
|
744 part of the XEmacs main source code) should use DECLARE_EXTERNAL_LRECORD
|
|
745 and DEFINE_EXTERNAL_LRECORD_IMPLEMENTATION rather than DECLARE_LRECORD
|
|
746 and DEFINE_LRECORD_IMPLEMENTATION.
|
|
747
|
|
748 */
|
|
749
|
428
|
750
|
|
751 #ifdef ERROR_CHECK_TYPECHECK
|
|
752
|
|
753 # define DECLARE_LRECORD(c_name, structtype) \
|
442
|
754 extern const struct lrecord_implementation lrecord_##c_name; \
|
|
755 INLINE_HEADER structtype * \
|
|
756 error_check_##c_name (Lisp_Object obj); \
|
|
757 INLINE_HEADER structtype * \
|
428
|
758 error_check_##c_name (Lisp_Object obj) \
|
|
759 { \
|
442
|
760 assert (RECORD_TYPEP (obj, lrecord_type_##c_name)); \
|
428
|
761 return (structtype *) XPNTR (obj); \
|
|
762 } \
|
|
763 extern Lisp_Object Q##c_name##p
|
|
764
|
442
|
765 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
|
647
|
766 extern int lrecord_type_##c_name; \
|
444
|
767 extern struct lrecord_implementation lrecord_##c_name; \
|
|
768 INLINE_HEADER structtype * \
|
|
769 error_check_##c_name (Lisp_Object obj); \
|
|
770 INLINE_HEADER structtype * \
|
|
771 error_check_##c_name (Lisp_Object obj) \
|
|
772 { \
|
|
773 assert (RECORD_TYPEP (obj, lrecord_type_##c_name)); \
|
|
774 return (structtype *) XPNTR (obj); \
|
|
775 } \
|
|
776 extern Lisp_Object Q##c_name##p
|
442
|
777
|
428
|
778 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
|
442
|
779 INLINE_HEADER structtype * \
|
|
780 error_check_##c_name (Lisp_Object obj); \
|
|
781 INLINE_HEADER structtype * \
|
428
|
782 error_check_##c_name (Lisp_Object obj) \
|
|
783 { \
|
|
784 assert (XTYPE (obj) == type_enum); \
|
|
785 return (structtype *) XPNTR (obj); \
|
|
786 } \
|
|
787 extern Lisp_Object Q##c_name##p
|
|
788
|
|
789 # define XRECORD(x, c_name, structtype) error_check_##c_name (x)
|
|
790 # define XNONRECORD(x, c_name, type_enum, structtype) error_check_##c_name (x)
|
|
791
|
|
792 # define XSETRECORD(var, p, c_name) do \
|
|
793 { \
|
442
|
794 XSETOBJ (var, p); \
|
|
795 assert (RECORD_TYPEP (var, lrecord_type_##c_name)); \
|
428
|
796 } while (0)
|
|
797
|
617
|
798 INLINE_HEADER Lisp_Object wrap_record_1 (void *ptr, enum lrecord_type ty);
|
|
799 INLINE_HEADER Lisp_Object
|
|
800 wrap_record_1 (void *ptr, enum lrecord_type ty)
|
|
801 {
|
|
802 Lisp_Object obj;
|
|
803 XSETOBJ (obj, ptr);
|
|
804 assert (RECORD_TYPEP (obj, ty));
|
|
805 return obj;
|
|
806 }
|
|
807
|
|
808 #define wrap_record(ptr, ty) wrap_record_1 (ptr, lrecord_type_##ty)
|
|
809
|
428
|
810 #else /* not ERROR_CHECK_TYPECHECK */
|
|
811
|
|
812 # define DECLARE_LRECORD(c_name, structtype) \
|
|
813 extern Lisp_Object Q##c_name##p; \
|
442
|
814 extern const struct lrecord_implementation lrecord_##c_name
|
|
815 # define DECLARE_EXTERNAL_LRECORD(c_name, structtype) \
|
|
816 extern Lisp_Object Q##c_name##p; \
|
647
|
817 extern int lrecord_type_##c_name; \
|
444
|
818 extern struct lrecord_implementation lrecord_##c_name
|
428
|
819 # define DECLARE_NONRECORD(c_name, type_enum, structtype) \
|
|
820 extern Lisp_Object Q##c_name##p
|
|
821 # define XRECORD(x, c_name, structtype) ((structtype *) XPNTR (x))
|
|
822 # define XNONRECORD(x, c_name, type_enum, structtype) \
|
|
823 ((structtype *) XPNTR (x))
|
442
|
824 # define XSETRECORD(var, p, c_name) XSETOBJ (var, p)
|
617
|
825 /* wrap_pointer_1 is so named as a suggestion not to use it unless you
|
|
826 know what you're doing. */
|
|
827 #define wrap_record(ptr, ty) wrap_pointer_1 (ptr)
|
428
|
828
|
|
829 #endif /* not ERROR_CHECK_TYPECHECK */
|
|
830
|
442
|
831 #define RECORDP(x, c_name) RECORD_TYPEP (x, lrecord_type_##c_name)
|
428
|
832
|
|
833 /* Note: we now have two different kinds of type-checking macros.
|
|
834 The "old" kind has now been renamed CONCHECK_foo. The reason for
|
|
835 this is that the CONCHECK_foo macros signal a continuable error,
|
|
836 allowing the user (through debug-on-error) to substitute a different
|
|
837 value and return from the signal, which causes the lvalue argument
|
|
838 to get changed. Quite a lot of code would crash if that happened,
|
|
839 because it did things like
|
|
840
|
|
841 foo = XCAR (list);
|
|
842 CHECK_STRING (foo);
|
|
843
|
|
844 and later on did XSTRING (XCAR (list)), assuming that the type
|
|
845 is correct (when it might be wrong, if the user substituted a
|
|
846 correct value in the debugger).
|
|
847
|
|
848 To get around this, I made all the CHECK_foo macros signal a
|
|
849 non-continuable error. Places where a continuable error is OK
|
|
850 (generally only when called directly on the argument of a Lisp
|
|
851 primitive) should be changed to use CONCHECK().
|
|
852
|
|
853 FSF Emacs does not have this problem because RMS took the cheesy
|
|
854 way out and disabled returning from a signal entirely. */
|
|
855
|
|
856 #define CONCHECK_RECORD(x, c_name) do { \
|
442
|
857 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
|
428
|
858 x = wrong_type_argument (Q##c_name##p, x); \
|
|
859 } while (0)
|
|
860 #define CONCHECK_NONRECORD(x, lisp_enum, predicate) do {\
|
|
861 if (XTYPE (x) != lisp_enum) \
|
|
862 x = wrong_type_argument (predicate, x); \
|
|
863 } while (0)
|
|
864 #define CHECK_RECORD(x, c_name) do { \
|
442
|
865 if (!RECORD_TYPEP (x, lrecord_type_##c_name)) \
|
428
|
866 dead_wrong_type_argument (Q##c_name##p, x); \
|
|
867 } while (0)
|
|
868 #define CHECK_NONRECORD(x, lisp_enum, predicate) do { \
|
|
869 if (XTYPE (x) != lisp_enum) \
|
|
870 dead_wrong_type_argument (predicate, x); \
|
|
871 } while (0)
|
|
872
|
665
|
873 void *alloc_lcrecord (Bytecount size,
|
647
|
874 const struct lrecord_implementation *);
|
428
|
875
|
771
|
876 void *alloc_automanaged_lcrecord (Bytecount size,
|
|
877 const struct lrecord_implementation *);
|
|
878
|
|
879 #define alloc_unmanaged_lcrecord_type(type, lrecord_implementation) \
|
|
880 ((type *) alloc_lcrecord (sizeof (type), lrecord_implementation))
|
|
881
|
428
|
882 #define alloc_lcrecord_type(type, lrecord_implementation) \
|
771
|
883 ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation))
|
|
884
|
|
885 void free_lcrecord (Lisp_Object rec);
|
|
886
|
428
|
887
|
|
888 /* Copy the data from one lcrecord structure into another, but don't
|
|
889 overwrite the header information. */
|
|
890
|
771
|
891 #define copy_sized_lcrecord(dst, src, size) \
|
430
|
892 memcpy ((char *) (dst) + sizeof (struct lcrecord_header), \
|
|
893 (char *) (src) + sizeof (struct lcrecord_header), \
|
771
|
894 (size) - sizeof (struct lcrecord_header))
|
|
895
|
|
896 #define copy_lcrecord(dst, src) copy_sized_lcrecord (dst, src, sizeof (*(dst)))
|
428
|
897
|
771
|
898 #define zero_sized_lcrecord(lcr, size) \
|
430
|
899 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \
|
771
|
900 (size) - sizeof (struct lcrecord_header))
|
|
901
|
|
902 #define zero_lcrecord(lcr) zero_sized_lcrecord(lcr, sizeof (*(lcr)))
|
428
|
903
|
440
|
904 #endif /* INCLUDED_lrecord_h_ */
|