This is the mail archive of the glibc-cvs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

GNU C Library master sources branch zack/libio-minimization created. glibc-2.26.9000-1041-g7959f85


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU C Library master sources".

The branch, zack/libio-minimization has been created
        at  7959f855a7c739602a2227c85563650b28d8a0cf (commit)

- Log -----------------------------------------------------------------
http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=7959f855a7c739602a2227c85563650b28d8a0cf

commit 7959f855a7c739602a2227c85563650b28d8a0cf
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Dec 25 20:58:46 2017 -0800

    Don't include libio.h from stdio.h.
    
    The only thing stdio.h really needed libio.h for was the complete
    definition of the FILE struct.  This is moved to
    bits/types/struct_FILE.h, along with just enough ancillary definitions
    for the inlines in bits/stdio.h.  stdio.h itself leaves FILE as an
    opaque typedef; bits/types/struct_FILE.h will only be read when the
    inlines are active.
    
    Code within glibc that needs to see libio internal definitions should,
    for the time being, include <libio/libioP.h>.  Once we stop shipping
    libio.h as an exposed header, we can fold libio.h, libioP.h, and
    iolibio.h together and much cruft will become unneccessary.
    
    Unlike the earlier patch where I had us stop shipping libio.h
    entirely, I left the struct _IO_FILE / struct _IO_FILE_complete
    distinction strictly alone in this patch, so it shouldn't break old
    ABI compatibility.  This is still quite messy, particularly where it
    touches on the _IO_MTSAFE_IO mess; close review would be appreciated.
    
    More automatic PLT bypassing is added for fwide, flockfile, and
    funlockfile; the earlier patches were apparently not thorough enough.
    
    	* libio/stdio.h: Don't include bits/libio.h.  Don't define getc or
    	putc as macros.  Declare __underflow, __uflow, and __overflow here.
    
    	* libio/bits/types/struct_FILE.h: New header containing the complete
    	definitions of struct _IO_FILE and struct _IO_FILE_complete and a few
    	ancillary definitions.
    	* libio/Makefile: Install bits/types/struct_FILE.h.
    	* libio/bits/stdio.h: Add multiple inclusion guard.  Include
    	bits/types/struct_FILE.h.  Use getc, not _IO_getc; putc, not _IO_putc;
    	__getc_unlocked_body, not _IO_getc_unlocked; __putc_unlocked_body, not
    	_IO_putc_unlocked; __feof_unlocked_body, not _IO_feof_unlocked;
    	__ferror_unlocked_body, not _IO_ferror_unlocked.
    	* libio/bits/stdio2.h: Add multiple inclusion guard.
            Use getc_unlocked, not _IO_getc_unlocked.
    	* libio/bits/libio.h: Allow inclusion by libioP.h, not stdio.h.
    	Move __HAVE_COLUMN and _IO_file_flags to the set of compatibility
    	defines.  Get definition of _IO_FILE and fallback definition of
    	_IO_lock_t from bits/types/struct_FILE.h. Use macros from
    	bits/types/struct_FILE.h for _IO_getc_unlocked, _IO_putc_unlocked,
    	_IO_feof_unlocked, and _IO_ferror_unlocked.
    	Remove some #if 0 blocks and redundant prototypes.  Only provide
    	non-thread-safe fallback definitions of several macros when
    	neither _IO_MTSAFE_IO nor _LIBC is defined.  Avoid unwanted macro
    	expansion when declaring _IO_flockfile and _IO_funlockfile.
    	* libio/libioP.h: Add multiple-include guard.  Include stdio.h and
    	bits/libio.h.
    	* libio/strfile.h: Include libio/libioP.h.
    
    	* include/bits/libio.h: Move the libc_hidden_proto declarations
    	for __woverflow, __wunderflow, __wuflow, _IO_free_backup_area,
    	_IO_free_wbackup_area, _IO_padn, _IO_putc, _IO_sgetn, _IO_vfprintf,
    	and _IO_vfscanf back here.  Add libc_hidden_proto declarations for
    	_IO_flockfile, _IO_ftrylockfile, and _IO_funlockfile.
    	* include/stdio.h: Use __gnuc_va_list instead of _G_va_list, __ssize_t
    	instead of _IO_ssize_t, and FILE instead of _IO_FILE.  Don't redefine
    	_IO_peekc.  Don't macro-redirect putc.  Define _IO_USER_LOCK here.
    	Add libc_hidden_proto declarations for __flockfile, __funlockfile, and
    	__ftrylockfile.  When IS_IN(libc), macro-redirect flockfile to
    	__flockfile and funlockfile to __funlockfile.  When IS_IN(libc) and
    	_IO_MTSAFE_IO, macro-redirect __flockfile to _IO_flockfile and
    	__funlockfile to _IO_funlockfile.  Use __flockfile and __funlockfile
    	in the expensive-lock variants of _IO_flockfile and _IO_funlockfile.
    	* include/stdio_ext.h: Define _IO_USER_LOCK here.
    	* include/wchar.h: When IS_IN(libc), macro-redirect fwide to _IO_fwide.
    	* include/bits/types/struct_FILE.h: New wrapper.
    
    	* argp/argp-fmtstream.c, argp/argp-help.c, misc/err.c, misc/error.c:
    	Use fwide, not _IO_fwide.
    	* resolv/res_init.c: Use ferror_unlocked, not _IO_ferror_unlocked.
    	* stdio-common/scanf.c: Use __vfscanf, not _IO_vfscanf.
    	* stdio-common/tstgetln.c: Get ssize_t from sys/types.h.
    	* csu/init.c, libio/__fbufsize.c, libio/__flbf.c, libio/__fpending.c
    	* libio/__freadable.c, libio/__fwritable.c, libio/__fwriting.c
    	* malloc/malloc.c, misc/err.c, misc/error.c, stdio-common/perror.c
    	Include libio/libioP.h instead of, or in addition to, stdio.h.
    	* libio/fwide.c: #undef fwide before defining it as a function.
    
    	* stdio-common/flockfile.c: Include stdio.h and libio/libioP.h and
    	remove unnecessary headers.  #undef flockfile, __flockfile, and
    	_IO_flockfile before defining __flockfile as a function.  Make
    	_IO_flockfile a strong alias.  Add libc_hidden_def for __flockfile and
    	_IO_flockfile.
    	* stdio-common/ftrylockfile.c, stdio-common/funlockfile.c
    	* sysdeps/pthread/flockfile.c, sysdeps/pthread/ftrylockfile.c
    	* sysdeps/pthread/funlockfile.c: Similarly.

diff --git a/NEWS b/NEWS
index 7a75891..7c97b79 100644
--- a/NEWS
+++ b/NEWS
@@ -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:
 
diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index eeb7520..3804454 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -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);
diff --git a/argp/argp-help.c b/argp/argp-help.c
index ab8eeb9..124708b 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -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);
diff --git a/csu/init.c b/csu/init.c
index c50bb35..d1f622a 100644
--- a/csu/init.c
+++ b/csu/init.c
@@ -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;
diff --git a/include/bits/libio.h b/include/bits/libio.h
index 40b6851..e12c746 100644
--- a/include/bits/libio.h
+++ b/include/bits/libio.h
@@ -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
diff --git a/include/bits/types/struct_FILE.h b/include/bits/types/struct_FILE.h
new file mode 100644
index 0000000..9714072
--- /dev/null
+++ b/include/bits/types/struct_FILE.h
@@ -0,0 +1 @@
+#include <libio/bits/types/struct_FILE.h>
diff --git a/include/stdio.h b/include/stdio.h
index 8c85807..13cd932 100644
--- a/include/stdio.h
+++ b/include/stdio.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 */
diff --git a/include/stdio_ext.h b/include/stdio_ext.h
index 29c6e68..7c07d78 100644
--- a/include/stdio_ext.h
+++ b/include/stdio_ext.h
@@ -3,6 +3,8 @@
 
 # ifndef _ISOMAC
 
+#  define _IO_USER_LOCK 0x8000
+
 libc_hidden_proto (__fsetlocking)
 
 #define __fsetlocking(fp, type) \
diff --git a/include/wchar.h b/include/wchar.h
index 1db0ac8..64157f4 100644
--- a/include/wchar.h
+++ b/include/wchar.h
@@ -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
diff --git a/libio/Makefile b/libio/Makefile
index b0cf4d4..3c85afb 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -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      \
diff --git a/libio/__fbufsize.c b/libio/__fbufsize.c
index 74d2ebb..fc91a71 100644
--- a/libio/__fbufsize.c
+++ b/libio/__fbufsize.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 size_t
 __fbufsize (FILE *fp)
diff --git a/libio/__flbf.c b/libio/__flbf.c
index 929175d..96a2995 100644
--- a/libio/__flbf.c
+++ b/libio/__flbf.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 int
 __flbf (FILE *fp)
diff --git a/libio/__fpending.c b/libio/__fpending.c
index e957839..33d1f0c 100644
--- a/libio/__fpending.c
+++ b/libio/__fpending.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 size_t
 __fpending (FILE *fp)
diff --git a/libio/__freadable.c b/libio/__freadable.c
index 3bde42a..750d743 100644
--- a/libio/__freadable.c
+++ b/libio/__freadable.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 int
 __freadable (FILE *fp)
diff --git a/libio/__freading.c b/libio/__freading.c
index f16f426..db77952 100644
--- a/libio/__freading.c
+++ b/libio/__freading.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 int
 __freading (FILE *fp)
diff --git a/libio/__fwritable.c b/libio/__fwritable.c
index 1584aec..704c656 100644
--- a/libio/__fwritable.c
+++ b/libio/__fwritable.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 int
 __fwritable (FILE *fp)
diff --git a/libio/__fwriting.c b/libio/__fwriting.c
index 1769d21..3acbbe4 100644
--- a/libio/__fwriting.c
+++ b/libio/__fwriting.c
@@ -16,6 +16,7 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
+#include <libio/libioP.h>
 
 int
 __fwriting (FILE *fp)
