Mercurial > hg > xemacs-beta
annotate src/mc-alloc.h @ 5486:58e320bde005
Handle redisplay edge case.
With motion events when entering a frame and the minibuffer is
active, row and column can be zero, and there aren't any runes.
| author | Mike Kupfer <mike.kupfer@xemacs.org> |
|---|---|
| date | Sat, 30 Apr 2011 13:30:47 +0900 |
| parents | 308d34e9f07d |
| children |
| rev | line source |
|---|---|
| 2720 | 1 /* New allocator for XEmacs. |
| 2 Copyright (C) 2005 Marcus Crestani. | |
|
5167
e374ea766cc1
clean up, rearrange allocation statistics code
Ben Wing <ben@xemacs.org>
parents:
5157
diff
changeset
|
3 Copyright (C) 2010 Ben Wing. |
| 2720 | 4 |
| 5 This file is part of XEmacs. | |
| 6 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5167
diff
changeset
|
7 XEmacs is free software: you can redistribute it and/or modify it |
| 2720 | 8 under the terms of the GNU General Public License as published by the |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5167
diff
changeset
|
9 Free Software Foundation, either version 3 of the License, or (at your |
|
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5167
diff
changeset
|
10 option) any later version. |
| 2720 | 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 | |
|
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5167
diff
changeset
|
18 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
| 2720 | 19 |
| 20 /* Synched up with: Not in FSF. */ | |
| 21 | |
| 22 #ifndef INCLUDED_mc_alloc_h_ | |
| 23 #define INCLUDED_mc_alloc_h_ | |
| 24 | |
| 25 /*--- prototypes -------------------------------------------------------*/ | |
| 26 | |
| 27 BEGIN_C_DECLS | |
| 28 | |
| 3305 | 29 /* Set to 1 if memory becomes short. */ |
| 30 extern EMACS_INT memory_shortage; | |
| 2720 | 31 |
| 32 | |
| 3092 | 33 /* Internal Allocator Functions: */ |
| 2720 | 34 |
| 3092 | 35 /* Initialize the allocator. This has to be called prior to |
| 36 requesting memory. */ | |
| 2720 | 37 void init_mc_allocator (void); |
| 38 | |
| 3092 | 39 /* Allocate a block of memory of given size and return the pointer to |
| 40 it. */ | |
| 2720 | 41 void *mc_alloc (size_t size); |
| 42 | |
| 3092 | 43 /* Allocate a block of memory as an array with elemcount elements of |
| 44 given size and return the pointer to it. Arrays contain several | |
| 45 objects that are allocated in one consecutive block of memory with | |
| 46 each element being a fully qualified object---that is, it has a | |
| 47 Lisp object header and a mark bit. Objects like hash tables and | |
| 48 dynamic arrays use this function. */ | |
| 49 void *mc_alloc_array (size_t size, EMACS_INT elemcount); | |
| 50 | |
| 51 /* Modify the size of the memory block pointed to by ptr. Return the | |
| 52 address of the new block of given size. The content of the memory | |
| 53 block will be unchanged to the minimum of the old and new sizes: if | |
| 54 the new size is smaller, the overlaying data is cut off; if the new | |
| 55 size is bigger, the newly allocated memory will be uninitialized.*/ | |
| 2720 | 56 void *mc_realloc (void *ptr, size_t size); |
| 57 | |
| 3092 | 58 /* Modify the size of the array pointed to by ptr. Return the address |
| 59 of the new array block with elemcount elements of given size. The | |
| 60 content of the memory block will be unchanged to the minimum of the | |
| 61 old and new sizes: if the new size is smaller, the overlaying data | |
| 62 is cut off; if the new size is bigger, the newly allocated memory | |
| 63 will be uninitialized.*/ | |
| 64 void *mc_realloc_array (void *ptr, size_t size, EMACS_INT elemcount); | |
| 65 | |
| 2720 | 66 |
| 67 | |
| 68 /* Garbage collection related functions and macros: */ | |
| 69 | |
| 3092 | 70 enum mark_bit_colors |
| 71 { | |
| 72 WHITE = 0, | |
| 73 BLACK = 1, | |
| 74 GREY = 2 | |
| 75 }; | |
| 76 | |
| 77 /* Set the mark bit of the object pointed to by ptr to value.*/ | |
| 78 void set_mark_bit (void *ptr, EMACS_INT value); | |
| 79 | |
| 80 /* Return the mark bit of the object pointed to by ptr. */ | |
| 81 EMACS_INT get_mark_bit (void *ptr); | |
| 82 | |
| 83 /* mark bit macros */ | |
| 84 /* Returns true if the mark bit of the object pointed to by ptr is set. */ | |
| 85 #define MARKED_P(ptr) (get_mark_bit (ptr) != WHITE) | |
| 86 | |
| 87 /* Marks the object pointed to by ptr (sets the mark bit to 1). */ | |
| 88 #define MARK(ptr) set_mark_bit (ptr, BLACK) | |
| 89 | |
| 90 /* Unmarks the object pointed to by ptr (sets the mark bit to 0). */ | |
| 91 #define UNMARK(ptr) set_mark_bit (ptr, WHITE) | |
| 92 | |
| 93 #define MARK_WHITE(ptr) set_mark_bit (ptr, WHITE) | |
| 94 #define MARK_GREY(ptr) set_mark_bit (ptr, GREY) | |
| 95 #define MARK_BLACK(ptr) set_mark_bit (ptr, BLACK) | |
| 96 | |
| 97 #define MARKED_WHITE_P(ptr) (get_mark_bit (ptr) == WHITE) | |
| 98 #define MARKED_GREY_P(ptr) (get_mark_bit (ptr) == GREY) | |
| 99 #define MARKED_BLACK_P(ptr) (get_mark_bit (ptr) == BLACK) | |
| 2720 | 100 |
| 3092 | 101 /* The finalizer of every not marked object is called. The macro |
| 2720 | 102 MC_ALLOC_CALL_FINALIZER has to be defined and call the finalizer of |
| 3303 | 103 the object. Returns number of processed pages. */ |
| 104 EMACS_INT mc_finalize (void); | |
| 2720 | 105 |
| 3303 | 106 /* All not marked objects of the used heap are freed. Returns number |
| 107 of processed pages. */ | |
| 108 EMACS_INT mc_sweep (void); | |
| 2720 | 109 |
| 110 | |
| 111 | |
| 112 /* Portable dumper related functions and macros: */ | |
| 113 | |
| 114 /* The finalizer for disksave of every object is called to shrink the | |
| 3092 | 115 dump image. The macro MC_ALLOC_CALL_FINALIZER_FOR_DISKSAVE has to |
| 3303 | 116 be defined and call the finalizer for disksave of the object. |
| 117 Returns number of processed pages. */ | |
| 118 EMACS_INT mc_finalize_for_disksave (void); | |
| 2720 | 119 |
| 120 | |
| 121 | |
| 122 /* Functions and macros related with allocation statistics: */ | |
| 123 | |
| 124 /* Returns the real size, including overhead, which is actually alloced | |
| 125 for an object with given claimed_size. */ | |
| 126 Bytecount mc_alloced_storage_size (Bytecount claimed_size, | |
|
5157
1fae11d56ad2
redo memory-usage mechanism, add way of dynamically initializing Lisp objects
Ben Wing <ben@xemacs.org>
parents:
4117
diff
changeset
|
127 struct usage_stats *stats); |
| 2720 | 128 |
| 3092 | 129 |
| 130 /* Incremental Garbage Collector / Write Barrier Support: */ | |
| 131 | |
| 132 /* Return the PAGESIZE the allocator uses. Generally equals to the | |
| 133 system's PAGESIZE. */ | |
| 134 EMACS_INT mc_get_page_size (void); | |
| 135 | |
| 136 /* Is the fault at ptr on a protected page? */ | |
| 137 EMACS_INT fault_on_protected_page (void *ptr); | |
| 138 | |
| 3303 | 139 /* Remove protection (if there) of heap page of given page header ph. |
| 140 Returns number of processed pages. */ | |
| 141 EMACS_INT protect_heap_pages (void); | |
| 3092 | 142 |
| 3303 | 143 /* Remove protection for all heap pages which are protected. Returns |
| 144 number of processed pages. */ | |
| 145 EMACS_INT unprotect_heap_pages (void); | |
| 3092 | 146 |
| 147 /* Remove protection and mark page dirty. */ | |
| 148 void unprotect_page_and_mark_dirty (void *ptr); | |
| 149 | |
| 150 /* Repush all objects on dirty pages onto the mark stack. Return | |
| 151 number of repushed objects. */ | |
| 152 int repush_all_objects_on_page (void *ptr); | |
| 153 | |
| 154 /* Mark black if object is currently grey. */ | |
| 155 EMACS_INT maybe_mark_black (void *ptr); | |
| 156 | |
| 157 /* Only for debugging---not used anywhere in the sources. */ | |
| 158 EMACS_INT object_on_heap_p (void *ptr); | |
| 159 | |
| 2720 | 160 END_C_DECLS |
| 161 | |
| 162 #endif /* INCLUDED_mc_alloc_h_ */ |
