about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog93
-rw-r--r--libio/fcloseall.c2
-rw-r--r--libio/feof.c2
-rw-r--r--libio/ferror.c2
-rw-r--r--libio/fileno.c2
-rw-r--r--libio/fileops.c95
-rw-r--r--libio/ftello.c4
-rw-r--r--libio/ftello64.c2
-rw-r--r--libio/genops.c40
-rw-r--r--libio/getc.c2
-rw-r--r--libio/getwc.c2
-rw-r--r--libio/iofclose.c13
-rw-r--r--libio/iofdopen.c23
-rw-r--r--libio/iofflush.c2
-rw-r--r--libio/iofgetpos.c4
-rw-r--r--libio/iofgetpos64.c2
-rw-r--r--libio/iofgets.c2
-rw-r--r--libio/iofopen.c12
-rw-r--r--libio/iofopen64.c4
-rw-r--r--libio/iofputs.c2
-rw-r--r--libio/iofread.c2
-rw-r--r--libio/iofsetpos.c2
-rw-r--r--libio/iofsetpos64.c2
-rw-r--r--libio/ioftell.c6
-rw-r--r--libio/iofwide.c154
-rw-r--r--libio/iofwrite.c2
-rw-r--r--libio/iogetdelim.c2
-rw-r--r--libio/iogets.c4
-rw-r--r--libio/iogetwline.c10
-rw-r--r--libio/iopopen.c68
-rw-r--r--libio/ioputs.c2
-rw-r--r--libio/ioseekoff.c6
-rw-r--r--libio/iosetbuffer.c2
-rw-r--r--libio/iosetvbuf.c2
-rw-r--r--libio/ioungetc.c2
-rw-r--r--libio/libioP.h88
-rw-r--r--libio/oldfileops.c31
-rw-r--r--libio/oldiofdopen.c15
-rw-r--r--libio/oldiofgetpos.c4
-rw-r--r--libio/oldiofgetpos64.c4
-rw-r--r--libio/oldiofsetpos.c4
-rw-r--r--libio/oldiofsetpos64.c4
-rw-r--r--libio/oldiopopen.c85
-rw-r--r--libio/putc.c2
-rw-r--r--libio/stdfiles.c19
-rw-r--r--libio/stdio.c6
-rw-r--r--libio/wfileops.c25
-rw-r--r--libio/wgenops.c54
48 files changed, 166 insertions, 751 deletions
diff --git a/ChangeLog b/ChangeLog
index c94f4c1639..f9625dec80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,98 @@
 2017-08-31  Florian Weimer  <fweimer@redhat.com>
 
+	* libio/fcloseall.c: Assume weak_alias is defined.
+	* libio/feof.c: Likewise.
+	* libio/fileno.c: Likewise.
+	* libio/fileops.c: Assume _LIBC, errno, __set_errno are defined.
+	(_POSIX_SOURCE, open, lseek, read, write): Remove macro
+	definitions.
+	(_IO_file_open): Call __open directly.
+	(_IO_new_file_sync): Assume ESPIPE is defined.
+	(_IO_file_seekoff_maybe_mmap): Call __read directly.
+	(_IO_new_file_write): Call __write directly.
+	* libio/ftello.c (__ftello): Assume EIO, EOVERFLOW are defined.
+	* libio/ftello64.c (__ftello64): Assume EIO is defined.
+	* libio/genops.c: Assume _LIBC is defined.
+	(save_for_backup): Remove internal_function.
+	* libio/getc.c: Assume weak_alias is defined.
+	* libio/getwc.c: Likewise.
+	* libio/iofclose.c: Assume _LIBC is defined.
+	* libio/iofdopen.c: Likewise.
+	(_IO_fcntl): Remove macro definition.
+	(_IO_new_fdopen): Assume F_GETFL, F_SETFL, O_ACCMODE are defined.
+	Call __fcntl directly.
+	* libio/iofflush.c: Assume weak_alias is defined.
+	* libio/iofgetpos.c (_IO_new_fgetpos): Assume EIO, EOVERFLOW are
+	defined.
+	* libio/iofgetpos64.c (_IO_new_fgetpos64): Assume EIO is defined.
+	* libio/iofgets.c: Likewise.
+	* libio/iofopen.c: Assume _LIBC is defined.
+	* libio/iofopen64.c: Assume _LIBC, weak_alias are defined.
+	* libio/iofputs.c: Assume weak_alias is defined.
+	* libio/iofread.c: Likewise.
+	* libio/iofsetpos.c (_IO_new_fsetpos): Assume EIO is defined.
+	* libio/iofsetpos64.c (_IO_new_fsetpos64): Likewise.
+	* libio/ioftell.c: Assume weak_alias is defined.
+	(_IO_ftell): Assume EIO, EOVERFLOW are defined.
+	* libio/iofwide.c: Assume _LIBC is defined.
+	(_IO_fwide): Drop SHARED conditional because it is implied by
+	SHLIB_COMPAT.
+	* libio/iofwrite.c: Assume weak_alias is defined.
+	* libio/iogetdelim.c: Likewise.
+	* libio/iogets.c: Assume _LIBC, weak_alias are defined.
+	* libio/iogetwline.c (wmemcpy): Remove macro definition.
+	(_IO_getwline): Call __wmemcpy directly.
+	* libio/iopopen.c: Assume _LIBC is defined.
+	(_POSIX_SOURCE, _IO_fork, _IO_dup2, _IO_waitpid, _IO_execl)
+	(_IO_close): Remove macro definitions.
+	(_IO_new_proc_open): Call __fork, __dup2, __close_nocancel, execl,
+	_exit directly.
+	(_IO_new_proc_close): Call __close_nocancel, __waitpid_nocancel
+	directly.
+	* libio/ioputs.c: Assume weak_alias is defined.
+	* libio/ioseekoff.c: Assume errno, __set_errno are defined.
+	* libio/iosetbuffer.c: Assume weak_alias is defined.
+	* libio/iosetvbuf.c: Likewise.
+	* libio/ioungetc.c: Likewise.
+	* libio/libioP.h: Assume _LIBC, __GLIBC__, libc_hidden_proto,
+	libc_hidden_def, libc_hidden_weak, NULL are defined.
+	(mmap, munmap, ftruncate, OS_FSTAT): Remove macro definitions.
+	* libio/oldfilepos.c: Assume _LIBC, errno, __set_errno are
+	defined.
+	(_POSIX_SOURCE, open, lseek, read, write): Remove macro
+	definitions.
+	(_IO_old_file_init_internal): Drop SHARED conditional because it
+	is implied by SHLIB_COMPAT.
+	(_IO_old_file_fopen): Call __open directly.
+	(_IO_old_file_sync): Assume ESPIPE is defined.
+	(_IO_old_file_write): Call __write directly.
+	* libio/oldfdopen.c (_IO_fcntl): Remove macro definition.
+	(_IO_old_fdopen): Assume F_GETFL, O_ACCMODE, F_SETFL are defined.
+	Call __fcntl directly.
+	* libio/oldiofgetpos.c: Assume weak_alias is defined.
+	(_IO_old_fgetpos): Assume EIO is defined.
+	* libio/oldiofgetpos64.c: Assume weak_alias is defined.
+	(_IO_old_fgetpos64): Assume EIO is defined.
+	* libio/oldiofsetpos.c: Assume weak_alias is defined.
+	(_IO_old_fsetpos): Assume EIO is defined.
+	* libio/oldiofsetpos64.c: Assume weak_alias is defined.
+	(_IO_old_fsetpos64): Assume EIO is defined.
+	* libio/oldiopopen.c:  Assume _LIBC is defined.
+	(_POSIX_SOURCE, _IO_fork, _IO_dup2, _IO_waitpid, _IO_execl)
+	(_IO_close): Remove macro definitions.
+	(_IO_old_proc_open): Call __pipe, __close, __dup2, execl, _exit
+	directly.
+	(_IO_old_proc_close): Call __close, __waitpid directly.
+	* libio/put.c: Assume weak_alias is defined.
+	* libio/stdfiles.c: Assume _LIBC is defined.
+	* libio/stdio.c: Likewise.
+	* libio/wfileops.c: Likewise.
+	(_IO_wfile_sync): Assume ESPIPE is defined.
+	* libio/wgenops.c: Assume _LIBC is defined.
+	(save_for_wbackup): Remove internal_function.
+
+2017-08-31  Florian Weimer  <fweimer@redhat.com>
+
 	* malloc/malloc.c (top_check): Change return type to void.  Remove
 	internal_function.
 	* malloc/hooks.c (top_check): Likewise.
diff --git a/libio/fcloseall.c b/libio/fcloseall.c
index 59c33ccf48..80e1ae01d7 100644
--- a/libio/fcloseall.c
+++ b/libio/fcloseall.c
@@ -34,6 +34,4 @@ __fcloseall (void)
   return _IO_cleanup ();
 }
 
-#ifdef weak_alias
 weak_alias (__fcloseall, fcloseall)
-#endif
diff --git a/libio/feof.c b/libio/feof.c
index 8890a5f51f..72dde1f82d 100644
--- a/libio/feof.c
+++ b/libio/feof.c
@@ -40,11 +40,9 @@ _IO_feof (_IO_FILE *fp)
   return result;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_feof, feof)
 
 #ifndef _IO_MTSAFE_IO
 #undef feof_unlocked
 weak_alias (_IO_feof, feof_unlocked)
 #endif
-#endif
diff --git a/libio/ferror.c b/libio/ferror.c
index d10fcd9fff..ab6185bade 100644
--- a/libio/ferror.c
+++ b/libio/ferror.c
@@ -40,11 +40,9 @@ _IO_ferror (_IO_FILE *fp)
   return result;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_ferror, ferror)
 
 #ifndef _IO_MTSAFE_IO
 #undef ferror_unlocked
 weak_alias (_IO_ferror, ferror_unlocked)
 #endif