diff --git a/libio/bits/libio.h b/libio/bits/libio.h
index 05668c4..28ac017 100644
--- a/libio/bits/libio.h
+++ b/libio/bits/libio.h
@@ -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)
diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h
index 601fc27..7218f5d 100644
--- a/libio/bits/stdio.h
+++ b/libio/bits/stdio.h
@@ -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.  */
diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h
index 16fd38a..4384711 100644
--- a/libio/bits/stdio2.h
+++ b/libio/bits/stdio2.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.  */
diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h
new file mode 100644
index 0000000..18dbba4
--- /dev/null
+++ b/libio/bits/types/struct_FILE.h
@@ -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
diff --git a/libio/fwide.c b/libio/fwide.c
index d725d43..4229532 100644
--- a/libio/fwide.c
+++ b/libio/fwide.c
@@ -28,6 +28,8 @@
 #include <stdio.h>
 #include <wchar.h>
 
+#undef fwide
+
 int
 fwide (_IO_FILE *fp, int mode)
 {
diff --git a/libio/libioP.h b/libio/libioP.h
index 0613439..914caac 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -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.  */
diff --git a/libio/stdio.h b/libio/stdio.h
index 8cf6412..0da68d7 100644
--- a/libio/stdio.h
+++ b/libio/stdio.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
diff --git a/libio/strfile.h b/libio/strfile.h
index 494526b..9325394 100644
--- a/libio/strfile.h
+++ b/libio/strfile.h
@@ -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*);
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 6253fbe..c6cae36 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -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>
diff --git a/misc/err.c b/misc/err.c
index d96778a..7943783 100644
--- a/misc/err.c
+++ b/misc/err.c
@@ -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)
diff --git a/misc/error.c b/misc/error.c
index de11b7a..491c0f7 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -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;
diff --git a/resolv/res_init.c b/resolv/res_init.c
index 4e1f9fe..a595e9b 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -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;
diff --git a/stdio-common/flockfile.c b/stdio-common/flockfile.c
index 4080ecf..e9c58a3 100644
--- a/stdio-common/flockfile.c
+++ b/stdio-common/flockfile.c
@@ -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)
diff --git a/stdio-common/ftrylockfile.c b/stdio-common/ftrylockfile.c
index 366ad31..1352a10 100644
--- a/stdio-common/ftrylockfile.c
+++ b/stdio-common/ftrylockfile.c
@@ -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)
diff --git a/stdio-common/funlockfile.c b/stdio-common/funlockfile.c
index 2204fde..15de582 100644
--- a/stdio-common/funlockfile.c
+++ b/stdio-common/funlockfile.c
@@ -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)
+
diff --git a/stdio-common/perror.c b/stdio-common/perror.c
index 98cf1c4..2fdbf5a 100644
--- a/stdio-common/perror.c
+++ b/stdio-common/perror.c
@@ -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)
 {
diff --git a/stdio-common/scanf.c b/stdio-common/scanf.c
index 385fba6..f50e2a3 100644
--- a/stdio-common/scanf.c
+++ b/stdio-common/scanf.c
@@ -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;
diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c
index 79ab90c..d6a0eb9 100644
--- a/stdio-common/tstgetln.c
+++ b/stdio-common/tstgetln.c
@@ -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[])
diff --git a/sysdeps/pthread/flockfile.c b/sysdeps/pthread/flockfile.c
index 14c1be1..e422e1a 100644
--- a/sysdeps/pthread/flockfile.c
+++ b/sysdeps/pthread/flockfile.c
@@ -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)
diff --git a/sysdeps/pthread/ftrylockfile.c b/sysdeps/pthread/ftrylockfile.c
index c1d9da6..d8b1a2a 100644
--- a/sysdeps/pthread/ftrylockfile.c
+++ b/sysdeps/pthread/ftrylockfile.c
@@ -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)
diff --git a/sysdeps/pthread/funlockfile.c b/sysdeps/pthread/funlockfile.c
index 9f54634..5e75d54 100644
--- a/sysdeps/pthread/funlockfile.c
+++ b/sysdeps/pthread/funlockfile.c
@@ -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)

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=d663336f8e3aae73b0beb7e42cd37d2dd4b04b9d

commit d663336f8e3aae73b0beb7e42cd37d2dd4b04b9d
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Dec 25 12:34:14 2017 -0800

    Minimize use of _IO_ and _G_ symbols in public headers.
    
    This is groundwork for removing the inclusion of (bits/)libio.h from
    stdio.h.  It doesn't make a whole lot of sense by itself, but it is
    also much more mechanical than the next piece, which involves moving
    the definition of struct _IO_FILE.
    
    	* libio/bits/types/__fpos64_t.h, libio/bits/types/__fpos_t.h
    	* libio/bits/types/cookie_io_functions_t.h: New single-type headers.
    	* include/bits/types/__fpos64_t.h, include/bits/types/__fpos_t.h
    	* include/bits/types/cookie_io_functions_t.h: New wrappers.
    	* libio/Makefile: Install the new headers.
    
    	* libio/stdio.h: Get __gnuc_va_list directly from stdarg.h.
    	Get __fpos_t, __fpos64_t, and cookie_io_functions_t from the new
    	headers.  Don't use _G_ names when defining va_list, fpos_t, or
    	fpos64_t.  Define BUFSIZ unconditionally as 8192, and EOF
    	unconditionally as (-1).  Declare stdin, stdout, and stderr with
    	type FILE.  Use cookie_io_functions_t instead of
    	_IO_cookie_io_functions_t, __gnuc_va_list instead of _G_va_list,
    	and __ssize_t instead of _IO_ssize_t.  Move getc and putc macros
    	and inclusion of bits/libio.h to bottom of file.
    
    	* libio/bits/stdio.h, libio/bits/stdio2.h: Use __ssize_t instead
    	of _IO_ssize_t, and __gnuc_va_list instead of _G_va_list.
    
    	* bits/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h: Get
    	definitions of __fpos_t and __fpos64_t from the new headers.
    	Define _G_fpos_t as __fpos_t and _G_fpos64_t as __fpos64_t.
    
    	* libio/bits/libio.h: Include stdio.h and don't repeat anything
    	that it does.  Define _IO_BUFSIZ as BUFSIZ, _IO_fpos_t as
    	__fpos_t, _IO_fpos64_t as __fpos64_t, _IO_va_list as __gnuc_va_list,
    	__io_read_fn as cookie_read_fn_t, __io_write_fn as cookie_write_fn_t,
    	__io_seek_fn as cookie_seek_fn_t, __io_close_fn as cookie_close_fn_t,
    	and _IO_cookie_io_functions_t as cookie_io_functions_t.

diff --git a/NEWS b/NEWS
index 95f3683..7a75891 100644
--- a/NEWS
+++ b/NEWS
@@ -121,6 +121,9 @@ Deprecated and removed features, and other changes affecting compatibility:
   any remaining external users.  _G_config.h was never intended for public
   use, but predates the bits convention.
 
+* The C++ name mangling for interfaces involving the types fpos_t and
+  fpos64_t has changed.
+
 Changes to build and runtime requirements:
 
 * bison version 2.7 or later is required to generate code in the 'intl'
diff --git a/bits/_G_config.h b/bits/_G_config.h
index 2b60d29..6da3c5f 100644
--- a/bits/_G_config.h
+++ b/bits/_G_config.h
@@ -19,20 +19,17 @@
 #include <stddef.h>
 
 #include <bits/types/__mbstate_t.h>
+#include <bits/types/__fpos_t.h>
+#include <bits/types/__fpos64_t.h>
+
+#define _G_fpos_t __fpos_t
+#define _G_fpos64_t __fpos64_t
+
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 # include <bits/types/wint_t.h>
 #endif
 
-typedef struct
-{
-  __off_t __pos;
-  __mbstate_t __state;
-} _G_fpos_t;
-typedef struct
-{
-  __off64_t __pos;
-  __mbstate_t __state;
-} _G_fpos64_t;
+
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 # include <gconv.h>
 typedef union
diff --git a/include/bits/types/__fpos64_t.h b/include/bits/types/__fpos64_t.h
new file mode 100644
index 0000000..68cc4e8
--- /dev/null
+++ b/include/bits/types/__fpos64_t.h
@@ -0,0 +1 @@
+#include <libio/bits/types/__fpos64_t.h>
diff --git a/include/bits/types/__fpos_t.h b/include/bits/types/__fpos_t.h
new file mode 100644
index 0000000..2dcdc98
--- /dev/null
+++ b/include/bits/types/__fpos_t.h
@@ -0,0 +1 @@
+#include <libio/bits/types/__fpos_t.h>
diff --git a/include/bits/types/cookie_io_functions_t.h b/include/bits/types/cookie_io_functions_t.h
new file mode 100644
index 0000000..87f7930
--- /dev/null
+++ b/include/bits/types/cookie_io_functions_t.h
@@ -0,0 +1 @@
+#include <libio/bits/types/cookie_io_functions_t.h>
diff --git a/libio/Makefile b/libio/Makefile
index 6eb03ab..b0cf4d4 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -25,7 +25,8 @@ 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/FILE.h bits/types/__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      \
diff --git a/libio/bits/libio.h b/libio/bits/libio.h
index 485b457..05668c4 100644
--- a/libio/bits/libio.h
+++ b/libio/bits/libio.h
@@ -32,10 +32,12 @@
 # error "Never include <bits/libio.h> directly; use <stdio.h> instead."
 #endif
 
+#include <stdio.h>
+
 #include <bits/_G_config.h>
 /* ALL of these should be defined in _G_config.h */
-#define _IO_fpos_t _G_fpos_t
-#define _IO_fpos64_t _G_fpos64_t
+#define _IO_fpos_t __fpos_t
+#define _IO_fpos64_t __fpos64_t
 #define _IO_size_t size_t
 #define _IO_ssize_t __ssize_t
 #define _IO_off_t __off_t
@@ -44,40 +46,13 @@
 #define _IO_uid_t __uid_t
 #define _IO_iconv_t _G_iconv_t
 #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
-#define _IO_BUFSIZ _G_BUFSIZ
-#define _IO_va_list _G_va_list
+#define _IO_BUFSIZ BUFSIZ
 #define _IO_wint_t wint_t
+#define _IO_va_list __gnuc_va_list
 
-/* This define avoids name pollution if we're using GNU stdarg.h */
-#define __need___va_list
-#include <stdarg.h>
-#ifdef __GNUC_VA_LIST
-# undef _IO_va_list
-# define _IO_va_list __gnuc_va_list
-#endif /* __GNUC_VA_LIST */
-
-#ifndef __P
-# include <sys/cdefs.h>
-#endif /*!__P*/
-
+#define _STDIO_USES_IOSTREAM
 #define _IO_UNIFIED_JUMPTABLES 1
 
