[1/3] Reduce use of libioP.h and iolibio.h outside the stdio implementation.

Message ID 20171226061052.20907-2-zackw@panix.com
State Superseded
Headers

Commit Message

Zack Weinberg Dec. 26, 2017, 6:10 a.m. UTC
  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.
---
 argp/argp-fmtstream.c                   |  2 --
 argp/argp-help.c                        |  9 ++---
 assert/assert.c                         |  6 +---
 grp/fgetgrent_r.c                       |  4 ---
 grp/putgrent.c                          |  3 --
 gshadow/fgetsgent_r.c                   |  8 ++---
 gshadow/putsgent.c                      |  4 +--
 iconv/gconv_conf.c                      |  3 --
 include/bits/libio.h                    | 44 -----------------------
 include/stdio.h                         | 63 ++++++++++++++++++++++++++++++++-
 libio/iofread.c                         |  1 +
 libio/ioftell.c                         |  1 +
 libio/iogetdelim.c                      |  1 +
 libio/iosetvbuf.c                       |  1 +
 libio/iovsprintf.c                      |  1 +
 libio/iovsscanf.c                       |  1 +
 libio/vasprintf.c                       |  1 +
 libio/vsnprintf.c                       |  1 +
 malloc/malloc.c                         |  4 +--
 malloc/mtrace.c                         |  5 ---
 malloc/obstack.c                        |  4 ---
 misc/err.c                              |  4 +--
 misc/error.c                            | 14 +++-----
 misc/getpass.c                          |  3 --
 misc/getttyent.c                        |  3 --
 misc/mntent_r.c                         |  3 --
 misc/syslog.c                           |  3 --
 posix/getopt.c                          | 10 ++----
 pwd/fgetpwent_r.c                       |  3 --
 shadow/fgetspent_r.c                    |  3 --
 shadow/putspent.c                       |  3 --
 stdio-common/asprintf.c                 |  4 +--
 stdio-common/fprintf.c                  |  1 -
 stdio-common/fscanf.c                   |  1 -
 stdio-common/getline.c                  |  5 ---
 stdio-common/getw.c                     |  3 --
 stdio-common/isoc99_sscanf.c            |  1 -
 stdio-common/perror.c                   |  1 -
 stdio-common/printf.c                   |  1 -
 stdio-common/putw.c                     |  2 --
 stdio-common/scanf.c                    |  2 --
 stdio-common/snprintf.c                 |  2 --
 stdio-common/sprintf.c                  |  2 --
 stdio-common/sscanf.c                   |  2 --
 stdio-common/tmpfile.c                  |  4 +--
 stdio-common/vprintf.c                  |  1 -
 stdlib/strfmon_l.c                      |  4 +--
 sunrpc/clnt_perr.c                      |  1 -
 sunrpc/openchild.c                      |  8 ++---
 sunrpc/svc_simple.c                     |  2 --
 sunrpc/svc_tcp.c                        |  2 --
 sunrpc/svc_udp.c                        |  1 -
 sunrpc/xdr_rec.c                        |  1 -
 sunrpc/xdr_ref.c                        |  1 -
 sunrpc/xdr_stdio.c                      |  6 ----
 sysdeps/ieee754/ldbl-opt/nldbl-compat.c |  1 -
 sysdeps/mach/hurd/tmpfile.c             |  1 -
 sysdeps/unix/sysv/linux/readonly-area.c |  3 +-
 58 files changed, 97 insertions(+), 182 deletions(-)
  

Comments

Joseph Myers Jan. 1, 2018, 1:24 a.m. UTC | #1
On Tue, 26 Dec 2017, Zack Weinberg wrote:

> 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.

> diff --git a/libio/vasprintf.c b/libio/vasprintf.c
> index a9a21545a2..cf7ad0a972 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)