-#endif
diff --git a/libio/fileno.c b/libio/fileno.c
index b78d4a1461..d4d749d4d0 100644
--- a/libio/fileno.c
+++ b/libio/fileno.c
@@ -44,10 +44,8 @@ libc_hidden_def (__fileno)
 weak_alias (__fileno, fileno)
 libc_hidden_weak (fileno)
 
-#ifdef weak_alias
 /* The fileno implementation for libio does not require locking because
    it only accesses once a single variable and this is already atomic
    (at least at thread level).  Therefore we don't test _IO_MTSAFE_IO here.  */
 
 weak_alias (__fileno, fileno_unlocked)
-#endif
diff --git a/libio/fileops.c b/libio/fileops.c
index b8b02ba261..a9e948f31e 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -26,9 +26,6 @@
    in files containing the exception.  */
 
 
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
 #include "libioP.h"
 #include <assert.h>
 #include <fcntl.h>
@@ -40,48 +37,14 @@
 #include <errno.h>
 #include <unistd.h>
 #include <stdlib.h>
-#if _LIBC
-# include "../wcsmbs/wcsmbsload.h"
-# include "../iconv/gconv_charset.h"
-# include "../iconv/gconv_int.h"
-# include <shlib-compat.h>
-# include <not-cancel.h>
-# include <kernel-features.h>
-#endif
-#ifndef errno
-extern int errno;
-#endif
-#ifndef __set_errno
-# define __set_errno(Val) errno = (Val)
-#endif
-
-
-#ifdef _LIBC
-# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
-# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
-# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
-# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
-#else
-# define _IO_new_do_write _IO_do_write
-# define _IO_new_file_attach _IO_file_attach
-# define _IO_new_file_close_it _IO_file_close_it
-# define _IO_new_file_finish _IO_file_finish
-# define _IO_new_file_fopen _IO_file_fopen
-# define _IO_new_file_init _IO_file_init
-# define _IO_new_file_setbuf _IO_file_setbuf
-# define _IO_new_file_sync _IO_file_sync
-# define _IO_new_file_overflow _IO_file_overflow
-# define _IO_new_file_seekoff _IO_file_seekoff
-# define _IO_new_file_underflow _IO_file_underflow
-# define _IO_new_file_write _IO_file_write
-# define _IO_new_file_xsputn _IO_file_xsputn
-#endif
+#include "../wcsmbs/wcsmbsload.h"
+#include "../iconv/gconv_charset.h"
+#include "../iconv/gconv_int.h"
+#include <shlib-compat.h>
+#include <not-cancel.h>
+#include <kernel-features.h>
 
-
-#ifdef _LIBC
 extern struct __gconv_trans_data __libio_translit attribute_hidden;
-#endif
-
 
 /* An fstream can be in at most one of put mode, get mode, or putback mode.
    Putback mode is a variant of get mode.
@@ -180,7 +143,6 @@ _IO_new_file_close_it (_IO_FILE *fp)
 		      ? _IO_SYSCLOSE (fp) : 0);
 
   /* Free buffer. */
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
   if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
@@ -189,7 +151,6 @@ _IO_new_file_close_it (_IO_FILE *fp)
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
     }
-#endif
   _IO_setb (fp, NULL, NULL, 0);
   _IO_setg (fp, NULL, NULL, NULL);
   _IO_setp (fp, NULL, NULL);
@@ -221,15 +182,11 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot,
 	       int read_write, int is32not64)
 {
   int fdesc;
-#ifdef _LIBC
   if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
     fdesc = __open_nocancel (filename,
 			     posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
   else
-    fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
-#else
-  fdesc = open (filename, posix_mode, prot);
-#endif
+    fdesc = __open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
   if (fdesc < 0)
     return NULL;
   fp->_fileno = fdesc;
@@ -260,10 +217,8 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
   int oprot = 0666;
   int i;
   _IO_FILE *result;
-#ifdef _LIBC
   const char *cs;
   const char *last_recognized;
-#endif
 
   if (_IO_file_is_open (fp))
     return 0;
@@ -287,9 +242,7 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
       __set_errno (EINVAL);
       return NULL;
     }
-#ifdef _LIBC
   last_recognized = mode;
-#endif
   for (i = 1; i < 7; ++i)
     {
       switch (*++mode)
@@ -299,20 +252,14 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode,
 	case '+':
 	  omode = O_RDWR;
 	  read_write &= _IO_IS_APPENDING;
-#ifdef _LIBC
 	  last_recognized = mode;
-#endif
 	  continue;
 	case 'x':
 	  oflags |= O_EXCL;
-#ifdef _LIBC
 	  last_recognized = mode;
-#endif
 	  continue;
 	case 'b':
-#ifdef _LIBC
 	  last_recognized = mode;
-#endif
 	  continue;
 	case 'm':
 	  fp->_flags2 |= _IO_FLAGS2_MMAP;
@@ -874,10 +821,8 @@ _IO_new_file_sync (_IO_FILE *fp)
       _IO_off64_t new_pos = _IO_SYSSEEK (fp, delta, 1);
       if (new_pos != (_IO_off64_t) EOF)
 	fp->_IO_read_end = fp->_IO_read_ptr;
-#ifdef ESPIPE
       else if (errno == ESPIPE)
 	; /* Ignore error from unseekable devices. */
-#endif
       else
 	retval = EOF;
     }
@@ -1205,7 +1150,7 @@ _IO_file_read (_IO_FILE *fp, void *buf, _IO_ssize_t size)
 {
   return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)
 	  ? __read_nocancel (fp->_fileno, buf, size)
-	  : read (fp->_fileno, buf, size));
+	  : __read (fp->_fileno, buf, size));
 }
 libc_hidden_def (_IO_file_read)
 