-#ifndef EOF
-# define EOF (-1)
-#endif
-#ifndef NULL
-# if defined __GNUG__ && \
-    (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 8))
-#  define NULL (__null)
-# else
-#  if !defined(__cplusplus)
-#   define NULL ((void*)0)
-#  else
-#   define NULL (0)
-#  endif
-# endif
-#endif
-
 #define _IOS_INPUT	1
 #define _IOS_OUTPUT	2
 #define _IOS_ATEND	4
@@ -330,49 +305,13 @@ extern _IO_FILE *_IO_stderr attribute_hidden;
 #endif
 
 
-/* Functions to do I/O and file management for a stream.  */
-
-/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.
-   Return number of bytes read.  */
-typedef __ssize_t __io_read_fn (void *__cookie, char *__buf, size_t __nbytes);
-
-/* Write N bytes pointed to by BUF to COOKIE.  Write all N bytes
-   unless there is an error.  Return number of bytes written.  If
-   there is an error, return 0 and do not write anything.  If the file
-   has been opened for append (__mode.__append set), then set the file
-   pointer to the end of the file and then do the write; if not, just
-   write at the current file pointer.  */
-typedef __ssize_t __io_write_fn (void *__cookie, const char *__buf,
-				 size_t __n);
-
-/* Move COOKIE's file position to *POS bytes from the
-   beginning of the file (if W is SEEK_SET),
-   the current position (if W is SEEK_CUR),
-   or the end of the file (if W is SEEK_END).
-   Set *POS to the new file position.
-   Returns zero if successful, nonzero if not.  */
-typedef int __io_seek_fn (void *__cookie, _IO_off64_t *__pos, int __w);
-
-/* Close COOKIE.  */
-typedef int __io_close_fn (void *__cookie);
-
-
+/* Compatibility names for cookie I/O functions.  */
 #ifdef __USE_GNU
-/* User-visible names for the above.  */
-typedef __io_read_fn cookie_read_function_t;
-typedef __io_write_fn cookie_write_function_t;
-typedef __io_seek_fn cookie_seek_function_t;
-typedef __io_close_fn cookie_close_function_t;
-
-/* The structure with the cookie function pointers.  */
-typedef struct
-{
-  __io_read_fn *read;		/* Read bytes.  */
-  __io_write_fn *write;		/* Write bytes.  */
-  __io_seek_fn *seek;		/* Seek/tell file position.  */
-  __io_close_fn *close;		/* Close file.  */
-} _IO_cookie_io_functions_t;
-typedef _IO_cookie_io_functions_t cookie_io_functions_t;
+typedef cookie_read_function_t __io_read_fn;
+typedef cookie_write_function_t __io_write_fn;
+typedef cookie_seek_function_t __io_seek_fn;
+typedef cookie_close_function_t __io_close_fn;
+typedef cookie_io_functions_t _IO_cookie_io_functions_t;
 
 struct _IO_cookie_file;
 
diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h
index 21ad2fb..601fc27 100644
--- a/libio/bits/stdio.h
+++ b/libio/bits/stdio.h
@@ -33,7 +33,7 @@
 # if !(__USE_FORTIFY_LEVEL > 0 && defined __fortify_function)
 /* Write formatted output to stdout from argument list ARG.  */
 __STDIO_INLINE int
-vprintf (const char *__restrict __fmt, _G_va_list __arg)
+vprintf (const char *__restrict __fmt, __gnuc_va_list __arg)
 {
   return vfprintf (stdout, __fmt, __arg);
 }
@@ -111,7 +111,7 @@ putchar_unlocked (int __c)
 
 # ifdef	__USE_GNU
 /* Like `getdelim', but reads up to a newline.  */
-__STDIO_INLINE _IO_ssize_t
+__STDIO_INLINE __ssize_t
 getline (char **__lineptr, size_t *__n, FILE *__stream)
 {
   return __getdelim (__lineptr, __n, '\n', __stream);
diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h
index e9f9d69..16fd38a 100644
--- a/libio/bits/stdio2.h
+++ b/libio/bits/stdio2.h
@@ -24,7 +24,7 @@ extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
 			  const char *__restrict __format, ...) __THROW;
 extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
 			   const char *__restrict __format,
-			   _G_va_list __ap) __THROW;
+			   __gnuc_va_list __ap) __THROW;
 
 #ifdef __va_arg_pack
 __fortify_function int
@@ -41,7 +41,7 @@ __NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
 
 __fortify_function int
 __NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
-		 _G_va_list __ap))
+		 __gnuc_va_list __ap))
 {
   return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
 				   __bos (__s), __fmt, __ap);
@@ -54,7 +54,7 @@ extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
 			   ...) __THROW;
 extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
 			    size_t __slen, const char *__restrict __format,
-			    _G_va_list __ap) __THROW;
+			    __gnuc_va_list __ap) __THROW;
 
 # ifdef __va_arg_pack
 __fortify_function int
@@ -72,7 +72,7 @@ __NTH (snprintf (char *__restrict __s, size_t __n,
 
 __fortify_function int
 __NTH (vsnprintf (char *__restrict __s, size_t __n,
-		  const char *__restrict __fmt, _G_va_list __ap))
+		  const char *__restrict __fmt, __gnuc_va_list __ap))
 {
   return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
 				    __bos (__s), __fmt, __ap);
@@ -86,9 +86,9 @@ extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
 			  const char *__restrict __format, ...);
 extern int __printf_chk (int __flag, const char *__restrict __format, ...);
 extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
-			   const char *__restrict __format, _G_va_list __ap);
+			   const char *__restrict __format, __gnuc_va_list __ap);
 extern int __vprintf_chk (int __flag, const char *__restrict __format,
-			  _G_va_list __ap);
+			  __gnuc_va_list __ap);
 
 # ifdef __va_arg_pack
 __fortify_function int
@@ -111,7 +111,7 @@ printf (const char *__restrict __fmt, ...)
 # endif
 
 __fortify_function int
-vprintf (const char *__restrict __fmt, _G_va_list __ap)
+vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
 {
 #ifdef __USE_EXTERN_INLINES
   return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
@@ -122,7 +122,7 @@ vprintf (const char *__restrict __fmt, _G_va_list __ap)
 
 __fortify_function int
 vfprintf (FILE *__restrict __stream,
-	  const char *__restrict __fmt, _G_va_list __ap)
+	  const char *__restrict __fmt, __gnuc_va_list __ap)
 {
   return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
 }
@@ -131,7 +131,7 @@ vfprintf (FILE *__restrict __stream,
 extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
 			  ...) __attribute__ ((__format__ (__printf__, 3, 4)));
 extern int __vdprintf_chk (int __fd, int __flag,
-			   const char *__restrict __fmt, _G_va_list __arg)
+			   const char *__restrict __fmt, __gnuc_va_list __arg)
      __attribute__ ((__format__ (__printf__, 3, 0)));
 
 #  ifdef __va_arg_pack
@@ -147,7 +147,7 @@ dprintf (int __fd, const char *__restrict __fmt, ...)
 #  endif
 
 __fortify_function int
-vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap)
+vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
 {
   return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
 }
@@ -159,7 +159,7 @@ extern int __asprintf_chk (char **__restrict __ptr, int __flag,
 			   const char *__restrict __fmt, ...)
      __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur;
 extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
-			    const char *__restrict __fmt, _G_va_list __arg)
+			    const char *__restrict __fmt, __gnuc_va_list __arg)
      __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur;
 extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
 				 int __flag, const char *__restrict __format,
@@ -168,7 +168,7 @@ extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
 extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
 				  int __flag,
 				  const char *__restrict __format,
-				  _G_va_list __args)
+				  __gnuc_va_list __args)
      __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
 
 #  ifdef __va_arg_pack
@@ -205,14 +205,14 @@ __NTH (obstack_printf (struct obstack *__restrict __obstack,
 
 __fortify_function int
 __NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
-		  _G_va_list __ap))
+		  __gnuc_va_list __ap))
 {
   return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
 }
 
 __fortify_function int
 __NTH (obstack_vprintf (struct obstack *__restrict __obstack,
-			const char *__restrict __fmt, _G_va_list __ap))
+			const char *__restrict __fmt, __gnuc_va_list __ap))
 {
   return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
 				__ap);
diff --git a/libio/bits/types/__fpos64_t.h b/libio/bits/types/__fpos64_t.h
new file mode 100644
index 0000000..dbfdd1f
--- /dev/null
+++ b/libio/bits/types/__fpos64_t.h
@@ -0,0 +1,13 @@
+#ifndef _____fpos64_t_defined
+#define _____fpos64_t_defined 1
+
+#include <bits/types.h>
+#include <bits/types/__mbstate_t.h>
+
+typedef struct
+{
+  __off64_t __pos;
+  __mbstate_t __state;
+} __fpos64_t;
+
+#endif
diff --git a/libio/bits/types/__fpos_t.h b/libio/bits/types/__fpos_t.h
new file mode 100644
index 0000000..dd00762
--- /dev/null
+++ b/libio/bits/types/__fpos_t.h
@@ -0,0 +1,13 @@
+#ifndef _____fpos_t_defined
+#define _____fpos_t_defined 1
+
+#include <bits/types.h>
+#include <bits/types/__mbstate_t.h>
+
+typedef struct
+{
+  __off_t __pos;
+  __mbstate_t __state;
+} __fpos_t;
+
+#endif
diff --git a/libio/bits/types/cookie_io_functions_t.h b/libio/bits/types/cookie_io_functions_t.h
new file mode 100644
index 0000000..2942f85
--- /dev/null
+++ b/libio/bits/types/cookie_io_functions_t.h
@@ -0,0 +1,41 @@
+#ifndef __cookie_io_functions_t_defined
+#define __cookie_io_functions_t_defined 1
+
+#include <bits/types.h>
+
+/* Functions to do I/O and file management for a stream.  */
+
+/* Read NBYTES bytes from COOKIE into a buffer pointed to by BUF.
+   Return number of bytes read.  */
+typedef __ssize_t cookie_read_function_t (void *__cookie, char *__buf, size_t __nbytes);
+
+/* Write NBYTES bytes pointed to by BUF to COOKIE.  Write all NBYTES bytes
+   unless there is an error.  Return number of bytes written.  If
+   there is an error, return 0 and do not write anything.  If the file
+   has been opened for append (__mode.__append set), then set the file
+   pointer to the end of the file and then do the write; if not, just
+   write at the current file pointer.  */
+typedef __ssize_t cookie_write_function_t (void *__cookie, const char *__buf,
+                                           size_t __nbytes);
+
+/* Move COOKIE's file position to *POS bytes from the
+   beginning of the file (if W is SEEK_SET),
+   the current position (if W is SEEK_CUR),
+   or the end of the file (if W is SEEK_END).
+   Set *POS to the new file position.
+   Returns zero if successful, nonzero if not.  */
+typedef int cookie_seek_function_t (void *__cookie, __off64_t *__pos, int __w);
+
+/* Close COOKIE.  */
+typedef int cookie_close_function_t (void *__cookie);
+
+/* The structure with the cookie function pointers.  */
+typedef struct
+{
+  cookie_read_function_t *read;		/* Read bytes.  */
+  cookie_write_function_t *write;	/* Write bytes.  */
+  cookie_seek_function_t *seek;		/* Seek/tell file position.  */
+  cookie_close_function_t *close;	/* Close file.  */
+} cookie_io_functions_t;
+
+#endif
diff --git a/libio/stdio.h b/libio/stdio.h
index 6798cf1..8cf6412 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -32,18 +32,23 @@ __BEGIN_DECLS
 #define __need_NULL
 #include <stddef.h>
 
