comparison src/lrecord.h @ 3017:1e7cc382eb16

[xemacs-hg @ 2005-10-24 10:07:26 by ben] refactor mc-alloc dependencies next-error.el, occur.el: Fix some byte-compile warnings. alloc.c, buffer.c, buffer.h, casetab.c, casetab.h, charset.h, chartab.c, chartab.h, console-impl.h, console-msw-impl.h, console.c, data.c, database.c, device-impl.h, device-msw.c, device.c, dialog-msw.c, elhash.c, events.h, extents-impl.h, extents.c, faces.c, faces.h, file-coding.c, file-coding.h, frame-impl.h, frame.c, glyphs.c, glyphs.h, gui.c, gui.h, keymap.c, lisp.h, lrecord.h, lstream.c, lstream.h, mule-charset.c, objects-impl.h, objects.c, opaque.c, opaque.h, print.c, process.c, procimpl.h, rangetab.c, rangetab.h, scrollbar-gtk.c, scrollbar-msw.c, scrollbar-x.c, scrollbar.c, scrollbar.h, specifier.c, specifier.h, symbols.c, symeval.h, toolbar.c, toolbar.h, tooltalk.c, ui-gtk.c, ui-gtk.h, unicode.c, window-impl.h, window.c: Eliminate the majority of #ifdef MC_ALLOC occurrences through macros LCRECORD_HEADER, ALLOC_LCRECORD_TYPE, MALLOCED_STORAGE_SIZE, etc. (defined in lrecord.h).
author ben
date Mon, 24 Oct 2005 10:07:42 +0000
parents ec5f23ea6d2e
children b7f26b2f78bd
comparison
equal deleted inserted replaced
3016:f252275fb013 3017:1e7cc382eb16
1 /* The "lrecord" structure (header of a compound lisp object). 1 /* The "lrecord" structure (header of a compound lisp object).
2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc. 2 Copyright (C) 1993, 1994, 1995 Free Software Foundation, Inc.
3 Copyright (C) 1996, 2001, 2002, 2004 Ben Wing. 3 Copyright (C) 1996, 2001, 2002, 2004, 2005 Ben Wing.
4 4
5 This file is part of XEmacs. 5 This file is part of XEmacs.
6 6
7 XEmacs is free software; you can redistribute it and/or modify it 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 8 under the terms of the GNU General Public License as published by the
657 Lisp_Object value; 657 Lisp_Object value;
658 } htentry; 658 } htentry;
659 659
660 struct Lisp_Hash_Table 660 struct Lisp_Hash_Table
661 { 661 {
662 #ifdef MC_ALLOC 662 struct LCRECORD_HEADER header;
663 struct lrecord_header header;
664 #else
665 struct lcrecord_header header;
666 #endif
667 Elemcount size; 663 Elemcount size;
668 Elemcount count; 664 Elemcount count;
669 Elemcount rehash_count; 665 Elemcount rehash_count;
670 double rehash_size; 666 double rehash_size;
671 double rehash_threshold; 667 double rehash_threshold;
726 ... 722 ...
727 }; 723 };
728 724
729 struct Lisp_Specifier 725 struct Lisp_Specifier
730 { 726 {
731 #ifdef MC_ALLOC 727 struct LCRECORD_HEADER header;
732 struct lrecord_header header;
733 #else
734 struct lcrecord_header header;
735 #endif
736 struct specifier_methods *methods; 728 struct specifier_methods *methods;
737 729
738 ... 730 ...
739 // type-specific extra data attached to a specifier 731 // type-specific extra data attached to a specifier
740 max_align_t data[1]; 732 max_align_t data[1];
1204 /* Steps to create a new object: 1196 /* Steps to create a new object:
1205 1197
1206 1. Declare the struct for your object in a header file somewhere. 1198 1. Declare the struct for your object in a header file somewhere.
1207 Remember that it must begin with 1199 Remember that it must begin with
1208 1200
1209 #ifdef MC_ALLOC 1201 struct LCRECORD_HEADER header;
1210 struct lrecord_header header;
1211 #else
1212 struct lcrecord_header header;
1213 #endif
1214 1202
1215 2. Put the "standard junk" (DECLARE_RECORD()/XFOO/etc.) below the 1203 2. Put the "standard junk" (DECLARE_RECORD()/XFOO/etc.) below the
1216 struct definition -- see below. 1204 struct definition -- see below.
1217 1205
1218 3. Add this header file to inline.c. 1206 3. Add this header file to inline.c.
1242 1230
1243 ------------------------------ in toolbar.h ----------------------------- 1231 ------------------------------ in toolbar.h -----------------------------
1244 1232
1245 struct toolbar_button 1233 struct toolbar_button
1246 { 1234 {
1247 #ifdef MC_ALLOC 1235 struct LCRECORD_HEADER header;
1248 struct lrecord_header header;
1249 #else
1250 struct lcrecord_header header;
1251 #endif
1252 1236
1253 Lisp_Object next; 1237 Lisp_Object next;
1254 Lisp_Object frame; 1238 Lisp_Object frame;
1255 1239
1256 Lisp_Object up_glyph; 1240 Lisp_Object up_glyph;
1616 1600
1617 /* AUTO-MANAGED MODEL: */ 1601 /* AUTO-MANAGED MODEL: */
1618 MODULE_API void * 1602 MODULE_API void *
1619 alloc_automanaged_lcrecord (Bytecount size, 1603 alloc_automanaged_lcrecord (Bytecount size,
1620 const struct lrecord_implementation *); 1604 const struct lrecord_implementation *);
1605
1621 #define alloc_lcrecord_type(type, lrecord_implementation) \ 1606 #define alloc_lcrecord_type(type, lrecord_implementation) \
1622 ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation)) 1607 ((type *) alloc_automanaged_lcrecord (sizeof (type), lrecord_implementation))
1623 1608
1624 void free_lcrecord (Lisp_Object rec); 1609 void free_lcrecord (Lisp_Object rec);
1625 1610
1679 (char *) (src) + sizeof (struct lrecord_header), \ 1664 (char *) (src) + sizeof (struct lrecord_header), \
1680 (size) - sizeof (struct lrecord_header)) 1665 (size) - sizeof (struct lrecord_header))
1681 1666
1682 #define copy_lrecord(dst, src) copy_sized_lrecord (dst, src, sizeof (*(dst))) 1667 #define copy_lrecord(dst, src) copy_sized_lrecord (dst, src, sizeof (*(dst)))
1683 1668
1669 #endif /* MC_ALLOC */
1670
1684 #define zero_sized_lrecord(lcr, size) \ 1671 #define zero_sized_lrecord(lcr, size) \
1685 memset ((char *) (lcr) + sizeof (struct lrecord_header), 0, \ 1672 memset ((char *) (lcr) + sizeof (struct lrecord_header), 0, \
1686 (size) - sizeof (struct lrecord_header)) 1673 (size) - sizeof (struct lrecord_header))
1687 1674
1688 #define zero_lrecord(lcr) zero_sized_lrecord (lcr, sizeof (*(lcr))) 1675 #define zero_lrecord(lcr) zero_sized_lrecord (lcr, sizeof (*(lcr)))
1689
1690 #endif /* MC_ALLOC */
1691 1676
1692 DECLARE_INLINE_HEADER ( 1677 DECLARE_INLINE_HEADER (
1693 Bytecount 1678 Bytecount
1694 detagged_lisp_object_size (const struct lrecord_header *h) 1679 detagged_lisp_object_size (const struct lrecord_header *h)
1695 ) 1680 )
1706 lisp_object_size (Lisp_Object o) 1691 lisp_object_size (Lisp_Object o)
1707 ) 1692 )
1708 { 1693 {
1709 return detagged_lisp_object_size (XRECORD_LHEADER (o)); 1694 return detagged_lisp_object_size (XRECORD_LHEADER (o));
1710 } 1695 }
1696
1697 #ifdef MC_ALLOC
1698 #define ALLOC_LCRECORD_TYPE alloc_lrecord_type
1699 #define COPY_SIZED_LCRECORD copy_sized_lrecord
1700 #define COPY_LCRECORD copy_lrecord
1701 #define MALLOCED_STORAGE_SIZE(ptr, size, stats) \
1702 mc_alloced_storage_size (size, stats)
1703 #define ZERO_LCRECORD zero_lrecord
1704 #define LCRECORD_HEADER lrecord_header
1705 #define BASIC_ALLOC_LCRECORD alloc_lrecord
1706 #define FREE_LCRECORD free_lrecord
1707 #else
1708 #define ALLOC_LCRECORD_TYPE alloc_lcrecord_type
1709 #define COPY_SIZED_LCRECORD copy_sized_lcrecord
1710 #define COPY_LCRECORD copy_lcrecord
1711 #define MALLOCED_STORAGE_SIZE malloced_storage_size
1712 #define ZERO_LCRECORD zero_lcrecord
1713 #define LCRECORD_HEADER lcrecord_header
1714 #define BASIC_ALLOC_LCRECORD basic_alloc_lcrecord
1715 #define FREE_LCRECORD free_lcrecord
1716 #endif
1711 1717
1712 1718
1713 /************************************************************************/ 1719 /************************************************************************/
1714 /* Dumping */ 1720 /* Dumping */
1715 /************************************************************************/ 1721 /************************************************************************/