@@ -1252,7 +1197,7 @@ _IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n)
       _IO_ssize_t count = (__builtin_expect (f->_flags2
 					     & _IO_FLAGS2_NOTCANCEL, 0)
 			   ? __write_nocancel (f->_fileno, data, to_do)
-			   : write (f->_fileno, data, to_do));
+			   : __write (f->_fileno, data, to_do));
       if (count < 0)
 	{
 	  f->_flags |= _IO_ERR_SEEN;
@@ -1307,12 +1252,7 @@ _IO_new_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
     {
       if (count > to_do)
 	count = to_do;
-#ifdef _LIBC
       f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
-#else
-      memcpy (f->_IO_write_ptr, s, count);
-      f->_IO_write_ptr += count;
-#endif
       s += count;
       to_do -= count;
     }
@@ -1380,12 +1320,7 @@ _IO_file_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
 	{
 	  if (have > 0)
 	    {
-#ifdef _LIBC
 	      s = __mempcpy (s, fp->_IO_read_ptr, have);
-#else
-	      memcpy (s, fp->_IO_read_ptr, have);
-	      s += have;
-#endif
 	      want -= have;
 	      fp->_IO_read_ptr += have;
 	    }
@@ -1458,12 +1393,7 @@ _IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
     {
       if (__glibc_unlikely (_IO_in_backup (fp)))
 	{
-#ifdef _LIBC
 	  s = __mempcpy (s, read_ptr, have);
-#else
-	  memcpy (s, read_ptr, have);
-	  s += have;
-#endif
 	  n -= have;
 	  _IO_switch_to_main_get_area (fp);
 	  read_ptr = fp->_IO_read_ptr;
@@ -1488,12 +1418,7 @@ _IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
   if (have != 0)
     {
       have = MIN (have, n);
-#ifdef _LIBC
       s = __mempcpy (s, read_ptr, have);
-#else
-      memcpy (s, read_ptr, have);
-      s += have;
-#endif
       fp->_IO_read_ptr = read_ptr + have;
     }
 
@@ -1510,7 +1435,6 @@ _IO_file_xsgetn_maybe_mmap (_IO_FILE *fp, void *data, _IO_size_t n)
   return _IO_XSGETN (fp, data, n);
 }
 
-#ifdef _LIBC
 versioned_symbol (libc, _IO_new_do_write, _IO_do_write, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_attach, _IO_file_attach, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_close_it, _IO_file_close_it, GLIBC_2_1);
@@ -1524,7 +1448,6 @@ versioned_symbol (libc, _IO_new_file_seekoff, _IO_file_seekoff, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_underflow, _IO_file_underflow, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_write, _IO_file_write, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_xsputn, _IO_file_xsputn, GLIBC_2_1);
-#endif
 
 const struct _IO_jump_t _IO_file_jumps libio_vtable =
 {
diff --git a/libio/ftello.c b/libio/ftello.c
index 38863e16c3..9791e835c6 100644
--- a/libio/ftello.c
+++ b/libio/ftello.c
@@ -45,17 +45,13 @@ __ftello (_IO_FILE *fp)
   _IO_release_lock (fp);
   if (pos == _IO_pos_BAD)
     {
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       return -1L;
     }
   if ((_IO_off64_t) (off_t) pos != pos)
     {
-#ifdef EOVERFLOW
       __set_errno (EOVERFLOW);
-#endif
       return -1L;
     }
   return pos;
diff --git a/libio/ftello64.c b/libio/ftello64.c
index edb10e0880..15518af7a6 100644
--- a/libio/ftello64.c
+++ b/libio/ftello64.c
@@ -46,10 +46,8 @@ ftello64 (_IO_FILE *fp)
   _IO_release_lock (fp);
   if (pos == _IO_pos_BAD)
     {
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       return -1L;
     }
   return pos;
diff --git a/libio/genops.c b/libio/genops.c
index 6ad7346cae..e3f372520a 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -30,9 +30,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <stdbool.h>
-#ifdef _LIBC
 #include <sched.h>
-#endif
 
 #ifdef _IO_MTSAFE_IO
 static _IO_lock_t list_all_lock = _IO_lock_initializer;
@@ -233,16 +231,7 @@ __overflow (_IO_FILE *f, int ch)
 }
 libc_hidden_def (__overflow)
 
-static int save_for_backup (_IO_FILE *fp, char *end_p)
-#ifdef _LIBC
-     internal_function
-#endif
-     ;
-
 static int
-#ifdef _LIBC
-internal_function
-#endif
 save_for_backup (_IO_FILE *fp, char *end_p)
 {
   /* Append [_IO_read_base..end_p] to backup area. */
@@ -263,20 +252,11 @@ save_for_backup (_IO_FILE *fp, char *end_p)
 	return EOF;		/* FIXME */
       if (least_mark < 0)
 	{
-#ifdef _LIBC
 	  __mempcpy (__mempcpy (new_buffer + avail,
 				fp->_IO_save_end + least_mark,
 				-least_mark),
 		     fp->_IO_read_base,
 		     end_p - fp->_IO_read_base);
-#else
-	  memcpy (new_buffer + avail,
-		  fp->_IO_save_end + least_mark,
-		  -least_mark);
-	  memcpy (new_buffer + avail - least_mark,
-		  fp->_IO_read_base,
-		  end_p - fp->_IO_read_base);
-#endif
 	}
       else
 	memcpy (new_buffer + avail,
@@ -314,10 +294,8 @@ save_for_backup (_IO_FILE *fp, char *end_p)
 int
 __underflow (_IO_FILE *fp)
 {
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
-#endif
 
   if (fp->_mode == 0)
     _IO_fwide (fp, -1);
@@ -346,10 +324,8 @@ libc_hidden_def (__underflow)
 int
 __uflow (_IO_FILE *fp)
 {
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
   if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
     return EOF;
-#endif
 
   if (fp->_mode == 0)
     _IO_fwide (fp, -1);
@@ -434,12 +410,7 @@ _IO_default_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
 	    count = more;
 	  if (count > 20)
 	    {
-#ifdef _LIBC
 	      f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
-#else
-	      memcpy (f->_IO_write_ptr, s, count);
-	      f->_IO_write_ptr += count;
-#endif
 	      s += count;
 	    }
 	  else if (count)
@@ -483,12 +454,7 @@ _IO_default_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
 	    count = more;
 	  if (count > 20)
 	    {
-#ifdef _LIBC
 	      s = __mempcpy (s, fp->_IO_read_ptr, count);
-#else
-	      memcpy (s, fp->_IO_read_ptr, count);
-	      s += count;
-#endif
 	      fp->_IO_read_ptr += count;
 	    }
 	  else if (count)
@@ -633,7 +599,6 @@ _IO_no_init (_IO_FILE *fp, int flags, int orientation,
 {
   _IO_old_init (fp, flags);
   fp->_mode = orientation;
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
   if (orientation >= 0)
     {
       fp->_wide_data = wd;
@@ -655,7 +620,6 @@ _IO_no_init (_IO_FILE *fp, int flags, int orientation,
     /* Cause predictable crash when a wide function is called on a byte
        stream.  */
     fp->_wide_data = (struct _IO_wide_data *) -1L;
-#endif
   fp->_freeres_list = NULL;
 }
 
@@ -811,11 +775,9 @@ _IO_flush_all_lockp (int do_lock)
 	_IO_flockfile (fp);
 
       if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 	   || (_IO_vtable_offset (fp) == 0
 	       && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
 				    > fp->_wide_data->_IO_write_base))
-#endif
 	   )
 	  && _IO_OVERFLOW (fp, EOF) == EOF)
 	result = EOF;
@@ -892,9 +854,7 @@ _IO_flush_all_linebuffered (void)
 #endif
 }
 libc_hidden_def (_IO_flush_all_linebuffered)
-#ifdef _LIBC
 weak_alias (_IO_flush_all_linebuffered, _flushlbf)
-#endif
 
 
 /* The following is a bit tricky.  In general, we want to unbuffer the
diff --git a/libio/getc.c b/libio/getc.c
index fd66ef93cf..2df0fcc983 100644
--- a/libio/getc.c
+++ b/libio/getc.c
@@ -44,7 +44,6 @@ _IO_getc (FILE *fp)
 
 #undef getc
 
-#ifdef weak_alias
 weak_alias (_IO_getc, getc)
 weak_alias (_IO_getc, fgetc)
 
@@ -53,4 +52,3 @@ weak_alias (_IO_getc, fgetc)
 weak_alias (_IO_getc, getc_unlocked)
 weak_alias (_IO_getc, fgetc_unlocked)
 #endif
-#endif
diff --git a/libio/getwc.c b/libio/getwc.c
index 9959aab2f0..fbc2bb1ab7 100644
--- a/libio/getwc.c
+++ b/libio/getwc.c
@@ -43,7 +43,5 @@ _IO_getwc (FILE *fp)
 
 #undef getwc
 
-#ifdef weak_alias
 weak_alias (_IO_getwc, getwc)
 weak_alias (_IO_getwc, fgetwc)
-#endif
diff --git a/libio/iofclose.c b/libio/iofclose.c
index 9c51c4efd2..f5dc3db2a3 100644
--- a/libio/iofclose.c
+++ b/libio/iofclose.c
@@ -26,13 +26,8 @@
 
 #include "libioP.h"
 #include <stdlib.h>
-#if _LIBC
-# include "../iconv/gconv_int.h"
-# include <shlib-compat.h>
-#else
-# define SHLIB_COMPAT(a, b, c) 0
-# define _IO_new_fclose fclose
-#endif
+#include "../iconv/gconv_int.h"
+#include <shlib-compat.h>
 
 int
 _IO_new_fclose (_IO_FILE *fp)
@@ -62,7 +57,6 @@ _IO_new_fclose (_IO_FILE *fp)
   _IO_FINISH (fp);
   if (fp->_mode > 0)
     {
-#if _LIBC
       /* This stream has a wide orientation.  This means we have to free
 	 the conversion functions.  */
       struct _IO_codecvt *cc = fp->_codecvt;
@@ -71,7 +65,6 @@ _IO_new_fclose (_IO_FILE *fp)
       __gconv_release_step (cc->__cd_in.__cd.__steps);
       __gconv_release_step (cc->__cd_out.__cd.__steps);
       __libc_lock_unlock (__gconv_lock);
-#endif
     }
   else
     {
@@ -87,8 +80,6 @@ _IO_new_fclose (_IO_FILE *fp)
   return status;
 }
 
-#ifdef _LIBC
 versioned_symbol (libc, _IO_new_fclose, _IO_fclose, GLIBC_2_1);
 strong_alias (_IO_new_fclose, __new_fclose)
 versioned_symbol (libc, __new_fclose, fclose, GLIBC_2_1);
-#endif
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index 2a1df4680a..90346a4ece 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -28,17 +28,7 @@
 #include "libioP.h"
 #include <fcntl.h>
 
-#ifdef _LIBC
-# include <shlib-compat.h>
-#endif
-
-#ifndef _IO_fcntl
-#ifdef _LIBC
-#define _IO_fcntl __fcntl
-#else
-#define _IO_fcntl fcntl
-#endif
-#endif
+#include <shlib-compat.h>
 
 _IO_FILE *
 _IO_new_fdopen (int fd, const char *mode)
@@ -95,11 +85,7 @@ _IO_new_fdopen (int fd, const char *mode)
 	}
       break;
     }
-#ifdef F_GETFL
-  int fd_flags = _IO_fcntl (fd, F_GETFL);
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
+  int fd_flags = __fcntl (fd, F_GETFL);
   if (fd_flags == -1)
     return NULL;
 
@@ -129,12 +115,9 @@ _IO_new_fdopen (int fd, const char *mode)
   if ((read_write & _IO_IS_APPENDING) && !(fd_flags & O_APPEND))
     {
       do_seek = true;
-#ifdef F_SETFL
-      if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
-#endif
+      if (__fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
 	return NULL;
     }
-#endif
 
   new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
   if (new_f == NULL)
diff --git a/libio/iofflush.c b/libio/iofflush.c
index c6b1f15946..b312fd23ab 100644
--- a/libio/iofflush.c
+++ b/libio/iofflush.c
@@ -44,7 +44,6 @@ _IO_fflush (_IO_FILE *fp)
 }
 libc_hidden_def (_IO_fflush)
 
-#ifdef weak_alias
 weak_alias (_IO_fflush, fflush)
 libc_hidden_weak (fflush)
 
@@ -54,4 +53,3 @@ libc_hidden_def (__fflush_unlocked)
 weak_alias (_IO_fflush, fflush_unlocked)
 libc_hidden_weak (fflush_unlocked)
 #endif
-#endif
diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c
index c1330dee29..f3034528f1 100644
--- a/libio/iofgetpos.c
+++ b/libio/iofgetpos.c
@@ -56,17 +56,13 @@ _IO_new_fgetpos (_IO_FILE *fp, _IO_fpos_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       result = EOF;
     }
   else if ((_IO_off64_t) (__typeof (posp->__pos)) pos != pos)
     {
-#ifdef EOVERFLOW
       __set_errno (EOVERFLOW);
-#endif
       result = EOF;
     }
   else
diff --git a/libio/iofgetpos64.c b/libio/iofgetpos64.c
index 340dded802..e9c464d108 100644
--- a/libio/iofgetpos64.c
+++ b/libio/iofgetpos64.c
@@ -47,10 +47,8 @@ _IO_new_fgetpos64 (_IO_FILE *fp, _IO_fpos64_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-# ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-# endif
       result = EOF;
     }
   else
diff --git a/libio/iofgets.c b/libio/iofgets.c
index 8643e7c6cc..232d28ef81 100644
--- a/libio/iofgets.c
+++ b/libio/iofgets.c
@@ -66,7 +66,6 @@ _IO_fgets (char *buf, int n, _IO_FILE *fp)
   return result;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_fgets, fgets)
 
 # ifndef _IO_MTSAFE_IO
@@ -75,4 +74,3 @@ libc_hidden_def (__fgets_unlocked)
 weak_alias (_IO_fgets, fgets_unlocked)
 libc_hidden_weak (fgets_unlocked)
 # endif
-#endif
diff --git a/libio/iofopen.c b/libio/iofopen.c
index 3d30dfd94a..62d0332994 100644
--- a/libio/iofopen.c
+++ b/libio/iofopen.c
@@ -28,11 +28,7 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <stddef.h>
-#ifdef _LIBC
-# include <shlib-compat.h>
-#else
-# define _IO_new_fopen fopen
-#endif
+#include <shlib-compat.h>
 
 _IO_FILE *
 __fopen_maybe_mmap (_IO_FILE *fp)
@@ -73,11 +69,7 @@ __fopen_internal (const char *filename, const char *mode, int is32)
 #ifdef _IO_MTSAFE_IO
   new_f->fp.file._lock = &new_f->lock;
 #endif
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
   _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps);
-#else
-  _IO_no_init (&new_f->fp.file, 1, 0, NULL, NULL);
-#endif
   _IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
   _IO_new_file_init_internal (&new_f->fp);
 #if  !_IO_UNIFIED_JUMPTABLES
@@ -97,7 +89,6 @@ _IO_new_fopen (const char *filename, const char *mode)
   return __fopen_internal (filename, mode, 1);
 }
 