+#define __need___va_list
+#include <stdarg.h>
+
 #include <bits/types.h>
+#include <bits/types/__fpos_t.h>
+#include <bits/types/__fpos64_t.h>
 #include <bits/types/__FILE.h>
 #include <bits/types/FILE.h>
 
-#define _STDIO_USES_IOSTREAM
-
-#include <bits/libio.h>
+#ifdef __USE_GNU
+# include <bits/types/cookie_io_functions_t.h>
+#endif
 
 #if defined __USE_XOPEN || defined __USE_XOPEN2K8
 # ifdef __GNUC__
 #  ifndef _VA_LIST_DEFINED
-typedef _G_va_list va_list;
+typedef __gnuc_va_list va_list;
 #   define _VA_LIST_DEFINED
 #  endif
 # else
@@ -75,12 +80,12 @@ typedef __ssize_t ssize_t;
 
 /* The type of the second argument to `fgetpos' and `fsetpos'.  */
 #ifndef __USE_FILE_OFFSET64
-typedef _G_fpos_t fpos_t;
+typedef __fpos_t fpos_t;
 #else
-typedef _G_fpos64_t fpos_t;
+typedef __fpos64_t fpos_t;
 #endif
 #ifdef __USE_LARGEFILE64
-typedef _G_fpos64_t fpos64_t;
+typedef __fpos64_t fpos64_t;
 #endif
 
 /* The possibilities for the third argument to `setvbuf'.  */
@@ -90,16 +95,11 @@ typedef _G_fpos64_t fpos64_t;
 
 
 /* Default buffer size.  */
-#ifndef BUFSIZ
-# define BUFSIZ _IO_BUFSIZ
-#endif
+#define BUFSIZ 8192
 
 
-/* End of file character.
-   Some things throughout the library rely on this being -1.  */
-#ifndef EOF
-# define EOF (-1)
-#endif
+/* End of file character.  */
+#define EOF (-1)
 
 
 /* The possibilities for the third argument to `fseek'.
@@ -132,9 +132,9 @@ typedef _G_fpos64_t fpos64_t;
 
 
 /* Standard streams.  */
-extern struct _IO_FILE *stdin;		/* Standard input stream.  */
-extern struct _IO_FILE *stdout;		/* Standard output stream.  */
-extern struct _IO_FILE *stderr;		/* Standard error output stream.  */
+extern FILE *stdin;		/* Standard input stream.  */
+extern FILE *stdout;		/* Standard output stream.  */
+extern FILE *stderr;		/* Standard error output stream.  */
 /* C89/C99 say they're macros.  Make them happy.  */
 #define stdin stdin
 #define stdout stdout
@@ -270,7 +270,7 @@ extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
    and uses the given functions for input and output.  */
 extern FILE *fopencookie (void *__restrict __magic_cookie,
 			  const char *__restrict __modes,
-			  _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
+			  cookie_io_functions_t __io_funcs) __THROW __wur;
 #endif
 
 #if defined __USE_XOPEN2K8 || __GLIBC_USE (LIB_EXT2)
@@ -325,15 +325,15 @@ extern int sprintf (char *__restrict __s,
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
 extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
-		     _G_va_list __arg);
+		     __gnuc_va_list __arg);
 /* Write formatted output to stdout from argument list ARG.
 
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
-extern int vprintf (const char *__restrict __format, _G_va_list __arg);
+extern int vprintf (const char *__restrict __format, __gnuc_va_list __arg);
 /* Write formatted output to S from argument list ARG.  */
 extern int vsprintf (char *__restrict __s, const char *__restrict __format,
-		     _G_va_list __arg) __THROWNL;
+		     __gnuc_va_list __arg) __THROWNL;
 
 #if defined __USE_ISOC99 || defined __USE_UNIX98
 /* Maximum chars of output to write in MAXLEN.  */
@@ -342,7 +342,7 @@ extern int snprintf (char *__restrict __s, size_t __maxlen,
      __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
 
 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)
      __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
 #endif
 
@@ -350,7 +350,7 @@ extern int vsnprintf (char *__restrict __s, size_t __maxlen,
 /* Write formatted output to a string dynamically allocated with `malloc'.
    Store the address of the string in *PTR.  */
 extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
-		      _G_va_list __arg)
+		      __gnuc_va_list __arg)
      __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
 extern int __asprintf (char **__restrict __ptr,
 		       const char *__restrict __fmt, ...)
@@ -363,7 +363,7 @@ extern int asprintf (char **__restrict __ptr,
 #ifdef __USE_XOPEN2K8
 /* Write formatted output to a file descriptor.  */
 extern int vdprintf (int __fd, const char *__restrict __fmt,
-		     _G_va_list __arg)
+		     __gnuc_va_list __arg)
      __attribute__ ((__format__ (__printf__, 2, 0)));
 extern int dprintf (int __fd, const char *__restrict __fmt, ...)
      __attribute__ ((__format__ (__printf__, 2, 3)));
@@ -418,19 +418,19 @@ extern int __isoc99_sscanf (const char *__restrict __s,
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
 extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
-		    _G_va_list __arg)
+		    __gnuc_va_list __arg)
      __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
 
 /* Read formatted input from stdin into argument list ARG.
 
    This function is a possible cancellation point and therefore not
    marked with __THROW.  */
-extern int vscanf (const char *__restrict __format, _G_va_list __arg)
+extern int vscanf (const char *__restrict __format, __gnuc_va_list __arg)
      __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
 
 /* Read formatted input from S into argument list ARG.  */
 extern int vsscanf (const char *__restrict __s,
-		    const char *__restrict __format, _G_va_list __arg)
+		    const char *__restrict __format, __gnuc_va_list __arg)
      __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
 
 # if !defined __USE_GNU \
@@ -442,26 +442,26 @@ extern int vsscanf (const char *__restrict __s,
    s, S or [.  */
 extern int __REDIRECT (vfscanf,
 		       (FILE *__restrict __s,
-			const char *__restrict __format, _G_va_list __arg),
+			const char *__restrict __format, __gnuc_va_list __arg),
 		       __isoc99_vfscanf)
      __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
 extern int __REDIRECT (vscanf, (const char *__restrict __format,
-				_G_va_list __arg), __isoc99_vscanf)
+				__gnuc_va_list __arg), __isoc99_vscanf)
      __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
 extern int __REDIRECT_NTH (vsscanf,
 			   (const char *__restrict __s,
 			    const char *__restrict __format,
-			    _G_va_list __arg), __isoc99_vsscanf)
+			    __gnuc_va_list __arg), __isoc99_vsscanf)
      __attribute__ ((__format__ (__scanf__, 2, 0)));
 #  else
 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;
 #   define vfscanf __isoc99_vfscanf
 #   define vscanf __isoc99_vscanf
 #   define vsscanf __isoc99_vsscanf
@@ -483,10 +483,6 @@ extern int getc (FILE *__stream);
    marked with __THROW.  */
 extern int getchar (void);
 
-/* The C standard explicitly says this is a macro, so we always do the
-   optimization for it.  */
-#define getc(_fp) _IO_getc (_fp)
-
 #ifdef __USE_POSIX199506
 /* These are defined in POSIX.1:1996.
 
@@ -523,10 +519,6 @@ extern int putc (int __c, FILE *__stream);
    marked with __THROW.  */
 extern int putchar (int __c);
 
-/* 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)
-
 #ifdef __USE_MISC
 /* Faster version when locking is not necessary.
 
@@ -600,12 +592,12 @@ extern char *fgets_unlocked (char *__restrict __s, int __n,
    cancellation point.  But due to similarity with an POSIX interface
    or due to the implementation they are cancellation points and
    therefore not marked with __THROW.  */
-extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
-			       size_t *__restrict __n, int __delimiter,
-			       FILE *__restrict __stream) __wur;
-extern _IO_ssize_t getdelim (char **__restrict __lineptr,
-			     size_t *__restrict __n, int __delimiter,
-			     FILE *__restrict __stream) __wur;
+extern __ssize_t __getdelim (char **__restrict __lineptr,
+                             size_t *__restrict __n, int __delimiter,
+                             FILE *__restrict __stream) __wur;
+extern __ssize_t getdelim (char **__restrict __lineptr,
+                           size_t *__restrict __n, int __delimiter,
+                           FILE *__restrict __stream) __wur;
 
 /* Like `getdelim', but reads up to a newline.
 
@@ -613,9 +605,9 @@ extern _IO_ssize_t getdelim (char **__restrict __lineptr,
    cancellation point.  But due to similarity with an POSIX interface
    or due to the implementation it is a cancellation point and
    therefore not marked with __THROW.  */
-extern _IO_ssize_t getline (char **__restrict __lineptr,
-			    size_t *__restrict __n,
-			    FILE *__restrict __stream) __wur;
+extern __ssize_t getline (char **__restrict __lineptr,
+                          size_t *__restrict __n,
+                          FILE *__restrict __stream) __wur;
 #endif
 
 
