Mercurial > hg > xemacs-beta
comparison src/opaque.c @ 3263:d674024a8674
[xemacs-hg @ 2006-02-27 16:29:00 by crestani]
- Introduce a fancy asynchronous finalization strategy on C level.
- Merge the code conditioned on MC_ALLOC into the code conditioned on
NEW_GC.
- Remove the possibility to free objects manually outside garbage
collections when the new collector is enabled.
author | crestani |
---|---|
date | Mon, 27 Feb 2006 16:29:29 +0000 |
parents | 1e7cc382eb16 |
children | 6ef8256a020a e0db3c197671 |
comparison
equal
deleted
inserted
replaced
3262:79d41cfd8e6b | 3263:d674024a8674 |
---|---|
36 | 36 |
37 #include <config.h> | 37 #include <config.h> |
38 #include "lisp.h" | 38 #include "lisp.h" |
39 #include "opaque.h" | 39 #include "opaque.h" |
40 | 40 |
41 #ifndef MC_ALLOC | 41 #ifndef NEW_GC |
42 Lisp_Object Vopaque_ptr_free_list; | 42 Lisp_Object Vopaque_ptr_free_list; |
43 #endif /* not MC_ALLOC */ | 43 #endif /* not NEW_GC */ |
44 | 44 |
45 /* Should never, ever be called. (except by an external debugger) */ | 45 /* Should never, ever be called. (except by an external debugger) */ |
46 static void | 46 static void |
47 print_opaque (Lisp_Object obj, Lisp_Object printcharfun, | 47 print_opaque (Lisp_Object obj, Lisp_Object printcharfun, |
48 int UNUSED (escapeflag)) | 48 int UNUSED (escapeflag)) |
160 opaque_ptr_description, Lisp_Opaque_Ptr); | 160 opaque_ptr_description, Lisp_Opaque_Ptr); |
161 | 161 |
162 Lisp_Object | 162 Lisp_Object |
163 make_opaque_ptr (void *val) | 163 make_opaque_ptr (void *val) |
164 { | 164 { |
165 #ifdef MC_ALLOC | 165 #ifdef NEW_GC |
166 Lisp_Object res = | 166 Lisp_Object res = |
167 wrap_pointer_1 (alloc_lrecord_type (Lisp_Opaque_Ptr, | 167 wrap_pointer_1 (alloc_lrecord_type (Lisp_Opaque_Ptr, |
168 &lrecord_opaque_ptr)); | 168 &lrecord_opaque_ptr)); |
169 #else /* not MC_ALLOC */ | 169 #else /* not NEW_GC */ |
170 Lisp_Object res = alloc_managed_lcrecord (Vopaque_ptr_free_list); | 170 Lisp_Object res = alloc_managed_lcrecord (Vopaque_ptr_free_list); |
171 #endif /* not MC_ALLOC */ | 171 #endif /* not NEW_GC */ |
172 set_opaque_ptr (res, val); | 172 set_opaque_ptr (res, val); |
173 return res; | 173 return res; |
174 } | 174 } |
175 | 175 |
176 /* Be very very careful with this. Same admonitions as with | 176 /* Be very very careful with this. Same admonitions as with |
177 free_cons() apply. */ | 177 free_cons() apply. */ |
178 | 178 |
179 void | 179 void |
180 free_opaque_ptr (Lisp_Object ptr) | 180 free_opaque_ptr (Lisp_Object ptr) |
181 { | 181 { |
182 #ifdef MC_ALLOC | 182 #ifdef NEW_GC |
183 free_lrecord (ptr); | 183 free_lrecord (ptr); |
184 #else /* not MC_ALLOC */ | 184 #else /* not NEW_GC */ |
185 free_managed_lcrecord (Vopaque_ptr_free_list, ptr); | 185 free_managed_lcrecord (Vopaque_ptr_free_list, ptr); |
186 #endif /* not MC_ALLOC */ | 186 #endif /* not NEW_GC */ |
187 } | 187 } |
188 | 188 |
189 #ifndef MC_ALLOC | 189 #ifndef NEW_GC |
190 void | 190 void |
191 reinit_opaque_early (void) | 191 reinit_opaque_early (void) |
192 { | 192 { |
193 Vopaque_ptr_free_list = make_lcrecord_list (sizeof (Lisp_Opaque_Ptr), | 193 Vopaque_ptr_free_list = make_lcrecord_list (sizeof (Lisp_Opaque_Ptr), |
194 &lrecord_opaque_ptr); | 194 &lrecord_opaque_ptr); |
195 staticpro_nodump (&Vopaque_ptr_free_list); | 195 staticpro_nodump (&Vopaque_ptr_free_list); |
196 } | 196 } |
197 #endif /* not MC_ALLOC */ | 197 #endif /* not NEW_GC */ |
198 | 198 |
199 void | 199 void |
200 init_opaque_once_early (void) | 200 init_opaque_once_early (void) |
201 { | 201 { |
202 INIT_LRECORD_IMPLEMENTATION (opaque); | 202 INIT_LRECORD_IMPLEMENTATION (opaque); |
203 INIT_LRECORD_IMPLEMENTATION (opaque_ptr); | 203 INIT_LRECORD_IMPLEMENTATION (opaque_ptr); |
204 | 204 |
205 #ifndef MC_ALLOC | 205 #ifndef NEW_GC |
206 reinit_opaque_early (); | 206 reinit_opaque_early (); |
207 #endif /* not MC_ALLOC */ | 207 #endif /* not NEW_GC */ |
208 } | 208 } |