Mercurial > hg > xemacs-beta
comparison src/lrecord.h @ 2551:9f70af3ac939
[xemacs-hg @ 2005-02-03 16:14:02 by james]
Commit Olivier Galibert's dumper updates for bignums and use them.
See xemacs-patches message with ID <ps8y685c6p.fsf@diannao.ittc.ku.edu>.
author | james |
---|---|
date | Thu, 03 Feb 2005 16:14:08 +0000 |
parents | de9952d2ed18 |
children | 6fa9919a9a0b |
comparison
equal
deleted
inserted
replaced
2550:317f30471f4e | 2551:9f70af3ac939 |
---|---|
503 | 503 |
504 static const struct memory_description foo_description[] = { | 504 static const struct memory_description foo_description[] = { |
505 ... | 505 ... |
506 { XD_INT, offsetof (Lisp_Foo, count) }, | 506 { XD_INT, offsetof (Lisp_Foo, count) }, |
507 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects), | 507 { XD_BLOCK_PTR, offsetof (Lisp_Foo, objects), |
508 XD_INDIRECT (0, 0), &lisp_object_description }, | 508 XD_INDIRECT (0, 0), { &lisp_object_description } }, |
509 ... | 509 ... |
510 }; | 510 }; |
511 | 511 |
512 lisp_object_description is declared in alloc.c, like this: | 512 lisp_object_description is declared in alloc.c, like this: |
513 | 513 |
558 }; | 558 }; |
559 | 559 |
560 const struct memory_description hash_table_description[] = { | 560 const struct memory_description hash_table_description[] = { |
561 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) }, | 561 { XD_ELEMCOUNT, offsetof (Lisp_Hash_Table, size) }, |
562 { XD_BLOCK_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT (0, 1), | 562 { XD_BLOCK_PTR, offsetof (Lisp_Hash_Table, hentries), XD_INDIRECT (0, 1), |
563 &htentry_description }, | 563 { &htentry_description } }, |
564 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) }, | 564 { XD_LO_LINK, offsetof (Lisp_Hash_Table, next_weak) }, |
565 { XD_END } | 565 { XD_END } |
566 }; | 566 }; |
567 | 567 |
568 Note that we don't need to declare all the elements in the structure, just | 568 Note that we don't need to declare all the elements in the structure, just |
578 }; | 578 }; |
579 | 579 |
580 const struct memory_description specifier_description[] = { | 580 const struct memory_description specifier_description[] = { |
581 ... | 581 ... |
582 { XD_BLOCK_ARRAY, offset (Lisp_Specifier, data), 1, | 582 { XD_BLOCK_ARRAY, offset (Lisp_Specifier, data), 1, |
583 specifier_extra_description_map }, | 583 { specifier_extra_description_map } }, |
584 ... | 584 ... |
585 { XD_END } | 585 { XD_END } |
586 }; | 586 }; |
587 | 587 |
588 This would be appropriate for an object that looks like this: | 588 This would be appropriate for an object that looks like this: |
645 object. | 645 object. |
646 | 646 |
647 XD_OPAQUE_PTR | 647 XD_OPAQUE_PTR |
648 | 648 |
649 Pointer to undumpable data. Must be NULL when dumping. | 649 Pointer to undumpable data. Must be NULL when dumping. |
650 | |
651 XD_OPAQUE_PTR_CONVERTIBLE | |
652 | |
653 Pointer to data which is not directly dumpable but can be converted | |
654 to a dumpable, opaque external representation. The parameter is | |
655 a pointer to an opaque_convert_functions struct. | |
656 | |
657 XD_OPAQUE_DATA_CONVERTIBLE | |
658 | |
659 Data which is not directly dumpable but can be converted to a | |
660 dumpable, opaque external representation. The parameter is a | |
661 pointer to an opaque_convert_functions struct. | |
650 | 662 |
651 XD_BLOCK_PTR | 663 XD_BLOCK_PTR |
652 | 664 |
653 Pointer to block of described memory. (This is misnamed: It is NOT | 665 Pointer to block of described memory. (This is misnamed: It is NOT |
654 necessarily a pointer to a struct foo.) Parameters are number of | 666 necessarily a pointer to a struct foo.) Parameters are number of |
784 { | 796 { |
785 XD_LISP_OBJECT_ARRAY, | 797 XD_LISP_OBJECT_ARRAY, |
786 XD_LISP_OBJECT, | 798 XD_LISP_OBJECT, |
787 XD_LO_LINK, | 799 XD_LO_LINK, |
788 XD_OPAQUE_PTR, | 800 XD_OPAQUE_PTR, |
801 XD_OPAQUE_PTR_CONVERTIBLE, | |
802 XD_OPAQUE_DATA_CONVERTIBLE, | |
803 XD_OPAQUE_DATA_PTR, | |
789 XD_BLOCK_PTR, | 804 XD_BLOCK_PTR, |
790 XD_BLOCK_ARRAY, | 805 XD_BLOCK_ARRAY, |
791 XD_OPAQUE_DATA_PTR, | |
792 XD_UNION, | 806 XD_UNION, |
793 XD_UNION_DYNAMIC_SIZE, | 807 XD_UNION_DYNAMIC_SIZE, |
794 XD_ASCII_STRING, | 808 XD_ASCII_STRING, |
795 XD_DOC_STRING, | 809 XD_DOC_STRING, |
796 XD_INT_RESET, | 810 XD_INT_RESET, |
845 or <0). */ | 859 or <0). */ |
846 XD_FLAG_DESCRIPTION_MAP = 32 | 860 XD_FLAG_DESCRIPTION_MAP = 32 |
847 #endif | 861 #endif |
848 }; | 862 }; |
849 | 863 |
864 union memory_contents_description | |
865 { | |
866 /* The first element is used by static initializers only. We always read | |
867 from one of the other two pointers. */ | |
868 const void *write_only; | |
869 const struct sized_memory_description *descr; | |
870 const struct opaque_convert_functions *funcs; | |
871 }; | |
872 | |
850 struct memory_description | 873 struct memory_description |
851 { | 874 { |
852 enum memory_description_type type; | 875 enum memory_description_type type; |
853 Bytecount offset; | 876 Bytecount offset; |
854 EMACS_INT data1; | 877 EMACS_INT data1; |
855 const struct sized_memory_description *data2; | 878 union memory_contents_description data2; |
856 /* Indicates which subsystems process this entry, plus (potentially) other | 879 /* Indicates which subsystems process this entry, plus (potentially) other |
857 flags that apply to this entry. */ | 880 flags that apply to this entry. */ |
858 int flags; | 881 int flags; |
859 }; | 882 }; |
860 | 883 |
862 { | 885 { |
863 Bytecount size; | 886 Bytecount size; |
864 const struct memory_description *description; | 887 const struct memory_description *description; |
865 }; | 888 }; |
866 | 889 |
890 | |
891 struct opaque_convert_functions | |
892 { | |
893 /* Used by XD_OPAQUE_PTR_CONVERTIBLE and | |
894 XD_OPAQUE_DATA_CONVERTIBLE */ | |
895 | |
896 /* Converter to external representation, for those objects from | |
897 external libraries that can't be directly dumped as opaque data | |
898 because they contain pointers. This is called at dump time to | |
899 convert to an opaque, pointer-less representation. | |
900 | |
901 This function must put a pointer to the opaque result in *data | |
902 and its size in *size. */ | |
903 void (*convert)(const void *object, void **data, Bytecount *size); | |
904 | |
905 /* Post-conversion cleanup. Optional (null if not provided). | |
906 | |
907 When provided it will be called post-dumping to free any storage | |
908 allocated for the conversion results. */ | |
909 void (*convert_free)(const void *object, void *data, Bytecount size); | |
910 | |
911 /* De-conversion. | |
912 | |
913 At reload time, rebuilds the object from the converted form. | |
914 "object" is 0 for the PTR case, return is ignored in the DATA | |
915 case. */ | |
916 void *(*deconvert)(void *object, void *data, Bytecount size); | |
917 | |
918 }; | |
919 | |
867 extern const struct sized_memory_description lisp_object_description; | 920 extern const struct sized_memory_description lisp_object_description; |
868 | 921 |
869 #define XD_INDIRECT(val, delta) (-1 - (Bytecount) ((val) | ((delta) << 8))) | 922 #define XD_INDIRECT(val, delta) (-1 - (Bytecount) ((val) | ((delta) << 8))) |
870 | 923 |
871 #define XD_IS_INDIRECT(code) ((code) < 0) | 924 #define XD_IS_INDIRECT(code) ((code) < 0) |
872 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) | 925 #define XD_INDIRECT_VAL(code) ((-1 - (code)) & 255) |
873 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) | 926 #define XD_INDIRECT_DELTA(code) ((-1 - (code)) >> 8) |
874 | 927 |
875 #define XD_DYNARR_DESC(base_type, sub_desc) \ | 928 #define XD_DYNARR_DESC(base_type, sub_desc) \ |
876 { XD_BLOCK_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), sub_desc }, \ | 929 { XD_BLOCK_PTR, offsetof (base_type, base), XD_INDIRECT(1, 0), {sub_desc} },\ |
877 { XD_INT, offsetof (base_type, cur) }, \ | 930 { XD_INT, offsetof (base_type, cur) }, \ |
878 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } \ | 931 { XD_INT_RESET, offsetof (base_type, max), XD_INDIRECT(1, 0) } \ |
879 | |
880 | 932 |
881 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size. | 933 /* DEFINE_LRECORD_IMPLEMENTATION is for objects with constant size. |
882 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies. | 934 DEFINE_LRECORD_SEQUENCE_IMPLEMENTATION is for objects whose size varies. |
883 */ | 935 */ |
884 | 936 |
1603 { | 1655 { |
1604 int count = 0; | 1656 int count = 0; |
1605 EMACS_INT variant = lispdesc_indirect_count (desc1->data1, desc, | 1657 EMACS_INT variant = lispdesc_indirect_count (desc1->data1, desc, |
1606 data); | 1658 data); |
1607 desc1 = | 1659 desc1 = |
1608 lispdesc_indirect_description (data, desc1->data2)->description; | 1660 lispdesc_indirect_description (data, desc1->data2.descr)->description; |
1609 | 1661 |
1610 for (count = 0; desc1[count].type != XD_END; count++) | 1662 for (count = 0; desc1[count].type != XD_END; count++) |
1611 { | 1663 { |
1612 if ((desc1[count].flags & XD_FLAG_UNION_DEFAULT_ENTRY) || | 1664 if ((desc1[count].flags & XD_FLAG_UNION_DEFAULT_ENTRY) || |
1613 desc1[count].offset == variant) | 1665 desc1[count].offset == variant) |