-#ifdef _LIBC
 strong_alias (_IO_new_fopen, __new_fopen)
 versioned_symbol (libc, _IO_new_fopen, _IO_fopen, GLIBC_2_1);
 versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1);
@@ -106,4 +97,3 @@ versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1);
 weak_alias (_IO_new_fopen, _IO_fopen64)
 weak_alias (_IO_new_fopen, fopen64)
 # endif
-#endif
diff --git a/libio/iofopen64.c b/libio/iofopen64.c
index 1ec2375990..9230fc173f 100644
--- a/libio/iofopen64.c
+++ b/libio/iofopen64.c
@@ -29,7 +29,7 @@
 #include <stdlib.h>
 
 /* iofopen.c defines _IO_fopen64/fopen64 as aliases if O_LARGEFILE==0.  */
-#if !defined _LIBC || (defined O_LARGEFILE && O_LARGEFILE != 0)
+#if defined O_LARGEFILE && O_LARGEFILE != 0
 
 _IO_FILE *
 _IO_fopen64 (const char *filename, const char *mode)
@@ -37,8 +37,6 @@ _IO_fopen64 (const char *filename, const char *mode)
   return __fopen_internal (filename, mode, 0);
 }
 
-#ifdef weak_alias
 weak_alias (_IO_fopen64, fopen64)
-#endif
 
 #endif
diff --git a/libio/iofputs.c b/libio/iofputs.c
index 379f9b0695..c40efc0644 100644
--- a/libio/iofputs.c
+++ b/libio/iofputs.c
@@ -42,7 +42,6 @@ _IO_fputs (const char *str, _IO_FILE *fp)
 }
 libc_hidden_def (_IO_fputs)
 
-#ifdef weak_alias
 weak_alias (_IO_fputs, fputs)
 
 # ifndef _IO_MTSAFE_IO
@@ -51,4 +50,3 @@ libc_hidden_def (__fputs_unlocked)
 weak_alias (_IO_fputs, fputs_unlocked)
 libc_hidden_ver (_IO_fputs, fputs_unlocked)
 # endif
-#endif
diff --git a/libio/iofread.c b/libio/iofread.c
index c6922d3dbf..8bb948ef4a 100644
--- a/libio/iofread.c
+++ b/libio/iofread.c
@@ -41,7 +41,6 @@ _IO_fread (void *buf, _IO_size_t size, _IO_size_t count, _IO_FILE *fp)
 }
 libc_hidden_def (_IO_fread)
 
-#ifdef weak_alias
 weak_alias (_IO_fread, fread)
 
 # ifndef _IO_MTSAFE_IO
@@ -49,4 +48,3 @@ strong_alias (_IO_fread, __fread_unlocked)
 libc_hidden_def (__fread_unlocked)
 weak_alias (_IO_fread, fread_unlocked)
 # endif
-#endif
diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c
index 3809b6a0b0..1a71867e59 100644
--- a/libio/iofsetpos.c
+++ b/libio/iofsetpos.c
@@ -49,10 +49,8 @@ _IO_new_fsetpos (_IO_FILE *fp, const _IO_fpos_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       result = EOF;
     }
   else
diff --git a/libio/iofsetpos64.c b/libio/iofsetpos64.c
index 04b4ddf29f..d3166ea20b 100644
--- a/libio/iofsetpos64.c
+++ b/libio/iofsetpos64.c
@@ -41,10 +41,8 @@ _IO_new_fsetpos64 (_IO_FILE *fp, const _IO_fpos64_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       result = EOF;
     }
   else
diff --git a/libio/ioftell.c b/libio/ioftell.c
index 21ba5fc6e3..09d2a1147d 100644
--- a/libio/ioftell.c
+++ b/libio/ioftell.c
@@ -44,23 +44,17 @@ _IO_ftell (_IO_FILE *fp)
   _IO_release_lock (fp);
   if (pos == _IO_pos_BAD)
     {
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       return -1L;
     }
   if ((_IO_off64_t) (long int) pos != pos)
     {
-#ifdef EOVERFLOW
       __set_errno (EOVERFLOW);
-#endif
       return -1L;
     }
   return pos;
 }
 libc_hidden_def (_IO_ftell)
 
-#ifdef weak_alias
 weak_alias (_IO_ftell, ftell)
-#endif
diff --git a/libio/iofwide.c b/libio/iofwide.c
index 76efb32f5d..9b718c0ccd 100644
--- a/libio/iofwide.c
+++ b/libio/iofwide.c
@@ -25,22 +25,18 @@
    in files containing the exception.  */
 
 #include <libioP.h>
-#ifdef _LIBC
-# include <dlfcn.h>
-# include <wchar.h>
-#endif
+#include <dlfcn.h>
+#include <wchar.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef _LIBC
-# include <langinfo.h>
-# include <locale/localeinfo.h>
-# include <wcsmbs/wcsmbsload.h>
-# include <iconv/gconv_int.h>
-# include <shlib-compat.h>
-# include <sysdep.h>
-#endif
+#include <langinfo.h>
+#include <locale/localeinfo.h>
+#include <wcsmbs/wcsmbsload.h>
+#include <iconv/gconv_int.h>
+#include <shlib-compat.h>
+#include <sysdep.h>
 
 
 /* Prototypes of libio's codecvt functions.  */
@@ -90,8 +86,7 @@ _IO_fwide (_IO_FILE *fp, int mode)
   /* Normalize the value.  */
   mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
 
-#if defined SHARED && defined _LIBC \
-    && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
   if (__builtin_expect (&_IO_stdin_used == NULL, 0)
       && (fp == _IO_stdin || fp == _IO_stdout || fp == _IO_stderr))
     /* This is for a stream in the glibc 2.0 format.  */
@@ -114,7 +109,6 @@ _IO_fwide (_IO_FILE *fp, int mode)
 
       /* Get the character conversion functions based on the currently
 	 selected locale for LC_CTYPE.  */
-#ifdef _LIBC
       {
 	/* Clear the state.  We start all over again.  */
 	memset (&fp->_wide_data->_IO_state, '\0', sizeof (__mbstate_t));
@@ -145,41 +139,6 @@ _IO_fwide (_IO_FILE *fp, int mode)
 	  = __GCONV_IS_LAST | __GCONV_TRANSLIT;
 	cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
       }
-#else
-# ifdef _GLIBCPP_USE_WCHAR_T
-      {
-	/* Determine internal and external character sets.
-
-	   XXX For now we make our life easy: we assume a fixed internal
-	   encoding (as most sane systems have; hi HP/UX!).  If somebody
-	   cares about systems which changing internal charsets they
-	   should come up with a solution for the determination of the
-	   currently used internal character set.  */
-	const char *internal_ccs = _G_INTERNAL_CCS;
-	const char *external_ccs = NULL;
-
-#  ifdef HAVE_NL_LANGINFO
-	external_ccs = nl_langinfo (CODESET);
-#  endif
-	if (external_ccs == NULL)
-	  external_ccs = "ISO-8859-1";
-
-	cc->__cd_in = iconv_open (internal_ccs, external_ccs);
-	if (cc->__cd_in != (iconv_t) -1)
-	  cc->__cd_out = iconv_open (external_ccs, internal_ccs);
-
-	if (cc->__cd_in == (iconv_t) -1 || cc->__cd_out == (iconv_t) -1)
-	  {
-	    if (cc->__cd_in != (iconv_t) -1)
-	      iconv_close (cc->__cd_in);
-	    /* XXX */
-	    abort ();
-	  }
-      }
-# else
-#  error "somehow determine this from LC_CTYPE"
-# endif
-#endif
 
       /* From now on use the wide character callback functions.  */
       _IO_JUMPS_FILE_plus (fp) = fp->_wide_data->_wide_vtable;
@@ -200,7 +159,6 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 {
   enum __codecvt_result result;
 
-#ifdef _LIBC
   struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
   int status;
   size_t dummy;
@@ -240,28 +198,6 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
       result = __codecvt_error;
       break;
     }
-#else
-# ifdef _GLIBCPP_USE_WCHAR_T
-  size_t res;
-  const char *from_start_copy = (const char *) from_start;
-  size_t from_len = from_end - from_start;
-  char *to_start_copy = to_start;
-  size_t to_len = to_end - to_start;
-  res = iconv (codecvt->__cd_out, &from_start_copy, &from_len,
-	       &to_start_copy, &to_len);
-
-  if (res == 0 || from_len == 0)
-    result = __codecvt_ok;
-  else if (to_len < codecvt->__codecvt_do_max_length (codecvt))
-    result = __codecvt_partial;
-  else
-    result = __codecvt_error;
-
-# else
-  /* Decide what to do.  */
-  result = __codecvt_error;
-# endif
-#endif
 
   return result;
 }