I think the point of ldbl_strong_alias / ldbl_weak_alias is that they 
define the main symbol using long_double_symbol (i.e. give it an explicit 
symbol version).  Since __vasprintf is not a public symbol in 
ieee754/ldbl-opt/Versions at version NLDBL_VERSION, I don't think it 
should logically be using ldbl_strong_alias (although such usage is also 
fairly harmless - the symbol won't actually get exported without being 
listed in a Versions file).
  
Zack Weinberg Jan. 1, 2018, 1:36 a.m. UTC | #2
On Sun, Dec 31, 2017 at 5:24 PM, Joseph Myers <joseph@codesourcery.com> wrote:
> On Tue, 26 Dec 2017, Zack Weinberg wrote:
>
>> 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.
>
>> diff --git a/libio/vasprintf.c b/libio/vasprintf.c
>> index a9a21545a2..cf7ad0a972 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)
>
> I think the point of ldbl_strong_alias / ldbl_weak_alias is that they
> define the main symbol using long_double_symbol (i.e. give it an explicit
> symbol version).  Since __vasprintf is not a public symbol in
> ieee754/ldbl-opt/Versions at version NLDBL_VERSION, I don't think it
> should logically be using ldbl_strong_alias (although such usage is also
> fairly harmless - the symbol won't actually get exported without being
> listed in a Versions file).

Yes, and it turns out check-abi-libc objects to this usage (but only
on targets where the nldbl-opt versions of the ldbl_* macros are
used).  A revised patch is coming Real Soon Now (I keep discovering
problems that require me to run additional complete build-many-glibcs
cycles to validate fixes).

zw
  

Patch

diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index f12c265196..eeb7520429 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 821d98c3d6..ab8eeb95a0 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 57d9644e2f..efd9f69078 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 5a4107ba9c..7bcbdfe539 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 5a12c70557..cd3588ded3 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 f1d0650333..95c21e960c 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 4e219c478a..70063d74c2 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 f1c28ce83a..5e023c6e04 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 572395d5ff..40b6851fe9 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 f1e987ae5e..8c8580766c 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 8bb948ef4a..da77c55606 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 09d2a1147d..035755c733 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 0fce4af768..1354fafe79 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 eda49ab3aa..7236c645cf 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 80a2aee1cb..63290fb365 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 ae87a1f3a3..b96ad6b2fe 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 a9a21545a2..cf7ad0a972 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 0e93c368bd..8a8a34ef89 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 0c9e0748b4..6253fbe58b 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 9eb2f5f1c7..f7a4a1aa99 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 4ac8938c73..c28a973d34 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 3da4e9d6b0..d96778adac 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 1d960be23f..de11b7a09b 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 89c783fe20..727db0a758 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 0fa4ddbdde..57bae5b423 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 96bd1e2fb4..0d1fb1a775 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 2b6bd373bc..bd86f3507a 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 543c8e7284..43cc871306 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 8aa8f69372..044f19b20b 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 42106302c1..164c377384 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 5e27340b5d..790b76326f 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 a61cf64740..593a30b159 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 2bbaba8b99..149b6e5c31 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 019ce899ab..144074905c 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 1976dd916f..d05e890c5f 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 f698707d2c..580047de59 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 9242102718..f065a61a11 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 d109c63607..98cf1c40da 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 ba84064e9e..638367bf5f 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 2b0e6ad3d7..76583cb9c6 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 3caddcb5aa..385fba667f 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 66bcd198a8..93972108b2 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 391c495393..e5768036f8 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 63b9503db5..7122d92938 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 c5cbb688f4..72863a3111 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 c5d8b84ba7..71e0d9dcbc 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 1df184e8b2..5ce6dcf668 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 cac1dd9913..a1d6176f82 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 29f274a8ad..ae92707986 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 f12ed31441..cf07ec61c5 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 0c1ecc3e73..c53c88d0c3 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 54ec331e1b..52ae4fac04 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 c9a1eaad63..5bfe0f14bf 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 eab3b74227..968aab4797 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 0c2cbb78de..83a55a2311 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 e11d6d1bd0..3e0143529a 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 8bcfb81a10..6255a6d618 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 e2288e98d6..5df1795b07 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;