@@ -828,7 +820,7 @@ extern int obstack_printf (struct obstack *__restrict __obstack,
      __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
 extern int obstack_vprintf (struct obstack *__restrict __obstack,
 			    const char *__restrict __format,
-			    _G_va_list __args)
+			    __gnuc_va_list __args)
      __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
 #endif /* Use GNU.  */
 
@@ -853,6 +845,17 @@ extern void funlockfile (FILE *__stream) __THROW;
 # include <bits/getopt_posix.h>
 #endif
 
+/* Internal definitions used by optimizing inlines.  */
+#include <bits/libio.h>
+
+/* 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
diff --git a/stdio-common/vfprintf.c b/stdio-common/vfprintf.c
index e272237..c2d833c 100644
--- a/stdio-common/vfprintf.c
+++ b/stdio-common/vfprintf.c
@@ -39,13 +39,8 @@
    Beside this it is also shared between the normal and wide character
    implementation as defined in ISO/IEC 9899:1990/Amendment 1:1995.  */
 
-
 #include <libioP.h>
-#define FILE		_IO_FILE
-#undef va_list
-#define va_list	_IO_va_list
-#undef BUFSIZ
-#define BUFSIZ		_IO_BUFSIZ
+
 /* In some cases we need extra space for all the output which is not
    counted in the width of the string. We assume 32 characters is
    enough.  */
diff --git a/sysdeps/unix/sysv/linux/bits/_G_config.h b/sysdeps/unix/sysv/linux/bits/_G_config.h
index 9994869..3381502 100644
--- a/sysdeps/unix/sysv/linux/bits/_G_config.h
+++ b/sysdeps/unix/sysv/linux/bits/_G_config.h
@@ -19,20 +19,16 @@
 #include <stddef.h>
 
 #include <bits/types/__mbstate_t.h>
+#include <bits/types/__fpos_t.h>
+#include <bits/types/__fpos64_t.h>
+
+#define _G_fpos_t __fpos_t
+#define _G_fpos64_t __fpos64_t
+
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 # include <bits/types/wint_t.h>
 #endif
 
-typedef struct
-{
-  __off_t __pos;
-  __mbstate_t __state;
-} _G_fpos_t;
-typedef struct
-{
-  __off64_t __pos;
-  __mbstate_t __state;
-} _G_fpos64_t;
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 # include <gconv.h>
 typedef union

http://sourceware.org/git/gitweb.cgi?p=glibc.git;a=commitdiff;h=4900e9832e0e1977d4db125b36588b9e8c85b0f2

commit 4900e9832e0e1977d4db125b36588b9e8c85b0f2
Author: Zack Weinberg <zackw@panix.com>
Date:   Mon Dec 25 10:41:27 2017 -0800

    Reduce use of libioP.h and iolibio.h outside the stdio implementation.
    
    There are a lot of files outside the stdio implementation that use
    either libioP.h or iolibio.h.  Some of these are actually reaching
    into the guts of stdio, usually either to work around ISO C's
    semantics for stream orientation, or to take greater control of
    locking, and I haven't touched any of that.  However, many more are
    just doing PLT bypass by hand.  This patch changes those files to do
    proper PLT bypass via include/stdio.h.
    
    Please carefully review my use of the ldbl_*/libc_* distinction, which
    I do not fully understand; it might be necessary to introduce
    ldbl_hidden_weak, which we don't currently have.
    
    Also note that this is not meant to be a thorough cleanup of __foo vs
    foo, even in cases where the unadorned name is in C89.  I just picked
    whichever symbol was already available via include/stdio.h, or, when
    neither was available, whichever one was already in use.
    
    	* include/bits/libio.h: Only include libio/bits/libio.h.
    	All other contents moved...
    	* include/stdio.h: ...here.  Also: include math_ldbl_opt.h; add
    	libc_hidden_proto tags (and prototypes if necessary) for __vsnprintf,
    	__getdelim, __vasprintf, vsprintf, fread, ftell, setvbuf; add macro
    	redirections for flockfile, funlockfile, and putc.
    
    	* libio/iofread.c: Add libc_hidden_weak for fread.
    	* libio/ioftell.c: Add libc_hidden_weak for ftell.
    	* libio/iogetdelim.c: Add libc_hidden_weak for __getdelim.
    	* libio/iosetvbuf.c: Add libc_hidden_weak for setvbuf.
    	* libio/iovsprintf.c: Add libc_hidden_weak for vsprintf.
    	* libio/iovsscanf.c: Add libc_hidden_weak for __vsscanf.
    	* libio/vasprintf.c: Add ldbl_strong_alias for __vasprintf.
    	* libio/vsnprintf.c: Add libc_hidden_weak for __vsnprintf.
    
    	* argp/argp-fmtstream.c, argp/argp-help.c, assert/assert.c
    	* grp/fgetgrent_r.c, grp/putgrent.c, gshadow/fgetsgent_r.c
    	* gshadow/putsgent.c, iconv/gconv_conf.c, malloc/malloc.c
    	* malloc/mtrace.c, malloc/obstack.c, misc/err.c, misc/getpass.c
    	* misc/getttyent.c, misc/mntent_r.c, misc/syslog.c, posix/getopt.c
    	* pwd/fgetpwent_r.c, shadow/fgetspent_r.c, shadow/putspent.c
    	* stdio-common/asprintf.c, stdio-common/fprintf.c
    	* stdio-common/fscanf.c, stdio-common/getline.c, stdio-common/getw.c
    	* stdio-common/isoc99_sscanf.c, stdio-common/perror.c
    	* stdio-common/printf.c, stdio-common/putw.c, stdio-common/scanf.c
    	* stdio-common/snprintf.c, stdio-common/sprintf.c
    	* stdio-common/sscanf.c, stdio-common/tmpfile.c, stdio-common/vprintf.c
    	* sunrpc/clnt_perr.c, sunrpc/openchild.c, sunrpc/svc_simple.c
    	* sunrpc/svc_tcp.c, sunrpc/svc_udp.c, sunrpc/xdr_rec.c
    	* sunrpc/xdr_ref.c, sunrpc/xdr_stdio.c
    	* sysdeps/ieee754/ldbl-opt/nldbl-compat.c, sysdeps/mach/hurd/tmpfile.c
    	* sysdeps/unix/sysv/linux/readonly-area.c:
    	Don't include libioP.h or iolibio.h.
    	Don't macro-redirect any of __getdelim, __fdopen, __vsnprintf,
    	__vsscanf, vsprintf, fflush, fread, flockfile, funlockfile, ftell,
    	fwrite, putc, setvbuf, or ssize_t.
    	Use __vasprintf instead of _IO_vasprintf or vasprintf;
    	flockfile instead of _IO_flockfile;
    	funlockfile instead of _IO_funlockfile;
    	fdopen instead of __fdopen.
    	* argp/argp-help.c: Include wchar.h unconditionally.
    	* stdlib/strfmon_l.c: Move private libio includes below standard includes.

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index f12c265..eeb7520 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -41,8 +41,6 @@
 
 #ifdef _LIBC
 # include <wchar.h>
-# include <libio/libioP.h>
-# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
 #endif
 
 #define INIT_BUF_SIZE 200
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 821d98c..ab8eeb9 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -48,10 +48,7 @@ char *alloca ();
 #include <stdarg.h>
 #include <ctype.h>
 #include <limits.h>
-#ifdef _LIBC
-# include <../libio/libioP.h>
-# include <wchar.h>
-#endif
+#include <wchar.h>
 
 #ifndef _
 /* This is for other GNU distributions with internationalized messages.  */
@@ -1769,7 +1766,7 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)
 #ifdef _LIBC
 	  char *buf;
 
-	  if (_IO_vasprintf (&buf, fmt, ap) < 0)
+	  if (__vasprintf (&buf, fmt, ap) < 0)
 	    buf = NULL;
 
 	  __fxprintf (stream, "%s: %s\n",
@@ -1839,7 +1836,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
 #ifdef _LIBC
 	      char *buf;
 
-	      if (_IO_vasprintf (&buf, fmt, ap) < 0)
+	      if (__vasprintf (&buf, fmt, ap) < 0)
 		buf = NULL;
 
 	      __fxprintf (stream, ": %s", buf);
diff --git a/assert/assert.c b/assert/assert.c
index 57d9644..efd9f69 100644
--- a/assert/assert.c
+++ b/assert/assert.c
@@ -24,14 +24,10 @@
 #include <sysdep.h>
 #include <unistd.h>
 #include <sys/mman.h>
-
+#include <wchar.h>
 
 extern const char *__progname;
 
-#include <wchar.h>
-#include <libio/iolibio.h>
-#define fflush(s) _IO_fflush (s)
-
 /* This function, when passed a string containing an asserted
    expression, a filename, and a line number, prints a message
    on the standard error stream of the form:
diff --git a/grp/fgetgrent_r.c b/grp/fgetgrent_r.c
index 5a4107b..7bcbdfe 100644
--- a/grp/fgetgrent_r.c
+++ b/grp/fgetgrent_r.c
@@ -20,10 +20,6 @@
 #include <grp.h>
 #include <stdio.h>
 
-#include <libio/iolibio.h>
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 /* Define a line parsing function using the common code
    used in the nss_files module.  */
 
diff --git a/grp/putgrent.c b/grp/putgrent.c
index 5a12c70..cd3588d 100644
--- a/grp/putgrent.c
+++ b/grp/putgrent.c
@@ -21,9 +21,6 @@
 #include <string.h>
 #include <grp.h>
 
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 #define _S(x)	x ? x : ""
 
 /* Write an entry to the given stream.
diff --git a/gshadow/fgetsgent_r.c b/gshadow/fgetsgent_r.c
index f1d0650..95c21e9 100644
--- a/gshadow/fgetsgent_r.c
+++ b/gshadow/fgetsgent_r.c
@@ -38,21 +38,21 @@ __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
 {
   char *p;
 
-  _IO_flockfile (stream);
+  flockfile (stream);
   do
     {
       buffer[buflen - 1] = '\xff';
       p = fgets_unlocked (buffer, buflen, stream);
       if (p == NULL && feof_unlocked (stream))
 	{
-	  _IO_funlockfile (stream);
+	  funlockfile (stream);
 	  *result = NULL;
 	  __set_errno (ENOENT);
 	  return errno;
 	}
       if (p == NULL || buffer[buflen - 1] != '\xff')
 	{
-	  _IO_funlockfile (stream);
+	  funlockfile (stream);
 	  *result = NULL;
 	  __set_errno (ERANGE);
 	  return errno;
@@ -67,7 +67,7 @@ __fgetsgent_r (FILE *stream, struct sgrp *resbuf, char *buffer, size_t buflen,
 	     ! parse_line (buffer, (void *) resbuf, (void *) buffer, buflen,
 			   &errno));
 
-  _IO_funlockfile (stream);
+  funlockfile (stream);
 
   *result = resbuf;
   return 0;
diff --git a/gshadow/putsgent.c b/gshadow/putsgent.c
index 4e219c4..70063d7 100644
--- a/gshadow/putsgent.c
+++ b/gshadow/putsgent.c
@@ -40,7 +40,7 @@ putsgent (const struct sgrp *g, FILE *stream)
       return -1;
     }
 
-  _IO_flockfile (stream);
+  flockfile (stream);
 
   if (fprintf (stream, "%s:%s:", g->sg_namp, _S (g->sg_passwd)) < 0)
     ++errors;
@@ -75,7 +75,7 @@ putsgent (const struct sgrp *g, FILE *stream)
   if (putc_unlocked ('\n', stream) == EOF)
     ++errors;
 
-  _IO_funlockfile (stream);
+  funlockfile (stream);
 
   return errors ? -1 : 0;
 }
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index f1c28ce..5e023c6 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -89,9 +89,6 @@ static const char builtin_aliases[] =
 #undef BUILTIN_ALIAS
 };
 
-#include <libio/libioP.h>
-#define __getdelim(line, len, c, fp) _IO_getdelim (line, len, c, fp)
-
 
 /* Value of the GCONV_PATH environment variable.  */
 const char *__gconv_path_envvar;
diff --git a/include/bits/libio.h b/include/bits/libio.h
index 572395d..40b6851 100644
--- a/include/bits/libio.h
+++ b/include/bits/libio.h
@@ -1,45 +1 @@
-#if !defined _ISOMAC && defined _IO_MTSAFE_IO
-# include <stdio-lock.h>
-#endif
 #include <libio/bits/libio.h>
-
-#ifndef _ISOMAC
-#ifndef _LIBC_LIBIO_H
-#define _LIBC_LIBIO_H
-
-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)
-
-#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_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)
-#  define _IO_funlockfile(_fp) \
-  if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
-# endif
-#endif /* _IO_MTSAFE_IO */
-
-#endif
-#endif
diff --git a/include/stdio.h b/include/stdio.h
index f1e987a..8c85807 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -1,7 +1,12 @@
 #ifndef _STDIO_H