@@ -273,7 +209,6 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 {
   enum __codecvt_result result;
 
-#ifdef _LIBC
   struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
   int status;
   size_t dummy;
@@ -310,25 +245,6 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
       result = __codecvt_error;
       break;
     }
-#else
-# ifdef _GLIBCPP_USE_WCHAR_T
-  size_t res;
-  char *to_start_copy = (char *) to_start;
-  size_t to_len = to_end - to_start;
-
-  res = iconv (codecvt->__cd_out, NULL, NULL, &to_start_copy, &to_len);
-
-  if (res == 0)
-    result = __codecvt_ok;
-  else if (to_len < codecvt->__codecvt_do_max_length (codecvt))
-    result = __codecvt_partial;
-  else
-    result = __codecvt_error;
-# else
-  /* Decide what to do.  */
-  result = __codecvt_error;
-# endif
-#endif
 
   return result;
 }
@@ -341,7 +257,6 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 {
   enum __codecvt_result result;
 
-#ifdef _LIBC
   struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
   int status;
   size_t dummy;
@@ -381,30 +296,6 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
       result = __codecvt_error;
       break;
     }
-#else
-# ifdef _GLIBCPP_USE_WCHAR_T
-  size_t res;
-  const char *from_start_copy = (const char *) from_start;
-  size_t from_len = from_end - from_start;
-  char *to_start_copy = (char *) from_start;
-  size_t to_len = to_end - to_start;
-
-  res = iconv (codecvt->__cd_in, &from_start_copy, &from_len,
-	       &to_start_copy, &to_len);
-
-  if (res == 0)
-    result = __codecvt_ok;
-  else if (to_len == 0)
-    result = __codecvt_partial;
-  else if (from_len < codecvt->__codecvt_do_max_length (codecvt))
-    result = __codecvt_partial;
-  else
-    result = __codecvt_error;
-# else
-  /* Decide what to do.  */
-  result = __codecvt_error;
-# endif
-#endif
 
   return result;
 }
@@ -413,7 +304,6 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 static int
 do_encoding (struct _IO_codecvt *codecvt)
 {
-#ifdef _LIBC
   /* See whether the encoding is stateful.  */
   if (codecvt->__cd_in.__cd.__steps[0].__stateful)
     return -1;
@@ -425,10 +315,6 @@ do_encoding (struct _IO_codecvt *codecvt)
     return 0;
 
   return codecvt->__cd_in.__cd.__steps[0].__min_needed_from;
-#else
-  /* Worst case scenario.  */
-  return -1;
-#endif
 }
 
 
@@ -444,7 +330,6 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 	   const char *from_start, const char *from_end, _IO_size_t max)
 {
   int result;
-#ifdef _LIBC
   const unsigned char *cp = (const unsigned char *) from_start;
   wchar_t to_buf[max];
   struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
@@ -466,23 +351,6 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 		&dummy, 0, 0));
 
   result = cp - (const unsigned char *) from_start;
-#else
-# ifdef _GLIBCPP_USE_WCHAR_T
-  const char *from_start_copy = (const char *) from_start;
-  size_t from_len = from_end - from_start;
-  wchar_t to_buf[max];
-  size_t res;
-  char *to_start = (char *) to_buf;
-
-  res = iconv (codecvt->__cd_in, &from_start_copy, &from_len,
-	       &to_start, &max);
-
-  result = from_start_copy - (char *) from_start;
-# else
-  /* Decide what to do.  */
-  result = 0;
-# endif
-#endif
 
   return result;
 }
@@ -491,9 +359,5 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 static int
 do_max_length (struct _IO_codecvt *codecvt)
 {
-#ifdef _LIBC
   return codecvt->__cd_in.__cd.__steps[0].__max_needed_from;
-#else
-  return MB_CUR_MAX;
-#endif
 }
diff --git a/libio/iofwrite.c b/libio/iofwrite.c
index c89dd9091f..72f703af62 100644
--- a/libio/iofwrite.c
+++ b/libio/iofwrite.c
@@ -49,7 +49,6 @@ _IO_fwrite (const void *buf, _IO_size_t size, _IO_size_t count, _IO_FILE *fp)
 }
 libc_hidden_def (_IO_fwrite)
 
-#ifdef weak_alias
 # include <stdio.h>
 weak_alias (_IO_fwrite, fwrite)
 libc_hidden_weak (fwrite)
@@ -57,4 +56,3 @@ libc_hidden_weak (fwrite)
 weak_alias (_IO_fwrite, fwrite_unlocked)
 libc_hidden_weak (fwrite_unlocked)
 # endif
-#endif
diff --git a/libio/iogetdelim.c b/libio/iogetdelim.c
index 59138881b8..0fce4af768 100644
--- a/libio/iogetdelim.c
+++ b/libio/iogetdelim.c
@@ -123,7 +123,5 @@ unlock_return:
   return result;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_getdelim, __getdelim)
 weak_alias (_IO_getdelim, getdelim)
-#endif
diff --git a/libio/iogets.c b/libio/iogets.c
index 432cecb75c..166a88a4a9 100644
--- a/libio/iogets.c
+++ b/libio/iogets.c
@@ -67,10 +67,6 @@ unlock_return:
   return retval;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_gets, gets)
-#endif
 
-#ifdef _LIBC
 link_warning (gets, "the `gets' function is dangerous and should not be used.")
-#endif
diff --git a/libio/iogetwline.c b/libio/iogetwline.c
index e60a590cc4..535f90339e 100644
--- a/libio/iogetwline.c
+++ b/libio/iogetwline.c
@@ -28,10 +28,6 @@
 #include <string.h>
 #include <wchar.h>
 
-#ifdef _LIBC
-# define wmemcpy __wmemcpy
-#endif
-
 _IO_size_t
 _IO_getwline (_IO_FILE *fp, wchar_t *buf, _IO_size_t n, wint_t delim,
 	      int extract_delim)
@@ -98,12 +94,12 @@ _IO_getwline_info (_IO_FILE *fp, wchar_t *buf, _IO_size_t n, wint_t delim,
 		  if (extract_delim > 0)
 		    ++len;
 		}
-	      wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr,
-		       len);
+	      __wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr,
+			 len);
 	      fp->_wide_data->_IO_read_ptr = t;
 	      return old_len + len;
 	    }
-	  wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, len);
+	  __wmemcpy ((void *) ptr, (void *) fp->_wide_data->_IO_read_ptr, len);
 	  fp->_wide_data->_IO_read_ptr += len;
 	  ptr += len;
 	  n -= len;
diff --git a/libio/iopopen.c b/libio/iopopen.c
index a2ddebb32b..466260ea55 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -25,63 +25,17 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
 #include "libioP.h"
 #include <fcntl.h>
 #include <signal.h>
 #include <unistd.h>
 #include <stdlib.h>
-#ifdef _LIBC
-# include <shlib-compat.h>
-# include <not-cancel.h>
-#endif
+#include <shlib-compat.h>
+#include <not-cancel.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 #include <kernel-features.h>
 
-#ifndef _IO_fork
-#ifdef _LIBC
-#define _IO_fork __fork
-#else
-#define _IO_fork fork /* defined in libiberty, if needed */
-#endif
-extern _IO_pid_t _IO_fork (void) __THROW;
-#endif
-
-#ifndef _IO_dup2
-#ifdef _LIBC
-#define _IO_dup2 __dup2
-#else
-#define _IO_dup2 dup2
-#endif
-extern int _IO_dup2 (int fd, int fd2) __THROW;
-#endif
-
-#ifndef _IO_waitpid
-#ifdef _LIBC
-#define _IO_waitpid __waitpid_nocancel
-#else
-#define _IO_waitpid waitpid
-#endif
-#endif
-
-#ifndef _IO_execl
-#define _IO_execl execl
-#endif
-#ifndef _IO__exit
-#define _IO__exit _exit
-#endif
-
-#ifndef _IO_close
-#ifdef _LIBC
-#define _IO_close __close_nocancel
-#else
-#define _IO_close close
-#endif
-#endif
-
 struct _IO_proc_file
 {
   struct _IO_FILE_plus file;
@@ -165,14 +119,14 @@ _IO_new_proc_open (_IO_FILE *fp, const char *command, const char *mode)
       read_or_write = _IO_NO_READS;
     }
 
-  ((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
+  ((_IO_proc_file *) fp)->pid = child_pid = __fork ();
   if (child_pid == 0)
     {
       int child_std_end = do_read ? 1 : 0;
       struct _IO_proc_file *p;
 
       if (child_end != child_std_end)
-	_IO_dup2 (child_end, child_std_end);
+	__dup2 (child_end, child_std_end);
       else
 	/* The descriptor is already the one we will use.  But it must
 	   not be marked close-on-exec.  Undo the effects.  */
@@ -188,16 +142,16 @@ _IO_new_proc_open (_IO_FILE *fp, const char *command, const char *mode)
 	     child_std_end, it has been already closed by the dup2 syscall
 	     above.  */
 	  if (fd != child_std_end)
-	    _IO_close (fd);
+	    __close_nocancel (fd);
 	}
 
-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
-      _IO__exit (127);
+      execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      _exit (127);
     }
-  _IO_close (child_end);
+  __close_nocancel (child_end);
   if (child_pid < 0)
     {
-      _IO_close (parent_end);
+      __close_nocancel (parent_end);
       return NULL;
     }
 
@@ -284,7 +238,7 @@ _IO_new_proc_close (_IO_FILE *fp)
   _IO_cleanup_region_end (0);
 #endif
 
-  if (status < 0 || _IO_close (_IO_fileno(fp)) < 0)
+  if (status < 0 || __close_nocancel (_IO_fileno(fp)) < 0)
     return -1;
   /* POSIX.2 Rationale:  "Some historical implementations either block
      or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
@@ -292,7 +246,7 @@ _IO_new_proc_close (_IO_FILE *fp)
      described in POSIX.2, such implementations are not conforming." */
   do
     {
-      wait_pid = _IO_waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
+      wait_pid = __waitpid_nocancel (((_IO_proc_file *) fp)->pid, &wstatus, 0);
     }
   while (wait_pid == -1 && errno == EINTR);
   if (wait_pid == -1)
diff --git a/libio/ioputs.c b/libio/ioputs.c
index bf3224e9ab..2529c7bbd1 100644
--- a/libio/ioputs.c
+++ b/libio/ioputs.c
@@ -45,6 +45,4 @@ _IO_puts (const char *str)
   return result;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_puts, puts)
