comparison src/lrecord.h @ 440:8de8e3f6228a r21-2-28

Import from CVS: tag r21-2-28
author cvs
date Mon, 13 Aug 2007 11:33:38 +0200
parents 3a7e78e1142d
children abe6d1db359e
comparison
equal deleted inserted replaced
439:357dd071b03c 440:8de8e3f6228a
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */ 20 Boston, MA 02111-1307, USA. */
21 21
22 /* Synched up with: Not in FSF. */ 22 /* Synched up with: Not in FSF. */
23 23
24 #ifndef _XEMACS_LRECORD_H_ 24 #ifndef INCLUDED_lrecord_h_
25 #define _XEMACS_LRECORD_H_ 25 #define INCLUDED_lrecord_h_
26 26
27 /* The "lrecord" type of Lisp object is used for all object types 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 28 other than a few simple ones. This allows many types to be
29 implemented but only a few bits required in a Lisp object for 29 implemented but only a few bits required in a Lisp object for
30 type information. (The tradeoff is that each object has its 30 type information. (The tradeoff is that each object has its
208 and number is type-dependant. 208 and number is type-dependant.
209 209
210 The description ends with a "XD_END" or "XD_SPECIFIER_END" record. 210 The description ends with a "XD_END" or "XD_SPECIFIER_END" record.
211 211
212 Some example descriptions : 212 Some example descriptions :
213
213 static const struct lrecord_description cons_description[] = { 214 static const struct lrecord_description cons_description[] = {
214 { XD_LISP_OBJECT, offsetof(struct Lisp_Cons, car), 2 }, 215 { XD_LISP_OBJECT, offsetof (Lisp_Cons, car) },
216 { XD_LISP_OBJECT, offsetof (Lisp_Cons, cdr) },
215 { XD_END } 217 { XD_END }
216 }; 218 };
217 219
218 Which means "two lisp objects starting at the 'car' element" 220 Which means "two lisp objects starting at the 'car' and 'cdr' elements"
219 221
220 static const struct lrecord_description string_description[] = { 222 static const struct lrecord_description string_description[] = {
221 { XD_BYTECOUNT, offsetof(Lisp_String, size) }, 223 { XD_BYTECOUNT, offsetof (Lisp_String, size) },
222 { XD_OPAQUE_DATA_PTR, offsetof(Lisp_String, data), XD_INDIRECT(0, 1) }, 224 { XD_OPAQUE_DATA_PTR, offsetof (Lisp_String, data), XD_INDIRECT(0, 1) },
223 { XD_LISP_OBJECT, offsetof(Lisp_String, plist), 1 }, 225 { XD_LISP_OBJECT, offsetof (Lisp_String, plist) },
224 { XD_END } 226 { XD_END }
225 }; 227 };
226 "A pointer to string data at 'data', the size of the pointed array being the value 228 "A pointer to string data at 'data', the size of the pointed array being the value
227 of the size variable plus 1, and one lisp object at 'plist'" 229 of the size variable plus 1, and one lisp object at 'plist'"
228 230
229 The existing types : 231 The existing types :
230 XD_LISP_OBJECT 232 XD_LISP_OBJECT
231 Lisp objects. The third element is the count. This is also the type to use 233 A Lisp object. This is also the type to use for pointers to other lrecords.
232 for pointers to other lrecords. 234
233 235 XD_LISP_OBJECT_ARRAY
234 XD_LO_RESET_NIL 236 An array of Lisp objects or pointers to lrecords.
237 The third element is the count.
238
239 XD_LO_RESET_NIL
235 Lisp objects which will be reset to Qnil when dumping. Useful for cleaning 240 Lisp objects which will be reset to Qnil when dumping. Useful for cleaning
236 up caches. 241 up caches.
237 242
238 XD_LO_LINK 243 XD_LO_LINK
239 Link in a linked list of objects of the same type. 244 Link in a linked list of objects of the same type.
285 the element which is at line number 'line' in the description (count 290 the element which is at line number 'line' in the description (count
286 starts at zero) and adds delta to it. 291 starts at zero) and adds delta to it.
287 */ 292 */
288 293
289 enum lrecord_description_type { 294 enum lrecord_description_type {
295 XD_LISP_OBJECT_ARRAY,
290 XD_LISP_OBJECT, 296 XD_LISP_OBJECT,
291 XD_LO_RESET_NIL, 297 XD_LO_RESET_NIL,
292 XD_LO_LINK, 298 XD_LO_LINK,
293 XD_OPAQUE_PTR, 299 XD_OPAQUE_PTR,
294 XD_STRUCT_PTR, 300 XD_STRUCT_PTR,
321 #define XD_IS_INDIRECT(code) (code<0) 327 #define XD_IS_INDIRECT(code) (code<0)
322 #define XD_INDIRECT_VAL(code) ((-1-code) & 255) 328 #define XD_INDIRECT_VAL(code) ((-1-code) & 255)
323 #define XD_INDIRECT_DELTA(code) (((-1-code)>>8) & 255) 329 #define XD_INDIRECT_DELTA(code) (((-1-code)>>8) & 255)
324 330
325 #define XD_DYNARR_DESC(base_type, sub_desc) \ 331 #define XD_DYNARR_DESC(base_type, sub_desc) \
326 { XD_STRUCT_PTR, offsetof(base_type, base), XD_INDIRECT(1, 0), sub_desc }, \ 332 { XD_STRUCT_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \
327 { XD_INT, offsetof(base_type, cur) }, \ 333 { XD_INT, offsetof (base_type, cur) }, \
328 { XD_INT_RESET, offsetof(base_type, max), XD_INDIRECT(1, 0) } 334 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) }
329 335
330 /* Declaring the following structures as const puts them in the 336 /* Declaring the following structures as const puts them in the
331 text (read-only) segment, which makes debugging inconvenient 337 text (read-only) segment, which makes debugging inconvenient
332 because this segment is not mapped when processing a core- 338 because this segment is not mapped when processing a core-
333 dump file */ 339 dump file */
495 501
496 #define zero_lcrecord(lcr) \ 502 #define zero_lcrecord(lcr) \
497 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \ 503 memset ((char *) (lcr) + sizeof (struct lcrecord_header), 0, \
498 sizeof (*(lcr)) - sizeof (struct lcrecord_header)) 504 sizeof (*(lcr)) - sizeof (struct lcrecord_header))
499 505
500 #endif /* _XEMACS_LRECORD_H_ */ 506 #endif /* INCLUDED_lrecord_h_ */