+# if !defined _ISOMAC && defined _IO_MTSAFE_IO
+#  include <stdio-lock.h>
+# endif
 # include <libio/stdio.h>
 # ifndef _ISOMAC
 
+#  include <math_ldbl_opt.h>
+
 /* Now define the internal interfaces.  */
 
 extern int __fcloseall (void) attribute_hidden;
@@ -12,6 +17,7 @@ libc_hidden_proto (__snprintf)
 extern int __vsnprintf (char *__restrict __s, size_t __maxlen,
 			const char *__restrict __format, _G_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)
@@ -22,10 +28,15 @@ extern int __vscanf (const char *__restrict __format,
      __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);
+libc_hidden_proto (__getdelim)
+
 extern int __vsscanf (const char *__restrict __s,
 		      const char *__restrict __format,
 		      _G_va_list __arg)
      __attribute__ ((__format__ (__scanf__, 2, 0)));
+libc_hidden_proto (__vsscanf)
 
 extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW;
 extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...)
@@ -125,7 +136,6 @@ extern int __fxprintf_nocancel (FILE *__fp, const char *__fmt, ...)
 extern const char *const _sys_errlist_internal[] attribute_hidden;
 extern int _sys_nerr_internal attribute_hidden;
 
-libc_hidden_proto (__asprintf)
 #  if IS_IN (libc)
 extern _IO_FILE *_IO_new_fopen (const char*, const char*);
 #   define fopen(fname, mode) _IO_new_fopen (fname, mode)
@@ -142,6 +152,10 @@ extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
 #   define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp)
 #  endif
 
+libc_hidden_proto (__asprintf)
+extern __typeof (vasprintf) __vasprintf
+     __attribute__ ((__format__ (__printf__, 2, 0)));
+libc_hidden_proto (__vasprintf)
 libc_hidden_proto (dprintf)
 extern __typeof (dprintf) __dprintf
      __attribute__ ((__format__ (__printf__, 2, 3)));
@@ -149,6 +163,7 @@ libc_hidden_proto (__dprintf)
 libc_hidden_proto (fprintf)
 libc_hidden_proto (vfprintf)
 libc_hidden_proto (sprintf)
+libc_hidden_proto (vsprintf)
 libc_hidden_proto (sscanf)
 libc_hidden_proto (fwrite)
 libc_hidden_proto (perror)
@@ -157,11 +172,14 @@ libc_hidden_proto (rewind)
 libc_hidden_proto (fileno)
 extern __typeof (fileno) __fileno;
 libc_hidden_proto (__fileno)
+libc_hidden_proto (fread)
 libc_hidden_proto (fwrite)
 libc_hidden_proto (fseek)
+libc_hidden_proto (ftell)
 extern __typeof (ftello) __ftello;
 libc_hidden_proto (__ftello)
 libc_hidden_proto (fflush)
+libc_hidden_proto (setvbuf)
 libc_hidden_proto (fflush_unlocked)
 extern __typeof (fflush_unlocked) __fflush_unlocked;
 libc_hidden_proto (__fflush_unlocked)
@@ -194,5 +212,48 @@ libc_hidden_proto (__fmemopen)
 extern int __gen_tempfd (int flags);
 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)
+
+#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_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)
+#  define _IO_funlockfile(_fp) \
+  if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
+# 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
+
 # endif /* not _ISOMAC */
 #endif /* stdio.h */
diff --git a/libio/iofread.c b/libio/iofread.c
index 8bb948e..da77c55 100644
--- a/libio/iofread.c
+++ b/libio/iofread.c
@@ -42,6 +42,7 @@ _IO_fread (void *buf, _IO_size_t size, _IO_size_t count, _IO_FILE *fp)
 libc_hidden_def (_IO_fread)
 
 weak_alias (_IO_fread, fread)
+libc_hidden_weak (fread)
 
 # ifndef _IO_MTSAFE_IO
 strong_alias (_IO_fread, __fread_unlocked)
diff --git a/libio/ioftell.c b/libio/ioftell.c
index 09d2a11..035755c 100644
--- a/libio/ioftell.c
+++ b/libio/ioftell.c
@@ -58,3 +58,4 @@ _IO_ftell (_IO_FILE *fp)
 libc_hidden_def (_IO_ftell)
 
 weak_alias (_IO_ftell, ftell)
+libc_hidden_weak (ftell)
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index 0fce4af..1354faf 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -125,3 +125,4 @@ unlock_return:
 
 weak_alias (_IO_getdelim, __getdelim)
 weak_alias (_IO_getdelim, getdelim)
+libc_hidden_weak (__getdelim)
diff --git a/libio/iosetvbuf.c b/libio/iosetvbuf.c
index eda49ab..7236c64 100644
--- a/libio/iosetvbuf.c
+++ b/libio/iosetvbuf.c
@@ -96,3 +96,4 @@ unlock_return:
 libc_hidden_def (_IO_setvbuf)
 
 weak_alias (_IO_setvbuf, setvbuf)
+libc_hidden_weak (setvbuf)
diff --git a/libio/iovsprintf.c b/libio/iovsprintf.c
index 80a2aee..63290fb 100644
--- a/libio/iovsprintf.c
+++ b/libio/iovsprintf.c
@@ -47,3 +47,4 @@ ldbl_hidden_def (__IO_vsprintf, _IO_vsprintf)
 
 ldbl_strong_alias (__IO_vsprintf, _IO_vsprintf)
 ldbl_weak_alias (__IO_vsprintf, vsprintf)
+libc_hidden_weak (vsprintf)
diff --git a/libio/iovsscanf.c b/libio/iovsscanf.c
index ae87a1f..b96ad6b 100644
--- a/libio/iovsscanf.c
+++ b/libio/iovsscanf.c
@@ -42,4 +42,5 @@ _IO_vsscanf (const char *string, const char *format, _IO_va_list args)
   return ret;
 }
 ldbl_weak_alias (_IO_vsscanf, __vsscanf)
+libc_hidden_weak (__vsscanf)
 ldbl_weak_alias (_IO_vsscanf, vsscanf)
diff --git a/libio/vasprintf.c b/libio/vasprintf.c
index a9a2154..cf7ad0a 100644
--- a/libio/vasprintf.c
+++ b/libio/vasprintf.c
@@ -85,4 +85,5 @@ _IO_vasprintf (char **result_ptr, const char *format, _IO_va_list args)
   (*result_ptr)[needed - 1] = '\0';
   return ret;
 }
+ldbl_strong_alias (_IO_vasprintf, __vasprintf)
 ldbl_weak_alias (_IO_vasprintf, vasprintf)
diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c
index 0e93c36..8a8a34e 100644
--- a/libio/vsnprintf.c
+++ b/libio/vsnprintf.c
@@ -119,3 +119,4 @@ _IO_vsnprintf (char *string, _IO_size_t maxlen, const char *format,
 }
 ldbl_weak_alias (_IO_vsnprintf, __vsnprintf)
 ldbl_weak_alias (_IO_vsnprintf, vsnprintf)
+libc_hidden_weak (__vsnprintf)
diff --git a/malloc/malloc.c b/malloc/malloc.c
index 0c9e074..6253fbe 100644
--- a/malloc/malloc.c
+++ b/malloc/malloc.c
@@ -4962,7 +4962,7 @@ __malloc_stats (void)
 
   if (__malloc_initialized < 0)
     ptmalloc_init ();
-  _IO_flockfile (stderr);
+  flockfile (stderr);
   int old_flags2 = ((_IO_FILE *) stderr)->_flags2;
   ((_IO_FILE *) stderr)->_flags2 |= _IO_FLAGS2_NOTCANCEL;
   for (i = 0, ar_ptr = &main_arena;; i++)
@@ -4993,7 +4993,7 @@ __malloc_stats (void)
   fprintf (stderr, "max mmap bytes   = %10lu\n",
            (unsigned long) mp_.max_mmapped_mem);
   ((_IO_FILE *) stderr)->_flags2 |= old_flags2;