-#endif
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index 425c020c51..e06b066a6f 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -27,12 +27,6 @@
 #include <stdlib.h>
 #include <libioP.h>
 #include <errno.h>
-#ifndef errno
-extern int errno;
-#endif
-#ifndef __set_errno
-# define __set_errno(Val) errno = (Val)
-#endif
 
 _IO_off64_t
 _IO_seekoff_unlocked (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode)
diff --git a/libio/iosetbuffer.c b/libio/iosetbuffer.c
index c5df900fd9..25a6032979 100644
--- a/libio/iosetbuffer.c
+++ b/libio/iosetbuffer.c
@@ -42,6 +42,4 @@ _IO_setbuffer (_IO_FILE *fp, char *buf, _IO_size_t size)
 }
 libc_hidden_def (_IO_setbuffer)
 
-#ifdef weak_alias
 weak_alias (_IO_setbuffer, setbuffer)
-#endif
diff --git a/libio/iosetvbuf.c b/libio/iosetvbuf.c
index b242018c0b..eda49ab3aa 100644
--- a/libio/iosetvbuf.c
+++ b/libio/iosetvbuf.c
@@ -95,6 +95,4 @@ unlock_return:
 }
 libc_hidden_def (_IO_setvbuf)
 
-#ifdef weak_alias
 weak_alias (_IO_setvbuf, setvbuf)
-#endif
diff --git a/libio/ioungetc.c b/libio/ioungetc.c
index 917cad8abb..cb59e0eb98 100644
--- a/libio/ioungetc.c
+++ b/libio/ioungetc.c
@@ -41,6 +41,4 @@ _IO_ungetc (int c, _IO_FILE *fp)
   return result;
 }
 
-#ifdef weak_alias
 weak_alias (_IO_ungetc, ungetc)
-#endif
diff --git a/libio/libioP.h b/libio/libioP.h
index 1832b44cc7..0613439ad4 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -35,31 +35,12 @@
 #include <stddef.h>
 
 #include <errno.h>
-#ifndef __set_errno
-# define __set_errno(Val) errno = (Val)
-#endif
-#if defined __GLIBC__ && __GLIBC__ >= 2
-# include <libc-lock.h>
-#else
-/*# include <comthread.h>*/
-#endif
+#include <libc-lock.h>
 
 #include <math_ldbl_opt.h>
 
 #include "iolibio.h"
 
-/* Control of exported symbols.  Used in glibc.  By default we don't
-   do anything.  */
-#ifndef libc_hidden_proto
-# define libc_hidden_proto(name)
-#endif
-#ifndef libc_hidden_def
-# define libc_hidden_def(name)
-#endif
-#ifndef libc_hidden_weak
-# define libc_hidden_weak(name)
-#endif
-
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -89,14 +70,12 @@ extern "C" {
  * object being acted on (i.e. the 'this' parameter).
  */
 
-#ifdef _LIBC
-# include <shlib-compat.h>
-# if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
-   /* Setting this macro disables the use of the _vtable_offset
-      bias in _IO_JUMPS_FUNCS, below.  That is only needed if we
-      want to support old binaries (see oldfileops.c).  */
-#  define _G_IO_NO_BACKWARD_COMPAT 1
-# endif
+#include <shlib-compat.h>
+#if !SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
+  /* Setting this macro disables the use of the _vtable_offset bias in
+     _IO_JUMPS_FUNCS, below.  That is only needed if we want to
+     support old binaries (see oldfileops.c).  */
+# define _G_IO_NO_BACKWARD_COMPAT 1
 #endif
 
 #if (!defined _IO_USE_OLD_IO_FILE \
@@ -524,19 +503,13 @@ extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
 extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
 
 
-#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-# define _IO_do_flush(_f) \
+#define _IO_do_flush(_f) \
   ((_f)->_mode <= 0							      \
    ? _IO_do_write(_f, (_f)->_IO_write_base,				      \
 		  (_f)->_IO_write_ptr-(_f)->_IO_write_base)		      \
    : _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base,		      \
 		   ((_f)->_wide_data->_IO_write_ptr			      \
 		    - (_f)->_wide_data->_IO_write_base)))
-#else
-# define _IO_do_flush(_f) \
-  _IO_do_write(_f, (_f)->_IO_write_base,				      \
-	       (_f)->_IO_write_ptr-(_f)->_IO_write_base)
-#endif
 #define _IO_old_do_flush(_f) \
   _IO_old_do_write(_f, (_f)->_IO_write_base, \
 		   (_f)->_IO_write_ptr-(_f)->_IO_write_base)
@@ -719,18 +692,6 @@ extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
 #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
 
 #if _G_HAVE_MMAP
 
@@ -750,19 +711,6 @@ extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
 
 #endif /* _G_HAVE_MMAP */
 
-#if _G_HAVE_MMAP
-
-# ifdef _LIBC
-/* When using this code in the GNU libc we must not pollute the name space.  */
-#  define mmap __mmap
-#  define munmap __munmap
-#  define ftruncate __ftruncate
-# endif
-#endif /* _G_HAVE_MMAP */
-
-#ifndef OS_FSTAT
-# define OS_FSTAT fstat
-#endif
 extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
 
 /* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
@@ -790,19 +738,11 @@ extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
 	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
 	 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock }
 # else
-#  if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-#   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
+#  define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
 	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
 	 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
 	 NULL, WDP, 0 }
-#  else
-#   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
-       { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
-	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
-	 0, _IO_pos_BAD, 0, 0, { 0 }, &_IO_stdfile_##FD##_lock, _IO_pos_BAD,\
-	 0 }
-#  endif
 # endif
 #else
 # ifdef _IO_USE_OLD_IO_FILE
@@ -811,19 +751,11 @@ extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
 	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
 	 0, _IO_pos_BAD }
 # else
-#  if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-#   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
+#  define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
        { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
 	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
 	 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
 	 NULL, WDP, 0 }
-#  else
-#   define FILEBUF_LITERAL(CHAIN, FLAGS, FD, WDP) \
-       { _IO_MAGIC+_IO_LINKED+_IO_IS_FILEBUF+FLAGS, \
-	 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (_IO_FILE *) CHAIN, FD, \
-	 0, _IO_pos_BAD, 0, 0, { 0 }, 0, _IO_pos_BAD, \
-	 0 }
-#  endif
 # endif
 #endif
 
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
index 2eceefa68a..671b9822f0 100644
--- a/libio/oldfileops.c
+++ b/libio/oldfileops.c
@@ -30,9 +30,6 @@
 #include <shlib-compat.h>
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
 
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
 #define _IO_USE_OLD_IO_FILE
 #include "libioP.h"
 #include <fcntl.h>
@@ -42,21 +39,6 @@
 #include <errno.h>
 #include <stdlib.h>
 #include <unistd.h>
-#ifndef errno
-extern int errno;
-#endif
-#ifndef __set_errno
-# define __set_errno(Val) errno = (Val)
-#endif
-
-
-#ifdef _LIBC
-# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
-# define close(FD) __close (FD)
-# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
-# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
-# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
-#endif
 
 /* An fstream can be in at most one of put mode, get mode, or putback mode.
    Putback mode is a variant of get mode.
@@ -127,7 +109,6 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp)
 			     - (int) sizeof (struct _IO_FILE_complete));
   fp->file._fileno = -1;
 
-#if defined SHARED && defined _LIBC
   if (__builtin_expect (&_IO_stdin_used != NULL, 1)
       || (fp != (struct _IO_FILE_plus *) _IO_stdin
 	  && fp != (struct _IO_FILE_plus *) _IO_stdout
@@ -135,7 +116,6 @@ _IO_old_file_init_internal (struct _IO_FILE_plus *fp)
     /* The object is dynamically allocated and large enough.  Initialize
        the _mode element as well.  */
     ((struct _IO_FILE_complete *) fp)->_mode = -1;
-#endif
 }
 
 void
@@ -221,7 +201,7 @@ _IO_old_file_fopen (_IO_FILE *fp, const char *filename, const char *mode)
       omode = O_RDWR;
       read_write &= _IO_IS_APPENDING;
     }
-  fdesc = open (filename, omode|oflags, oprot);
+  fdesc = __open (filename, omode|oflags, oprot);
   if (fdesc < 0)
     return NULL;
   fp->_fileno = fdesc;
@@ -443,10 +423,8 @@ _IO_old_file_sync (_IO_FILE *fp)
       _IO_off_t new_pos = _IO_SYSSEEK (fp, delta, 1);
       if (new_pos != (_IO_off_t) EOF)
 	fp->_IO_read_end = fp->_IO_read_ptr;
-#ifdef ESPIPE
       else if (errno == ESPIPE)
 	; /* Ignore error from unseekable devices. */
-#endif
       else
 	retval = EOF;
     }
