@@ -110,19 +110,19 @@ Deprecated and removed features, and other changes affecting compatibility:
* The tilepro-*-linux-gnu configuration is no longer supported.
-* The nonstandard header files <libio.h> and <_G_config.h> are deprecated
- and will be removed in a future release. Software that is still using
- either header should be updated to use standard <stdio.h> interfaces
- instead.
+* The nonstandard header files <libio.h> and <_G_config.h> are deprecated.
+ <stdio.h> no longer includes either of them, and they will be removed in a
+ future release. Software that is still using these headers, or their
+ contents, should be updated to use standard <stdio.h> interfaces instead.
libio.h was originally the header for a set of supported GNU extensions,
but they have not been maintained as such in many years, they are now
- standing in the way of improvements to stdio, and we don't think there are
- any remaining external users. _G_config.h was never intended for public
- use, but predates the bits convention.
+ standing in the way of improvements to stdio, and we are not aware of any
+ remaining external users. _G_config.h was never intended for public use,
+ but predates the "bits" convention for private-but-installed headers.
-* The C++ name mangling for interfaces involving the types fpos_t and
- fpos64_t has changed.
+ As a side-effect of this deprecation, the C++ name mangling for interfaces
+ involving the types fpos_t and fpos64_t has changed.
Changes to build and runtime requirements:
@@ -147,7 +147,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
size_t i;
for (i = 0; i < pad; i++)
{
- if (_IO_fwide (fs->stream, 0) > 0)
+ if (fwide (fs->stream, 0) > 0)
putwc_unlocked (L' ', fs->stream);
else
putc_unlocked (' ', fs->stream);
@@ -310,7 +310,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
*nl++ = ' ';
else
for (i = 0; i < fs->wmargin; ++i)
- if (_IO_fwide (fs->stream, 0) > 0)
+ if (fwide (fs->stream, 0) > 0)
putwc_unlocked (L' ', fs->stream);
else
putc_unlocked (' ', fs->stream);
@@ -1870,7 +1870,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
#endif
}
- if (_IO_fwide (stream, 0) > 0)
+ if (fwide (stream, 0) > 0)
putwc_unlocked (L'\n', stream);
else
putc_unlocked ('\n', stream);
@@ -18,7 +18,7 @@
#if defined __GNUC__ && __GNUC__ >= 2
-#include <stdio.h>
+#include <libio/libioP.h>
/* This records which stdio is linked against in the application. */
const int _IO_stdin_used = _G_IO_IO_FILE_VERSION;
@@ -1 +1,20 @@
-#include <libio/bits/libio.h>
+#ifndef _BITS_LIBIO_H
+# include <libio/bits/libio.h>
+# ifndef _ISOMAC
+
+libc_hidden_proto (__woverflow)
+libc_hidden_proto (__wunderflow)
+libc_hidden_proto (__wuflow)
+libc_hidden_proto (_IO_flockfile)
+libc_hidden_proto (_IO_free_backup_area)
+libc_hidden_proto (_IO_free_wbackup_area)
+libc_hidden_proto (_IO_ftrylockfile)
+libc_hidden_proto (_IO_funlockfile)
+libc_hidden_proto (_IO_padn)
+libc_hidden_proto (_IO_putc)
+libc_hidden_proto (_IO_sgetn)
+libc_hidden_proto (_IO_vfprintf)
+libc_hidden_proto (_IO_vfscanf)
+
+# endif
+#endif
new file mode 100644
@@ -0,0 +1 @@
+#include <libio/bits/types/struct_FILE.h>
@@ -15,26 +15,26 @@ extern int __snprintf (char *__restrict __s, size_t __maxlen,
__attribute__ ((__format__ (__printf__, 3, 4)));
libc_hidden_proto (__snprintf)
extern int __vsnprintf (char *__restrict __s, size_t __maxlen,
- const char *__restrict __format, _G_va_list __arg)
+ const char *__restrict __format, __gnuc_va_list __arg)
__attribute__ ((__format__ (__printf__, 3, 0)));
libc_hidden_proto (__vsnprintf)
extern int __vfscanf (FILE *__restrict __s,
const char *__restrict __format,
- _G_va_list __arg)
+ __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0)));
libc_hidden_proto (__vfscanf)
extern int __vscanf (const char *__restrict __format,
- _G_va_list __arg)
+ __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 1, 0)));
-extern _IO_ssize_t __getline (char **__lineptr, size_t *__n,
- FILE *__stream) attribute_hidden;
-extern _IO_ssize_t __getdelim (char **__lineptr, size_t *__n,
- int __delim, FILE *__stream);
+extern __ssize_t __getline (char **__lineptr, size_t *__n,
+ FILE *__stream) attribute_hidden;
+extern __ssize_t __getdelim (char **__lineptr, size_t *__n,
+ int __delim, FILE *__stream);
libc_hidden_proto (__getdelim)
extern int __vsscanf (const char *__restrict __s,
const char *__restrict __format,
- _G_va_list __arg)
+ __gnuc_va_list __arg)
__attribute__ ((__format__ (__scanf__, 2, 0)));
libc_hidden_proto (__vsscanf)
@@ -42,23 +42,23 @@ extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
__THROW;
extern int __vsprintf_chk (char *, int, size_t, const char *,
- _G_va_list) __THROW;
+ __gnuc_va_list) __THROW;
extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *,
- _G_va_list) __THROW;
+ __gnuc_va_list) __THROW;
extern int __printf_chk (int, const char *, ...);
extern int __fprintf_chk (FILE *, int, const char *, ...);
-extern int __vprintf_chk (int, const char *, _G_va_list);
-extern int __vfprintf_chk (FILE *, int, const char *, _G_va_list);
+extern int __vprintf_chk (int, const char *, __gnuc_va_list);
+extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list);
extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp);
extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp);
extern int __asprintf_chk (char **, int, const char *, ...) __THROW;
-extern int __vasprintf_chk (char **, int, const char *, _G_va_list) __THROW;
+extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW;
extern int __dprintf_chk (int, int, const char *, ...);
-extern int __vdprintf_chk (int, int, const char *, _G_va_list);
+extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list);
extern int __obstack_printf_chk (struct obstack *, int, const char *, ...)
__THROW;
extern int __obstack_vprintf_chk (struct obstack *, int, const char *,
- _G_va_list) __THROW;
+ __gnuc_va_list) __THROW;
extern int __isoc99_fscanf (FILE *__restrict __stream,
const char *__restrict __format, ...) __wur;
@@ -67,12 +67,12 @@ extern int __isoc99_sscanf (const char *__restrict __s,
const char *__restrict __format, ...) __THROW;
extern int __isoc99_vfscanf (FILE *__restrict __s,
const char *__restrict __format,
- _G_va_list __arg) __wur;
+ __gnuc_va_list __arg) __wur;
extern int __isoc99_vscanf (const char *__restrict __format,
- _G_va_list __arg) __wur;
+ __gnuc_va_list __arg) __wur;
extern int __isoc99_vsscanf (const char *__restrict __s,
const char *__restrict __format,
- _G_va_list __arg) __THROW;
+ __gnuc_va_list __arg) __THROW;
libc_hidden_proto (__isoc99_vsscanf)
libc_hidden_proto (__isoc99_vfscanf)
@@ -116,14 +116,17 @@ libc_hidden_proto (__fortify_fail)
libc_hidden_proto (__fortify_fail_abort)
/* Acquire ownership of STREAM. */
-extern void __flockfile (FILE *__stream) attribute_hidden;
+extern void __flockfile (FILE *__stream);
+libc_hidden_proto (__flockfile)
/* Relinquish the ownership granted for STREAM. */
-extern void __funlockfile (FILE *__stream) attribute_hidden;
+extern void __funlockfile (FILE *__stream);
+libc_hidden_proto (__funlockfile)
/* Try to acquire ownership of STREAM but do not block if it is not
possible. */
extern int __ftrylockfile (FILE *__stream);
+libc_hidden_proto (__ftrylockfile)
extern int __getc_unlocked (FILE *__fp);
extern wint_t __getwc_unlocked (FILE *__fp);
@@ -137,18 +140,18 @@ extern const char *const _sys_errlist_internal[] attribute_hidden;
extern int _sys_nerr_internal attribute_hidden;
# if IS_IN (libc)
-extern _IO_FILE *_IO_new_fopen (const char*, const char*);
+extern FILE *_IO_new_fopen (const char*, const char*);
# define fopen(fname, mode) _IO_new_fopen (fname, mode)
-extern _IO_FILE *_IO_new_fdopen (int, const char*);
+extern FILE *_IO_new_fdopen (int, const char*);
# define fdopen(fd, mode) _IO_new_fdopen (fd, mode)
-extern int _IO_new_fclose (_IO_FILE*);
+extern int _IO_new_fclose (FILE *);
# define fclose(fp) _IO_new_fclose (fp)
-extern int _IO_fputs (const char*, _IO_FILE*);
+extern int _IO_fputs (const char*, FILE *);
libc_hidden_proto (_IO_fputs)
# define fputs(str, fp) _IO_fputs (str, fp)
-extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *);
+extern int _IO_new_fsetpos (FILE *, const fpos_t *);
# define fsetpos(fp, posp) _IO_new_fsetpos (fp, posp)
-extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
+extern int _IO_new_fgetpos (FILE *, fpos_t *);
# define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp)
# endif
@@ -215,45 +218,38 @@ libc_hidden_proto (__gen_tempfd)
libc_hidden_proto (__overflow)
libc_hidden_proto (__underflow)
libc_hidden_proto (__uflow)
-libc_hidden_proto (__woverflow)
-libc_hidden_proto (__wunderflow)
-libc_hidden_proto (__wuflow)
-libc_hidden_proto (_IO_free_backup_area)
-libc_hidden_proto (_IO_free_wbackup_area)
-libc_hidden_proto (_IO_padn)
-libc_hidden_proto (_IO_putc)
-libc_hidden_proto (_IO_sgetn)
-libc_hidden_proto (_IO_vfprintf)
-libc_hidden_proto (_IO_vfscanf)
+
+#if IS_IN (libc)
+# undef flockfile
+# define flockfile(s) __flockfile (s)
+# undef funlockfile
+# define funlockfile(s) __funlockfile (s)
+#endif
#ifdef _IO_MTSAFE_IO
-# undef _IO_peekc
# undef _IO_flockfile
# undef _IO_funlockfile
# undef _IO_ftrylockfile
-# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
# if _IO_lock_inexpensive
+# define _IO_USER_LOCK 0x8000
# define _IO_flockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_lock (*(_fp)->_lock)
# define _IO_funlockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_unlock (*(_fp)->_lock)
# else
# define _IO_flockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
+ do { if (((_fp)->_flags & _IO_USER_LOCK) == 0) __flockfile (_fp) } while (0)
# define _IO_funlockfile(_fp) \
- if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
+ do { if (((_fp)->_flags & _IO_USER_LOCK) == 0) __funlockfile (_fp) } while (0)
# endif
-#endif /* _IO_MTSAFE_IO */
-#if IS_IN (libc)
-# undef flockfile
-# define flockfile(s) _IO_flockfile (s)
-# undef funlockfile
-# define funlockfile(s) _IO_funlockfile (s)
-# undef putc
-# define putc(c, fp) _IO_putc (c, fp)
-#endif
+# undef __flockfile
+# define __flockfile(s) _IO_flockfile (s)
+# undef __funlockfile
+# define __funlockfile(s) _IO_funlockfile (s)
+
+#endif /* _IO_MTSAFE_IO */
# endif /* not _ISOMAC */
#endif /* stdio.h */
@@ -3,6 +3,8 @@
# ifndef _ISOMAC
+# define _IO_USER_LOCK 0x8000
+
libc_hidden_proto (__fsetlocking)
#define __fsetlocking(fp, type) \
@@ -260,5 +260,11 @@ extern size_t __mbsrtowcs_l (wchar_t *dst, const char **src, size_t len,
# define mbsinit(state) ((state)->__count == 0)
# define __mbsinit(state) ((state)->__count == 0)
+# if IS_IN (libc)
+extern __typeof (fwide) _IO_fwide;
+# undef fwide
+# define fwide(s, m) _IO_fwide (s, m)
+# endif
+
# endif
#endif
@@ -25,8 +25,9 @@ include ../Makeconfig
headers := stdio.h libio.h _G_config.h \
bits/stdio.h bits/libio.h bits/_G_config.h \
bits/sys_errlist.h bits/stdio2.h bits/stdio-ldbl.h bits/libio-ldbl.h \
- bits/types/FILE.h bits/types/__FILE.h bits/types/__fpos_t.h \
- bits/types/__fpos64_t.h bits/types/cookie_io_functions_t.h
+ bits/types/FILE.h bits/types/__FILE.h bits/types/struct_FILE.h \
+ bits/types/__fpos_t.h bits/types/__fpos64_t.h \
+ bits/types/cookie_io_functions_t.h
routines := \
filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
size_t
__fbufsize (FILE *fp)
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
int
__flbf (FILE *fp)
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
size_t
__fpending (FILE *fp)
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
int
__freadable (FILE *fp)
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
int
__freading (FILE *fp)
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
int
__fwritable (FILE *fp)
@@ -16,6 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio_ext.h>
+#include <libio/libioP.h>
int
__fwriting (FILE *fp)
@@ -28,11 +28,12 @@
#ifndef _BITS_LIBIO_H
#define _BITS_LIBIO_H 1
-#if !defined _STDIO_H && !defined _LIBIO_H
+#if !defined _LIBIO_H && !defined _LIBIOP_H
# error "Never include <bits/libio.h> directly; use <stdio.h> instead."
#endif
#include <stdio.h>
+#include <bits/types/struct_FILE.h>
#include <bits/_G_config.h>
/* ALL of these should be defined in _G_config.h */
@@ -50,9 +51,13 @@
#define _IO_wint_t wint_t
#define _IO_va_list __gnuc_va_list
+/* compatibility defines */
#define _STDIO_USES_IOSTREAM
#define _IO_UNIFIED_JUMPTABLES 1
+#define __HAVE_COLUMN
+#define _IO_file_flags _flags
+/* open modes */
#define _IOS_INPUT 1
#define _IOS_OUTPUT 2
#define _IOS_ATEND 4
@@ -121,14 +126,7 @@
#define _IO_BOOLALPHA 0200000
-struct _IO_jump_t; struct _IO_FILE;
-
-/* During the build of glibc itself, _IO_lock_t will already have been
- defined by internal headers. */
-#ifndef _IO_lock_t_defined
-typedef void _IO_lock_t;
-#endif
-
+struct _IO_jump_t;
/* A streammarker remembers a position in a buffer. */
@@ -139,16 +137,6 @@ struct _IO_marker {
it points to _buf->Gbase()+_pos. FIXME comment */
/* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */
int _pos;
-#if 0
- void set_streampos(streampos sp) { _spos = sp; }
- void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); }
- public:
- streammarker(streambuf *sb);
- ~streammarker();
- int saving() { return _spos == -2; }
- int delta(streammarker&);
- int delta();
-#endif
};
/* This is the structure from the libstdc++ codecvt class. */
@@ -217,73 +205,6 @@ struct _IO_wide_data
};
#endif
-struct _IO_FILE {
- int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
-#define _IO_file_flags _flags
-
- /* The following pointers correspond to the C++ streambuf protocol. */
- /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */
- char* _IO_read_ptr; /* Current read pointer */
- char* _IO_read_end; /* End of get area. */
- char* _IO_read_base; /* Start of putback+get area. */
- char* _IO_write_base; /* Start of put area. */
- char* _IO_write_ptr; /* Current put pointer. */
- char* _IO_write_end; /* End of put area. */
- char* _IO_buf_base; /* Start of reserve area. */
- char* _IO_buf_end; /* End of reserve area. */
- /* The following fields are used to support backing up and undo. */
- char *_IO_save_base; /* Pointer to start of non-current get area. */
- char *_IO_backup_base; /* Pointer to first valid character of backup area */
- char *_IO_save_end; /* Pointer to end of non-current get area. */
-
- struct _IO_marker *_markers;
-
- struct _IO_FILE *_chain;
-
- int _fileno;
-#if 0
- int _blksize;
-#else
- int _flags2;
-#endif
- _IO_off_t _old_offset; /* This used to be _offset but it's too small. */
-
-#define __HAVE_COLUMN /* temporary */
- /* 1+column number of pbase(); 0 is unknown. */
- unsigned short _cur_column;
- signed char _vtable_offset;
- char _shortbuf[1];
-
- /* char* _save_gptr; char* _save_egptr; */
-
- _IO_lock_t *_lock;
-#ifdef _IO_USE_OLD_IO_FILE
-};
-
-struct _IO_FILE_complete
-{
- struct _IO_FILE _file;
-#endif
-#if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001
- _IO_off64_t _offset;
-# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
- /* Wide character stream stuff. */
- struct _IO_codecvt *_codecvt;
- struct _IO_wide_data *_wide_data;
- struct _IO_FILE *_freeres_list;
- void *_freeres_buf;
-# else
- void *__pad1;
- void *__pad2;
- void *__pad3;
- void *__pad4;
-# endif
- size_t __pad5;
- int _mode;
- /* Make sure we don't get into trouble again. */
- char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
-#endif
-};
#ifndef __cplusplus
typedef struct _IO_FILE _IO_FILE;
@@ -325,9 +246,6 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
extern "C" {
#endif
-extern int __underflow (_IO_FILE *);
-extern int __uflow (_IO_FILE *);
-extern int __overflow (_IO_FILE *, int);
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
extern _IO_wint_t __wunderflow (_IO_FILE *);
extern _IO_wint_t __wuflow (_IO_FILE *);
@@ -340,17 +258,12 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
# define _IO_BE(expr, res) (expr)
#endif
-#define _IO_getc_unlocked(_fp) \
- (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
- ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
+#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
#define _IO_peekc_unlocked(_fp) \
(_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
&& __underflow (_fp) == EOF ? EOF \
: *(unsigned char *) (_fp)->_IO_read_ptr)
-#define _IO_putc_unlocked(_ch, _fp) \
- (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \
- ? __overflow (_fp, (unsigned char) (_ch)) \
- : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
+#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
# define _IO_getwc_unlocked(_fp) \
@@ -366,8 +279,8 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
: (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
#endif
-#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
-#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
+#define _IO_feof_unlocked(_fp) __feof_unlocked_body (_fp)
+#define _IO_ferror_unlocked(_fp) __ferror_unlocked_body (_fp)
extern int _IO_getc (_IO_FILE *__fp);
extern int _IO_putc (int __c, _IO_FILE *__fp);
@@ -380,11 +293,13 @@ extern int _IO_peekc_locked (_IO_FILE *__fp);
#define _IO_PENDING_OUTPUT_COUNT(_fp) \
((_fp)->_IO_write_ptr - (_fp)->_IO_write_base)
-extern void _IO_flockfile (_IO_FILE *) __THROW;
-extern void _IO_funlockfile (_IO_FILE *) __THROW;
+/* These might have macro definitions while building libc itself. */
+extern void (_IO_flockfile) (_IO_FILE *) __THROW;
+extern void (_IO_funlockfile) (_IO_FILE *) __THROW;
extern int _IO_ftrylockfile (_IO_FILE *) __THROW;
#define _IO_peekc(_fp) _IO_peekc_unlocked (_fp)
+#if !defined _LIBC && !defined _IO_MTSAFE_IO
#define _IO_flockfile(_fp) /**/
#define _IO_funlockfile(_fp) /**/
#define _IO_ftrylockfile(_fp) /**/
@@ -394,6 +309,7 @@ extern int _IO_ftrylockfile (_IO_FILE *) __THROW;
#ifndef _IO_cleanup_region_end
#define _IO_cleanup_region_end(_Doit) /**/
#endif
+#endif
#define _IO_need_lock(_fp) \
(((_fp)->_flags2 & _IO_FLAGS2_NEED_LOCK) != 0)
@@ -16,10 +16,15 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_STDIO_H
+#define _BITS_STDIO_H 1
+
#ifndef _STDIO_H
# error "Never include <bits/stdio.h> directly; use <stdio.h> instead."
#endif
+#include <bits/types/struct_FILE.h>
+
#ifndef __extern_inline
# define __STDIO_INLINE inline
#else
@@ -43,7 +48,7 @@ vprintf (const char *__restrict __fmt, __gnuc_va_list __arg)
__STDIO_INLINE int
getchar (void)
{
- return _IO_getc (stdin);
+ return getc (stdin);
}
@@ -52,7 +57,7 @@ getchar (void)
__STDIO_INLINE int
fgetc_unlocked (FILE *__fp)
{
- return _IO_getc_unlocked (__fp);
+ return __getc_unlocked_body (__fp);
}
# endif /* misc */
@@ -62,14 +67,14 @@ fgetc_unlocked (FILE *__fp)
__STDIO_INLINE int
getc_unlocked (FILE *__fp)
{
- return _IO_getc_unlocked (__fp);
+ return __getc_unlocked_body (__fp);
}
/* This is defined in POSIX.1:1996. */
__STDIO_INLINE int
getchar_unlocked (void)
{
- return _IO_getc_unlocked (stdin);
+ return __getc_unlocked_body (stdin);
}
# endif /* POSIX */
@@ -78,7 +83,7 @@ getchar_unlocked (void)
__STDIO_INLINE int
putchar (int __c)
{
- return _IO_putc (__c, stdout);
+ return putc (__c, stdout);
}
@@ -87,7 +92,7 @@ putchar (int __c)
__STDIO_INLINE int
fputc_unlocked (int __c, FILE *__stream)
{
- return _IO_putc_unlocked (__c, __stream);
+ return __putc_unlocked_body (__c, __stream);
}
# endif /* misc */
@@ -97,14 +102,14 @@ fputc_unlocked (int __c, FILE *__stream)
__STDIO_INLINE int
putc_unlocked (int __c, FILE *__stream)
{
- return _IO_putc_unlocked (__c, __stream);
+ return __putc_unlocked_body (__c, __stream);
}
/* This is defined in POSIX.1:1996. */
__STDIO_INLINE int
putchar_unlocked (int __c)
{
- return _IO_putc_unlocked (__c, stdout);
+ return __putc_unlocked_body (__c, stdout);
}
# endif /* POSIX */
@@ -124,14 +129,14 @@ getline (char **__lineptr, size_t *__n, FILE *__stream)
__STDIO_INLINE int
__NTH (feof_unlocked (FILE *__stream))
{
- return _IO_feof_unlocked (__stream);
+ return __feof_unlocked_body (__stream);
}
/* Faster versions when locking is not required. */
__STDIO_INLINE int
__NTH (ferror_unlocked (FILE *__stream))
{
- return _IO_ferror_unlocked (__stream);
+ return __ferror_unlocked_body (__stream);
}
# endif /* misc */
@@ -151,7 +156,7 @@ __NTH (ferror_unlocked (FILE *__stream))
for (__cnt = (size_t) (size) * (size_t) (n); \
__cnt > 0; --__cnt) \
{ \
- int __c = _IO_getc_unlocked (__stream); \
+ int __c = getc_unlocked (__stream); \
if (__c == EOF) \
break; \
*__ptr++ = __c; \
@@ -174,7 +179,7 @@ __NTH (ferror_unlocked (FILE *__stream))
size_t __cnt; \
for (__cnt = (size_t) (size) * (size_t) (n); \
__cnt > 0; --__cnt) \
- if (_IO_putc_unlocked (*__ptr++, __stream) == EOF) \
+ if (putc_unlocked (*__ptr++, __stream) == EOF) \
break; \
((size_t) (size) * (size_t) (n) - __cnt) \
/ (size_t) (size); }) \
@@ -188,3 +193,5 @@ __NTH (ferror_unlocked (FILE *__stream))
/* Define helper macro. */
#undef __STDIO_INLINE
+
+#endif /* bits/stdio.h. */
@@ -16,6 +16,9 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
+#ifndef _BITS_STDIO2_H
+#define _BITS_STDIO2_H 1
+
#ifndef _STDIO_H
# error "Never include <bits/stdio2.h> directly; use <stdio.h> instead."
#endif
@@ -368,7 +371,7 @@ fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
for (; __cnt > 0; --__cnt)
{
- int __c = _IO_getc_unlocked (__stream);
+ int __c = getc_unlocked (__stream);
if (__c == EOF)
break;
*__cptr++ = __c;
@@ -379,3 +382,5 @@ fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
return __fread_unlocked_alias (__ptr, __size, __n, __stream);
}
#endif
+
+#endif /* bits/stdio2.h. */
new file mode 100644
@@ -0,0 +1,97 @@
+#ifndef __struct_FILE_defined
+#define __struct_FILE_defined 1
+
+/* Caution: The contents of this file are not part of the official
+ stdio.h API. However, much of it is part of the official *binary*
+ interface, and therefore cannot be changed. */
+
+#if defined _IO_USE_OLD_IO_FILE && !defined _LIBC
+# error "_IO_USE_OLD_IO_FILE should only be defined when building libc itself"
+#endif
+
+#if defined _IO_lock_t_defined && !defined _LIBC
+# error "_IO_lock_t_defined should only be defined when building libc itself"
+#endif
+
+#include <bits/types.h>
+
+struct _IO_FILE;
+struct _IO_marker;
+struct _IO_codecvt;
+struct _IO_wide_data;
+
+/* During the build of glibc itself, _IO_lock_t will already have been
+ defined by internal headers. */
+#ifndef _IO_lock_t_defined
+typedef void _IO_lock_t;
+#endif
+
+struct _IO_FILE
+{
+ int _flags; /* High-order word is _IO_MAGIC; rest is flags. */
+
+ /* The following pointers correspond to the C++ streambuf protocol. */
+ char *_IO_read_ptr; /* Current read pointer */
+ char *_IO_read_end; /* End of get area. */
+ char *_IO_read_base; /* Start of putback+get area. */
+ char *_IO_write_base; /* Start of put area. */
+ char *_IO_write_ptr; /* Current put pointer. */
+ char *_IO_write_end; /* End of put area. */
+ char *_IO_buf_base; /* Start of reserve area. */
+ char *_IO_buf_end; /* End of reserve area. */
+
+ /* The following fields are used to support backing up and undo. */
+ char *_IO_save_base; /* Pointer to start of non-current get area. */
+ char *_IO_backup_base; /* Pointer to first valid character of backup area */
+ char *_IO_save_end; /* Pointer to end of non-current get area. */
+
+ struct _IO_marker *_markers;
+
+ struct _IO_FILE *_chain;
+
+ int _fileno;
+ int _flags2;
+ __off_t _old_offset; /* This used to be _offset but it's too small. */
+
+ /* 1+column number of pbase(); 0 is unknown. */
+ unsigned short _cur_column;
+ signed char _vtable_offset;
+ char _shortbuf[1];
+
+ _IO_lock_t *_lock;
+#ifdef _IO_USE_OLD_IO_FILE
+};
+
+struct _IO_FILE_complete
+{
+ struct _IO_FILE _file;
+#endif
+ __off64_t _offset;
+ /* Wide character stream stuff. */
+ struct _IO_codecvt *_codecvt;
+ struct _IO_wide_data *_wide_data;
+ struct _IO_FILE *_freeres_list;
+ void *_freeres_buf;
+ size_t __pad5;
+ int _mode;
+ /* Make sure we don't get into trouble again. */
+ char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)];
+};
+
+/* These macros are used by bits/stdio.h and libio.h. */
+#define __getc_unlocked_body(_fp) \
+ (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \
+ ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
+
+#define __putc_unlocked_body(_ch, _fp) \
+ (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
+ ? __overflow (_fp, (unsigned char) (_ch)) \
+ : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
+
+#define _IO_EOF_SEEN 0x10
+#define __feof_unlocked_body(_fp) (((_fp)->_flags & _IO_EOF_SEEN) != 0)
+
+#define _IO_ERR_SEEN 0x20
+#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
+
+#endif
@@ -28,6 +28,8 @@
#include <stdio.h>
#include <wchar.h>
+#undef fwide
+
int
fwide (_IO_FILE *fp, int mode)
{
@@ -24,6 +24,9 @@
This exception applies to code released by its copyright holders
in files containing the exception. */
+#ifndef _LIBIOP_H
+#define _LIBIOP_H 1
+
/* NOTE: libio is now exclusively used only by glibc since libstdc++ has its
own implementation. As a result, functions that were implemented for C++
(like *sputn) may no longer have C++ semantics. This is of course only
@@ -33,12 +36,13 @@
FIXME: All of the C++ cruft eventually needs to go away. */
#include <stddef.h>
-
+#include <stdio.h>
#include <errno.h>
#include <libc-lock.h>
#include <math_ldbl_opt.h>
+#include <bits/libio.h>
#include "iolibio.h"
#ifdef __cplusplus
@@ -876,3 +880,5 @@ IO_validate_vtable (const struct _IO_jump_t *vtable)
_IO_vtable_check ();
return vtable;
}
+
+#endif /* libioP.h. */
@@ -845,19 +845,11 @@ extern void funlockfile (FILE *__stream) __THROW;
# include <bits/getopt_posix.h>
#endif
-/* Internal definitions used by optimizing inlines. */
-#include <bits/libio.h>
+/* Slow-path routines used by the optimized inline functions in bits/stdio.h. */
+extern int __underflow (FILE *);
+extern int __uflow (FILE *);
+extern int __overflow (FILE *, int);
-/* The C standard explicitly says this can be a macro,
- so we always do the optimization for it. */
-#define getc(_fp) _IO_getc (_fp)
-
-/* The C standard explicitly says this can be a macro,
- so we always do the optimization for it. */
-#define putc(_ch, _fp) _IO_putc (_ch, _fp)
-
-/* If we are compiling with optimizing read this file. It contains
- several optimizing inline functions and macros. */
#ifdef __USE_EXTERN_INLINES
# include <bits/stdio.h>
#endif
@@ -25,6 +25,7 @@
in files containing the exception. */
#include <stdio.h>
+#include <libio/libioP.h>
typedef void *(*_IO_alloc_type) (_IO_size_t);
typedef void (*_IO_free_type) (void*);
@@ -222,6 +222,7 @@
#include <unistd.h>
#include <stdio.h> /* needed for malloc_stats */
+#include <libio/libioP.h> /* needed for cancellation handling in malloc_stats */
#include <errno.h>
#include <shlib-compat.h>
@@ -23,6 +23,7 @@
#include <string.h>
#include <stdio.h>
#include <wchar.h>
+#include <libio/libioP.h>
extern char *__progname;
@@ -84,7 +85,7 @@ void
vwarnx (const char *format, __gnuc_va_list ap)
{
flockfile (stderr);
- if (_IO_fwide (stderr, 0) > 0)
+ if (fwide (stderr, 0) > 0)
{
__fwprintf (stderr, L"%s: ", __progname);
convert_and_print (format, ap);
@@ -107,7 +108,7 @@ vwarn (const char *format, __gnuc_va_list ap)
int error = errno;
flockfile (stderr);
- if (_IO_fwide (stderr, 0) > 0)
+ if (fwide (stderr, 0) > 0)
{
__fwprintf (stderr, L"%s: ", __progname);
if (format)
@@ -39,6 +39,7 @@
# include <stdbool.h>
# include <stdint.h>
# include <wchar.h>
+# include <libio/libioP.h>
# define mbsrtowcs __mbsrtowcs
# define USE_UNLOCKED_IO 0
# define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b)
@@ -197,7 +198,7 @@ static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3))
error_tail (int status, int errnum, const char *message, va_list args)
{
#if _LIBC
- if (_IO_fwide (stderr, 0) > 0)
+ if (fwide (stderr, 0) > 0)
{
size_t len = strlen (message) + 1;
wchar_t *wmessage = NULL;
@@ -313,7 +313,7 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser)
ssize_t ret = __getline (&parser->buffer, &buffer_size, fp);
if (ret <= 0)
{
- if (_IO_ferror_unlocked (fp))
+ if (ferror_unlocked (fp))
return false;
else
break;
@@ -17,7 +17,10 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
+#include <libio/libioP.h>
+#undef flockfile
+#undef __flockfile
#undef _IO_flockfile
void
@@ -25,5 +28,7 @@ __flockfile (FILE *stream)
{
/* Do nothing. Using this version does not do any locking. */
}
-weak_alias (__flockfile, flockfile);
-weak_alias (__flockfile, _IO_flockfile)
+strong_alias (__flockfile, _IO_flockfile)
+weak_alias (__flockfile, flockfile)
+libc_hidden_def (__flockfile)
+libc_hidden_def (_IO_flockfile)
@@ -17,7 +17,10 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
+#include <libio/libioP.h>
+#undef ftrylockfile
+#undef __ftrylockfile
#undef _IO_ftrylockfile
int
@@ -26,5 +29,7 @@ __ftrylockfile (FILE *stream)
/* Do nothing. Using this version does not do any locking. */
return 1;
}
-weak_alias (__ftrylockfile, ftrylockfile);
-weak_alias (__ftrylockfile, _IO_ftrylockfile)
+strong_alias (__ftrylockfile, _IO_ftrylockfile)
+weak_alias (__ftrylockfile, ftrylockfile)
+libc_hidden_def (__ftrylockfile)
+libc_hidden_def (_IO_ftrylockfile)
@@ -17,7 +17,10 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
+#include <libio/libioP.h>
+#undef funlockfile
+#undef __funlockfile
#undef _IO_funlockfile
void
@@ -25,5 +28,8 @@ __funlockfile (FILE *stream)
{
/* Do nothing. Using this version does not do any locking. */
}
-weak_alias (__funlockfile, _IO_funlockfile)
-weak_alias (__funlockfile, funlockfile);
+strong_alias (__funlockfile, _IO_funlockfile)
+weak_alias (__funlockfile, funlockfile)
+libc_hidden_def (__funlockfile)
+libc_hidden_def (_IO_funlockfile)
+
@@ -21,6 +21,8 @@
#include <unistd.h>
#include <wchar.h>
+#include <libio/libioP.h>
+
static void
perror_internal (FILE *fp, const char *s, int errnum)
{
@@ -28,7 +28,7 @@ __scanf (const char *format, ...)
int done;
va_start (arg, format);
- done = _IO_vfscanf (stdin, format, arg, NULL);
+ done = __vfscanf (stdin, format, arg);
va_end (arg);
return done;
@@ -16,8 +16,7 @@
<http://www.gnu.org/licenses/>. */
#include <stdio.h>
-#undef ssize_t
-#define ssize_t _IO_ssize_t
+#include <sys/types.h>
int
main (int argc, char *argv[])
@@ -18,8 +18,11 @@
#include <pthread.h>
#include <stdio.h>
-#include <stdio-lock.h>
+#include <libio/libioP.h>
+#undef flockfile
+#undef __flockfile
+#undef _IO_flockfile
void
__flockfile (FILE *stream)
@@ -29,3 +32,5 @@ __flockfile (FILE *stream)
}
strong_alias (__flockfile, _IO_flockfile)
weak_alias (__flockfile, flockfile)
+libc_hidden_def (__flockfile)
+libc_hidden_def (_IO_flockfile)
@@ -16,11 +16,13 @@
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
-#include <errno.h>
#include <pthread.h>
#include <stdio.h>
-#include <stdio-lock.h>
+#include <libio/libioP.h>
+#undef ftrylockfile
+#undef __ftrylockfile
+#undef _IO_ftrylockfile
int
__ftrylockfile (FILE *stream)
@@ -29,3 +31,5 @@ __ftrylockfile (FILE *stream)
}
strong_alias (__ftrylockfile, _IO_ftrylockfile)
weak_alias (__ftrylockfile, ftrylockfile)
+libc_hidden_def (__ftrylockfile)
+libc_hidden_def (_IO_ftrylockfile)
@@ -18,8 +18,11 @@
#include <pthread.h>
#include <stdio.h>
-#include <stdio-lock.h>
+#include <libio/libioP.h>
+#undef funlockfile
+#undef __funlockfile
+#undef _IO_funlockfile
void
__funlockfile (FILE *stream)
@@ -28,3 +31,5 @@ __funlockfile (FILE *stream)
}
strong_alias (__funlockfile, _IO_funlockfile)
weak_alias (__funlockfile, funlockfile)
+libc_hidden_def (__funlockfile)
+libc_hidden_def (_IO_funlockfile)