-  _IO_funlockfile (stderr);
+  funlockfile (stderr);
 }
 
 
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 9eb2f5f..f7a4a1a 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -35,11 +35,6 @@
 
 #include <libc-internal.h>
 #include <dso_handle.h>
-
-#include <libio/iolibio.h>
-#define setvbuf(s, b, f, l) _IO_setvbuf (s, b, f, l)
-#define fwrite(buf, size, count, fp) _IO_fwrite (buf, size, count, fp)
-
 #include <kernel-features.h>
 
 #define TRACE_BUFFER_SIZE 512
diff --git a/malloc/obstack.c b/malloc/obstack.c
index 4ac8938..c28a973 100644
--- a/malloc/obstack.c
+++ b/malloc/obstack.c
@@ -400,10 +400,6 @@ _obstack_memory_used (struct obstack *h)
 #  define _(msgid) gettext (msgid)
 # endif
 
-# ifdef _LIBC
-#  include <libio/iolibio.h>
-# endif
-
 static _Noreturn void
 print_and_abort (void)
 {
diff --git a/misc/err.c b/misc/err.c
index 3da4e9d..d96778a 100644
--- a/misc/err.c
+++ b/misc/err.c
@@ -22,10 +22,8 @@
 #include <errno.h>
 #include <string.h>
 #include <stdio.h>
-
 #include <wchar.h>
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
+
 
 extern char *__progname;
 
diff --git a/misc/error.c b/misc/error.c
index 1d960be..de11b7a 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -67,7 +67,6 @@ unsigned int error_message_count;
 # define program_name program_invocation_name
 # include <errno.h>
 # include <limits.h>
-# include <libio/libioP.h>
 
 /* In GNU libc we want do not want to use the common name 'error' directly.
    Instead make it a weak alias.  */
@@ -80,11 +79,6 @@ extern void __error_at_line (int status, int errnum, const char *file_name,
 # define error __error
 # define error_at_line __error_at_line
 
-# include <libio/iolibio.h>
-# define fflush(s) _IO_fflush (s)
-# undef putc
-# define putc(c, fp) _IO_putc (c, fp)
-
 # include <libc-lock.h>
 
 #else /* not _LIBC */
@@ -304,7 +298,7 @@ error (int status, int errnum, const char *message, ...)
 
   flush_stdout ();
 #ifdef _LIBC
-  _IO_flockfile (stderr);
+  flockfile (stderr);
 #endif
   if (error_print_progname)
     (*error_print_progname) ();
@@ -321,7 +315,7 @@ error (int status, int errnum, const char *message, ...)
   error_tail (status, errnum, message, args);
 
 #ifdef _LIBC
-  _IO_funlockfile (stderr);
+  funlockfile (stderr);
 # ifdef __libc_ptf_call
   __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0);
 # endif
@@ -367,7 +361,7 @@ error_at_line (int status, int errnum, const char *file_name,
 
   flush_stdout ();
 #ifdef _LIBC
-  _IO_flockfile (stderr);
+  flockfile (stderr);
 #endif
   if (error_print_progname)
     (*error_print_progname) ();
@@ -392,7 +386,7 @@ error_at_line (int status, int errnum, const char *file_name,
   error_tail (status, errnum, message, args);
 
 #ifdef _LIBC
-  _IO_funlockfile (stderr);
+  funlockfile (stderr);
 # ifdef __libc_ptf_call
   __libc_ptf_call (__pthread_setcancelstate, (state, NULL), 0);
 # endif
diff --git a/misc/getpass.c b/misc/getpass.c
index 89c783f..727db0a 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -20,10 +20,7 @@
 #include <string.h>		/* For string function builtin redirect.  */
 #include <termios.h>
 #include <unistd.h>
-
 #include <wchar.h>
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
 #include <libc-lock.h>
 
 /* It is desirable to use this bit on systems that have it.
diff --git a/misc/getttyent.c b/misc/getttyent.c
index 0fa4ddb..57bae5b 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -37,9 +37,6 @@ static char sccsid[] = "@(#)getttyent.c	8.1 (Berkeley) 6/4/93";
 #include <ctype.h>
 #include <string.h>
 
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 static char zapchar;
 static FILE *tf;
 
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 96bd1e2..0d1fb1a 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -23,9 +23,6 @@
 #include <string.h>
 #include <sys/types.h>
 
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 #undef __setmntent
 #undef __endmntent
 #undef __getmntent_r
diff --git a/misc/syslog.c b/misc/syslog.c
index 2b6bd37..bd86f35 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -53,13 +53,10 @@ static char sccsid[] = "@(#)syslog.c	8.4 (Berkeley) 3/18/94";
 
 #include <stdarg.h>
 
-#include <libio/iolibio.h>
 #include <math_ldbl_opt.h>
 
 #include <kernel-features.h>
 
-#define ftell(s) _IO_ftell (s)
-
 static int	LogType = SOCK_DGRAM;	/* type of socket connection */
 static int	LogFile = -1;		/* fd for log */
 static int	connected;		/* have done connect */
diff --git a/posix/getopt.c b/posix/getopt.c
index 543c8e7..43cc871 100644
--- a/posix/getopt.c
+++ b/posix/getopt.c
@@ -31,15 +31,11 @@
 #ifdef _LIBC
 /* When used as part of glibc, error printing must be done differently
    for standards compliance.  getopt is not a cancellation point, so
-   it must not call functions that are, and it is specified by an
-   older standard than stdio locking, so it must not refer to
-   functions in the "user namespace" related to stdio locking.
-   Finally, it must use glibc's internal message translation so that
-   the messages are looked up in the proper text domain.  */
+   it must not call functions that are, and it must use glibc's
+   internal message translation so that the messages are looked up in
+   the proper text domain.  */
 # include <libintl.h>
 # define fprintf __fxprintf_nocancel
-# define flockfile(fp) _IO_flockfile (fp)
-# define funlockfile(fp) _IO_funlockfile (fp)
 #else
 # include "gettext.h"
 # define _(msgid) gettext (msgid)
diff --git a/pwd/fgetpwent_r.c b/pwd/fgetpwent_r.c
index 8aa8f69..044f19b 100644
--- a/pwd/fgetpwent_r.c
+++ b/pwd/fgetpwent_r.c
@@ -20,9 +20,6 @@
 #include <stdio.h>
 #include <pwd.h>
 
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 /* Define a line parsing function using the common code
    used in the nss_files module.  */
 
diff --git a/shadow/fgetspent_r.c b/shadow/fgetspent_r.c
index 4210630..164c377 100644
--- a/shadow/fgetspent_r.c
+++ b/shadow/fgetspent_r.c
@@ -20,9 +20,6 @@
 #include <shadow.h>
 #include <stdio.h>
 
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 /* Define a line parsing function using the common code
    used in the nss_files module.  */
 
diff --git a/shadow/putspent.c b/shadow/putspent.c
index 5e27340..790b763 100644
--- a/shadow/putspent.c
+++ b/shadow/putspent.c
@@ -20,9 +20,6 @@
 #include <stdio.h>
 #include <shadow.h>
 
-#define flockfile(s) _IO_flockfile (s)
-#define funlockfile(s) _IO_funlockfile (s)
-
 #define _S(x)	x ? x : ""
 
 
diff --git a/stdio-common/asprintf.c b/stdio-common/asprintf.c
index a61cf64..593a30b 100644
--- a/stdio-common/asprintf.c
+++ b/stdio-common/asprintf.c
@@ -18,8 +18,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include <libioP.h>
-#define vasprintf(s, f, a) _IO_vasprintf (s, f, a)
 #undef __asprintf
 
 /* Write formatted output from FORMAT to a string which is
@@ -32,7 +30,7 @@ ___asprintf (char **string_ptr, const char *format, ...)
   int done;
 
   va_start (arg, format);
-  done = vasprintf (string_ptr, format, arg);
+  done = __vasprintf (string_ptr, format, arg);
   va_end (arg);
 
   return done;
diff --git a/stdio-common/fprintf.c b/stdio-common/fprintf.c
index 2bbaba8..149b6e5 100644
--- a/stdio-common/fprintf.c
+++ b/stdio-common/fprintf.c
@@ -17,7 +17,6 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <libioP.h>
 
 
 /* Write formatted output to STREAM from the format string FORMAT.  */
diff --git a/stdio-common/fscanf.c b/stdio-common/fscanf.c
index 019ce89..1440749 100644
--- a/stdio-common/fscanf.c
+++ b/stdio-common/fscanf.c
@@ -15,7 +15,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 
diff --git a/stdio-common/getline.c b/stdio-common/getline.c
index 1976dd9..d05e890 100644
--- a/stdio-common/getline.c
+++ b/stdio-common/getline.c
@@ -20,11 +20,6 @@
 
 #undef __getline
 
-#include "../libio/libioP.h"
-#undef ssize_t
-#define ssize_t _IO_ssize_t
-#define __getdelim _IO_getdelim
-
 /* Like getdelim, but always looks for a newline.  */
 ssize_t
 __getline (char **lineptr, size_t *n, FILE *stream)
diff --git a/stdio-common/getw.c b/stdio-common/getw.c
index f698707..580047d 100644
--- a/stdio-common/getw.c
+++ b/stdio-common/getw.c
@@ -17,9 +17,6 @@
 
 #include <stdio.h>
 
-#include <libio/iolibio.h>
-#define fread(p, m, n, s) _IO_fread (p, m, n, s)
-
 /* Read a word (int) from STREAM.  */
 int
 getw (FILE *stream)
diff --git a/stdio-common/isoc99_sscanf.c b/stdio-common/isoc99_sscanf.c
index 9242102..f065a61 100644
--- a/stdio-common/isoc99_sscanf.c
+++ b/stdio-common/isoc99_sscanf.c
@@ -17,7 +17,6 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <libioP.h>
 
 /* Read formatted input from S, according to the format string FORMAT.  */
 /* VARARGS2 */
diff --git a/stdio-common/perror.c b/stdio-common/perror.c
index d109c63..98cf1c4 100644
--- a/stdio-common/perror.c
+++ b/stdio-common/perror.c
@@ -20,7 +20,6 @@
 #include <string.h>
 #include <unistd.h>
 #include <wchar.h>
-#include "libioP.h"
 
 static void
 perror_internal (FILE *fp, const char *s, int errnum)
diff --git a/stdio-common/printf.c b/stdio-common/printf.c
index ba84064..638367b 100644
--- a/stdio-common/printf.c
+++ b/stdio-common/printf.c
@@ -15,7 +15,6 @@
    License along with the GNU C Library; if not, see
    <http://www.gnu.org/licenses/>.  */
 
-#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 
diff --git a/stdio-common/putw.c b/stdio-common/putw.c
index 2b0e6ad..76583cb 100644
--- a/stdio-common/putw.c
+++ b/stdio-common/putw.c
@@ -16,8 +16,6 @@
    <http://www.gnu.org/licenses/>.  */
 
 #include <stdio.h>
-#include <libio/iolibio.h>
-#define fwrite(p, n, m, s) _IO_fwrite (p, n, m, s)
 
 /* Write the word (int) W to STREAM.  */
 int
diff --git a/stdio-common/scanf.c b/stdio-common/scanf.c
index 3caddcb..385fba6 100644
--- a/stdio-common/scanf.c
+++ b/stdio-common/scanf.c
@@ -18,8 +18,6 @@
 #include <stdarg.h>
 #include <stdio.h>
 
-#include <libioP.h>
-
 
 /* Read formatted input from stdin according to the format string FORMAT.  */
 /* VARARGS1 */
diff --git a/stdio-common/snprintf.c b/stdio-common/snprintf.c
index 66bcd19..9397210 100644
--- a/stdio-common/snprintf.c
+++ b/stdio-common/snprintf.c
@@ -17,8 +17,6 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <libioP.h>
-#define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
 
 /* Write formatted output into S, according to the format
    string FORMAT, writing no more than MAXLEN characters.  */
diff --git a/stdio-common/sprintf.c b/stdio-common/sprintf.c
index 391c495..e576803 100644
--- a/stdio-common/sprintf.c
+++ b/stdio-common/sprintf.c
@@ -17,8 +17,6 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <libioP.h>
-#define vsprintf(s, f, a) _IO_vsprintf (s, f, a)
 
 /* Write formatted output into S, according to the format string FORMAT.  */
 /* VARARGS2 */
diff --git a/stdio-common/sscanf.c b/stdio-common/sscanf.c
index 63b9503..7122d92 100644
--- a/stdio-common/sscanf.c
+++ b/stdio-common/sscanf.c
@@ -17,8 +17,6 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <libioP.h>
-#define __vsscanf(s, f, a) _IO_vsscanf (s, f, a)
 
 /* Read formatted input from S, according to the format string FORMAT.  */
 /* VARARGS2 */
diff --git a/stdio-common/tmpfile.c b/stdio-common/tmpfile.c
index c5cbb68..72863a3 100644
--- a/stdio-common/tmpfile.c
+++ b/stdio-common/tmpfile.c
@@ -20,8 +20,6 @@
 #include <stdio.h>
 #include <unistd.h>
 
-#include <iolibio.h>
-#define __fdopen _IO_fdopen
 #ifndef tmpfile
 # define tmpfile __new_tmpfile
 #endif
@@ -60,7 +58,7 @@ tmpfile (void)
       (void) __unlink (buf);
     }
 
-  if ((f = __fdopen (fd, "w+b")) == NULL)
+  if ((f = fdopen (fd, "w+b")) == NULL)
     __close (fd);
 
   return f;
diff --git a/stdio-common/vprintf.c b/stdio-common/vprintf.c
index c5d8b84..71e0d9d 100644
--- a/stdio-common/vprintf.c
+++ b/stdio-common/vprintf.c
@@ -18,7 +18,6 @@
 #include <stdarg.h>
 #undef	__OPTIMIZE__	/* Avoid inline `vprintf' function.  */
 #include <stdio.h>
-#include <libioP.h>
 
 #undef	vprintf
 
diff --git a/stdlib/strfmon_l.c b/stdlib/strfmon_l.c
index 1df184e..5ce6dcf 100644
--- a/stdlib/strfmon_l.c
+++ b/stdlib/strfmon_l.c
@@ -22,12 +22,12 @@
 #include <langinfo.h>
 #include <locale.h>
 #include <monetary.h>
-#include "../libio/libioP.h"
-#include "../libio/strfile.h"
 #include <printf.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <string.h>
+#include "../libio/libioP.h"
+#include "../libio/strfile.h"
 #include "../locale/localeinfo.h"
 
 
diff --git a/sunrpc/clnt_perr.c b/sunrpc/clnt_perr.c
index cac1dd9..a1d6176 100644
--- a/sunrpc/clnt_perr.c
+++ b/sunrpc/clnt_perr.c
@@ -35,7 +35,6 @@
 #include <libintl.h>
 #include <rpc/rpc.h>
 #include <wchar.h>
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
 static char *auth_errmsg (enum auth_stat stat);
diff --git a/sunrpc/openchild.c b/sunrpc/openchild.c
index 29f274a..ae92707 100644
--- a/sunrpc/openchild.c
+++ b/sunrpc/openchild.c
@@ -41,10 +41,6 @@
 #include <rpc/rpc.h>
 #include <rpc/clnt.h>
 
-#include <libio/iolibio.h>
-#define fflush(s) _IO_fflush (s)
-#define __fdopen(fd,m) _IO_fdopen (fd,m)
-
 /*
  * returns pid, or -1 for failure
  */
@@ -85,9 +81,9 @@ _openchild (const char *command, FILE ** fto, FILE ** ffrom)
       /*
        * parent: write into pdto[1], read from pdfrom[0]
        */
-      *fto = __fdopen (pdto[1], "w");
+      *fto = fdopen (pdto[1], "w");
       __close (pdto[0]);
-      *ffrom = __fdopen (pdfrom[0], "r");
+      *ffrom = fdopen (pdfrom[0], "r");
       __close (pdfrom[1]);
       break;
     }
diff --git a/sunrpc/svc_simple.c b/sunrpc/svc_simple.c
index f12ed31..cf07ec6 100644
--- a/sunrpc/svc_simple.c
+++ b/sunrpc/svc_simple.c
@@ -40,9 +40,7 @@
 #include <rpc/pmap_clnt.h>
 #include <sys/socket.h>
 #include <netdb.h>
-
 #include <wchar.h>
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
 struct proglst_
diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c
index 0c1ecc3..c53c88d 100644
--- a/sunrpc/svc_tcp.c
+++ b/sunrpc/svc_tcp.c
@@ -61,9 +61,7 @@
 #include <sys/poll.h>
 #include <errno.h>
 #include <stdlib.h>
-
 #include <wchar.h>
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
 /*
diff --git a/sunrpc/svc_udp.c b/sunrpc/svc_udp.c
index 54ec331..52ae4fa 100644
--- a/sunrpc/svc_udp.c
+++ b/sunrpc/svc_udp.c
@@ -63,7 +63,6 @@
 #endif
 
 #include <wchar.h>
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
 #define rpc_buffer(xprt) ((xprt)->xp_p1)
diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c
index c9a1eaa..5bfe0f1 100644
--- a/sunrpc/xdr_rec.c
+++ b/sunrpc/xdr_rec.c
@@ -49,7 +49,6 @@
 #include <rpc/rpc.h>
 #include <libintl.h>
 #include <wchar.h>
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
 static bool_t xdrrec_getlong (XDR *, long *);
diff --git a/sunrpc/xdr_ref.c b/sunrpc/xdr_ref.c
index eab3b74..968aab4 100644
--- a/sunrpc/xdr_ref.c
+++ b/sunrpc/xdr_ref.c
@@ -40,7 +40,6 @@
 #include <rpc/xdr.h>
 #include <libintl.h>
 #include <wchar.h>
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
 #define LASTUNSIGNED	((u_int)0-1)
diff --git a/sunrpc/xdr_stdio.c b/sunrpc/xdr_stdio.c
index 0c2cbb7..83a55a2 100644
--- a/sunrpc/xdr_stdio.c
+++ b/sunrpc/xdr_stdio.c
@@ -39,14 +39,8 @@
 #include <stdio.h>
 #include <rpc/xdr.h>
 
-#include <libio/iolibio.h>
 #include <shlib-compat.h>
 
-#define fflush(s) _IO_fflush (s)
-#define fread(p, m, n, s) _IO_fread (p, m, n, s)
-#define ftell(s) _IO_ftell (s)
-#define fwrite(p, m, n, s) _IO_fwrite (p, m, n, s)
-
 static bool_t xdrstdio_getlong (XDR *, long *);
 static bool_t xdrstdio_putlong (XDR *, const long *);
 static bool_t xdrstdio_getbytes (XDR *, caddr_t, u_int);
diff --git a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
index e11d6d1..3e01435 100644
--- a/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
+++ b/sysdeps/ieee754/ldbl-opt/nldbl-compat.c
@@ -19,7 +19,6 @@
 
 #include <stdarg.h>
 #include <stdio.h>
-#include <libioP.h>
 #include <wchar.h>
 #include <printf.h>
 #include <monetary.h>
diff --git a/sysdeps/mach/hurd/tmpfile.c b/sysdeps/mach/hurd/tmpfile.c
index 8bcfb81..6255a6d 100644
--- a/sysdeps/mach/hurd/tmpfile.c
+++ b/sysdeps/mach/hurd/tmpfile.c
@@ -22,7 +22,6 @@
 #include <hurd/fd.h>
 #include <fcntl.h>
 #include <unistd.h>
-#include <iolibio.h>
 
 /* This returns a new stream opened on a temporary file (generated
    by tmpnam).  The file is opened with mode "w+b" (binary read/write).
diff --git a/sysdeps/unix/sysv/linux/readonly-area.c b/sysdeps/unix/sysv/linux/readonly-area.c
index e2288e9..5df1795 100644
--- a/sysdeps/unix/sysv/linux/readonly-area.c
+++ b/sysdeps/unix/sysv/linux/readonly-area.c
@@ -21,7 +21,6 @@
 #include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
-#include "libio/libioP.h"
 
 /* Return 1 if the whole area PTR .. PTR+SIZE is not writable.
    Return -1 if it is writable.  */
@@ -55,7 +54,7 @@ __readonly_area (const char *ptr, size_t size)
 
   while (! feof_unlocked (fp))
     {
-      if (_IO_getdelim (&line, &linelen, '\n', fp) <= 0)
+      if (__getdelim (&line, &linelen, '\n', fp) <= 0)
 	break;
 
       char *p;

-----------------------------------------------------------------------


hooks/post-receive
-- 
GNU C Library master sources


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]