@@ -647,7 +625,7 @@ _IO_old_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n)
   _IO_ssize_t to_do = n;
   while (to_do > 0)
     {
-      _IO_ssize_t count = write (f->_fileno, data, to_do);
+      _IO_ssize_t count = __write (f->_fileno, data, to_do);
       if (count == EOF)
 	{
 	  f->_flags |= _IO_ERR_SEEN;
@@ -705,12 +683,7 @@ _IO_old_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
 	count = to_do;
       if (count > 20)
 	{
-#ifdef _LIBC
 	  f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
-#else
-	  memcpy (f->_IO_write_ptr, s, count);
-	  f->_IO_write_ptr += count;
-#endif
 	  s += count;
 	}
       else
diff --git a/libio/oldiofdopen.c b/libio/oldiofdopen.c
index 7f6180767e..42284263ba 100644
--- a/libio/oldiofdopen.c
+++ b/libio/oldiofdopen.c
@@ -32,10 +32,6 @@
 #include "libioP.h"
 #include <fcntl.h>
 
-#ifndef _IO_fcntl
-# define _IO_fcntl __fcntl
-#endif
-
 _IO_FILE *
 attribute_compat_text_section
 _IO_old_fdopen (int fd, const char *mode)
@@ -69,11 +65,7 @@ _IO_old_fdopen (int fd, const char *mode)
   }
   if (mode[0] == '+' || (mode[0] == 'b' && mode[1] == '+'))
     read_write &= _IO_IS_APPENDING;
-#ifdef F_GETFL
-  fd_flags = _IO_fcntl (fd, F_GETFL);
-#ifndef O_ACCMODE
-#define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
-#endif
+  fd_flags = __fcntl (fd, F_GETFL);
   if (fd_flags == -1
       || ((fd_flags & O_ACCMODE) == O_RDONLY && !(read_write & _IO_NO_WRITES))
       || ((fd_flags & O_ACCMODE) == O_WRONLY && !(read_write & _IO_NO_READS)))
@@ -97,12 +89,9 @@ _IO_old_fdopen (int fd, const char *mode)
      */
   if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
     {
-#ifdef F_SETFL
-      if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
-#endif
+      if (__fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
 	return NULL;
     }
-#endif
 
   new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
   if (new_f == NULL)
diff --git a/libio/oldiofgetpos.c b/libio/oldiofgetpos.c
index 9781b46d73..4d5d4f8ceb 100644
--- a/libio/oldiofgetpos.c
+++ b/libio/oldiofgetpos.c
@@ -45,20 +45,16 @@ _IO_old_fgetpos (_IO_FILE *fp, _IO_fpos_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       return EOF;
     }
   posp->__pos = pos;
   return 0;
 }
 
-#ifdef weak_alias
 compat_symbol (libc, _IO_old_fgetpos, _IO_fgetpos, GLIBC_2_0);
 strong_alias (_IO_old_fgetpos, __old_fgetpos)
 compat_symbol (libc, __old_fgetpos, fgetpos, GLIBC_2_0);
-#endif
 
 #endif
diff --git a/libio/oldiofgetpos64.c b/libio/oldiofgetpos64.c
index 2221f9140b..3ba8941e90 100644
--- a/libio/oldiofgetpos64.c
+++ b/libio/oldiofgetpos64.c
@@ -45,20 +45,16 @@ _IO_old_fgetpos64 (_IO_FILE *fp, _IO_fpos64_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       return EOF;
     }
   posp->__pos = pos;
   return 0;
 }
 
-#ifdef weak_alias
 compat_symbol (libc, _IO_old_fgetpos64, _IO_fgetpos64, GLIBC_2_1);
 strong_alias (_IO_old_fgetpos64, __old_fgetpos64)
 compat_symbol (libc, __old_fgetpos64, fgetpos64, GLIBC_2_1);
-#endif
 
 #endif
diff --git a/libio/oldiofsetpos.c b/libio/oldiofsetpos.c
index d711937263..4f93bf3578 100644
--- a/libio/oldiofsetpos.c
+++ b/libio/oldiofsetpos.c
@@ -41,10 +41,8 @@ _IO_old_fsetpos (_IO_FILE *fp, const _IO_fpos_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       result = EOF;
     }
   else
@@ -53,10 +51,8 @@ _IO_old_fsetpos (_IO_FILE *fp, const _IO_fpos_t *posp)
   return result;
 }
 
-#ifdef weak_alias
 compat_symbol (libc, _IO_old_fsetpos, _IO_fsetpos, GLIBC_2_0);
 strong_alias (_IO_old_fsetpos, __old_fsetpos)
 compat_symbol (libc, __old_fsetpos, fsetpos, GLIBC_2_0);
-#endif
 
 #endif
diff --git a/libio/oldiofsetpos64.c b/libio/oldiofsetpos64.c
index 7fad4081a1..391cf5cf2a 100644
--- a/libio/oldiofsetpos64.c
+++ b/libio/oldiofsetpos64.c
@@ -42,10 +42,8 @@ _IO_old_fsetpos64 (_IO_FILE *fp, const _IO_fpos64_t *posp)
     {
       /* ANSI explicitly requires setting errno to a positive value on
 	 failure.  */
-#ifdef EIO
       if (errno == 0)
 	__set_errno (EIO);
-#endif
       result = EOF;
     }
   else
@@ -54,10 +52,8 @@ _IO_old_fsetpos64 (_IO_FILE *fp, const _IO_fpos64_t *posp)
   return result;
 }
 
-#ifdef weak_alias
 compat_symbol (libc, _IO_old_fsetpos64, _IO_fsetpos64, GLIBC_2_1);
 strong_alias (_IO_old_fsetpos64, __old_fsetpos64)
 compat_symbol (libc, __old_fsetpos64, fsetpos64, GLIBC_2_1);
-#endif
 
 #endif
diff --git a/libio/oldiopopen.c b/libio/oldiopopen.c
index af7774ae90..2cb67879c3 100644
--- a/libio/oldiopopen.c
+++ b/libio/oldiopopen.c
@@ -26,72 +26,17 @@
    in files containing the exception.  */
 
 #define _IO_USE_OLD_IO_FILE
-#ifndef _POSIX_SOURCE
-# define _POSIX_SOURCE
-#endif
 #include "libioP.h"
 #include <signal.h>
 #include <unistd.h>
 #include <stdlib.h>
-#ifdef _LIBC
-# include <unistd.h>
-#endif
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/wait.h>
 
-#ifndef _IO_fork
-#ifdef _LIBC
-#define _IO_fork __fork
-#else
-#define _IO_fork fork /* defined in libiberty, if needed */
-#endif
-extern _IO_pid_t _IO_fork (void) __THROW;
-#endif
-
 #include <shlib-compat.h>
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
 
-#ifndef _IO_pipe
-#ifdef _LIBC
-#define _IO_pipe __pipe
-#else
-#define _IO_pipe pipe
-#endif
-extern int _IO_pipe (int des[2]) __THROW;
-#endif
-
-#ifndef _IO_dup2
-#ifdef _LIBC
-#define _IO_dup2 __dup2
-#else
-#define _IO_dup2 dup2
-#endif
-extern int _IO_dup2 (int fd, int fd2) __THROW;
-#endif
-
-#ifndef _IO_waitpid
-#ifdef _LIBC
-#define _IO_waitpid __waitpid
-#else
-#define _IO_waitpid waitpid
-#endif
-#endif
-
-#ifndef _IO_execl
-#define _IO_execl execl
-#endif
-#ifndef _IO__exit
-#define _IO__exit _exit
-#endif
-
-#ifndef _IO_close
-#ifdef _LIBC
-#define _IO_close __close
-#else
-#define _IO_close close
-#endif
-#endif
-
 struct _IO_proc_file
 {
   struct _IO_FILE_complete_plus file;
@@ -123,7 +68,7 @@ _IO_old_proc_open (_IO_FILE *fp, const char *command, const char *mode)
   _IO_pid_t child_pid;
   if (_IO_file_is_open (fp))
     return NULL;
-  if (_IO_pipe (pipe_fds) < 0)
+  if (__pipe (pipe_fds) < 0)
     return NULL;
   if (mode[0] == 'r' && mode[1] == '\0')
     {
@@ -139,36 +84,36 @@ _IO_old_proc_open (_IO_FILE *fp, const char *command, const char *mode)
     }
   else
     {
-      _IO_close (pipe_fds[0]);
-      _IO_close (pipe_fds[1]);
+      __close (pipe_fds[0]);
+      __close (pipe_fds[1]);
       __set_errno (EINVAL);
       return NULL;
     }
-  ((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
+  ((_IO_proc_file *) fp)->pid = child_pid = __fork ();
   if (child_pid == 0)
     {
       int child_std_end = mode[0] == 'r' ? 1 : 0;
       struct _IO_proc_file *p;
 
-      _IO_close (parent_end);
+      __close (parent_end);
       if (child_end != child_std_end)
 	{
-	  _IO_dup2 (child_end, child_std_end);
-	  _IO_close (child_end);
+	  __dup2 (child_end, child_std_end);
+	  __close (child_end);
 	}
       /* POSIX.2:  "popen() shall ensure that any streams from previous
          popen() calls that remain open in the parent process are closed
 	 in the new child process." */
       for (p = old_proc_file_chain; p; p = p->next)
-	_IO_close (_IO_fileno ((_IO_FILE *) p));
+	__close (_IO_fileno ((_IO_FILE *) p));
 
-      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
-      _IO__exit (127);
+      execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      _exit (127);
     }
-  _IO_close (child_end);
+  __close (child_end);
   if (child_pid < 0)
     {
-      _IO_close (parent_end);
+      __close (parent_end);
       return NULL;
     }
   _IO_fileno (fp) = parent_end;
@@ -251,7 +196,7 @@ _IO_old_proc_close (_IO_FILE *fp)
   _IO_cleanup_region_end (0);
 #endif
 
-  if (status < 0 || _IO_close (_IO_fileno(fp)) < 0)
+  if (status < 0 || __close (_IO_fileno(fp)) < 0)
     return -1;
   /* POSIX.2 Rationale:  "Some historical implementations either block
      or ignore the signals SIGINT, SIGQUIT, and SIGHUP while waiting
@@ -259,7 +204,7 @@ _IO_old_proc_close (_IO_FILE *fp)
      described in POSIX.2, such implementations are not conforming." */
   do
     {
-      wait_pid = _IO_waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
+      wait_pid = __waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
     }
   while (wait_pid == -1 && errno == EINTR);
   if (wait_pid == -1)
diff --git a/libio/putc.c b/libio/putc.c
index 6e1fdeef3a..2f48cd15e5 100644
--- a/libio/putc.c
+++ b/libio/putc.c
@@ -36,11 +36,9 @@ libc_hidden_def (_IO_putc)
 
 #undef putc
 
-#ifdef weak_alias
 weak_alias (_IO_putc, putc)
 
 #ifndef _IO_MTSAFE_IO
 #undef putc_unlocked
 weak_alias (_IO_putc, putc_unlocked)
 #endif
-#endif
diff --git a/libio/stdfiles.c b/libio/stdfiles.c
index 218be40e60..24725f0671 100644
--- a/libio/stdfiles.c
+++ b/libio/stdfiles.c
@@ -34,35 +34,20 @@
 #include "libioP.h"
 
 #ifdef _IO_MTSAFE_IO
-# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-#  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
+# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
   static struct _IO_wide_data _IO_wide_data_##FD \
     = { ._wide_vtable = &_IO_wfile_jumps }; \
   struct _IO_FILE_plus NAME \
     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
        &_IO_file_jumps};
-# else
-#  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
-  static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
-  struct _IO_FILE_plus NAME \
-    = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
-       &_IO_file_jumps};
-# endif
 #else
-# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-#  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
+# define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   static struct _IO_wide_data _IO_wide_data_##FD \
     = { ._wide_vtable = &_IO_wfile_jumps }; \
   struct _IO_FILE_plus NAME \
     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
        &_IO_file_jumps};
