comparison src/marker.c @ 5178:97eb4942aec8

merge
author Ben Wing <ben@xemacs.org>
date Mon, 29 Mar 2010 21:28:13 -0500
parents 5ddbab03b0e6
children 71ee43b8a74d
comparison
equal deleted inserted replaced
5177:b785049378e3 5178:97eb4942aec8
1 /* Markers: examining, setting and killing. 1 /* Markers: examining, setting and killing.
2 Copyright (C) 1985, 1992, 1993, 1994, 1995 Free Software Foundation, Inc. 2 Copyright (C) 1985, 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
3 Copyright (C) 2002 Ben Wing. 3 Copyright (C) 2002, 2010 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
58 int UNUSED (escapeflag)) 58 int UNUSED (escapeflag))
59 { 59 {
60 Lisp_Marker *marker = XMARKER (obj); 60 Lisp_Marker *marker = XMARKER (obj);
61 61
62 if (print_readably) 62 if (print_readably)
63 printing_unreadable_object ("#<marker 0x%lx>", (long) marker); 63 printing_unreadable_object_fmt ("#<marker 0x%x>", LISP_OBJECT_UID (obj));
64 64
65 write_ascstring (printcharfun, GETTEXT ("#<marker ")); 65 write_ascstring (printcharfun, GETTEXT ("#<marker "));
66 if (!marker->buffer) 66 if (!marker->buffer)
67 write_ascstring (printcharfun, GETTEXT ("in no buffer")); 67 write_ascstring (printcharfun, GETTEXT ("in no buffer"));
68 else 68 else
71 (long) marker_position (obj)); 71 (long) marker_position (obj));
72 print_internal (marker->buffer->name, printcharfun, 0); 72 print_internal (marker->buffer->name, printcharfun, 0);
73 } 73 }
74 if (marker->insertion_type) 74 if (marker->insertion_type)
75 write_ascstring (printcharfun, " insertion-type=t"); 75 write_ascstring (printcharfun, " insertion-type=t");
76 write_fmt_string (printcharfun, " 0x%lx>", (long) marker); 76 write_fmt_string (printcharfun, " 0x%x>", LISP_OBJECT_UID (obj));
77 } 77 }
78 78
79 static int 79 static int
80 marker_equal (Lisp_Object obj1, Lisp_Object obj2, int UNUSED (depth), 80 marker_equal (Lisp_Object obj1, Lisp_Object obj2, int UNUSED (depth),
81 int UNUSED (foldcase)) 81 int UNUSED (foldcase))
105 { XD_END } 105 { XD_END }
106 }; 106 };
107 107
108 #ifdef NEW_GC 108 #ifdef NEW_GC
109 static void 109 static void
110 finalize_marker (void *header, int for_disksave) 110 finalize_marker (Lisp_Object obj)
111 { 111 {
112 if (!for_disksave) 112 unchain_marker (obj);
113 { 113 }
114 Lisp_Object tem = wrap_marker (header); 114 #endif /* NEW_GC */
115 unchain_marker (tem); 115
116 } 116 DEFINE_DUMPABLE_FROB_BLOCK_LISP_OBJECT ("marker", marker,
117 } 117 mark_marker, print_marker,
118 118 IF_NEW_GC (finalize_marker),
119 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("marker", marker, 119 marker_equal, marker_hash,
120 1, /*dumpable-flag*/ 120 marker_description, Lisp_Marker);
121 mark_marker, print_marker,
122 finalize_marker,
123 marker_equal, marker_hash,
124 marker_description, Lisp_Marker);
125 #else /* not NEW_GC */
126 DEFINE_BASIC_LRECORD_IMPLEMENTATION ("marker", marker,
127 1, /*dumpable-flag*/
128 mark_marker, print_marker, 0,
129 marker_equal, marker_hash,
130 marker_description, Lisp_Marker);
131 #endif /* not NEW_GC */
132 121
133 /* Operations on markers. */ 122 /* Operations on markers. */
134 123
135 DEFUN ("marker-buffer", Fmarker_buffer, 1, 1, 0, /* 124 DEFUN ("marker-buffer", Fmarker_buffer, 1, 1, 0, /*
136 Return the buffer that MARKER points into, or nil if none. 125 Return the buffer that MARKER points into, or nil if none.
501 } 490 }
502 #endif /* 0 */ 491 #endif /* 0 */
503 492
504 #ifdef MEMORY_USAGE_STATS 493 #ifdef MEMORY_USAGE_STATS
505 494
506 int 495 Bytecount
507 compute_buffer_marker_usage (struct buffer *b, struct overhead_stats *ovstats) 496 compute_buffer_marker_usage (struct buffer *b)
508 { 497 {
509 Lisp_Marker *m; 498 Lisp_Marker *m;
510 int total = 0; 499 Bytecount total = 0;
511 int overhead;
512 500
513 for (m = BUF_MARKERS (b); m; m = m->next) 501 for (m = BUF_MARKERS (b); m; m = m->next)
514 total += sizeof (Lisp_Marker); 502 total += lisp_object_memory_usage (wrap_marker (m));
515 ovstats->was_requested += total; 503 return total;
516 #ifdef NEW_GC
517 overhead = mc_alloced_storage_size (total, 0);
518 #else /* not NEW_GC */
519 overhead = fixed_type_block_overhead (total);
520 #endif /* not NEW_GC */
521 /* #### claiming this is all malloc overhead is not really right,
522 but it has to go somewhere. */
523 ovstats->malloc_overhead += overhead;
524 return total + overhead;
525 } 504 }
526 505
527 #endif /* MEMORY_USAGE_STATS */ 506 #endif /* MEMORY_USAGE_STATS */
528 507
529 508
530 void 509 void
531 syms_of_marker (void) 510 syms_of_marker (void)
532 { 511 {
533 INIT_LRECORD_IMPLEMENTATION (marker); 512 INIT_LISP_OBJECT (marker);
534 513
535 DEFSUBR (Fmarker_position); 514 DEFSUBR (Fmarker_position);
536 DEFSUBR (Fmarker_buffer); 515 DEFSUBR (Fmarker_buffer);
537 DEFSUBR (Fset_marker); 516 DEFSUBR (Fset_marker);
538 DEFSUBR (Fcopy_marker); 517 DEFSUBR (Fcopy_marker);