Mercurial > hg > xemacs-beta
comparison src/lstream.c @ 5118:e0db3c197671 ben-lisp-object
merge up to latest default branch, doesn't compile yet
author | Ben Wing <ben@xemacs.org> |
---|---|
date | Sat, 26 Dec 2009 21:18:49 -0600 |
parents | 3742ea8250b5 d674024a8674 |
children | 623d57b7fbe8 |
comparison
equal
deleted
inserted
replaced
5117:3742ea8250b5 | 5118:e0db3c197671 |
---|---|
148 | 148 |
149 const struct sized_memory_description lstream_empty_extra_description = { | 149 const struct sized_memory_description lstream_empty_extra_description = { |
150 0, lstream_empty_extra_description_1 | 150 0, lstream_empty_extra_description_1 |
151 }; | 151 }; |
152 | 152 |
153 DEFINE_NONDUMPABLE_SIZABLE_LISP_OBJECT ("stream", lstream, | 153 DEFINE_NODUMP_SIZABLE_LISP_OBJECT ("stream", lstream, |
154 mark_lstream, print_lstream, | 154 mark_lstream, print_lstream, |
155 finalize_lstream, 0, 0, | 155 finalize_lstream, 0, 0, |
156 lstream_description, | 156 lstream_description, |
157 sizeof_lstream, Lstream); | 157 sizeof_lstream, Lstream); |
158 | 158 |
177 case LSTREAM_UNLIMITED: | 177 case LSTREAM_UNLIMITED: |
178 lstr->buffering_size = INT_MAX; break; | 178 lstr->buffering_size = INT_MAX; break; |
179 } | 179 } |
180 } | 180 } |
181 | 181 |
182 #ifndef MC_ALLOC | 182 #ifndef NEW_GC |
183 static const Lstream_implementation *lstream_types[32]; | 183 static const Lstream_implementation *lstream_types[32]; |
184 static Lisp_Object Vlstream_free_list[32]; | 184 static Lisp_Object Vlstream_free_list[32]; |
185 static int lstream_type_count; | 185 static int lstream_type_count; |
186 #endif /* not MC_ALLOC */ | 186 #endif /* not NEW_GC */ |
187 | 187 |
188 /* Allocate and return a new Lstream. This function is not really | 188 /* Allocate and return a new Lstream. This function is not really |
189 meant to be called directly; rather, each stream type should | 189 meant to be called directly; rather, each stream type should |
190 provide its own stream creation function, which creates the stream | 190 provide its own stream creation function, which creates the stream |
191 and does any other necessary creation stuff (e.g. opening a | 191 and does any other necessary creation stuff (e.g. opening a |
193 | 193 |
194 Lstream * | 194 Lstream * |
195 Lstream_new (const Lstream_implementation *imp, const char *mode) | 195 Lstream_new (const Lstream_implementation *imp, const char *mode) |
196 { | 196 { |
197 Lstream *p; | 197 Lstream *p; |
198 #ifdef MC_ALLOC | 198 #ifdef NEW_GC |
199 p = XLSTREAM (alloc_sized_lrecord (aligned_sizeof_lstream (imp->size), | 199 p = XLSTREAM (alloc_sized_lrecord (aligned_sizeof_lstream (imp->size), |
200 &lrecord_lstream)); | 200 &lrecord_lstream)); |
201 #else /* not MC_ALLOC */ | 201 #else /* not NEW_GC */ |
202 int i; | 202 int i; |
203 | 203 |
204 for (i = 0; i < lstream_type_count; i++) | 204 for (i = 0; i < lstream_type_count; i++) |
205 { | 205 { |
206 if (lstream_types[i] == imp) | 206 if (lstream_types[i] == imp) |
216 &lrecord_lstream); | 216 &lrecord_lstream); |
217 lstream_type_count++; | 217 lstream_type_count++; |
218 } | 218 } |
219 | 219 |
220 p = XLSTREAM (alloc_managed_lcrecord (Vlstream_free_list[i])); | 220 p = XLSTREAM (alloc_managed_lcrecord (Vlstream_free_list[i])); |
221 #endif /* not MC_ALLOC */ | 221 #endif /* not NEW_GC */ |
222 /* Zero it out, except the header. */ | 222 /* Zero it out, except the header. */ |
223 memset ((char *) p + sizeof (p->header), '\0', | 223 memset ((char *) p + sizeof (p->header), '\0', |
224 aligned_sizeof_lstream (imp->size) - sizeof (p->header)); | 224 aligned_sizeof_lstream (imp->size) - sizeof (p->header)); |
225 p->imp = imp; | 225 p->imp = imp; |
226 Lstream_set_buffering (p, LSTREAM_BLOCK_BUFFERED, 0); | 226 Lstream_set_buffering (p, LSTREAM_BLOCK_BUFFERED, 0); |
292 will be aborted. See free_managed_lcrecord(). */ | 292 will be aborted. See free_managed_lcrecord(). */ |
293 | 293 |
294 void | 294 void |
295 Lstream_delete (Lstream *lstr) | 295 Lstream_delete (Lstream *lstr) |
296 { | 296 { |
297 #ifndef MC_ALLOC | 297 #ifndef NEW_GC |
298 int i; | 298 int i; |
299 #endif /* not MC_ALLOC */ | 299 #endif /* not NEW_GC */ |
300 Lisp_Object val = wrap_lstream (lstr); | 300 Lisp_Object val = wrap_lstream (lstr); |
301 | 301 |
302 #ifdef MC_ALLOC | 302 #ifdef NEW_GC |
303 free_lrecord (val); | 303 free_lrecord (val); |
304 #else /* not MC_ALLOC */ | 304 #else /* not NEW_GC */ |
305 for (i = 0; i < lstream_type_count; i++) | 305 for (i = 0; i < lstream_type_count; i++) |
306 { | 306 { |
307 if (lstream_types[i] == lstr->imp) | 307 if (lstream_types[i] == lstr->imp) |
308 { | 308 { |
309 free_managed_lcrecord (Vlstream_free_list[i], val); | 309 free_managed_lcrecord (Vlstream_free_list[i], val); |
310 return; | 310 return; |
311 } | 311 } |
312 } | 312 } |
313 | 313 |
314 ABORT (); | 314 ABORT (); |
315 #endif /* not MC_ALLOC */ | 315 #endif /* not NEW_GC */ |
316 } | 316 } |
317 | 317 |
318 #define Lstream_internal_error(reason, lstr) \ | 318 #define Lstream_internal_error(reason, lstr) \ |
319 signal_error (Qinternal_error, reason, wrap_lstream (lstr)) | 319 signal_error (Qinternal_error, reason, wrap_lstream (lstr)) |
320 | 320 |
1861 LSTREAM_HAS_METHOD (lisp_buffer, writer); | 1861 LSTREAM_HAS_METHOD (lisp_buffer, writer); |
1862 LSTREAM_HAS_METHOD (lisp_buffer, rewinder); | 1862 LSTREAM_HAS_METHOD (lisp_buffer, rewinder); |
1863 LSTREAM_HAS_METHOD (lisp_buffer, marker); | 1863 LSTREAM_HAS_METHOD (lisp_buffer, marker); |
1864 } | 1864 } |
1865 | 1865 |
1866 #ifndef MC_ALLOC | 1866 #ifndef NEW_GC |
1867 void | 1867 void |
1868 reinit_vars_of_lstream (void) | 1868 reinit_vars_of_lstream (void) |
1869 { | 1869 { |
1870 int i; | 1870 int i; |
1871 | 1871 |
1873 { | 1873 { |
1874 Vlstream_free_list[i] = Qnil; | 1874 Vlstream_free_list[i] = Qnil; |
1875 staticpro_nodump (&Vlstream_free_list[i]); | 1875 staticpro_nodump (&Vlstream_free_list[i]); |
1876 } | 1876 } |
1877 } | 1877 } |
1878 #endif /* not MC_ALLOC */ | 1878 #endif /* not NEW_GC */ |
1879 | 1879 |
1880 void | 1880 void |
1881 vars_of_lstream (void) | 1881 vars_of_lstream (void) |
1882 { | 1882 { |
1883 INIT_LISP_OBJECT (lstream); | 1883 INIT_LISP_OBJECT (lstream); |