-# else
-#  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
-  struct _IO_FILE_plus NAME \
-    = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
-       &_IO_file_jumps};
-# endif
 #endif
 
 DEF_STDFILE(_IO_2_1_stdin_, 0, 0, _IO_NO_WRITES);
diff --git a/libio/stdio.c b/libio/stdio.c
index 3ff825241b..33292f0429 100644
--- a/libio/stdio.c
+++ b/libio/stdio.c
@@ -37,12 +37,10 @@ _IO_FILE *stderr = (FILE *) &_IO_2_1_stderr_;
 #undef _IO_stdin
 #undef _IO_stdout
 #undef _IO_stderr
-#ifdef _LIBC
-# define AL(name) AL2 (name, _IO_##name)
-# define AL2(name, al) \
+#define AL(name) AL2 (name, _IO_##name)
+#define AL2(name, al) \
   extern __typeof (name) al __attribute__ ((alias (#name),                    \
                                             visibility ("hidden")))
 AL(stdin);
 AL(stdout);
 AL(stderr);
-#endif
diff --git a/libio/wfileops.c b/libio/wfileops.c
index fb94f45040..8756b6fe1a 100644
--- a/libio/wfileops.c
+++ b/libio/wfileops.c
@@ -33,24 +33,6 @@
 #include <stdlib.h>
 #include <string.h>
 
-
-#ifndef _LIBC
-# define _IO_new_do_write _IO_do_write
-# define _IO_new_file_attach _IO_file_attach
-# define _IO_new_file_close_it _IO_file_close_it
-# define _IO_new_file_finish _IO_file_finish
-# define _IO_new_file_fopen _IO_file_fopen
-# define _IO_new_file_init _IO_file_init
-# define _IO_new_file_setbuf _IO_file_setbuf
-# define _IO_new_file_sync _IO_file_sync
-# define _IO_new_file_overflow _IO_file_overflow
-# define _IO_new_file_seekoff _IO_file_seekoff
-# define _IO_new_file_underflow _IO_file_underflow
-# define _IO_new_file_write _IO_file_write
-# define _IO_new_file_xsputn _IO_file_xsputn
-#endif
-
-
 /* Convert TO_DO wide character from DATA to FP.
    Then mark FP as having empty buffers. */
 int
@@ -541,10 +523,8 @@ _IO_wfile_sync (_IO_FILE *fp)
 	  fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
 	  fp->_IO_read_end = fp->_IO_read_ptr;
 	}
-#ifdef ESPIPE
       else if (errno == ESPIPE)
 	; /* Ignore error from unseekable devices. */
-#endif
       else
 	retval = WEOF;
     }
@@ -1010,13 +990,8 @@ _IO_wfile_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
 	count = to_do;
       if (count > 20)
 	{
-#ifdef _LIBC
 	  f->_wide_data->_IO_write_ptr =
 	    __wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
-#else
-	  wmemcpy (f->_wide_data->_IO_write_ptr, s, count);
-	  f->_wide_data->_IO_write_ptr += count;
-#endif
 	  s += count;
 	}
       else
diff --git a/libio/wgenops.c b/libio/wgenops.c
index d8072abea0..a309de47b4 100644
--- a/libio/wgenops.c
+++ b/libio/wgenops.c
@@ -34,16 +34,7 @@
 #include <wchar.h>
 
 
-#ifndef _LIBC
-# define __wmemcpy(dst, src, n) wmemcpy (dst, src, n)
-#endif
-
-
-static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW
-#ifdef _LIBC
-     internal_function
-#endif
-     ;
+static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW;
 
 /* Return minimum _pos markers
    Assumes the current get area is the main get area. */
@@ -307,13 +298,8 @@ _IO_wdefault_xsputn (_IO_FILE *f, const void *data, _IO_size_t n)
 	    count = more;
 	  if (count > 20)
 	    {
-#ifdef _LIBC
 	      f->_wide_data->_IO_write_ptr =
 		__wmempcpy (f->_wide_data->_IO_write_ptr, s, count);
-#else
-	      memcpy (f->_wide_data->_IO_write_ptr, s, count);
-	      f->_wide_data->_IO_write_ptr += count;
-#endif
 	      s += count;
             }
 	  else if (count <= 0)
@@ -353,12 +339,7 @@ _IO_wdefault_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n)
 	    count = more;
 	  if (count > 20)
 	    {
-#ifdef _LIBC
 	      s = __wmempcpy (s, fp->_wide_data->_IO_read_ptr, count);
-#else
-	      memcpy (s, fp->_wide_data->_IO_read_ptr, count);
-	      s += count;
-#endif
 	      fp->_wide_data->_IO_read_ptr += count;
 	    }
 	  else if (count <= 0)
@@ -466,9 +447,6 @@ _IO_switch_to_wput_mode (_IO_FILE *fp)
 
 
 static int
-#ifdef _LIBC
-internal_function
-#endif
 save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
 {
   /* Append [_IO_read_base..end_p] to backup area. */
@@ -492,32 +470,17 @@ save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
 	return EOF;		/* FIXME */
       if (least_mark < 0)
 	{
-#ifdef _LIBC
 	  __wmempcpy (__wmempcpy (new_buffer + avail,
 				  fp->_wide_data->_IO_save_end + least_mark,
 				  -least_mark),
 		      fp->_wide_data->_IO_read_base,
 		      end_p - fp->_wide_data->_IO_read_base);
-#else
-	  memcpy (new_buffer + avail,
-		  fp->_wide_data->_IO_save_end + least_mark,
-		  -least_mark * sizeof (wchar_t));
-	  memcpy (new_buffer + avail - least_mark,
-		  fp->_wide_data->_IO_read_base,
-		  (end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
-#endif
 	}
       else
 	{
-#ifdef _LIBC
 	  __wmemcpy (new_buffer + avail,
 		     fp->_wide_data->_IO_read_base + least_mark,
 		     needed_size);
-#else
-	  memcpy (new_buffer + avail,
-		  fp->_wide_data->_IO_read_base + least_mark,
-		  needed_size * sizeof (wchar_t));
-#endif
 	}
       free (fp->_wide_data->_IO_save_base);
       fp->_wide_data->_IO_save_base = new_buffer;
@@ -528,32 +491,17 @@ save_for_wbackup (_IO_FILE *fp, wchar_t *end_p)
       avail = current_Bsize - needed_size;
       if (least_mark < 0)
 	{
-#ifdef _LIBC
 	  __wmemmove (fp->_wide_data->_IO_save_base + avail,
 		      fp->_wide_data->_IO_save_end + least_mark,
 		      -least_mark);
 	  __wmemcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
 		     fp->_wide_data->_IO_read_base,
 		     end_p - fp->_wide_data->_IO_read_base);
-#else
-	  memmove (fp->_wide_data->_IO_save_base + avail,
-		   fp->_wide_data->_IO_save_end + least_mark,
-		   -least_mark * sizeof (wchar_t));
-	  memcpy (fp->_wide_data->_IO_save_base + avail - least_mark,
-		  fp->_wide_data->_IO_read_base,
-		  (end_p - fp->_wide_data->_IO_read_base) * sizeof (wchar_t));
-#endif
 	}
       else if (needed_size > 0)
-#ifdef _LIBC
 	__wmemcpy (fp->_wide_data->_IO_save_base + avail,
 		   fp->_wide_data->_IO_read_base + least_mark,
 		   needed_size);
-#else
-	memcpy (fp->_wide_data->_IO_save_base + avail,
-		fp->_wide_data->_IO_read_base + least_mark,
-		needed_size * sizeof (wchar_t));
-#endif
     }
   fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_base + avail;
   /* Adjust all the streammarkers. */