1 /* Copyright (C) 1993, 1995, 1997-1999, 2000 Free Software Foundation, Inc.
2 This file is part of the GNU IO Library.
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License as
6 published by the Free Software Foundation; either version 2, or (at
7 your option) any later version.
9 This library is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this library; see the file COPYING. If not, write to
16 the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
19 As a special exception, if you link this library with files
20 compiled with a GNU compiler to produce an executable, this does
21 not cause the resulting executable to be covered by the GNU General
22 Public License. This exception does not however invalidate any
23 other reasons why the executable file might be covered by the GNU
24 General Public License. */
26 /* Generic or default I/O operations. */
35 static _IO_lock_t list_all_lock
= _IO_lock_initializer
;
40 struct _IO_FILE_plus
*fp
;
42 if (fp
->file
._flags
& _IO_LINKED
)
44 struct _IO_FILE_plus
**f
;
46 _IO_lock_lock (list_all_lock
);
48 for (f
= &_IO_list_all
; *f
; f
= (struct _IO_FILE_plus
**) &(*f
)->file
._chain
)
52 *f
= (struct _IO_FILE_plus
*) fp
->file
._chain
;
57 _IO_lock_unlock (list_all_lock
);
59 fp
->file
._flags
&= ~_IO_LINKED
;
65 struct _IO_FILE_plus
*fp
;
67 if ((fp
->file
._flags
& _IO_LINKED
) == 0)
69 fp
->file
._flags
|= _IO_LINKED
;
71 _IO_lock_lock (list_all_lock
);
73 fp
->file
._chain
= (_IO_FILE
*) _IO_list_all
;
76 _IO_lock_unlock (list_all_lock
);
81 /* Return minimum _pos markers
82 Assumes the current get area is the main get area. */
83 _IO_ssize_t _IO_least_marker
__P ((_IO_FILE
*fp
, char *end_p
));
86 _IO_least_marker (fp
, end_p
)
90 _IO_ssize_t least_so_far
= end_p
- fp
->_IO_read_base
;
91 struct _IO_marker
*mark
;
92 for (mark
= fp
->_markers
; mark
!= NULL
; mark
= mark
->_next
)
93 if (mark
->_pos
< least_so_far
)
94 least_so_far
= mark
->_pos
;
98 /* Switch current get area from backup buffer to (start of) main get area. */
101 _IO_switch_to_main_get_area (fp
)
105 fp
->_flags
&= ~_IO_IN_BACKUP
;
106 /* Swap _IO_read_end and _IO_save_end. */
107 tmp
= fp
->_IO_read_end
;
108 fp
->_IO_read_end
= fp
->_IO_save_end
;
109 fp
->_IO_save_end
= tmp
;
110 /* Swap _IO_read_base and _IO_save_base. */
111 tmp
= fp
->_IO_read_base
;
112 fp
->_IO_read_base
= fp
->_IO_save_base
;
113 fp
->_IO_save_base
= tmp
;
114 /* Set _IO_read_ptr. */
115 fp
->_IO_read_ptr
= fp
->_IO_read_base
;
118 /* Switch current get area from main get area to (end of) backup area. */
121 _IO_switch_to_backup_area (fp
)
125 fp
->_flags
|= _IO_IN_BACKUP
;
126 /* Swap _IO_read_end and _IO_save_end. */
127 tmp
= fp
->_IO_read_end
;
128 fp
->_IO_read_end
= fp
->_IO_save_end
;
129 fp
->_IO_save_end
= tmp
;
130 /* Swap _IO_read_base and _IO_save_base. */
131 tmp
= fp
->_IO_read_base
;
132 fp
->_IO_read_base
= fp
->_IO_save_base
;
133 fp
->_IO_save_base
= tmp
;
134 /* Set _IO_read_ptr. */
135 fp
->_IO_read_ptr
= fp
->_IO_read_end
;
139 _IO_switch_to_get_mode (fp
)
142 if (fp
->_IO_write_ptr
> fp
->_IO_write_base
)
143 if (_IO_OVERFLOW (fp
, EOF
) == EOF
)
145 if (_IO_in_backup (fp
))
146 fp
->_IO_read_base
= fp
->_IO_backup_base
;
149 fp
->_IO_read_base
= fp
->_IO_buf_base
;
150 if (fp
->_IO_write_ptr
> fp
->_IO_read_end
)
151 fp
->_IO_read_end
= fp
->_IO_write_ptr
;
153 fp
->_IO_read_ptr
= fp
->_IO_write_ptr
;
155 fp
->_IO_write_base
= fp
->_IO_write_ptr
= fp
->_IO_write_end
= fp
->_IO_read_ptr
;
157 fp
->_flags
&= ~_IO_CURRENTLY_PUTTING
;
162 _IO_free_backup_area (fp
)
165 if (_IO_in_backup (fp
))
166 _IO_switch_to_main_get_area (fp
); /* Just in case. */
167 free (fp
->_IO_save_base
);
168 fp
->_IO_save_base
= NULL
;
169 fp
->_IO_save_end
= NULL
;
170 fp
->_IO_backup_base
= NULL
;
175 _IO_switch_to_put_mode (fp
)
178 fp
->_IO_write_base
= fp
->_IO_read_ptr
;
179 fp
->_IO_write_ptr
= fp
->_IO_read_ptr
;
180 /* Following is wrong if line- or un-buffered? */
181 fp
->_IO_write_end
= (fp
->_flags
& _IO_IN_BACKUP
182 ? fp
->_IO_read_end
: fp
->_IO_buf_end
);
184 fp
->_IO_read_ptr
= fp
->_IO_read_end
;
185 fp
->_IO_read_base
= fp
->_IO_read_end
;
187 fp
->_flags
|= _IO_CURRENTLY_PUTTING
;
197 /* This is a single-byte stream. */
200 return _IO_OVERFLOW (f
, ch
);
203 static int save_for_backup
__P ((_IO_FILE
*fp
, char *end_p
))
213 save_for_backup (fp
, end_p
)
217 /* Append [_IO_read_base..end_p] to backup area. */
218 _IO_ssize_t least_mark
= _IO_least_marker (fp
, end_p
);
219 /* needed_size is how much space we need in the backup area. */
220 _IO_size_t needed_size
= (end_p
- fp
->_IO_read_base
) - least_mark
;
221 /* FIXME: Dubious arithmetic if pointers are NULL */
222 _IO_size_t current_Bsize
= fp
->_IO_save_end
- fp
->_IO_save_base
;
223 _IO_size_t avail
; /* Extra space available for future expansion. */
225 struct _IO_marker
*mark
;
226 if (needed_size
> current_Bsize
)
230 new_buffer
= (char *) malloc (avail
+ needed_size
);
231 if (new_buffer
== NULL
)
232 return EOF
; /* FIXME */
236 __mempcpy (__mempcpy (new_buffer
+ avail
,
237 fp
->_IO_save_end
+ least_mark
,
240 end_p
- fp
->_IO_read_base
);
242 memcpy (new_buffer
+ avail
,
243 fp
->_IO_save_end
+ least_mark
,
245 memcpy (new_buffer
+ avail
- least_mark
,
247 end_p
- fp
->_IO_read_base
);
251 memcpy (new_buffer
+ avail
,
252 fp
->_IO_read_base
+ least_mark
,
254 if (fp
->_IO_save_base
)
255 free (fp
->_IO_save_base
);
256 fp
->_IO_save_base
= new_buffer
;
257 fp
->_IO_save_end
= new_buffer
+ avail
+ needed_size
;
261 avail
= current_Bsize
- needed_size
;
264 memmove (fp
->_IO_save_base
+ avail
,
265 fp
->_IO_save_end
+ least_mark
,
267 memcpy (fp
->_IO_save_base
+ avail
- least_mark
,
269 end_p
- fp
->_IO_read_base
);
271 else if (needed_size
> 0)
272 memcpy (fp
->_IO_save_base
+ avail
,
273 fp
->_IO_read_base
+ least_mark
,
276 fp
->_IO_backup_base
= fp
->_IO_save_base
+ avail
;
277 /* Adjust all the streammarkers. */
278 delta
= end_p
- fp
->_IO_read_base
;
279 for (mark
= fp
->_markers
; mark
!= NULL
; mark
= mark
->_next
)
288 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
289 if (fp
->_vtable_offset
== 0 && _IO_fwide (fp
, -1) != -1)
295 if (_IO_in_put_mode (fp
))
296 if (_IO_switch_to_get_mode (fp
) == EOF
)
298 if (fp
->_IO_read_ptr
< fp
->_IO_read_end
)
299 return *(unsigned char *) fp
->_IO_read_ptr
;
300 if (_IO_in_backup (fp
))
302 _IO_switch_to_main_get_area (fp
);
303 if (fp
->_IO_read_ptr
< fp
->_IO_read_end
)
304 return *(unsigned char *) fp
->_IO_read_ptr
;
306 if (_IO_have_markers (fp
))
308 if (save_for_backup (fp
, fp
->_IO_read_end
))
311 else if (_IO_have_backup (fp
))
312 _IO_free_backup_area (fp
);
313 return _IO_UNDERFLOW (fp
);
320 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
321 if (fp
->_vtable_offset
== 0 && _IO_fwide (fp
, -1) != -1)
327 if (_IO_in_put_mode (fp
))
328 if (_IO_switch_to_get_mode (fp
) == EOF
)
330 if (fp
->_IO_read_ptr
< fp
->_IO_read_end
)
331 return *(unsigned char *) fp
->_IO_read_ptr
++;
332 if (_IO_in_backup (fp
))
334 _IO_switch_to_main_get_area (fp
);
335 if (fp
->_IO_read_ptr
< fp
->_IO_read_end
)
336 return *(unsigned char *) fp
->_IO_read_ptr
++;
338 if (_IO_have_markers (fp
))
340 if (save_for_backup (fp
, fp
->_IO_read_end
))
343 else if (_IO_have_backup (fp
))
344 _IO_free_backup_area (fp
);
345 return _IO_UFLOW (fp
);
349 _IO_setb (f
, b
, eb
, a
)
355 if (f
->_IO_buf_base
&& !(f
->_flags
& _IO_USER_BUF
))
356 FREE_BUF (f
->_IO_buf_base
, _IO_blen (f
));
360 f
->_flags
&= ~_IO_USER_BUF
;
362 f
->_flags
|= _IO_USER_BUF
;
369 if (fp
->_IO_buf_base
)
371 if (!(fp
->_flags
& _IO_UNBUFFERED
))
372 if (_IO_DOALLOCATE (fp
) != EOF
)
374 _IO_setb (fp
, fp
->_shortbuf
, fp
->_shortbuf
+1, 0);
378 _IO_default_underflow (fp
)
385 _IO_default_uflow (fp
)
388 int ch
= _IO_UNDERFLOW (fp
);
391 return *(unsigned char *) fp
->_IO_read_ptr
++;
395 _IO_default_xsputn (f
, data
, n
)
400 const char *s
= (char *) data
;
406 /* Space available. */
407 _IO_ssize_t count
= f
->_IO_write_end
- f
->_IO_write_ptr
;
410 if ((_IO_size_t
) count
> more
)
415 f
->_IO_write_ptr
= __mempcpy (f
->_IO_write_ptr
, s
, count
);
417 memcpy (f
->_IO_write_ptr
, s
, count
);
418 f
->_IO_write_ptr
+= count
;
426 char *p
= f
->_IO_write_ptr
;
428 for (i
= count
; --i
>= 0; )
430 f
->_IO_write_ptr
= p
;
434 if (more
== 0 || _IO_OVERFLOW (f
, (unsigned char) *s
++) == EOF
)
442 _IO_sgetn (fp
, data
, n
)
447 /* FIXME handle putback buffer here! */
448 return _IO_XSGETN (fp
, data
, n
);
452 _IO_default_xsgetn (fp
, data
, n
)
458 char *s
= (char*) data
;
461 /* Data available. */
462 _IO_ssize_t count
= fp
->_IO_read_end
- fp
->_IO_read_ptr
;
465 if ((_IO_size_t
) count
> more
)
470 s
= __mempcpy (s
, fp
->_IO_read_ptr
, count
);
472 memcpy (s
, fp
->_IO_read_ptr
, count
);
475 fp
->_IO_read_ptr
+= count
;
481 char *p
= fp
->_IO_read_ptr
;
485 fp
->_IO_read_ptr
= p
;
489 if (more
== 0 || __underflow (fp
) == EOF
)
496 /* Seems not to be needed. --drepper */
506 _IO_default_setbuf (fp
, p
, len
)
511 if (_IO_SYNC (fp
) == EOF
)
513 if (p
== NULL
|| len
== 0)
515 fp
->_flags
|= _IO_UNBUFFERED
;
516 _IO_setb (fp
, fp
->_shortbuf
, fp
->_shortbuf
+1, 0);
520 fp
->_flags
&= ~_IO_UNBUFFERED
;
521 _IO_setb (fp
, p
, p
+len
, 0);
523 fp
->_IO_write_base
= fp
->_IO_write_ptr
= fp
->_IO_write_end
= 0;
524 fp
->_IO_read_base
= fp
->_IO_read_ptr
= fp
->_IO_read_end
= 0;
529 _IO_default_seekpos (fp
, pos
, mode
)
534 return _IO_SEEKOFF (fp
, pos
, 0, mode
);
538 _IO_default_doallocate (fp
)
543 ALLOC_BUF (buf
, _IO_BUFSIZ
, EOF
);
544 _IO_setb (fp
, buf
, buf
+_IO_BUFSIZ
, 1);
553 _IO_no_init (fp
, flags
, -1, NULL
, NULL
);
557 _IO_no_init (fp
, flags
, orientation
, wd
, jmp
)
561 struct _IO_wide_data
*wd
;
562 struct _IO_jump_t
*jmp
;
564 fp
->_flags
= _IO_MAGIC
|flags
;
565 fp
->_IO_buf_base
= NULL
;
566 fp
->_IO_buf_end
= NULL
;
567 fp
->_IO_read_base
= NULL
;
568 fp
->_IO_read_ptr
= NULL
;
569 fp
->_IO_read_end
= NULL
;
570 fp
->_IO_write_base
= NULL
;
571 fp
->_IO_write_ptr
= NULL
;
572 fp
->_IO_write_end
= NULL
;
573 fp
->_chain
= NULL
; /* Not necessary. */
575 fp
->_IO_save_base
= NULL
;
576 fp
->_IO_backup_base
= NULL
;
577 fp
->_IO_save_end
= NULL
;
581 fp
->_vtable_offset
= 0;
584 _IO_lock_init (*fp
->_lock
);
586 fp
->_mode
= orientation
;
587 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
588 if (orientation
>= 0)
591 fp
->_wide_data
->_IO_buf_base
= NULL
;
592 fp
->_wide_data
->_IO_buf_end
= NULL
;
593 fp
->_wide_data
->_IO_read_base
= NULL
;
594 fp
->_wide_data
->_IO_read_ptr
= NULL
;
595 fp
->_wide_data
->_IO_read_end
= NULL
;
596 fp
->_wide_data
->_IO_write_base
= NULL
;
597 fp
->_wide_data
->_IO_write_ptr
= NULL
;
598 fp
->_wide_data
->_IO_write_end
= NULL
;
599 fp
->_wide_data
->_IO_save_base
= NULL
;
600 fp
->_wide_data
->_IO_backup_base
= NULL
;
601 fp
->_wide_data
->_IO_save_end
= NULL
;
603 fp
->_wide_data
->_wide_vtable
= jmp
;
609 _IO_default_sync (fp
)
615 /* The way the C++ classes are mapped into the C functions in the
616 current implementation, this function can get called twice! */
619 _IO_default_finish (fp
, dummy
)
623 struct _IO_marker
*mark
;
624 if (fp
->_IO_buf_base
&& !(fp
->_flags
& _IO_USER_BUF
))
626 FREE_BUF (fp
->_IO_buf_base
, _IO_blen (fp
));
627 fp
->_IO_buf_base
= fp
->_IO_buf_end
= NULL
;
630 for (mark
= fp
->_markers
; mark
!= NULL
; mark
= mark
->_next
)
633 if (fp
->_IO_save_base
)
635 free (fp
->_IO_save_base
);
636 fp
->_IO_save_base
= NULL
;
640 _IO_lock_fini (*fp
->_lock
);
643 _IO_un_link ((struct _IO_FILE_plus
*) fp
);
647 _IO_default_seekoff (fp
, offset
, dir
, mode
)
657 _IO_sputbackc (fp
, c
)
663 if (fp
->_IO_read_ptr
> fp
->_IO_read_base
664 && (unsigned char)fp
->_IO_read_ptr
[-1] == (unsigned char)c
)
667 result
= (unsigned char) c
;
670 result
= _IO_PBACKFAIL (fp
, c
);
673 fp
->_flags
&= ~_IO_EOF_SEEN
;
684 if (fp
->_IO_read_ptr
> fp
->_IO_read_base
)
687 result
= (unsigned char) *fp
->_IO_read_ptr
;
690 result
= _IO_PBACKFAIL (fp
, EOF
);
693 fp
->_flags
&= ~_IO_EOF_SEEN
;
698 #if 0 /* Work in progress */
699 /* Seems not to be needed. */
702 _IO_set_column (fp
, c
)
709 fp
->_column
= c
- (fp
->_IO_write_ptr
- fp
->_IO_write_base
);
713 _IO_set_column (fp
, i
)
717 fp
->_cur_column
= i
+ 1;
725 _IO_adjust_column (start
, line
, count
)
730 const char *ptr
= line
+ count
;
733 return line
+ count
- ptr
- 1;
734 return start
+ count
;
738 /* Seems not to be needed. --drepper */
744 return _IO_adjust_column (fp
->_cur_column
- 1,
746 fp
->_IO_write_ptr
- fp
->_IO_write_base
);
756 for (fp
= (_IO_FILE
*) _IO_list_all
; fp
; fp
= fp
->_chain
)
757 if (((fp
->_mode
< 0 && fp
->_IO_write_ptr
> fp
->_IO_write_base
)
758 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
759 || (fp
->_vtable_offset
== 0
760 && fp
->_mode
> 0 && (fp
->_wide_data
->_IO_write_ptr
761 > fp
->_wide_data
->_IO_write_base
))
764 && _IO_OVERFLOW (fp
, EOF
) == EOF
)
770 _IO_flush_all_linebuffered ()
773 for (fp
= (_IO_FILE
*) _IO_list_all
; fp
; fp
= fp
->_chain
)
774 if ((fp
->_flags
& _IO_NO_WRITES
) == 0 && fp
->_flags
& _IO_LINE_BUF
)
775 _IO_OVERFLOW (fp
, EOF
);
778 static void _IO_unbuffer_write
__P ((void));
781 _IO_unbuffer_write ()
784 for (fp
= (_IO_FILE
*) _IO_list_all
; fp
; fp
= fp
->_chain
)
785 if (! (fp
->_flags
& _IO_UNBUFFERED
)
786 && (! (fp
->_flags
& _IO_NO_WRITES
)
787 || (fp
->_flags
& _IO_IS_APPENDING
))
788 /* Iff stream is un-orientated, it wasn't used. */
790 _IO_SETBUF (fp
, NULL
, 0);
796 int result
= _IO_flush_all ();
798 /* We currently don't have a reliable mechanism for making sure that
799 C++ static destructors are executed in the correct order.
800 So it is possible that other static destructors might want to
801 write to cout - and they're supposed to be able to do so.
803 The following will make the standard streambufs be unbuffered,
804 which forces any output from late destructors to be written out. */
805 _IO_unbuffer_write ();
812 _IO_init_marker (marker
, fp
)
813 struct _IO_marker
*marker
;
817 if (_IO_in_put_mode (fp
))
818 _IO_switch_to_get_mode (fp
);
819 if (_IO_in_backup (fp
))
820 marker
->_pos
= fp
->_IO_read_ptr
- fp
->_IO_read_end
;
822 marker
->_pos
= fp
->_IO_read_ptr
- fp
->_IO_read_base
;
824 /* Should perhaps sort the chain? */
825 marker
->_next
= fp
->_markers
;
826 fp
->_markers
= marker
;
830 _IO_remove_marker (marker
)
831 struct _IO_marker
*marker
;
833 /* Unlink from sb's chain. */
834 struct _IO_marker
**ptr
= &marker
->_sbuf
->_markers
;
835 for (; ; ptr
= &(*ptr
)->_next
)
839 else if (*ptr
== marker
)
841 *ptr
= marker
->_next
;
846 if _sbuf has a backup area that is no longer needed
, should we
delete
847 it now
, or wait until the next underflow
?
851 #define BAD_DELTA EOF
854 _IO_marker_difference (mark1
, mark2
)
855 struct _IO_marker
*mark1
;
856 struct _IO_marker
*mark2
;
858 return mark1
->_pos
- mark2
->_pos
;
861 /* Return difference between MARK and current position of MARK's stream. */
863 _IO_marker_delta (mark
)
864 struct _IO_marker
*mark
;
867 if (mark
->_sbuf
== NULL
)
869 if (_IO_in_backup (mark
->_sbuf
))
870 cur_pos
= mark
->_sbuf
->_IO_read_ptr
- mark
->_sbuf
->_IO_read_end
;
872 cur_pos
= mark
->_sbuf
->_IO_read_ptr
- mark
->_sbuf
->_IO_read_base
;
873 return mark
->_pos
- cur_pos
;
877 _IO_seekmark (fp
, mark
, delta
)
879 struct _IO_marker
*mark
;
882 if (mark
->_sbuf
!= fp
)
886 if (_IO_in_backup (fp
))
887 _IO_switch_to_main_get_area (fp
);
888 fp
->_IO_read_ptr
= fp
->_IO_read_base
+ mark
->_pos
;
892 if (!_IO_in_backup (fp
))
893 _IO_switch_to_backup_area (fp
);
894 fp
->_IO_read_ptr
= fp
->_IO_read_end
+ mark
->_pos
;
900 _IO_unsave_markers (fp
)
903 struct _IO_marker
*mark
= fp
->_markers
;
907 streampos offset
= seekoff (0, ios::cur
, ios::in
);
910 offset
+= eGptr () - Gbase ();
911 for ( ; mark
!= NULL
; mark
= mark
->_next
)
912 mark
->set_streampos (mark
->_pos
+ offset
);
916 for ( ; mark
!= NULL
; mark
= mark
->_next
)
917 mark
->set_streampos (EOF
);
923 if (_IO_have_backup (fp
))
924 _IO_free_backup_area (fp
);
928 /* Seems not to be needed. --drepper */
930 _IO_nobackup_pbackfail (fp
, c
)
934 if (fp
->_IO_read_ptr
> fp
->_IO_read_base
)
936 if (c
!= EOF
&& *fp
->_IO_read_ptr
!= c
)
937 *fp
->_IO_read_ptr
= c
;
938 return (unsigned char) c
;
943 _IO_default_pbackfail (fp
, c
)
947 if (fp
->_IO_read_ptr
> fp
->_IO_read_base
&& !_IO_in_backup (fp
)
948 && (unsigned char) fp
->_IO_read_ptr
[-1] == c
)
952 /* Need to handle a filebuf in write mode (switch to read mode). FIXME!*/
953 if (!_IO_in_backup (fp
))
955 /* We need to keep the invariant that the main get area
956 logically follows the backup area. */
957 if (fp
->_IO_read_ptr
> fp
->_IO_read_base
&& _IO_have_backup (fp
))
959 if (save_for_backup (fp
, fp
->_IO_read_ptr
))
962 else if (!_IO_have_backup (fp
))
964 /* No backup buffer: allocate one. */
965 /* Use nshort buffer, if unused? (probably not) FIXME */
966 int backup_size
= 128;
967 char *bbuf
= (char *) malloc (backup_size
);
970 fp
->_IO_save_base
= bbuf
;
971 fp
->_IO_save_end
= fp
->_IO_save_base
+ backup_size
;
972 fp
->_IO_backup_base
= fp
->_IO_save_end
;
974 fp
->_IO_read_base
= fp
->_IO_read_ptr
;
975 _IO_switch_to_backup_area (fp
);
977 else if (fp
->_IO_read_ptr
<= fp
->_IO_read_base
)
979 /* Increase size of existing backup buffer. */
981 _IO_size_t old_size
= fp
->_IO_read_end
- fp
->_IO_read_base
;
983 new_size
= 2 * old_size
;
984 new_buf
= (char *) malloc (new_size
);
987 memcpy (new_buf
+ (new_size
- old_size
), fp
->_IO_read_base
,
989 free (fp
->_IO_read_base
);
990 _IO_setg (fp
, new_buf
, new_buf
+ (new_size
- old_size
),
992 fp
->_IO_backup_base
= fp
->_IO_read_ptr
;
995 *--fp
->_IO_read_ptr
= c
;
997 return (unsigned char) c
;
1001 _IO_default_seek (fp
, offset
, dir
)
1010 _IO_default_stat (fp
, st
)
1018 _IO_default_read (fp
, data
, n
)
1027 _IO_default_write (fp
, data
, n
)
1036 _IO_default_showmanyc (fp
)
1043 _IO_default_imbue (fp
, locale
)
1052 return (_IO_ITER
) _IO_list_all
;
1065 return iter
->_chain
;
1078 #ifdef _IO_MTSAFE_IO
1079 _IO_lock_lock (list_all_lock
);
1086 #ifdef _IO_MTSAFE_IO
1087 _IO_lock_unlock (list_all_lock
);
1092 _IO_list_resetlock()
1094 #ifdef _IO_MTSAFE_IO
1095 _IO_lock_init (list_all_lock
);
1102 #define IO_CLEANUP ;
1110 ~__io_defs() { _IO_cleanup (); }
1112 __io_defs io_defs__
;
1118 weak_alias (_IO_cleanup
, _cleanup
)
1121 #ifdef text_set_element
1122 text_set_element(__libc_atexit
, _cleanup
);