]> sourceware.org Git - glibc.git/blame - libio/genops.c
Add libc_hidden_def.
[glibc.git] / libio / genops.c
CommitLineData
77fe0b9c 1/* Copyright (C) 1993,1995,1997-2001,2002 Free Software Foundation, Inc.
41bdb6e2 2 This file is part of the GNU C Library.
40a55d20 3
41bdb6e2
AJ
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
40a55d20 8
41bdb6e2
AJ
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
40a55d20 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2
AJ
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public
15 License along with the GNU C Library; if not, write to the Free
16 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
17 02111-1307 USA.
18
19 As a special exception, if you link the code in this file with
20 files compiled with a GNU compiler to produce an executable,
21 that does not cause the resulting executable to be covered by
22 the GNU Lesser General Public License. This exception does not
23 however invalidate any other reasons why the executable file
24 might be covered by the GNU Lesser General Public License.
25 This exception applies to code released by its copyright holders
26 in files containing the exception. */
96aa2d94
RM
27
28/* Generic or default I/O operations. */
29
30#include "libioP.h"
31#ifdef __STDC__
32#include <stdlib.h>
33#endif
34#include <string.h>
35
51e176c2 36#ifdef _IO_MTSAFE_IO
118bad87 37static _IO_lock_t list_all_lock = _IO_lock_initializer;
51e176c2 38#endif
118bad87 39
3afd9491
UD
40/* Used to signal modifications to the list of FILE decriptors. */
41static int _IO_list_all_stamp;
42
beafb752
UD
43
44static _IO_FILE *run_fp;
45
46static void
47flush_cleanup (void *not_used)
48{
49 if (run_fp != NULL)
50 _IO_funlockfile (run_fp);
c0ed7e09 51#ifdef _IO_MTSAFE_IO
beafb752 52 _IO_lock_unlock (list_all_lock);
c0ed7e09 53#endif
beafb752
UD
54}
55
96aa2d94 56void
40a55d20 57_IO_un_link (fp)
2ca8b1ee 58 struct _IO_FILE_plus *fp;
40a55d20 59{
2ca8b1ee 60 if (fp->file._flags & _IO_LINKED)
40a55d20 61 {
2ca8b1ee 62 struct _IO_FILE_plus **f;
d328b80b 63#ifdef _IO_MTSAFE_IO
beafb752 64 _IO_cleanup_region_start_noarg (flush_cleanup);
118bad87 65 _IO_lock_lock (list_all_lock);
beafb752
UD
66 run_fp = (_IO_FILE *) fp;
67 _IO_flockfile ((_IO_FILE *) fp);
51e176c2 68#endif
77fe0b9c
UD
69 for (f = &INTUSE(_IO_list_all); *f;
70 f = (struct _IO_FILE_plus **) &(*f)->file._chain)
40a55d20
UD
71 {
72 if (*f == fp)
73 {
73c115ed 74 *f = (struct _IO_FILE_plus *) fp->file._chain;
3afd9491 75 ++_IO_list_all_stamp;
40a55d20
UD
76 break;
77 }
78 }
beafb752 79 fp->file._flags &= ~_IO_LINKED;
51e176c2 80#ifdef _IO_MTSAFE_IO
beafb752
UD
81 _IO_funlockfile ((_IO_FILE *) fp);
82 run_fp = NULL;
118bad87 83 _IO_lock_unlock (list_all_lock);
beafb752 84 _IO_cleanup_region_end (0);
51e176c2 85#endif
96aa2d94 86 }
96aa2d94 87}
77fe0b9c 88INTDEF(_IO_un_link)
96aa2d94
RM
89
90void
40a55d20 91_IO_link_in (fp)
2ca8b1ee 92 struct _IO_FILE_plus *fp;
96aa2d94 93{
beafb752
UD
94 if ((fp->file._flags & _IO_LINKED) == 0)
95 {
96 fp->file._flags |= _IO_LINKED;
51e176c2 97#ifdef _IO_MTSAFE_IO
beafb752
UD
98 _IO_cleanup_region_start_noarg (flush_cleanup);
99 _IO_lock_lock (list_all_lock);
100 run_fp = (_IO_FILE *) fp;
101 _IO_flockfile ((_IO_FILE *) fp);
51e176c2 102#endif
77fe0b9c
UD
103 fp->file._chain = (_IO_FILE *) INTUSE(_IO_list_all);
104 INTUSE(_IO_list_all) = fp;
beafb752 105 ++_IO_list_all_stamp;
51e176c2 106#ifdef _IO_MTSAFE_IO
beafb752
UD
107 _IO_funlockfile ((_IO_FILE *) fp);
108 run_fp = NULL;
109 _IO_lock_unlock (list_all_lock);
110 _IO_cleanup_region_end (0);
51e176c2 111#endif
beafb752 112 }
96aa2d94 113}
77fe0b9c 114INTDEF(_IO_link_in)
96aa2d94
RM
115
116/* Return minimum _pos markers
117 Assumes the current get area is the main get area. */
d64b6ad0 118_IO_ssize_t _IO_least_marker __P ((_IO_FILE *fp, char *end_p));
96aa2d94 119
d64b6ad0 120_IO_ssize_t
05f732b3 121_IO_least_marker (fp, end_p)
40a55d20 122 _IO_FILE *fp;
05f732b3 123 char *end_p;
96aa2d94 124{
05f732b3 125 _IO_ssize_t least_so_far = end_p - fp->_IO_read_base;
40a55d20 126 struct _IO_marker *mark;
96aa2d94
RM
127 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
128 if (mark->_pos < least_so_far)
129 least_so_far = mark->_pos;
130 return least_so_far;
131}
132
133/* Switch current get area from backup buffer to (start of) main get area. */
134
135void
40a55d20
UD
136_IO_switch_to_main_get_area (fp)
137 _IO_FILE *fp;
96aa2d94
RM
138{
139 char *tmp;
140 fp->_flags &= ~_IO_IN_BACKUP;
141 /* Swap _IO_read_end and _IO_save_end. */
40a55d20
UD
142 tmp = fp->_IO_read_end;
143 fp->_IO_read_end = fp->_IO_save_end;
144 fp->_IO_save_end= tmp;
96aa2d94 145 /* Swap _IO_read_base and _IO_save_base. */
40a55d20
UD
146 tmp = fp->_IO_read_base;
147 fp->_IO_read_base = fp->_IO_save_base;
148 fp->_IO_save_base = tmp;
05f732b3
UD
149 /* Set _IO_read_ptr. */
150 fp->_IO_read_ptr = fp->_IO_read_base;
96aa2d94
RM
151}
152
153/* Switch current get area from main get area to (end of) backup area. */
154
155void
40a55d20
UD
156_IO_switch_to_backup_area (fp)
157 _IO_FILE *fp;
96aa2d94
RM
158{
159 char *tmp;
160 fp->_flags |= _IO_IN_BACKUP;
161 /* Swap _IO_read_end and _IO_save_end. */
40a55d20
UD
162 tmp = fp->_IO_read_end;
163 fp->_IO_read_end = fp->_IO_save_end;
164 fp->_IO_save_end = tmp;
05f732b3 165 /* Swap _IO_read_base and _IO_save_base. */
40a55d20
UD
166 tmp = fp->_IO_read_base;
167 fp->_IO_read_base = fp->_IO_save_base;
168 fp->_IO_save_base = tmp;
05f732b3 169 /* Set _IO_read_ptr. */
96aa2d94
RM
170 fp->_IO_read_ptr = fp->_IO_read_end;
171}
172
173int
40a55d20
UD
174_IO_switch_to_get_mode (fp)
175 _IO_FILE *fp;
96aa2d94
RM
176{
177 if (fp->_IO_write_ptr > fp->_IO_write_base)
178 if (_IO_OVERFLOW (fp, EOF) == EOF)
179 return EOF;
40a55d20 180 if (_IO_in_backup (fp))
96aa2d94
RM
181 fp->_IO_read_base = fp->_IO_backup_base;
182 else
183 {
184 fp->_IO_read_base = fp->_IO_buf_base;
185 if (fp->_IO_write_ptr > fp->_IO_read_end)
186 fp->_IO_read_end = fp->_IO_write_ptr;
187 }
188 fp->_IO_read_ptr = fp->_IO_write_ptr;
189
190 fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = fp->_IO_read_ptr;
191
192 fp->_flags &= ~_IO_CURRENTLY_PUTTING;
193 return 0;
194}
77fe0b9c 195INTDEF(_IO_switch_to_get_mode)
96aa2d94
RM
196
197void
40a55d20
UD
198_IO_free_backup_area (fp)
199 _IO_FILE *fp;
96aa2d94
RM
200{
201 if (_IO_in_backup (fp))
40a55d20 202 _IO_switch_to_main_get_area (fp); /* Just in case. */
96aa2d94
RM
203 free (fp->_IO_save_base);
204 fp->_IO_save_base = NULL;
205 fp->_IO_save_end = NULL;
206 fp->_IO_backup_base = NULL;
207}
77fe0b9c 208INTDEF(_IO_free_backup_area)
96aa2d94
RM
209
210#if 0
211int
40a55d20
UD
212_IO_switch_to_put_mode (fp)
213 _IO_FILE *fp;
96aa2d94
RM
214{
215 fp->_IO_write_base = fp->_IO_read_ptr;
216 fp->_IO_write_ptr = fp->_IO_read_ptr;
217 /* Following is wrong if line- or un-buffered? */
40a55d20
UD
218 fp->_IO_write_end = (fp->_flags & _IO_IN_BACKUP
219 ? fp->_IO_read_end : fp->_IO_buf_end);
96aa2d94
RM
220
221 fp->_IO_read_ptr = fp->_IO_read_end;
222 fp->_IO_read_base = fp->_IO_read_end;
223
224 fp->_flags |= _IO_CURRENTLY_PUTTING;
225 return 0;
226}
227#endif
228
229int
40a55d20
UD
230__overflow (f, ch)
231 _IO_FILE *f;
232 int ch;
96aa2d94 233{
6f98fd7e
UD
234 /* This is a single-byte stream. */
235 if (f->_mode == 0)
236 _IO_fwide (f, -1);
96aa2d94
RM
237 return _IO_OVERFLOW (f, ch);
238}
37ba7d66 239libc_hidden_def (__overflow)
96aa2d94 240
05f732b3 241static int save_for_backup __P ((_IO_FILE *fp, char *end_p))
dfd2257a
UD
242#ifdef _LIBC
243 internal_function
244#endif
245 ;
40a55d20 246
05f732b3 247static int
dfd2257a 248#ifdef _LIBC
05f732b3 249internal_function
dfd2257a 250#endif
05f732b3 251save_for_backup (fp, end_p)
40a55d20 252 _IO_FILE *fp;
05f732b3 253 char *end_p;
96aa2d94 254{
05f732b3
UD
255 /* Append [_IO_read_base..end_p] to backup area. */
256 _IO_ssize_t least_mark = _IO_least_marker (fp, end_p);
96aa2d94 257 /* needed_size is how much space we need in the backup area. */
05f732b3
UD
258 _IO_size_t needed_size = (end_p - fp->_IO_read_base) - least_mark;
259 /* FIXME: Dubious arithmetic if pointers are NULL */
260 _IO_size_t current_Bsize = fp->_IO_save_end - fp->_IO_save_base;
261 _IO_size_t avail; /* Extra space available for future expansion. */
262 _IO_ssize_t delta;
96aa2d94
RM
263 struct _IO_marker *mark;
264 if (needed_size > current_Bsize)
265 {
266 char *new_buffer;
267 avail = 100;
40a55d20 268 new_buffer = (char *) malloc (avail + needed_size);
96aa2d94
RM
269 if (new_buffer == NULL)
270 return EOF; /* FIXME */
271 if (least_mark < 0)
272 {
86187531
UD
273#ifdef _LIBC
274 __mempcpy (__mempcpy (new_buffer + avail,
275 fp->_IO_save_end + least_mark,
276 -least_mark),
277 fp->_IO_read_base,
05f732b3 278 end_p - fp->_IO_read_base);
86187531 279#else
40a55d20
UD
280 memcpy (new_buffer + avail,
281 fp->_IO_save_end + least_mark,
282 -least_mark);
283 memcpy (new_buffer + avail - least_mark,
284 fp->_IO_read_base,
05f732b3 285 end_p - fp->_IO_read_base);
86187531 286#endif
96aa2d94
RM
287 }
288 else
40a55d20
UD
289 memcpy (new_buffer + avail,
290 fp->_IO_read_base + least_mark,
291 needed_size);
96aa2d94
RM
292 if (fp->_IO_save_base)
293 free (fp->_IO_save_base);
294 fp->_IO_save_base = new_buffer;
295 fp->_IO_save_end = new_buffer + avail + needed_size;
296 }
297 else
298 {
299 avail = current_Bsize - needed_size;
300 if (least_mark < 0)
301 {
40a55d20
UD
302 memmove (fp->_IO_save_base + avail,
303 fp->_IO_save_end + least_mark,
304 -least_mark);
305 memcpy (fp->_IO_save_base + avail - least_mark,
306 fp->_IO_read_base,
05f732b3 307 end_p - fp->_IO_read_base);
96aa2d94
RM
308 }
309 else if (needed_size > 0)
40a55d20
UD
310 memcpy (fp->_IO_save_base + avail,
311 fp->_IO_read_base + least_mark,
312 needed_size);
96aa2d94 313 }
96aa2d94
RM
314 fp->_IO_backup_base = fp->_IO_save_base + avail;
315 /* Adjust all the streammarkers. */
05f732b3 316 delta = end_p - fp->_IO_read_base;
96aa2d94
RM
317 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
318 mark->_pos -= delta;
319 return 0;
320}
321
322int
40a55d20
UD
323__underflow (fp)
324 _IO_FILE *fp;
96aa2d94 325{
319d719d 326#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
c9eaa8b9 327 if (fp->_vtable_offset == 0 && _IO_fwide (fp, -1) != -1)
d64b6ad0 328 return EOF;
319d719d 329#endif
d64b6ad0 330
6f98fd7e
UD
331 if (fp->_mode == 0)
332 _IO_fwide (fp, -1);
40a55d20 333 if (_IO_in_put_mode (fp))
77fe0b9c 334 if (INTUSE(_IO_switch_to_get_mode) (fp) == EOF)
40a55d20 335 return EOF;
96aa2d94 336 if (fp->_IO_read_ptr < fp->_IO_read_end)
40a55d20
UD
337 return *(unsigned char *) fp->_IO_read_ptr;
338 if (_IO_in_backup (fp))
96aa2d94 339 {
40a55d20 340 _IO_switch_to_main_get_area (fp);
96aa2d94 341 if (fp->_IO_read_ptr < fp->_IO_read_end)
31f7410f 342 return *(unsigned char *) fp->_IO_read_ptr;
96aa2d94 343 }
40a55d20 344 if (_IO_have_markers (fp))
96aa2d94 345 {
05f732b3 346 if (save_for_backup (fp, fp->_IO_read_end))
96aa2d94
RM
347 return EOF;
348 }
40a55d20 349 else if (_IO_have_backup (fp))
77fe0b9c 350 INTUSE(_IO_free_backup_area) (fp);
96aa2d94
RM
351 return _IO_UNDERFLOW (fp);
352}
353
354int
40a55d20
UD
355__uflow (fp)
356 _IO_FILE *fp;
96aa2d94 357{
319d719d 358#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
c9eaa8b9 359 if (fp->_vtable_offset == 0 && _IO_fwide (fp, -1) != -1)
d64b6ad0 360 return EOF;
319d719d 361#endif
d64b6ad0 362
6f98fd7e
UD
363 if (fp->_mode == 0)
364 _IO_fwide (fp, -11);
40a55d20 365 if (_IO_in_put_mode (fp))
77fe0b9c 366 if (INTUSE(_IO_switch_to_get_mode) (fp) == EOF)
40a55d20 367 return EOF;
96aa2d94 368 if (fp->_IO_read_ptr < fp->_IO_read_end)
40a55d20
UD
369 return *(unsigned char *) fp->_IO_read_ptr++;
370 if (_IO_in_backup (fp))
96aa2d94 371 {
40a55d20 372 _IO_switch_to_main_get_area (fp);
96aa2d94 373 if (fp->_IO_read_ptr < fp->_IO_read_end)
31f7410f 374 return *(unsigned char *) fp->_IO_read_ptr++;
96aa2d94 375 }
40a55d20 376 if (_IO_have_markers (fp))
96aa2d94 377 {
05f732b3 378 if (save_for_backup (fp, fp->_IO_read_end))
96aa2d94
RM
379 return EOF;
380 }
40a55d20 381 else if (_IO_have_backup (fp))
77fe0b9c 382 INTUSE(_IO_free_backup_area) (fp);
96aa2d94
RM
383 return _IO_UFLOW (fp);
384}
385
386void
40a55d20
UD
387_IO_setb (f, b, eb, a)
388 _IO_FILE *f;
389 char *b;
390 char *eb;
391 int a;
96aa2d94
RM
392{
393 if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
40a55d20 394 FREE_BUF (f->_IO_buf_base, _IO_blen (f));
96aa2d94
RM
395 f->_IO_buf_base = b;
396 f->_IO_buf_end = eb;
397 if (a)
398 f->_flags &= ~_IO_USER_BUF;
399 else
400 f->_flags |= _IO_USER_BUF;
401}
77fe0b9c 402INTDEF(_IO_setb)
96aa2d94
RM
403
404void
40a55d20
UD
405_IO_doallocbuf (fp)
406 _IO_FILE *fp;
96aa2d94
RM
407{
408 if (fp->_IO_buf_base)
409 return;
655de5fd 410 if (!(fp->_flags & _IO_UNBUFFERED) || fp->_mode > 0)
96aa2d94
RM
411 if (_IO_DOALLOCATE (fp) != EOF)
412 return;
77fe0b9c 413 INTUSE(_IO_setb) (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
96aa2d94 414}
77fe0b9c 415INTDEF(_IO_doallocbuf)
96aa2d94
RM
416
417int
40a55d20
UD
418_IO_default_underflow (fp)
419 _IO_FILE *fp;
96aa2d94
RM
420{
421 return EOF;
422}
423
424int
40a55d20
UD
425_IO_default_uflow (fp)
426 _IO_FILE *fp;
96aa2d94
RM
427{
428 int ch = _IO_UNDERFLOW (fp);
429 if (ch == EOF)
430 return EOF;
40a55d20 431 return *(unsigned char *) fp->_IO_read_ptr++;
96aa2d94 432}
77fe0b9c 433INTDEF(_IO_default_uflow)
96aa2d94
RM
434
435_IO_size_t
40a55d20
UD
436_IO_default_xsputn (f, data, n)
437 _IO_FILE *f;
438 const void *data;
439 _IO_size_t n;
96aa2d94 440{
40a55d20
UD
441 const char *s = (char *) data;
442 _IO_size_t more = n;
96aa2d94
RM
443 if (more <= 0)
444 return 0;
445 for (;;)
446 {
40a55d20
UD
447 /* Space available. */
448 _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr;
96aa2d94
RM
449 if (count > 0)
450 {
a68b0d31 451 if ((_IO_size_t) count > more)
96aa2d94
RM
452 count = more;
453 if (count > 20)
454 {
86187531
UD
455#ifdef _LIBC
456 f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
457#else
40a55d20 458 memcpy (f->_IO_write_ptr, s, count);
96aa2d94 459 f->_IO_write_ptr += count;
86187531
UD
460#endif
461 s += count;
96aa2d94
RM
462 }
463 else if (count <= 0)
464 count = 0;
465 else
466 {
40a55d20
UD
467 char *p = f->_IO_write_ptr;
468 _IO_ssize_t i;
469 for (i = count; --i >= 0; )
470 *p++ = *s++;
96aa2d94
RM
471 f->_IO_write_ptr = p;
472 }
473 more -= count;
474 }
9202ffe3 475 if (more == 0 || _IO_OVERFLOW (f, (unsigned char) *s++) == EOF)
96aa2d94
RM
476 break;
477 more--;
478 }
479 return n - more;
480}
77fe0b9c 481INTDEF(_IO_default_xsputn)
96aa2d94
RM
482
483_IO_size_t
40a55d20
UD
484_IO_sgetn (fp, data, n)
485 _IO_FILE *fp;
486 void *data;
487 _IO_size_t n;
96aa2d94
RM
488{
489 /* FIXME handle putback buffer here! */
490 return _IO_XSGETN (fp, data, n);
491}
77fe0b9c 492INTDEF(_IO_sgetn)
96aa2d94
RM
493
494_IO_size_t
40a55d20
UD
495_IO_default_xsgetn (fp, data, n)
496 _IO_FILE *fp;
497 void *data;
498 _IO_size_t n;
96aa2d94 499{
40a55d20
UD
500 _IO_size_t more = n;
501 char *s = (char*) data;
96aa2d94
RM
502 for (;;)
503 {
40a55d20
UD
504 /* Data available. */
505 _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr;
96aa2d94
RM
506 if (count > 0)
507 {
a68b0d31 508 if ((_IO_size_t) count > more)
96aa2d94
RM
509 count = more;
510 if (count > 20)
511 {
86187531
UD
512#ifdef _LIBC
513 s = __mempcpy (s, fp->_IO_read_ptr, count);
514#else
40a55d20 515 memcpy (s, fp->_IO_read_ptr, count);
96aa2d94 516 s += count;
86187531 517#endif
96aa2d94
RM
518 fp->_IO_read_ptr += count;
519 }
520 else if (count <= 0)
521 count = 0;
522 else
523 {
40a55d20
UD
524 char *p = fp->_IO_read_ptr;
525 int i = (int) count;
526 while (--i >= 0)
527 *s++ = *p++;
96aa2d94
RM
528 fp->_IO_read_ptr = p;
529 }
530 more -= count;
531 }
40a55d20 532 if (more == 0 || __underflow (fp) == EOF)
96aa2d94
RM
533 break;
534 }
535 return n - more;
536}
77fe0b9c 537INTDEF(_IO_default_xsgetn)
96aa2d94 538
40a55d20
UD
539#if 0
540/* Seems not to be needed. --drepper */
96aa2d94 541int
40a55d20
UD
542_IO_sync (fp)
543 _IO_FILE *fp;
96aa2d94
RM
544{
545 return 0;
546}
40a55d20 547#endif
96aa2d94 548
40a55d20
UD
549_IO_FILE *
550_IO_default_setbuf (fp, p, len)
551 _IO_FILE *fp;
552 char *p;
553 _IO_ssize_t len;
96aa2d94
RM
554{
555 if (_IO_SYNC (fp) == EOF)
556 return NULL;
557 if (p == NULL || len == 0)
558 {
559 fp->_flags |= _IO_UNBUFFERED;
77fe0b9c 560 INTUSE(_IO_setb) (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
96aa2d94
RM
561 }
562 else
563 {
564 fp->_flags &= ~_IO_UNBUFFERED;
77fe0b9c 565 INTUSE(_IO_setb) (fp, p, p+len, 0);
96aa2d94
RM
566 }
567 fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = 0;
568 fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = 0;
569 return fp;
570}
571
d64b6ad0 572_IO_off64_t
40a55d20
UD
573_IO_default_seekpos (fp, pos, mode)
574 _IO_FILE *fp;
d64b6ad0 575 _IO_off64_t pos;
40a55d20 576 int mode;
96aa2d94 577{
d64b6ad0 578 return _IO_SEEKOFF (fp, pos, 0, mode);
96aa2d94
RM
579}
580
581int
40a55d20
UD
582_IO_default_doallocate (fp)
583 _IO_FILE *fp;
96aa2d94 584{
f8b87ef0
UD
585 char *buf;
586
40a55d20 587 ALLOC_BUF (buf, _IO_BUFSIZ, EOF);
77fe0b9c 588 INTUSE(_IO_setb) (fp, buf, buf+_IO_BUFSIZ, 1);
96aa2d94
RM
589 return 1;
590}
77fe0b9c 591INTDEF(_IO_default_doallocate)
96aa2d94
RM
592
593void
40a55d20
UD
594_IO_init (fp, flags)
595 _IO_FILE *fp;
596 int flags;
d64b6ad0
UD
597{
598 _IO_no_init (fp, flags, -1, NULL, NULL);
599}
77fe0b9c 600INTDEF(_IO_init)
d64b6ad0
UD
601
602void
603_IO_no_init (fp, flags, orientation, wd, jmp)
604 _IO_FILE *fp;
605 int flags;
606 int orientation;
607 struct _IO_wide_data *wd;
608 struct _IO_jump_t *jmp;
96aa2d94
RM
609{
610 fp->_flags = _IO_MAGIC|flags;
611 fp->_IO_buf_base = NULL;
612 fp->_IO_buf_end = NULL;
613 fp->_IO_read_base = NULL;
614 fp->_IO_read_ptr = NULL;
615 fp->_IO_read_end = NULL;
616 fp->_IO_write_base = NULL;
617 fp->_IO_write_ptr = NULL;
618 fp->_IO_write_end = NULL;
619 fp->_chain = NULL; /* Not necessary. */
620
621 fp->_IO_save_base = NULL;
622 fp->_IO_backup_base = NULL;
623 fp->_IO_save_end = NULL;
624 fp->_markers = NULL;
625 fp->_cur_column = 0;
bd355af0
UD
626#if _IO_JUMPS_OFFSET
627 fp->_vtable_offset = 0;
628#endif
7c713e28 629#ifdef _IO_MTSAFE_IO
c020d48c
UD
630 if (fp->_lock != NULL)
631 _IO_lock_init (*fp->_lock);
7c713e28 632#endif
d64b6ad0 633 fp->_mode = orientation;
319d719d 634#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
d64b6ad0
UD
635 if (orientation >= 0)
636 {
637 fp->_wide_data = wd;
638 fp->_wide_data->_IO_buf_base = NULL;
639 fp->_wide_data->_IO_buf_end = NULL;
640 fp->_wide_data->_IO_read_base = NULL;
641 fp->_wide_data->_IO_read_ptr = NULL;
642 fp->_wide_data->_IO_read_end = NULL;
643 fp->_wide_data->_IO_write_base = NULL;
644 fp->_wide_data->_IO_write_ptr = NULL;
645 fp->_wide_data->_IO_write_end = NULL;
646 fp->_wide_data->_IO_save_base = NULL;
647 fp->_wide_data->_IO_backup_base = NULL;
648 fp->_wide_data->_IO_save_end = NULL;
649
650 fp->_wide_data->_wide_vtable = jmp;
651 }
319d719d 652#endif
96aa2d94
RM
653}
654
655int
40a55d20
UD
656_IO_default_sync (fp)
657 _IO_FILE *fp;
96aa2d94
RM
658{
659 return 0;
660}
661
662/* The way the C++ classes are mapped into the C functions in the
663 current implementation, this function can get called twice! */
664
665void
40a55d20
UD
666_IO_default_finish (fp, dummy)
667 _IO_FILE *fp;
668 int dummy;
96aa2d94
RM
669{
670 struct _IO_marker *mark;
671 if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
672 {
40a55d20 673 FREE_BUF (fp->_IO_buf_base, _IO_blen (fp));
96aa2d94
RM
674 fp->_IO_buf_base = fp->_IO_buf_end = NULL;
675 }
676
677 for (mark = fp->_markers; mark != NULL; mark = mark->_next)
678 mark->_sbuf = NULL;
679
680 if (fp->_IO_save_base)
681 {
682 free (fp->_IO_save_base);
683 fp->_IO_save_base = NULL;
684 }
685
7c713e28 686#ifdef _IO_MTSAFE_IO
c020d48c
UD
687 if (fp->_lock != NULL)
688 _IO_lock_fini (*fp->_lock);
7c713e28 689#endif
adfa2078 690
77fe0b9c 691 INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
96aa2d94 692}
77fe0b9c 693INTDEF(_IO_default_finish)
96aa2d94 694
d64b6ad0 695_IO_off64_t
40a55d20
UD
696_IO_default_seekoff (fp, offset, dir, mode)
697 _IO_FILE *fp;
dfd2257a 698 _IO_off64_t offset;
40a55d20
UD
699 int dir;
700 int mode;
96aa2d94 701{
c020d48c 702 return _IO_pos_BAD;
96aa2d94
RM
703}
704
705int
40a55d20
UD
706_IO_sputbackc (fp, c)
707 _IO_FILE *fp;
708 int c;
96aa2d94 709{
19bc17a9 710 int result;
adfa2078 711
96aa2d94
RM
712 if (fp->_IO_read_ptr > fp->_IO_read_base
713 && (unsigned char)fp->_IO_read_ptr[-1] == (unsigned char)c)
714 {
715 fp->_IO_read_ptr--;
40a55d20 716 result = (unsigned char) c;
96aa2d94 717 }
19bc17a9
RM
718 else
719 result = _IO_PBACKFAIL (fp, c);
720
721 if (result != EOF)
722 fp->_flags &= ~_IO_EOF_SEEN;
723
724 return result;
96aa2d94 725}
77fe0b9c 726INTDEF(_IO_sputbackc)
96aa2d94
RM
727
728int
40a55d20
UD
729_IO_sungetc (fp)
730 _IO_FILE *fp;
96aa2d94 731{
19bc17a9 732 int result;
adfa2078 733
96aa2d94
RM
734 if (fp->_IO_read_ptr > fp->_IO_read_base)
735 {
736 fp->_IO_read_ptr--;
40a55d20 737 result = (unsigned char) *fp->_IO_read_ptr;
96aa2d94
RM
738 }
739 else
19bc17a9
RM
740 result = _IO_PBACKFAIL (fp, EOF);
741
742 if (result != EOF)
743 fp->_flags &= ~_IO_EOF_SEEN;
744
745 return result;
96aa2d94
RM
746}
747
748#if 0 /* Work in progress */
40a55d20
UD
749/* Seems not to be needed. */
750#if 0
96aa2d94 751void
40a55d20
UD
752_IO_set_column (fp, c)
753 _IO_FILE *fp;
754 int c;
96aa2d94
RM
755{
756 if (c == -1)
757 fp->_column = -1;
758 else
759 fp->_column = c - (fp->_IO_write_ptr - fp->_IO_write_base);
760}
761#else
762int
40a55d20
UD
763_IO_set_column (fp, i)
764 _IO_FILE *fp;
765 int i;
96aa2d94 766{
40a55d20 767 fp->_cur_column = i + 1;
96aa2d94
RM
768 return 0;
769}
770#endif
40a55d20 771#endif
96aa2d94
RM
772
773
774unsigned
40a55d20
UD
775_IO_adjust_column (start, line, count)
776 unsigned start;
777 const char *line;
778 int count;
96aa2d94 779{
40a55d20 780 const char *ptr = line + count;
96aa2d94
RM
781 while (ptr > line)
782 if (*--ptr == '\n')
783 return line + count - ptr - 1;
784 return start + count;
785}
77fe0b9c 786INTDEF(_IO_adjust_column)
96aa2d94 787
40a55d20
UD
788#if 0
789/* Seems not to be needed. --drepper */
96aa2d94 790int
40a55d20
UD
791_IO_get_column (fp)
792 _IO_FILE *fp;
96aa2d94 793{
adfa2078 794 if (fp->_cur_column)
40a55d20 795 return _IO_adjust_column (fp->_cur_column - 1,
96aa2d94
RM
796 fp->_IO_write_base,
797 fp->_IO_write_ptr - fp->_IO_write_base);
798 return -1;
799}
40a55d20 800#endif
96aa2d94 801
3afd9491 802
96aa2d94 803int
c6baa867 804_IO_flush_all_lockp (int do_lock)
96aa2d94
RM
805{
806 int result = 0;
73c115ed 807 struct _IO_FILE *fp;
3afd9491
UD
808 int last_stamp;
809
810#ifdef _IO_MTSAFE_IO
811 _IO_cleanup_region_start_noarg (flush_cleanup);
c6baa867
UD
812 if (do_lock)
813 _IO_lock_lock (list_all_lock);
3afd9491
UD
814#endif
815
816 last_stamp = _IO_list_all_stamp;
77fe0b9c 817 fp = (_IO_FILE *) INTUSE(_IO_list_all);
3afd9491
UD
818 while (fp != NULL)
819 {
820 run_fp = fp;
c6baa867
UD
821 if (do_lock)
822 _IO_flockfile (fp);
3afd9491
UD
823
824 if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
319d719d 825#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
3afd9491
UD
826 || (fp->_vtable_offset == 0
827 && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
828 > fp->_wide_data->_IO_write_base))
319d719d 829#endif
3afd9491
UD
830 )
831 && _IO_OVERFLOW (fp, EOF) == EOF)
832 result = EOF;
833
c6baa867
UD
834 if (do_lock)
835 _IO_funlockfile (fp);
3afd9491
UD
836 run_fp = NULL;
837
838 if (last_stamp != _IO_list_all_stamp)
839 {
840 /* Something was added to the list. Start all over again. */
77fe0b9c 841 fp = (_IO_FILE *) INTUSE(_IO_list_all);
3afd9491
UD
842 last_stamp = _IO_list_all_stamp;
843 }
844 else
845 fp = fp->_chain;
846 }
847
848#ifdef _IO_MTSAFE_IO
c6baa867
UD
849 if (do_lock)
850 _IO_lock_unlock (list_all_lock);
3afd9491
UD
851 _IO_cleanup_region_end (0);
852#endif
853
96aa2d94
RM
854 return result;
855}
856
c6baa867
UD
857
858int
859_IO_flush_all ()
860{
861 /* We want locking. */
862 return _IO_flush_all_lockp (1);
863}
77fe0b9c 864INTDEF(_IO_flush_all)
c6baa867 865
96aa2d94 866void
40a55d20 867_IO_flush_all_linebuffered ()
96aa2d94 868{
73c115ed 869 struct _IO_FILE *fp;
3afd9491
UD
870 int last_stamp;
871
872#ifdef _IO_MTSAFE_IO
873 _IO_cleanup_region_start_noarg (flush_cleanup);
874 _IO_lock_lock (list_all_lock);
875#endif
876
877 last_stamp = _IO_list_all_stamp;
77fe0b9c 878 fp = (_IO_FILE *) INTUSE(_IO_list_all);
3afd9491
UD
879 while (fp != NULL)
880 {
881 run_fp = fp;
882 _IO_flockfile (fp);
883
884 if ((fp->_flags & _IO_NO_WRITES) == 0 && fp->_flags & _IO_LINE_BUF)
885 _IO_OVERFLOW (fp, EOF);
886
887 _IO_funlockfile (fp);
888 run_fp = NULL;
889
890 if (last_stamp != _IO_list_all_stamp)
891 {
892 /* Something was added to the list. Start all over again. */
77fe0b9c 893 fp = (_IO_FILE *) INTUSE(_IO_list_all);
3afd9491
UD
894 last_stamp = _IO_list_all_stamp;
895 }
896 else
897 fp = fp->_chain;
898 }
899
900#ifdef _IO_MTSAFE_IO
901 _IO_lock_unlock (list_all_lock);
902 _IO_cleanup_region_end (0);
903#endif
96aa2d94 904}
77fe0b9c 905INTDEF(_IO_flush_all_linebuffered)
a91d3cd3
UD
906#ifdef _LIBC
907weak_alias (_IO_flush_all_linebuffered, _flushlbf)
908#endif
96aa2d94 909
628a0aa1 910static void _IO_unbuffer_write __P ((void));
40a55d20
UD
911
912static void
628a0aa1 913_IO_unbuffer_write ()
96aa2d94 914{
73c115ed 915 struct _IO_FILE *fp;
77fe0b9c 916 for (fp = (_IO_FILE *) INTUSE(_IO_list_all); fp; fp = fp->_chain)
6906cea4
UD
917 {
918 if (! (fp->_flags & _IO_UNBUFFERED)
919 && (! (fp->_flags & _IO_NO_WRITES)
920 || (fp->_flags & _IO_IS_APPENDING))
921 /* Iff stream is un-orientated, it wasn't used. */
922 && fp->_mode != 0)
923 _IO_SETBUF (fp, NULL, 0);
924
925 /* Make sure that never again the wide char functions can be
926 used. */
927 fp->_mode = -1;
928 }
96aa2d94
RM
929}
930
310b3460 931int
40a55d20 932_IO_cleanup ()
96aa2d94 933{
77fe0b9c 934 int result = INTUSE(_IO_flush_all) ();
96aa2d94
RM
935
936 /* We currently don't have a reliable mechanism for making sure that
937 C++ static destructors are executed in the correct order.
6d52618b 938 So it is possible that other static destructors might want to
96aa2d94
RM
939 write to cout - and they're supposed to be able to do so.
940
adfa2078 941 The following will make the standard streambufs be unbuffered,
96aa2d94 942 which forces any output from late destructors to be written out. */
628a0aa1 943 _IO_unbuffer_write ();
310b3460
UD
944
945 return result;
96aa2d94
RM
946}
947
f2ea0f5b 948
96aa2d94 949void
40a55d20
UD
950_IO_init_marker (marker, fp)
951 struct _IO_marker *marker;
952 _IO_FILE *fp;
96aa2d94
RM
953{
954 marker->_sbuf = fp;
40a55d20 955 if (_IO_in_put_mode (fp))
77fe0b9c 956 INTUSE(_IO_switch_to_get_mode) (fp);
40a55d20 957 if (_IO_in_backup (fp))
96aa2d94
RM
958 marker->_pos = fp->_IO_read_ptr - fp->_IO_read_end;
959 else
960 marker->_pos = fp->_IO_read_ptr - fp->_IO_read_base;
adfa2078 961
96aa2d94
RM
962 /* Should perhaps sort the chain? */
963 marker->_next = fp->_markers;
964 fp->_markers = marker;
965}
966
967void
40a55d20
UD
968_IO_remove_marker (marker)
969 struct _IO_marker *marker;
96aa2d94
RM
970{
971 /* Unlink from sb's chain. */
40a55d20 972 struct _IO_marker **ptr = &marker->_sbuf->_markers;
96aa2d94
RM
973 for (; ; ptr = &(*ptr)->_next)
974 {
975 if (*ptr == NULL)
976 break;
977 else if (*ptr == marker)
978 {
979 *ptr = marker->_next;
980 return;
981 }
982 }
983#if 0
984 if _sbuf has a backup area that is no longer needed, should we delete
985 it now, or wait until the next underflow?
986#endif
987}
988
989#define BAD_DELTA EOF
990
991int
40a55d20
UD
992_IO_marker_difference (mark1, mark2)
993 struct _IO_marker *mark1;
994 struct _IO_marker *mark2;
96aa2d94
RM
995{
996 return mark1->_pos - mark2->_pos;
997}
998
6d52618b 999/* Return difference between MARK and current position of MARK's stream. */
96aa2d94 1000int
40a55d20
UD
1001_IO_marker_delta (mark)
1002 struct _IO_marker *mark;
96aa2d94
RM
1003{
1004 int cur_pos;
1005 if (mark->_sbuf == NULL)
1006 return BAD_DELTA;
40a55d20 1007 if (_IO_in_backup (mark->_sbuf))
96aa2d94
RM
1008 cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_end;
1009 else
1010 cur_pos = mark->_sbuf->_IO_read_ptr - mark->_sbuf->_IO_read_base;
1011 return mark->_pos - cur_pos;
1012}
1013
1014int
40a55d20
UD
1015_IO_seekmark (fp, mark, delta)
1016 _IO_FILE *fp;
1017 struct _IO_marker *mark;
1018 int delta;
96aa2d94
RM
1019{
1020 if (mark->_sbuf != fp)
1021 return EOF;
1022 if (mark->_pos >= 0)
1023 {
40a55d20
UD
1024 if (_IO_in_backup (fp))
1025 _IO_switch_to_main_get_area (fp);
96aa2d94
RM
1026 fp->_IO_read_ptr = fp->_IO_read_base + mark->_pos;
1027 }
1028 else
1029 {
40a55d20 1030 if (!_IO_in_backup (fp))
05f732b3 1031 _IO_switch_to_backup_area (fp);
96aa2d94
RM
1032 fp->_IO_read_ptr = fp->_IO_read_end + mark->_pos;
1033 }
1034 return 0;
1035}
1036
1037void
40a55d20
UD
1038_IO_unsave_markers (fp)
1039 _IO_FILE *fp;
96aa2d94 1040{
40a55d20 1041 struct _IO_marker *mark = fp->_markers;
96aa2d94
RM
1042 if (mark)
1043 {
1044#ifdef TODO
40a55d20 1045 streampos offset = seekoff (0, ios::cur, ios::in);
96aa2d94
RM
1046 if (offset != EOF)
1047 {
40a55d20 1048 offset += eGptr () - Gbase ();
96aa2d94 1049 for ( ; mark != NULL; mark = mark->_next)
40a55d20 1050 mark->set_streampos (mark->_pos + offset);
96aa2d94
RM
1051 }
1052 else
1053 {
1054 for ( ; mark != NULL; mark = mark->_next)
40a55d20 1055 mark->set_streampos (EOF);
96aa2d94
RM
1056 }
1057#endif
1058 fp->_markers = 0;
1059 }
1060
40a55d20 1061 if (_IO_have_backup (fp))
77fe0b9c 1062 INTUSE(_IO_free_backup_area) (fp);
96aa2d94 1063}
77fe0b9c 1064INTDEF(_IO_unsave_markers)
96aa2d94 1065
40a55d20
UD
1066#if 0
1067/* Seems not to be needed. --drepper */
96aa2d94 1068int
40a55d20
UD
1069_IO_nobackup_pbackfail (fp, c)
1070 _IO_FILE *fp;
1071 int c;
96aa2d94
RM
1072{
1073 if (fp->_IO_read_ptr > fp->_IO_read_base)
1074 fp->_IO_read_ptr--;
1075 if (c != EOF && *fp->_IO_read_ptr != c)
1076 *fp->_IO_read_ptr = c;
40a55d20 1077 return (unsigned char) c;
96aa2d94 1078}
40a55d20 1079#endif
96aa2d94
RM
1080
1081int
40a55d20
UD
1082_IO_default_pbackfail (fp, c)
1083 _IO_FILE *fp;
1084 int c;
96aa2d94 1085{
00bc5db0 1086 if (fp->_IO_read_ptr > fp->_IO_read_base && !_IO_in_backup (fp)
c94a8080 1087 && (unsigned char) fp->_IO_read_ptr[-1] == c)
00bc5db0
UD
1088 --fp->_IO_read_ptr;
1089 else
40a55d20
UD
1090 {
1091 /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/
05f732b3 1092 if (!_IO_in_backup (fp))
40a55d20 1093 {
05f732b3
UD
1094 /* We need to keep the invariant that the main get area
1095 logically follows the backup area. */
1096 if (fp->_IO_read_ptr > fp->_IO_read_base && _IO_have_backup (fp))
1097 {
1098 if (save_for_backup (fp, fp->_IO_read_ptr))
1099 return EOF;
1100 }
1101 else if (!_IO_have_backup (fp))
1102 {
1103 /* No backup buffer: allocate one. */
1104 /* Use nshort buffer, if unused? (probably not) FIXME */
1105 int backup_size = 128;
1106 char *bbuf = (char *) malloc (backup_size);
1107 if (bbuf == NULL)
1108 return EOF;
1109 fp->_IO_save_base = bbuf;
1110 fp->_IO_save_end = fp->_IO_save_base + backup_size;
1111 fp->_IO_backup_base = fp->_IO_save_end;
1112 }
1113 fp->_IO_read_base = fp->_IO_read_ptr;
40a55d20
UD
1114 _IO_switch_to_backup_area (fp);
1115 }
1116 else if (fp->_IO_read_ptr <= fp->_IO_read_base)
1117 {
1118 /* Increase size of existing backup buffer. */
1119 _IO_size_t new_size;
1120 _IO_size_t old_size = fp->_IO_read_end - fp->_IO_read_base;
1121 char *new_buf;
1122 new_size = 2 * old_size;
1123 new_buf = (char *) malloc (new_size);
1124 if (new_buf == NULL)
1125 return EOF;
1126 memcpy (new_buf + (new_size - old_size), fp->_IO_read_base,
1127 old_size);
1128 free (fp->_IO_read_base);
1129 _IO_setg (fp, new_buf, new_buf + (new_size - old_size),
1130 new_buf + new_size);
1131 fp->_IO_backup_base = fp->_IO_read_ptr;
1132 }
00bc5db0
UD
1133
1134 *--fp->_IO_read_ptr = c;
40a55d20 1135 }
00bc5db0 1136 return (unsigned char) c;
96aa2d94 1137}
77fe0b9c 1138INTDEF(_IO_default_pbackfail)
96aa2d94 1139
d64b6ad0 1140_IO_off64_t
40a55d20
UD
1141_IO_default_seek (fp, offset, dir)
1142 _IO_FILE *fp;
dfd2257a 1143 _IO_off64_t offset;
40a55d20 1144 int dir;
96aa2d94
RM
1145{
1146 return _IO_pos_BAD;
1147}
1148
1149int
40a55d20
UD
1150_IO_default_stat (fp, st)
1151 _IO_FILE *fp;
1152 void* st;
96aa2d94
RM
1153{
1154 return EOF;
1155}
1156
1157_IO_ssize_t
40a55d20
UD
1158_IO_default_read (fp, data, n)
1159 _IO_FILE* fp;
1160 void *data;
1161 _IO_ssize_t n;
96aa2d94
RM
1162{
1163 return -1;
1164}
1165
1166_IO_ssize_t
40a55d20
UD
1167_IO_default_write (fp, data, n)
1168 _IO_FILE *fp;
1169 const void *data;
1170 _IO_ssize_t n;
96aa2d94
RM
1171{
1172 return 0;
1173}
1174
319d719d 1175int
dfd2257a
UD
1176_IO_default_showmanyc (fp)
1177 _IO_FILE *fp;
1178{
1179 return -1;
1180}
1181
1182void
1183_IO_default_imbue (fp, locale)
1184 _IO_FILE *fp;
1185 void *locale;
1186{
1187}
1188
3fc9ca4e
UD
1189_IO_ITER
1190_IO_iter_begin()
1191{
77fe0b9c 1192 return (_IO_ITER) INTUSE(_IO_list_all);
3fc9ca4e
UD
1193}
1194
1195_IO_ITER
1196_IO_iter_end()
1197{
2ca8b1ee 1198 return NULL;
3fc9ca4e
UD
1199}
1200
1201_IO_ITER
1202_IO_iter_next(iter)
1203 _IO_ITER iter;
1204{
73c115ed 1205 return iter->_chain;
3fc9ca4e
UD
1206}
1207
1208_IO_FILE *
1209_IO_iter_file(iter)
1210 _IO_ITER iter;
1211{
73c115ed 1212 return iter;
3fc9ca4e
UD
1213}
1214
1215void
1216_IO_list_lock()
1217{
92cfdd8a 1218#ifdef _IO_MTSAFE_IO
3fc9ca4e 1219 _IO_lock_lock (list_all_lock);
92cfdd8a 1220#endif
3fc9ca4e
UD
1221}
1222
1223void
1224_IO_list_unlock()
1225{
92cfdd8a
AJ
1226#ifdef _IO_MTSAFE_IO
1227 _IO_lock_unlock (list_all_lock);
1228#endif
3fc9ca4e
UD
1229}
1230
1231void
1232_IO_list_resetlock()
1233{
92cfdd8a 1234#ifdef _IO_MTSAFE_IO
3fc9ca4e 1235 _IO_lock_init (list_all_lock);
92cfdd8a 1236#endif
3fc9ca4e
UD
1237}
1238
96aa2d94
RM
1239
1240#ifdef TODO
1241#if defined(linux)
1242#define IO_CLEANUP ;
1243#endif
1244
1245#ifdef IO_CLEANUP
1246 IO_CLEANUP
1247#else
1248struct __io_defs {
1249 __io_defs() { }
40a55d20 1250 ~__io_defs() { _IO_cleanup (); }
adfa2078 1251};
96aa2d94
RM
1252__io_defs io_defs__;
1253#endif
1254
1255#endif /* TODO */
adfa2078
UD
1256
1257#ifdef weak_alias
1258weak_alias (_IO_cleanup, _cleanup)
1259#endif
f65fd747
UD
1260
1261#ifdef text_set_element
1262text_set_element(__libc_atexit, _cleanup);
1263#endif
This page took 0.321907 seconds and 5 git commands to generate.