about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog176
-rw-r--r--argp/argp-fmtstream.c18
-rw-r--r--argp/argp-help.c54
-rw-r--r--assert/assert-perr.c6
-rw-r--r--assert/assert.c8
-rw-r--r--configure.in2
-rw-r--r--dirent/scandir.c6
-rw-r--r--dirent/scandir64.c6
-rw-r--r--dirent/versionsort.c4
-rw-r--r--dirent/versionsort64.c4
-rw-r--r--elf/Makefile2
-rw-r--r--gmon/bb_exit_func.c11
-rw-r--r--gmon/gmon.c2
-rw-r--r--grp/fgetgrent_r.c15
-rw-r--r--grp/initgroups.c4
-rw-r--r--iconv/gconv_conf.c4
-rw-r--r--inet/getnameinfo.c6
-rw-r--r--inet/getnetgrent_r.c2
-rw-r--r--inet/inet_ntoa.c3
-rw-r--r--inet/rcmd.c58
-rw-r--r--inet/rexec.c36
-rw-r--r--inet/ruserpass.c14
-rw-r--r--io/fts.c39
-rw-r--r--io/ftw.c26
-rw-r--r--io/ftw64.c4
-rw-r--r--io/getdirname.c6
-rw-r--r--io/getwd.c4
-rw-r--r--io/lockf.c8
-rw-r--r--libio/Makefile3
-rw-r--r--libio/Versions2
-rw-r--r--libio/iofdopen.c4
-rw-r--r--libio/iofputs_u.c42
-rw-r--r--libio/iopopen.c22
-rw-r--r--libio/stdio.h6
-rw-r--r--linuxthreads/ChangeLog14
-rw-r--r--linuxthreads/attr.c2
-rw-r--r--linuxthreads/manager.c6
-rw-r--r--linuxthreads/mutex.c12
-rw-r--r--login/utmp_daemon.c18
-rw-r--r--malloc/mtrace.c4
-rw-r--r--malloc/obstack.c5
-rw-r--r--misc/daemon.c16
-rw-r--r--misc/efgcvt_r.c2
-rw-r--r--misc/err.c15
-rw-r--r--misc/error.c4
-rw-r--r--misc/fstab.c14
-rw-r--r--misc/getpass.c19
-rw-r--r--misc/getttyent.c5
-rw-r--r--misc/mntent_r.c5
-rw-r--r--misc/search.h2
-rw-r--r--misc/syslog.c28
-rw-r--r--nscd/nscd_getgr_r.c44
-rw-r--r--nscd/nscd_getpw_r.c24
-rw-r--r--posix/setpgrp.c4
-rw-r--r--posix/wordexp.c50
-rw-r--r--pwd/fgetpwent_r.c13
-rw-r--r--pwd/getpw.c4
-rw-r--r--resolv/herror.c2
-rw-r--r--resolv/res_init.c6
-rw-r--r--shadow/fgetspent_r.c13
-rw-r--r--shadow/lckpwdf.c22
-rw-r--r--signal/sigrelse.c4
-rw-r--r--stdio-common/asprintf.c4
-rw-r--r--stdio-common/dprintf.c6
-rw-r--r--stdio-common/getw.c5
-rw-r--r--stdio-common/putw.c5
-rw-r--r--stdio-common/snprintf.c6
-rw-r--r--stdio-common/sprintf.c6
-rw-r--r--stdio-common/sscanf.c6
-rw-r--r--stdlib/lrand48_r.c2
-rw-r--r--stdlib/mrand48_r.c2
-rw-r--r--string/argz-replace.c10
-rw-r--r--string/envz.c8
-rw-r--r--sunrpc/auth_des.c8
-rw-r--r--sunrpc/auth_unix.c12
-rw-r--r--sunrpc/bindrsvprt.c4
-rw-r--r--sunrpc/clnt_gen.c2
-rw-r--r--sunrpc/clnt_perr.c26
-rw-r--r--sunrpc/clnt_simp.c2
-rw-r--r--sunrpc/clnt_tcp.c20
-rw-r--r--sunrpc/clnt_udp.c10
-rw-r--r--sunrpc/get_myaddr.c10
-rw-r--r--sunrpc/key_call.c34
-rw-r--r--sunrpc/netname.c6
-rw-r--r--sunrpc/openchild.c33
-rw-r--r--sunrpc/pmap_rmt.c18
-rw-r--r--sunrpc/rpc/auth.h10
-rw-r--r--sunrpc/rpc/clnt.h16
-rw-r--r--sunrpc/rpc/pmap_clnt.h3
-rw-r--r--sunrpc/rpc/svc.h22
-rw-r--r--sunrpc/rpc/xdr.h22
-rw-r--r--sunrpc/rpc_dtable.c12
-rw-r--r--sunrpc/rtime.c8
-rw-r--r--sunrpc/svc_run.c4
-rw-r--r--sunrpc/svc_simple.c6
-rw-r--r--sunrpc/svc_tcp.c24
-rw-r--r--sunrpc/svc_udp.c16
-rw-r--r--sunrpc/svcauth_des.c8
-rw-r--r--sunrpc/xdr_array.c2
-rw-r--r--sunrpc/xdr_rec.c7
-rw-r--r--sunrpc/xdr_ref.c7
-rw-r--r--sunrpc/xdr_stdio.c8
-rw-r--r--sysdeps/generic/abort.c6
-rw-r--r--sysdeps/generic/dl-environ.c69
-rw-r--r--sysdeps/generic/dl-sysdep.c46
-rw-r--r--sysdeps/generic/fstatfs64.c4
-rw-r--r--sysdeps/generic/ftruncate64.c4
-rw-r--r--sysdeps/generic/getrlimit64.c4
-rw-r--r--sysdeps/generic/glob.c7
-rw-r--r--sysdeps/generic/prof-freq.c4
-rw-r--r--sysdeps/generic/putenv.c7
-rw-r--r--sysdeps/generic/statfs64.c4
-rw-r--r--sysdeps/generic/ttyname_r.c6
-rw-r--r--sysdeps/generic/utmp_file.c44
-rw-r--r--sysdeps/generic/vlimit.c4
-rw-r--r--sysdeps/generic/vtimes.c4
-rw-r--r--sysdeps/i386/fpu/bits/mathinline.h4
-rw-r--r--sysdeps/i386/memchr.S8
-rw-r--r--sysdeps/libm-i387/i686/s_fdim.S2
-rw-r--r--sysdeps/libm-i387/i686/s_fdimf.S2
-rw-r--r--sysdeps/libm-i387/i686/s_fdiml.S2
-rw-r--r--sysdeps/posix/cuserid.c4
-rw-r--r--sysdeps/posix/euidaccess.c8
-rw-r--r--sysdeps/posix/mkstemp.c4
-rw-r--r--sysdeps/posix/mktemp.c2
-rw-r--r--sysdeps/posix/pread.c10
-rw-r--r--sysdeps/posix/pread64.c10
-rw-r--r--sysdeps/posix/profil.c6
-rw-r--r--sysdeps/posix/pwrite.c10
-rw-r--r--sysdeps/posix/pwrite64.c10
-rw-r--r--sysdeps/posix/sigblock.c4
-rw-r--r--sysdeps/posix/sigpause.c6
-rw-r--r--sysdeps/posix/ttyname.c10
-rw-r--r--sysdeps/posix/ttyname_r.c10
-rw-r--r--sysdeps/posix/waitid.c2
-rw-r--r--sysdeps/unix/getlogin_r.c6
-rw-r--r--sysdeps/unix/grantpt.c10
-rw-r--r--sysdeps/unix/rewinddir.c4
-rw-r--r--sysdeps/unix/sysv/linux/accept.S1
-rw-r--r--sysdeps/unix/sysv/linux/bind.S1
-rw-r--r--sysdeps/unix/sysv/linux/gethostid.c4
-rw-r--r--sysdeps/unix/sysv/linux/getpt.c4
-rw-r--r--sysdeps/unix/sysv/linux/getsockname.S1
-rw-r--r--sysdeps/unix/sysv/linux/i386/socket.S6
-rw-r--r--sysdeps/unix/sysv/linux/if_index.c40
-rw-r--r--sysdeps/unix/sysv/linux/listen.S1
-rw-r--r--sysdeps/unix/sysv/linux/ptsname.c2
-rw-r--r--sysdeps/unix/sysv/linux/recvfrom.S1
-rw-r--r--sysdeps/unix/sysv/linux/sendmsg.c6
-rw-r--r--sysdeps/unix/sysv/linux/sendto.S1
-rw-r--r--sysdeps/unix/sysv/linux/setsockopt.S1
-rw-r--r--sysdeps/unix/sysv/linux/statvfs.c4
-rw-r--r--sysdeps/unix/sysv/linux/ttyname.c6
-rw-r--r--sysdeps/unix/sysv/linux/ttyname_r.c10
-rw-r--r--sysdeps/unix/sysv/linux/ulimit.c4
-rw-r--r--sysdeps/unix/sysv/linux/unlockpt.c2
-rw-r--r--sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h4
-rw-r--r--sysvipc/sys/shm.h4
-rw-r--r--time/ctime_r.c6
-rw-r--r--time/strptime.c4
-rw-r--r--wcsmbs/mbrlen.c4
-rw-r--r--wcsmbs/wcsdup.c4
-rw-r--r--wcsmbs/wcsxfrm.c4
-rw-r--r--wctype/wcfuncs.c8
164 files changed, 1173 insertions, 691 deletions
diff --git a/ChangeLog b/ChangeLog
index b0389d2b77..8cbdff4e0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,179 @@
+1998-07-16 10:23  Ulrich Drepper  <drepper@cygnus.com>
+
+	* argp/argp-fmtstream.c: Unify names of used global functions.
+	* argp/argp-help.c: Likewise.
+	* assert/assert-perr.c: Likewise
+	* assert/assert.c: Likewise
+	* dirent/scandir.c: Likewise
+	* dirent/scandir64.c: Likewise
+	* dirent/versionsort.c: Likewise
+	* dirent/versionsort64.c: Likewise
+	* gmon/bb_exit_func.c: Likewise.
+	* gmon/gmon.c: Likewise.
+	* grp/initgroups.c: Likewise.
+	* iconv/gconv_conf.c: Likewise.
+	* inet/getnameinfo.c: Likewise.
+	* inet/getnetgrent_r.c: Likewise.
+	* inet/inet_ntoa.c: Likewise.
+	* inet/rcmd.c: Likewise.
+	* inet/rexec.c: Likewise.
+	* inet/ruserpass.c: Likewise.
+	* io/fts.c: Likewise.
+	* io/ftw.c: Likewise.
+	* io/ftw64.c: Likewise.
+	* io/getdirname.c: Likewise.
+	* io/getwd.c: Likewise.
+	* io/lockf.c: Likewise.
+	* libio/iofdopen.c: Likewise.
+	* libio/iopopen.c: Likewise.
+	* login/utmp_daemon.c: Likewise.
+	* malloc/mtrace.c: Likewise.
+	* malloc/obstack.c
+	* misc/daemon.c: Likewise.
+	* misc/efgcvt_r.c: Likewise.
+	* misc/err.c: Likewise.
+	* misc/error.c: Likewise.
+	* misc/fstab.c: Likewise.
+	* misc/getpass.c: Likewise.
+	* misc/getttyent.c: Likewise.
+	* misc/mntent_r.c: Likewise.
+	* misc/search.h: Likewise.
+	* misc/syslog.c: Likewise.
+	* nscd/nscd_getgr_r.c: Likewise.
+	* nscd/nscd_getpw_r.c: Likewise.
+	* posix/getpgrp.c: Likewise.
+	* posix/wordexp.c: Likewise.
+	* pwd/fgetpwent_r.c: Likewise.
+	* pwd/getpw.c: Likewise.
+	* resolv/herror.c: Likewise.
+	* resolv/res_init.c: Likewise.
+	* shadow/fgetspent_r.c: Likewise.
+	* shadow/lckpwdf.c: Likewise.
+	* signal/sigrelse.c: Likewise.
+	* stdio-common/asprintf.c: Likewise.
+	* stdio-common/dprintf.c: Likewise.
+	* stdio-common/getw.c: Likewise.
+	* stdio-common/putw.c: Likewise.
+	* stdio-common/snprintf.c: Likewise.
+	* stdio-common/sprintf.c: Likewise.
+	* stdio-common/sscanf.c: Likewise.
+	* stdlib/lrand48_r.c: Likewise.
+	* stdlib/mrand48_r.c: Likewise.
+	* string/argz-replace.c: Likewise.
+	* string/envz.c: Likewise.
+	* sunrpc/auth_des.c: Likewise.
+	* sunrpc/auth_unix.c: Likewise.
+	* sunrpc/bindrsvprt.c: Likewise.
+	* sunrpc/clnt_gen.c: Likewise.
+	* sunrpc/clnt_perr.c: Likewise.
+	* sunrpc/clnt_simp.c: Likewise.
+	* sunrpc/clnt_tcp.c: Likewise.
+	* sunrpc/clnt_udp.c: Likewise.
+	* sunrpc/get_myaddr.c: Likewise.
+	* sunrpc/key_call.c: Likewise.
+	* sunrpc/netname.c: Likewise.
+	* sunrpc/openchild.c: Likewise.
+	* sunrpc/pmap_rmt.c: Likewise.
+	* sunrpc/rpc_dtable.c: Likewise.
+	* sunrpc/rtime.c: Likewise.
+	* sunrpc/svc_run.c: Likewise.
+	* sunrpc/svc_simple.c: Likewise.
+	* sunrpc/svc_tcp.c: Likewise.
+	* sunrpc/svc_udp.c: Likewise.
+	* sunrpc/svcauth_des.c: Likewise.
+	* sunrpc/xdr_array.c: Likewise.
+	* sunrpc/xdr_rec.c: Likewise.
+	* sunrpc/xdr_ref.c: Likewise.
+	* sunrpc/xdr_stdio.c: Likewise.
+	* sysdeps/generic/abort.c: Likewise.
+	* sysdeps/generic/dl-sysdep.c: Likewise.
+	* sysdeps/generic/fstatfs64.c: Likewise.
+	* sysdeps/generic/ftruncate64.c: Likewise.
+	* sysdeps/generic/getrlimit64.c: Likewise.
+	* sysdeps/generic/glob.c: Likewise.
+	* sysdeps/generic/prof-freq.c: Likewise.
+	* sysdeps/generic/putenv.c: Likewise.
+	* sysdeps/generic/statfs64.c: Likewise.
+	* sysdeps/generic/ttyname_r.c: Likewise.
+	* sysdeps/generic/utmp_file.c: Likewise.
+	* sysdeps/generic/vlimit.c: Likewise.
+	* sysdeps/generic/vtimes.c: Likewise.
+	* sysdeps/posix/cuserid.c: Likewise.
+	* sysdeps/posix/euidaccess.c: Likewise.
+	* sysdeps/posix/mkstemp.c: Likewise.
+	* sysdeps/posix/mktemp.c: Likewise.
+	* sysdeps/posix/pread.c: Likewise.
+	* sysdeps/posix/pread64.c: Likewise.
+	* sysdeps/posix/profil.c: Likewise.
+	* sysdeps/posix/pwrite.c: Likewise.
+	* sysdeps/posix/pwrite64.c: Likewise.
+	* sysdeps/posix/sigblock.c: Likewise.
+	* sysdeps/posix/sigpause.c: Likewise.
+	* sysdeps/posix/ttyname.c: Likewise.
+	* sysdeps/posix/ttyname_r.c: Likewise.
+	* sysdeps/posix/waitid.c: Likewise.
+	* sysdeps/unix/getlogin_r.c: Likewise.
+	* sysdeps/unix/grantpt.c: Likewise.
+	* sysdeps/unix/rewinddir.c: Likewise.
+	* sysdeps/unix/sysv/linux/gethostid.c: Likewise.
+	* sysdeps/unix/sysv/linux/getpt.c: Likewise.
+	* sysdeps/unix/sysv/linux/if_index.c: Likewise.
+	* sysdeps/unix/sysv/linux/ptsname.c: Likewise.
+	* sysdeps/unix/sysv/linux/sendmsg.c: Likewise.
+	* sysdeps/unix/sysv/linux/statvfs.c: Likewise.
+	* sysdeps/unix/sysv/linux/ttyname.c: Likewise.
+	* sysdeps/unix/sysv/linux/ttyname_r.c: Likewise.
+	* sysdeps/unix/sysv/linux/ulimit.c: Likewise.
+	* sysdeps/unix/sysv/linux/unlockpt.c: Likewise.
+	* sysvipc/sys/shm.h: Likewise.
+	* time/ctime_r.c: Likewise.
+	* time/strptime.c: Likewise.
+	* wcsmbs/mbrlen.c: Likewise.
+	* wcsmbs/wcsdup.c: Likewise.
+	* wcsmbs/wcsxfrm.c: Likewise.
+	* wctype/wcfuncs.c: Likewise.
+
+	* sysdeps/unix/sysv/linux/i386/socker.S: Change to honor NO_WEAK_ALIAS.
+	* sysdeps/unix/sysv/linux/accept.S: Don't generate __ name.
+	* sysdeps/unix/sysv/linux/bind.S: Likewise.
+	* sysdeps/unix/sysv/linux/getsockname.S: Likewise.
+	* sysdeps/unix/sysv/linux/listen.S: Likewise.
+	* sysdeps/unix/sysv/linux/recvfrom.S: Likewise.
+	* sysdeps/unix/sysv/linux/sendto.S: Likewise.
+	* sysdeps/unix/sysv/linux/setsockopt.S: Likewise.
+
+	* grp/fgetgrent_r.c: Use explicit locking of the stream.
+
+	* elf/Makefile (rtld-routines): Add dl-environ.
+	* sysdeps/generic/dl-environ.c: New file.
+
+	* libio/Makefile [REENTRANT] (routines): Add iofputs_u.
+	* libio/Versions: Add fputs_unlocked.
+	* libio/iofputs_u.c: New file.
+	* libio/stdio.h: Add prototype for fputs_unlocked.
+
+	* sunrpc/rpc/auth.h: Use __PMT instead of __P in type definitions.
+	* sunrpc/rpc/clnt.h: Likewise.
+	* sunrpc/rpc/pmap_clnt.h: Likewise.
+	* sunrpc/rpc/svc.h: Likewise.
+	* sunrpc/rpc/xdr.h: Likewise.
+
+	* sysdeps/i386/memchr.S: Correct for more strict gas.
+	* sysdeps/i386/fpu/bits/mathinline.h: Likewise.
+	* sysdeps/libm-i387/i686/s_fdim.S: Likewise.
+	* sysdeps/libm-i387/i686/s_fdimf.S: Likewise.
+	* sysdeps/libm-i387/i686/s_fdiml.S: Likewise.
+
+1998-07-15  Andreas Jaeger  <aj@arthur.rhein-neckar.de>
+
+	* configure.in: Change message for binutils version from
+	2.8.1.0.17->2.8.1.0.23.
+
+1998-07-15  Ulrich Drepper  <drepper@cygnus.com>
+
+	* sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h: Define LOC.
+	Patch by John Tobey <jtobey@banta-im.com>.
+
 1998-07-14  Ulrich Drepper  <drepper@cygnus.com>
 
 	* sunrpc/auth_unix.c (authunix_create_default): Use __sysconf
diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c
index 0c9b3118e2..e5acda68e6 100644
--- a/argp/argp-fmtstream.c
+++ b/argp/argp-fmtstream.c
@@ -1,5 +1,5 @@
 /* Word-wrapping and line-truncating streams
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>.
 
@@ -40,6 +40,10 @@
 #define isblank(ch) ((ch)==' ' || (ch)=='\t')
 #endif
 
+#if defined _LIBC && defined USE_IN_LIBIO
+# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+#endif
+
 #define INIT_BUF_SIZE 200
 #define PRINTF_SIZE_GUESS 150
 
@@ -89,7 +93,7 @@ __argp_fmtstream_free (argp_fmtstream_t fs)
 {
   __argp_fmtstream_update (fs);
   if (fs->p > fs->buf)
-    fwrite (fs->buf, 1, fs->p - fs->buf, fs->stream);
+    fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
   free (fs->buf);
   free (fs);
 }
@@ -129,7 +133,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
 	      /* No buffer space for spaces.  Must flush.  */
 	      size_t i;
 	      for (i = 0; i < pad; i++)
-		putc (' ', fs->stream);
+		putc_unlocked (' ', fs->stream);
 	    }
 	  fs->point_col = pad;
 	}
@@ -262,8 +266,8 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
 	      /* Output the first line so we can use the space.  */
 	      {
 		if (nl > fs->buf)
-		  fwrite (fs->buf, 1, nl - fs->buf, fs->stream);
-		putc ('\n', fs->stream);
+		  fwrite_unlocked (fs->buf, 1, nl - fs->buf, fs->stream);
+		putc_unlocked ('\n', fs->stream);
 		len += buf - fs->buf;
 		nl = buf = fs->buf;
 	      }
@@ -279,7 +283,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs)
 	      *nl++ = ' ';
 	  else
 	    for (i = 0; i < fs->wmargin; ++i)
-	      putc (' ', fs->stream);
+	      putc_unlocked (' ', fs->stream);
 
 	  /* Copy the tail of the original buffer into the current buffer
 	     position.  */
@@ -316,7 +320,7 @@ __argp_fmtstream_ensure (struct argp_fmtstream *fs, size_t amount)
       /* Flush FS's buffer.  */
       __argp_fmtstream_update (fs);
 
-      wrote = fwrite (fs->buf, 1, fs->p - fs->buf, fs->stream);
+      wrote = fwrite_unlocked (fs->buf, 1, fs->p - fs->buf, fs->stream);
       if (wrote == fs->p - fs->buf)
 	{
 	  fs->p = fs->buf;
diff --git a/argp/argp-help.c b/argp/argp-help.c
index 09daa63068..246096943f 100644
--- a/argp/argp-help.c
+++ b/argp/argp-help.c
@@ -32,11 +32,16 @@
 
 #ifndef _
 /* This is for other GNU distributions with internationalized messages.  */
-#ifdef HAVE_LIBINTL_H
-# include <libintl.h>
-#else
-# define dgettext(domain, msgid) (msgid)
+# ifdef HAVE_LIBINTL_H
+#  include <libintl.h>
+# else
+#  define dgettext(domain, msgid) (msgid)
+# endif
 #endif
+
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
 #endif
 
 #include "argp.h"
@@ -1405,7 +1410,7 @@ argp_doc (const struct argp *argp, const struct argp_state *state,
     {
       if (inp_text_limit)
 	/* Copy INP_TEXT so that it's nul-terminated.  */
-	inp_text = strndup (inp_text, inp_text_limit);
+	inp_text = __strndup (inp_text, inp_text_limit);
       input = __argp_input (argp, state);
       text =
 	(*argp->help_filter) (post
@@ -1479,12 +1484,17 @@ _help (const struct argp *argp, const struct argp_state *state, FILE *stream,
   if (! stream)
     return;
 
+  flockfile (stream);
+
   if (! uparams.valid)
     fill_in_uparams (state);
 
   fs = __argp_make_fmtstream (stream, 0, uparams.rmargin, 0);
   if (! fs)
-    return;
+    {
+      funlockfile (stream);
+      return;
+    }
 
   if (flags & (ARGP_HELP_USAGE | ARGP_HELP_SHORT_USAGE | ARGP_HELP_LONG))
     {
@@ -1590,6 +1600,8 @@ Try `%s --help' or `%s --usage' for more information.\n"),
       anything = 1;
     }
 
+  funlockfile (stream);
+
   if (hol)
     hol_free (hol);
 
@@ -1647,17 +1659,22 @@ __argp_error (const struct argp_state *state, const char *fmt, ...)
 	{
 	  va_list ap;
 
-	  fputs (state ? state->name : program_invocation_short_name, stream);
-	  putc (':', stream);
-	  putc (' ', stream);
+	  flockfile (stream);
+
+	  fputs_unlocked (state ? state->name : program_invocation_short_name,
+			  stream);
+	  putc_unlocked (':', stream);
+	  putc_unlocked (' ', stream);
 
 	  va_start (ap, fmt);
 	  vfprintf (stream, fmt, ap);
 	  va_end (ap);
 
-	  putc ('\n', stream);
+	  putc_unlocked ('\n', stream);
 
 	  __argp_state_help (state, stream, ARGP_HELP_STD_ERR);
+
+	  funlockfile (stream);
 	}
     }
 }
@@ -1683,14 +1700,17 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
 
       if (stream)
 	{
-	  fputs (state ? state->name : program_invocation_short_name, stream);
+	  flockfile (stream);
+
+	  fputs_unlocked (state ? state->name : program_invocation_short_name,
+			  stream);
 
 	  if (fmt)
 	    {
 	      va_list ap;
 
-	      putc (':', stream);
-	      putc (' ', stream);
+	      putc_unlocked (':', stream);
+	      putc_unlocked (' ', stream);
 
 	      va_start (ap, fmt);
 	      vfprintf (stream, fmt, ap);
@@ -1699,12 +1719,14 @@ __argp_failure (const struct argp_state *state, int status, int errnum,
 
 	  if (errnum)
 	    {
-	      putc (':', stream);
-	      putc (' ', stream);
+	      putc_unlocked (':', stream);
+	      putc_unlocked (' ', stream);
 	      fputs (strerror (errnum), stream);
 	    }
 
-	  putc ('\n', stream);
+	  putc_unlocked ('\n', stream);
+
+	  funlockfile (stream);
 
 	  if (status && (!state || !(state->flags & ARGP_NO_EXIT)))
 	    exit (status);
diff --git a/assert/assert-perr.c b/assert/assert-perr.c
index cdc07b56f9..ab6f55f7e2 100644
--- a/assert/assert-perr.c
+++ b/assert/assert-perr.c
@@ -24,13 +24,17 @@
 
 extern const char *__assert_program_name; /* In assert.c.  */
 
+#ifdef USE_IN_LIBIO
+# define fflush(s) _IO_fflush (s)
+#endif
+
 /* This function, when passed an error number, a filename, and a line
    number, prints a message on the standard error stream of the form:
    	a.c:10: foobar: Unexpected error: Computer bought the farm
    It then aborts program execution via a call to `abort'.  */
 
 #ifdef FATAL_PREPARE_INCLUDE
-#include FATAL_PREPARE_INCLUDE
+# include FATAL_PREPARE_INCLUDE
 #endif
 
 void
diff --git a/assert/assert.c b/assert/assert.c
index 33c6845cb4..1640fb0e77 100644
--- a/assert/assert.c
+++ b/assert/assert.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1994, 1995, 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -24,6 +24,10 @@
 
 const char *__assert_program_name;
 
+#ifdef USE_IN_LIBIO
+# define fflush(s) _IO_fflush (s)
+#endif
+
 /* 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:
@@ -31,7 +35,7 @@ const char *__assert_program_name;
    It then aborts program execution via a call to `abort'.  */
 
 #ifdef FATAL_PREPARE_INCLUDE
-#include FATAL_PREPARE_INCLUDE
+# include FATAL_PREPARE_INCLUDE
 #endif
 
 void
diff --git a/configure.in b/configure.in
index 5a2868d6c8..34ddcbd69c 100644
--- a/configure.in
+++ b/configure.in
@@ -731,7 +731,7 @@ if test $VERSIONING = no; then
 *** WARNING: You should not compile GNU libc without versioning. Not using
 *** versioning will introduce incompatibilities so that old binaries
 *** will not run anymore.
-*** For versioning you need recent binutils (binutils-2.8.1.0.17 or newer)."
+*** For versioning you need recent binutils (binutils-2.8.1.0.23 or newer)."
 fi
 if test $elf = yes; then
   AC_CACHE_CHECK(for .previous assembler directive,
diff --git a/dirent/scandir.c b/dirent/scandir.c
index cffc8a98cb..ed9071df6e 100644
--- a/dirent/scandir.c
+++ b/dirent/scandir.c
@@ -28,7 +28,7 @@ scandir (dir, namelist, select, cmp)
      int (*select) __P ((const struct dirent *));
      int (*cmp) __P ((const void *, const void *));
 {
-  DIR *dp = opendir (dir);
+  DIR *dp = __opendir (dir);
   struct dirent **v = NULL;
   size_t vsize = 0, i;
   struct dirent *d;
@@ -74,7 +74,7 @@ scandir (dir, namelist, select, cmp)
   if (errno != 0)
     {
       save = errno;
-      (void) closedir (dp);
+      (void) __closedir (dp);
       while (i > 0)
 	free (v[--i]);
       free (v);
@@ -82,7 +82,7 @@ scandir (dir, namelist, select, cmp)
       return -1;
     }
 
-  (void) closedir (dp);
+  (void) __closedir (dp);
   __set_errno (save);
 
   /* Sort the list if we have a comparison function to sort with.  */
diff --git a/dirent/scandir64.c b/dirent/scandir64.c
index a0b7406aac..e158b4045d 100644
--- a/dirent/scandir64.c
+++ b/dirent/scandir64.c
@@ -28,7 +28,7 @@ scandir64 (dir, namelist, select, cmp)
      int (*select) __P ((const struct dirent64 *));
      int (*cmp) __P ((const void *, const void *));
 {
-  DIR *dp = opendir (dir);
+  DIR *dp = __opendir (dir);
   struct dirent64 **v = NULL;
   size_t vsize = 0, i;
   struct dirent64 *d;
@@ -74,7 +74,7 @@ scandir64 (dir, namelist, select, cmp)
   if (errno != 0)
     {
       save = errno;
-      (void) closedir (dp);
+      (void) __closedir (dp);
       while (i > 0)
 	free (v[--i]);
       free (v);
@@ -82,7 +82,7 @@ scandir64 (dir, namelist, select, cmp)
       return -1;
     }
 
-  (void) closedir (dp);
+  (void) __closedir (dp);
   __set_errno (save);
 
   /* Sort the list if we have a comparison function to sort with.  */
diff --git a/dirent/versionsort.c b/dirent/versionsort.c
index 88d6a614e5..e37682a93b 100644
--- a/dirent/versionsort.c
+++ b/dirent/versionsort.c
@@ -22,6 +22,6 @@
 int
 versionsort (const void *a, const void *b)
 {
-  return strverscmp ((*(const struct dirent **) a)->d_name,
-		     (*(const struct dirent **) b)->d_name);
+  return __strverscmp ((*(const struct dirent **) a)->d_name,
+		       (*(const struct dirent **) b)->d_name);
 }
diff --git a/dirent/versionsort64.c b/dirent/versionsort64.c
index b21f246e83..dab34d66ae 100644
--- a/dirent/versionsort64.c
+++ b/dirent/versionsort64.c
@@ -22,6 +22,6 @@
 int
 versionsort64 (const void *a, const void *b)
 {
-  return strverscmp ((*(const struct dirent64 **) a)->d_name,
-		     (*(const struct dirent64 **) b)->d_name);
+  return __strverscmp ((*(const struct dirent64 **) a)->d_name,
+		       (*(const struct dirent64 **) b)->d_name);
 }
diff --git a/elf/Makefile b/elf/Makefile
index 243761cd04..ee11a107da 100644
--- a/elf/Makefile
+++ b/elf/Makefile
@@ -34,7 +34,7 @@ elide-routines.os = $(dl-routines) dl-support enbl-secure
 
 # ld.so uses those routines, plus some special stuff for being the program
 # interpreter and operating independent of libc.
-rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-minimal
+rtld-routines	:= rtld $(dl-routines) dl-sysdep dl-environ dl-minimal
 ld-map		= $(common-objpfx)libc.map
 distribute	= $(rtld-routines:=.c) dynamic-link.h do-rel.h dl-machine.h \
 		  dl-hash.h soinit.c sofini.c ldd.sh.in ldd.bash.in eval.c \
diff --git a/gmon/bb_exit_func.c b/gmon/bb_exit_func.c
index 032e4f68b2..4ba79885c1 100644
--- a/gmon/bb_exit_func.c
+++ b/gmon/bb_exit_func.c
@@ -57,7 +57,7 @@ __bb_exit_func (void)
     }
   memcpy (&ghdr.cookie[0], GMON_MAGIC, 4);
   memcpy (&ghdr.version, &version, sizeof (version));
-  fwrite (&ghdr, sizeof (ghdr), 1, fp);
+  fwrite_unlocked (&ghdr, sizeof (ghdr), 1, fp);
 
   for (ptr = __bb_head; ptr != 0; ptr = ptr->next)
     {
@@ -66,13 +66,14 @@ __bb_exit_func (void)
       u_int i;
 
       tag = GMON_TAG_BB_COUNT;
-      fwrite (&tag, sizeof (tag), 1, fp);
-      fwrite (&ncounts, sizeof (ncounts), 1, fp);
+      fwrite_unlocked (&tag, sizeof (tag), 1, fp);
+      fwrite_unlocked (&ncounts, sizeof (ncounts), 1, fp);
 
       for (i = 0; i < ncounts; ++i)
 	{
-	  fwrite (&ptr->addresses[i], sizeof (ptr->addresses[0]), 1, fp);
-	  fwrite (&ptr->counts[i], sizeof (ptr->counts[0]), 1, fp);
+	  fwrite_unlocked (&ptr->addresses[i], sizeof (ptr->addresses[0]), 1,
+			   fp);
+	  fwrite_unlocked (&ptr->counts[i], sizeof (ptr->counts[0]), 1, fp);
 	}
     }
   fclose (fp);
diff --git a/gmon/gmon.c b/gmon/gmon.c
index 834351eeec..a3cb9362f7 100644
--- a/gmon/gmon.c
+++ b/gmon/gmon.c
@@ -58,7 +58,7 @@ struct gmonparam _gmonparam = { GMON_PROF_OFF };
 static int	s_scale;
 #define		SCALE_1_TO_1	0x10000L
 
-#define ERR(s) write(2, s, sizeof(s) - 1)
+#define ERR(s) __write(2, s, sizeof(s) - 1)
 
 void moncontrol __P ((int mode));
 void __moncontrol __P ((int mode));
diff --git a/grp/fgetgrent_r.c b/grp/fgetgrent_r.c
index 0c87815064..4abadfd569 100644
--- a/grp/fgetgrent_r.c
+++ b/grp/fgetgrent_r.c
@@ -21,6 +21,12 @@
 #include <grp.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
 /* Define a line parsing function using the common code
    used in the nss_files module.  */
 
@@ -59,17 +65,20 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen,
   char *p;
   int parse_result;
 
+  flockfile (stream);
   do
     {
       buffer[buflen - 1] = '\xff';
-      p = fgets (buffer, buflen, stream);
-      if (p == NULL && feof (stream))
+      p = fgets_unlocked (buffer, buflen, stream);
+      if (p == NULL && feof_unlocked (stream))
 	{
+	  funlockfile (stream);
 	  *result = NULL;
 	  return errno;
 	}
       if (p == NULL || buffer[buflen - 1] != '\xff')
 	{
+	  funlockfile (stream);
 	  *result = NULL;
 	  return errno = ERANGE;
 	}
@@ -84,6 +93,8 @@ __fgetgrent_r (FILE *stream, struct group *resbuf, char *buffer, size_t buflen,
 					      (void *) buffer, buflen,
 					      &errno)));
 
+  funlockfile (stream);
+
   if (parse_result == -1)
     {
       /* The parser ran out of space.  */
diff --git a/grp/initgroups.c b/grp/initgroups.c
index d74d08ddd0..082c49fa4f 100644
--- a/grp/initgroups.c
+++ b/grp/initgroups.c
@@ -52,7 +52,7 @@ compat_call (service_user *nip, const char *user, gid_t group, long int *start,
 	     long int *size, gid_t *groups, long int limit, int *errnop)
 {
   struct group grpbuf, *g;
-  size_t buflen = sysconf (_SC_GETPW_R_SIZE_MAX);
+  size_t buflen = __sysconf (_SC_GETPW_R_SIZE_MAX);
   char *tmpbuf;
   enum nss_status status;
   set_function setgrent_fct;
@@ -155,7 +155,7 @@ initgroups (user, group)
 
   size = limit;
 #else
-  long int limit = sysconf (_SC_NGROUPS_MAX);
+  long int limit = __sysconf (_SC_NGROUPS_MAX);
 
   if (limit > 0)
     size = limit;
diff --git a/iconv/gconv_conf.c b/iconv/gconv_conf.c
index 002f4e4232..0658f455ab 100644
--- a/iconv/gconv_conf.c
+++ b/iconv/gconv_conf.c
@@ -77,6 +77,10 @@ builtin_aliases[] =
 #include "gconv_builtin.h"
 };
 
+#ifdef USE_IN_LIBIO
+# define __getdelim(line, len, c, fp) _IO_getdelim (line, len, c, fp)
+#endif
+
 
 /* Function for searching module.  */
 static int
diff --git a/inet/getnameinfo.c b/inet/getnameinfo.c
index 5cfb6ded35..f31d3b9538 100644
--- a/inet/getnameinfo.c
+++ b/inet/getnameinfo.c
@@ -102,7 +102,7 @@ nrl_domainname (void)
 	    {
 	      /* The name contains no domain information.  Use the name
 		 now to get more information.  */
-	      while (gethostname (tmpbuf, tmpbuflen))
+	      while (__gethostname (tmpbuf, tmpbuflen))
 		{
 		  tmpbuflen *= 2;
 		  tmpbuf = alloca (tmpbuflen);
@@ -337,8 +337,8 @@ getnameinfo (const struct sockaddr *sa, socklen_t addrlen, char *host,
 		break;
 	      }
 	  }
-	snprintf (serv, servlen, "%d",
-		  ntohs (((struct sockaddr_in *) sa)->sin_port));
+	__snprintf (serv, servlen, "%d",
+		    ntohs (((struct sockaddr_in *) sa)->sin_port));
 	break;
 
       case AF_LOCAL:
diff --git a/inet/getnetgrent_r.c b/inet/getnetgrent_r.c
index 5b2b241195..a04a47712a 100644
--- a/inet/getnetgrent_r.c
+++ b/inet/getnetgrent_r.c
@@ -319,7 +319,7 @@ innetgr (const char *netgroup, const char *host, const char *user,
 	  struct __netgrent entry;
 
 	  /* Clear the space for the netgroup data.  */
-	  bzero (&entry, sizeof (entry));
+	  __bzero (&entry, sizeof (entry));
 
 	  /* Open netgroup.  */
 	  status = (*setfct) (current_group, &entry);
diff --git a/inet/inet_ntoa.c b/inet/inet_ntoa.c
index d895a59ebf..d9c3153aba 100644
--- a/inet/inet_ntoa.c
+++ b/inet/inet_ntoa.c
@@ -70,7 +70,8 @@ inet_ntoa (struct in_addr in)
     }
 
   bytes = (unsigned char *) &in;
-  snprintf (buffer, 18, "%d.%d.%d.%d", bytes[0], bytes[1], bytes[2], bytes[3]);
+  __snprintf (buffer, 18, "%d.%d.%d.%d",
+	      bytes[0], bytes[1], bytes[2], bytes[3]);
 
   return buffer;
 }
diff --git a/inet/rcmd.c b/inet/rcmd.c
index e54d894f84..c734f2721f 100644
--- a/inet/rcmd.c
+++ b/inet/rcmd.c
@@ -76,7 +76,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 	char c;
 	int herr;
 
-	pid = getpid();
+	pid = __getpid();
 
 	hstbuflen = 1024;
 	tmphstbuf = __alloca (hstbuflen);
@@ -99,7 +99,7 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 	pfd[1].events = POLLIN;
 
 	*ahost = hp->h_name;
-	oldmask = sigblock(sigmask(SIGURG));
+	oldmask = __sigblock(sigmask(SIGURG));
 	for (timo = 1, lport = IPPORT_RESERVED - 1;;) {
 		s = rresvport(&lport);
 		if (s < 0) {
@@ -108,23 +108,23 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 				    _("rcmd: socket: All ports in use\n"));
 			else
 				(void)fprintf(stderr, "rcmd: socket: %m\n");
-			sigsetmask(oldmask);
+			__sigsetmask(oldmask);
 			return -1;
 		}
-		fcntl(s, F_SETOWN, pid);
+		__fcntl(s, F_SETOWN, pid);
 		sin.sin_family = hp->h_addrtype;
 		bcopy(hp->h_addr_list[0], &sin.sin_addr,
 		      MIN (sizeof (sin.sin_addr), hp->h_length));
 		sin.sin_port = rport;
-		if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
+		if (__connect(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
 			break;
-		(void)close(s);
+		(void)__close(s);
 		if (errno == EADDRINUSE) {
 			lport--;
 			continue;
 		}
 		if (errno == ECONNREFUSED && timo <= 16) {
-			(void)sleep(timo);
+			(void)__sleep(timo);
 			timo *= 2;
 			continue;
 		}
@@ -143,12 +143,12 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 			continue;
 		}
 		(void)fprintf(stderr, "%s: %m\n", hp->h_name);
-		sigsetmask(oldmask);
+		__sigsetmask(oldmask);
 		return -1;
 	}
 	lport--;
 	if (fd2p == 0) {
-		write(s, "", 1);
+		__write(s, "", 1);
 		lport = 0;
 	} else {
 		char num[8];
@@ -158,11 +158,11 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 		if (s2 < 0)
 			goto bad;
 		listen(s2, 1);
-		(void)snprintf(num, sizeof(num), "%d", lport);
-		if (write(s, num, strlen(num)+1) != strlen(num)+1) {
+		(void)__snprintf(num, sizeof(num), "%d", lport);
+		if (__write(s, num, strlen(num)+1) != strlen(num)+1) {
 			(void)fprintf(stderr,
 			    _("rcmd: write (setting up stderr): %m\n"));
-			(void)close(s2);
+			(void)__close(s2);
 			goto bad;
 		}
 		pfd[0].fd = s;
@@ -175,11 +175,11 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 			else
 				(void)fprintf(stderr,
 			     _("poll: protocol failure in circuit setup\n"));
-			(void)close(s2);
+			(void)__close(s2);
 			goto bad;
 		}
 		s3 = accept(s2, (struct sockaddr *)&from, &len);
-		(void)close(s2);
+		(void)__close(s2);
 		if (s3 < 0) {
 			(void)fprintf(stderr,
 			    "rcmd: accept: %m\n");
@@ -196,30 +196,30 @@ rcmd(ahost, rport, locuser, remuser, cmd, fd2p)
 			goto bad2;
 		}
 	}
-	(void)write(s, locuser, strlen(locuser)+1);
-	(void)write(s, remuser, strlen(remuser)+1);
-	(void)write(s, cmd, strlen(cmd)+1);
-	if (read(s, &c, 1) != 1) {
+	(void)__write(s, locuser, strlen(locuser)+1);
+	(void)__write(s, remuser, strlen(remuser)+1);
+	(void)__write(s, cmd, strlen(cmd)+1);
+	if (__read(s, &c, 1) != 1) {
 		(void)fprintf(stderr,
 		    "rcmd: %s: %m\n", *ahost);
 		goto bad2;
 	}
 	if (c != 0) {
-		while (read(s, &c, 1) == 1) {
-			(void)write(STDERR_FILENO, &c, 1);
+		while (__read(s, &c, 1) == 1) {
+			(void)__write(STDERR_FILENO, &c, 1);
 			if (c == '\n')
 				break;
 		}
 		goto bad2;
 	}
-	sigsetmask(oldmask);
+	__sigsetmask(oldmask);
 	return s;
 bad2:
 	if (lport)
-		(void)close(*fd2p);
+		(void)__close(*fd2p);
 bad:
-	(void)close(s);
-	sigsetmask(oldmask);
+	(void)__close(s);
+	__sigsetmask(oldmask);
 	return -1;
 }
 
@@ -232,7 +232,7 @@ rresvport(alport)
 
 	sin.sin_family = AF_INET;
 	sin.sin_addr.s_addr = INADDR_ANY;
-	s = socket(AF_INET, SOCK_STREAM, 0);
+	s = __socket(AF_INET, SOCK_STREAM, 0);
 	if (s < 0)
 		return -1;
 	for (;;) {
@@ -240,12 +240,12 @@ rresvport(alport)
 		if (bind(s, (struct sockaddr *)&sin, sizeof(sin)) >= 0)
 			return s;
 		if (errno != EADDRINUSE) {
-			(void)close(s);
+			(void)__close(s);
 			return -1;
 		}
 		(*alport)--;
 		if (*alport == IPPORT_RESERVED/2) {
-			(void)close(s);
+			(void)__close(s);
 			__set_errno (EAGAIN);		/* close */
 			return -1;
 		}
@@ -382,7 +382,7 @@ iruserok (raddr, superuser, ruser, luser)
        /* Change effective uid while reading .rhosts.  If root and
 	  reading an NFS mounted file system, can't read files that
 	  are protected read/write owner only.  */
-       uid = geteuid ();
+       uid = __geteuid ();
        seteuid (pwd->pw_uid);
        hostf = iruserfopen (pbuf, pwd->pw_uid);
 
@@ -481,7 +481,7 @@ __icheckhost(raddr, lhost)
 
 	/* Spin through ip addresses. */
 	for (pp = hp->h_addr_list; *pp; ++pp)
-		if (!bcmp(&raddr, *pp, sizeof(u_int32_t)))
+		if (!memcmp(&raddr, *pp, sizeof(u_int32_t)))
 			return 1;
 
 	/* No match. */
diff --git a/inet/rexec.c b/inet/rexec.c
index 72df066b03..8f329b575c 100644
--- a/inet/rexec.c
+++ b/inet/rexec.c
@@ -85,7 +85,7 @@ rexec(ahost, rport, name, pass, cmd, fd2p)
 	*ahost = hp->h_name;
 	ruserpass(hp->h_name, &name, &pass);
 retry:
-	s = socket(AF_INET, SOCK_STREAM, 0);
+	s = __socket(AF_INET, SOCK_STREAM, 0);
 	if (s < 0) {
 		perror("rexec: socket");
 		return (-1);
@@ -93,10 +93,10 @@ retry:
 	sin.sin_family = hp->h_addrtype;
 	sin.sin_port = rport;
 	bcopy(hp->h_addr, (caddr_t)&sin.sin_addr, hp->h_length);
-	if (connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
+	if (__connect(s, (struct sockaddr *)&sin, sizeof(sin)) < 0) {
 		if (errno == ECONNREFUSED && timo <= 16) {
-			(void) close(s);
-			sleep(timo);
+			(void) __close(s);
+			__sleep(timo);
 			timo *= 2;
 			goto retry;
 		}
@@ -104,15 +104,15 @@ retry:
 		return (-1);
 	}
 	if (fd2p == 0) {
-		(void) write(s, "", 1);
+		(void) __write(s, "", 1);
 		port = 0;
 	} else {
 		char num[32];
 		int s2, sin2len;
 
-		s2 = socket(AF_INET, SOCK_STREAM, 0);
+		s2 = __socket(AF_INET, SOCK_STREAM, 0);
 		if (s2 < 0) {
-			(void) close(s);
+			(void) __close(s);
 			return (-1);
 		}
 		listen(s2, 1);
@@ -120,15 +120,15 @@ retry:
 		if (getsockname(s2, (struct sockaddr *)&sin2, &sin2len) < 0 ||
 		  sin2len != sizeof (sin2)) {
 			perror("getsockname");
-			(void) close(s2);
+			(void) __close(s2);
 			goto bad;
 		}
 		port = ntohs((u_short)sin2.sin_port);
 		(void) sprintf(num, "%u", port);
-		(void) write(s, num, strlen(num)+1);
+		(void) __write(s, num, strlen(num)+1);
 		{ int len = sizeof (from);
 		  s3 = accept(s2, (struct sockaddr *)&from, &len);
-		  close(s2);
+		  __close(s2);
 		  if (s3 < 0) {
 			perror("accept");
 			port = 0;
@@ -137,17 +137,17 @@ retry:
 		}
 		*fd2p = s3;
 	}
-	(void) write(s, name, strlen(name) + 1);
+	(void) __write(s, name, strlen(name) + 1);
 	/* should public key encypt the password here */
-	(void) write(s, pass, strlen(pass) + 1);
-	(void) write(s, cmd, strlen(cmd) + 1);
-	if (read(s, &c, 1) != 1) {
+	(void) __write(s, pass, strlen(pass) + 1);
+	(void) __write(s, cmd, strlen(cmd) + 1);
+	if (__read(s, &c, 1) != 1) {
 		perror(*ahost);
 		goto bad;
 	}
 	if (c != 0) {
-		while (read(s, &c, 1) == 1) {
-			(void) write(2, &c, 1);
+		while (__read(s, &c, 1) == 1) {
+			(void) __write(2, &c, 1);
 			if (c == '\n')
 				break;
 		}
@@ -156,7 +156,7 @@ retry:
 	return (s);
 bad:
 	if (port)
-		(void) close(*fd2p);
-	(void) close(s);
+		(void) __close(*fd2p);
+	(void) __close(s);
 	return (-1);
 }
diff --git a/inet/ruserpass.c b/inet/ruserpass.c
index 3cdacd1625..f56931fb4b 100644
--- a/inet/ruserpass.c
+++ b/inet/ruserpass.c
@@ -105,7 +105,7 @@ ruserpass(host, aname, apass)
 			warn("%s", buf);
 		return (0);
 	}
-	if (gethostname(myname, sizeof(myname)) < 0)
+	if (__gethostname(myname, sizeof(myname)) < 0)
 		myname[0] = '\0';
 	if ((mydomain = strchr(myname, '.')) == NULL)
 		mydomain = "";
@@ -125,18 +125,18 @@ next:
 			 * or official hostname.  Also allow match of
 			 * incompletely-specified host in local domain.
 			 */
-			if (strcasecmp(host, tokval) == 0)
+			if (__strcasecmp(host, tokval) == 0)
 				goto match;
-/*			if (strcasecmp(hostname, tokval) == 0)
+/*			if (__strcasecmp(hostname, tokval) == 0)
 				goto match;
 			if ((tmp = strchr(hostname, '.')) != NULL &&
-			    strcasecmp(tmp, mydomain) == 0 &&
-			    strncasecmp(hostname, tokval, tmp-hostname) == 0 &&
+			    __strcasecmp(tmp, mydomain) == 0 &&
+			    __strncasecmp(hostname, tokval, tmp-hostname) == 0 &&
 			    tokval[tmp - hostname] == '\0')
 				goto match; */
 			if ((tmp = strchr(host, '.')) != NULL &&
-			    strcasecmp(tmp, mydomain) == 0 &&
-			    strncasecmp(host, tokval, tmp - host) == 0 &&
+			    __strcasecmp(tmp, mydomain) == 0 &&
+			    __strncasecmp(host, tokval, tmp - host) == 0 &&
 			    tokval[tmp - host] == '\0')
 				goto match;
 			continue;
diff --git a/io/fts.c b/io/fts.c
index 259274dca9..75bba1f4d5 100644
--- a/io/fts.c
+++ b/io/fts.c
@@ -79,8 +79,8 @@ static u_short	 fts_stat __P((FTS *, struct dirent *, FTSENT *, int))
 #define	ISSET(opt)	(sp->fts_options & opt)
 #define	SET(opt)	(sp->fts_options |= opt)
 
-#define	CHDIR(sp, path)	(!ISSET(FTS_NOCHDIR) && chdir(path))
-#define	FCHDIR(sp, fd)	(!ISSET(FTS_NOCHDIR) && fchdir(fd))
+#define	CHDIR(sp, path)	(!ISSET(FTS_NOCHDIR) && __chdir(path))
+#define	FCHDIR(sp, fd)	(!ISSET(FTS_NOCHDIR) && __fchdir(fd))
 
 /* fts_build flags */
 #define	BCHILD		1		/* fts_children */
@@ -108,7 +108,7 @@ fts_open(argv, options, compar)
 	/* Allocate/initialize the stream */
 	if ((sp = malloc((u_int)sizeof(FTS))) == NULL)
 		return (NULL);
-	bzero(sp, sizeof(FTS));
+	__bzero(sp, sizeof(FTS));
 	sp->fts_compar = (int (*) __P((const void *, const void *))) compar;
 	sp->fts_options = options;
 
@@ -186,7 +186,8 @@ fts_open(argv, options, compar)
 	 * and ".." are all fairly nasty problems.  Note, if we can't get the
 	 * descriptor we run anyway, just more slowly.
 	 */
-	if (!ISSET(FTS_NOCHDIR) && (sp->fts_rfd = open(".", O_RDONLY, 0)) < 0)
+	if (!ISSET(FTS_NOCHDIR)
+	    && (sp->fts_rfd = __open(".", O_RDONLY, 0)) < 0)
 		SET(FTS_NOCHDIR);
 
 	return (sp);
@@ -254,8 +255,8 @@ fts_close(sp)
 
 	/* Return to original directory, save errno if necessary. */
 	if (!ISSET(FTS_NOCHDIR)) {
-		saved_errno = fchdir(sp->fts_rfd) ? errno : 0;
-		(void)close(sp->fts_rfd);
+		saved_errno = __fchdir(sp->fts_rfd) ? errno : 0;
+		(void)__close(sp->fts_rfd);
 	}
 
 	/* Free up the stream pointer. */
@@ -313,7 +314,7 @@ fts_read(sp)
 	    (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) {
 		p->fts_info = fts_stat(sp, NULL, p, 1);
 		if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR))
-			if ((p->fts_symfd = open(".", O_RDONLY, 0)) < 0) {
+			if ((p->fts_symfd = __open(".", O_RDONLY, 0)) < 0) {
 				p->fts_errno = errno;
 				p->fts_info = FTS_ERR;
 			} else
@@ -327,7 +328,7 @@ fts_read(sp)
 		if (instr == FTS_SKIP ||
 		    ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev) {
 			if (p->fts_flags & FTS_SYMFOLLOW)
-				(void)close(p->fts_symfd);
+				(void)__close(p->fts_symfd);
 			if (sp->fts_child) {
 				fts_lfree(sp->fts_child);
 				sp->fts_child = NULL;
@@ -402,7 +403,7 @@ next:	tmp = p;
 			p->fts_info = fts_stat(sp, NULL, p, 1);
 			if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR))
 				if ((p->fts_symfd =
-				    open(".", O_RDONLY, 0)) < 0) {
+				    __open(".", O_RDONLY, 0)) < 0) {
 					p->fts_errno = errno;
 					p->fts_info = FTS_ERR;
 				} else
@@ -446,12 +447,12 @@ name:		t = sp->fts_path + NAPPEND(p->fts_parent);
 	} else if (p->fts_flags & FTS_SYMFOLLOW) {
 		if (FCHDIR(sp, p->fts_symfd)) {
 			saved_errno = errno;
-			(void)close(p->fts_symfd);
+			(void)__close(p->fts_symfd);
 			__set_errno (saved_errno);
 			SET(FTS_STOP);
 			return (NULL);
 		}
-		(void)close(p->fts_symfd);
+		(void)__close(p->fts_symfd);
 	} else if (!(p->fts_flags & FTS_DONTCHDIR)) {
 		if (CHDIR(sp, "..")) {
 			SET(FTS_STOP);
@@ -543,12 +544,12 @@ fts_children(sp, instr)
 	    ISSET(FTS_NOCHDIR))
 		return (sp->fts_child = fts_build(sp, instr));
 
-	if ((fd = open(".", O_RDONLY, 0)) < 0)
+	if ((fd = __open(".", O_RDONLY, 0)) < 0)
 		return (NULL);
 	sp->fts_child = fts_build(sp, instr);
-	if (fchdir(fd))
+	if (__fchdir(fd))
 		return (NULL);
-	(void)close(fd);
+	(void)__close(fd);
 	return (sp->fts_child);
 }
 
@@ -597,7 +598,7 @@ fts_build(sp, type)
 	else
 		oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND;
 #else
-# define __opendir2(path, flag) opendir(path)
+# define __opendir2(path, flag) __opendir(path)
 #endif
        if ((dirp = __opendir2 (cur->fts_accpath, oflag)) == NULL) {
 		if (type == BREAD) {
@@ -673,7 +674,7 @@ fts_build(sp, type)
 
 	/* Read the directory, attaching each entry to the `link' pointer. */
 	adjaddr = NULL;
-	for (head = tail = NULL, nitems = 0; dp = readdir(dirp);) {
+	for (head = tail = NULL, nitems = 0; dp = __readdir(dirp);) {
 		int namlen;
 
 		if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name))
@@ -693,7 +694,7 @@ mem1:				saved_errno = errno;
 				if (p)
 					free(p);
 				fts_lfree(head);
-				(void)closedir(dirp);
+				(void)__closedir(dirp);
 				__set_errno (saved_errno);
 				cur->fts_info = FTS_ERR;
 				SET(FTS_STOP);
@@ -749,7 +750,7 @@ mem1:				saved_errno = errno;
 		}
 		++nitems;
 	}
-	(void)closedir(dirp);
+	(void)__closedir(dirp);
 
 	/*
 	 * If had to realloc the path, adjust the addresses for the rest
@@ -843,7 +844,7 @@ fts_stat(sp, dp, p, follow)
 		}
 	} else if (lstat(p->fts_accpath, sbp)) {
 		p->fts_errno = errno;
-err:		bzero(sbp, sizeof(struct stat));
+err:		__bzero(sbp, sizeof(struct stat));
 		return (FTS_NS);
 	}
 
diff --git a/io/ftw.c b/io/ftw.c
index b8c82fa969..db687e3dbd 100644
--- a/io/ftw.c
+++ b/io/ftw.c
@@ -1,5 +1,5 @@
 /* File tree walker functions.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -38,7 +38,7 @@
 # define INO_T ino_t
 # define STAT stat
 # define DIRENT dirent
-# define READDIR readdir
+# define READDIR __readdir
 # define LXSTAT __lxstat
 # define XSTAT __xstat
 # define FTW_FUNC_T __ftw_func_t
@@ -205,7 +205,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp)
 	    }
 	  else
 	    {
-	      closedir (st);
+	      __closedir (st);
 	      data->dirstreams[data->actdir]->stream = NULL;
 	      data->dirstreams[data->actdir] = NULL;
 	    }
@@ -217,7 +217,7 @@ open_dir_stream (struct ftw_data *data, struct dir_data *dirp)
     {
       assert (data->dirstreams[data->actdir] == NULL);
 
-      dirp->stream = opendir (data->dirbuf);
+      dirp->stream = __opendir (data->dirbuf);
       if (dirp->stream == NULL)
 	result = -1;
       else
@@ -309,7 +309,7 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
 		    {
 		      if (data->ftw.base == 1)
 			{
-			  if (chdir ("/") < 0)
+			  if (__chdir ("/") < 0)
 			    result = -1;
 			}
 		      else
@@ -317,7 +317,7 @@ process_entry (struct ftw_data *data, struct dir_data *dir, const char *name,
 			  /* Please note that we overwrite a slash.  */
 			  data->dirbuf[data->ftw.base - 1] = '\0';
 
-			  if (chdir (data->dirbuf) < 0)
+			  if (__chdir (data->dirbuf) < 0)
 			    result = -1;
 
 			  data->dirbuf[data->ftw.base - 1] = '/';
@@ -372,7 +372,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st)
 	{
 	  if (errno == ENOSYS)
 	    {
-	      if (chdir (data->dirbuf) < 0)
+	      if (__chdir (data->dirbuf) < 0)
 		result = -1;
 	    }
 	  else
@@ -382,7 +382,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st)
       if (result != 0)
 	{
 	  int save_err = errno;
-	  closedir (dir.stream);
+	  __closedir (dir.stream);
 	  __set_errno (save_err);
 
 	  if (data->actdir-- == 0)
@@ -414,7 +414,7 @@ ftw_dir (struct ftw_data *data, struct STAT *st)
 
       assert (dir.content == NULL);
 
-      closedir (dir.stream);
+      __closedir (dir.stream);
       __set_errno (save_err);
 
       if (data->actdir-- == 0)
@@ -524,7 +524,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
   if ((flags & FTW_CHDIR) && data.ftw.base > 0)
     {
       /* GNU extension ahead.  */
-      cwd =  getcwd (NULL, 0);
+      cwd =  __getcwd (NULL, 0);
       if (cwd == NULL)
 	result = -1;
       else
@@ -534,12 +534,12 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
 	     terminate it for now and change the directory.  */
 	  if (data.ftw.base == 1)
 	    /* I.e., the file is in the root directory.  */
-	    result = chdir ("/");
+	    result = __chdir ("/");
 	  else
 	    {
 	      char ch = data.dirbuf[data.ftw.base - 1];
 	      data.dirbuf[data.ftw.base - 1] = '\0';
-	      result = chdir (data.dirbuf);
+	      result = __chdir (data.dirbuf);
 	      data.dirbuf[data.ftw.base - 1] = ch;
 	    }
 	}
@@ -592,7 +592,7 @@ ftw_startup (const char *dir, int is_nftw, void *func, int descriptors,
   if (cwd != NULL)
     {
       int save_err = errno;
-      chdir (cwd);
+      __chdir (cwd);
       free (cwd);
       __set_errno (save_err);
     }
diff --git a/io/ftw64.c b/io/ftw64.c
index 6dbd03e831..6a3c93f88b 100644
--- a/io/ftw64.c
+++ b/io/ftw64.c
@@ -1,5 +1,5 @@
 /* File tree walker functions.  LFS version.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -23,7 +23,7 @@
 #define INO_T ino64_t
 #define STAT stat64
 #define DIRENT dirent64
-#define READDIR readdir64
+#define READDIR __readdir64
 #define LXSTAT __lxstat64
 #define XSTAT __xstat64
 #define FTW_FUNC_T __ftw64_func_t
diff --git a/io/getdirname.c b/io/getdirname.c
index cc6dd9545c..f6c9bfff21 100644
--- a/io/getdirname.c
+++ b/io/getdirname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -38,7 +38,7 @@ get_current_dir_name (void)
       pwdstat.st_dev == dotstat.st_dev &&
       pwdstat.st_ino == dotstat.st_ino)
     /* The PWD value is correct.  Use it.  */
-    return strdup (pwd);
+    return __strdup (pwd);
 
-  return getcwd ((char *) NULL, 0);
+  return __getcwd ((char *) NULL, 0);
 }
diff --git a/io/getwd.c b/io/getwd.c
index ae1724545e..7ec56eebbf 100644
--- a/io/getwd.c
+++ b/io/getwd.c
@@ -1,5 +1,5 @@
 /* Obsolete function to get current working directory.
-   Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -38,7 +38,7 @@ getwd (buf)
       return NULL;
     }
 
-  if (getcwd (tmpbuf, PATH_MAX) == NULL)
+  if (__getcwd (tmpbuf, PATH_MAX) == NULL)
     {
       /* We use 1024 here since it should really be enough and because
 	 this is a safe value.  */
diff --git a/io/lockf.c b/io/lockf.c
index 7bf90c9b59..6d5049027f 100644
--- a/io/lockf.c
+++ b/io/lockf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1994, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -36,9 +36,9 @@ lockf (int fd, int cmd, off_t len)
     case F_TEST:
       /* Test the lock: return 0 if FD is unlocked or locked by this process;
 	 return -1, set errno to EACCES, if another process holds the lock.  */
-      if (fcntl (fd, F_GETLK, &fl) < 0)
+      if (__fcntl (fd, F_GETLK, &fl) < 0)
 	return -1;
-      if (fl.l_type == F_UNLCK || fl.l_pid == getpid ())
+      if (fl.l_type == F_UNLCK || fl.l_pid == __getpid ())
 	return 0;
       __set_errno (EACCES);
       return -1;
@@ -67,5 +67,5 @@ lockf (int fd, int cmd, off_t len)
 
   fl.l_len = len;
 
-  return fcntl (fd, cmd, &fl);
+  return __fcntl (fd, cmd, &fl);
 }
diff --git a/libio/Makefile b/libio/Makefile
index bc43ebb674..84240bd852 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -50,7 +50,8 @@ CPPFLAGS-.o += -DIO_DEBUG
 
 ifneq (,$(filter %REENTRANT, $(defines)))
 routines += clearerr_u feof_u ferror_u fputc_u getc_u getchar_u		      \
-	    iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u
+	    iofflush_u putc_u putchar_u peekc iofread_u iofwrite_u iofgets_u  \
+	    iofputs_u
 
 CPPFLAGS += -D_IO_MTSAFE_IO
 endif
diff --git a/libio/Versions b/libio/Versions
index 467ba22b74..7cc09454c3 100644
--- a/libio/Versions
+++ b/libio/Versions
@@ -89,6 +89,6 @@ libc {
     # f*
     fgetpos64; fopen64; freopen64; fseeko; fseeko64; fsetpos64; ftello;
     ftello64; fopen; fclose; fdopen; fread_unlocked; fwrite_unlocked;
-    fgets_unlocked;
+    fgets_unlocked; fputs_unlocked;
   }
 }
diff --git a/libio/iofdopen.c b/libio/iofdopen.c
index a51bc3c49a..44be50a37d 100644
--- a/libio/iofdopen.c
+++ b/libio/iofdopen.c
@@ -30,8 +30,12 @@
 #include <fcntl.h>
 
 #ifndef _IO_fcntl
+#ifdef _LIBC
+#define _IO_fcntl __fcntl
+#else
 #define _IO_fcntl fcntl
 #endif
+#endif
 
 _IO_FILE *
 _IO_new_fdopen (fd, mode)
diff --git a/libio/iofputs_u.c b/libio/iofputs_u.c
new file mode 100644
index 0000000000..6fca3048eb
--- /dev/null
+++ b/libio/iofputs_u.c
@@ -0,0 +1,42 @@
+/* Copyright (C) 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include "libioP.h"
+#include <string.h>
+
+int
+fputs_unlocked (str, fp)
+      const char *str;
+      _IO_FILE *fp;
+{
+  _IO_size_t len = strlen (str);
+  int result;
+  CHECK_FILE (fp, EOF);
+  if (_IO_sputn (fp, str, len) != len)
+    result = EOF;
+  else
+    result = 1;
+  return result;
+}
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 3d2a79635d..30ff4b8ae7 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU IO Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -41,25 +41,41 @@
 #include <sys/wait.h>
 
 #ifndef _IO_fork
+#ifdef _LIBC
+#define _IO_fork __vfork
+#else
 #define _IO_fork vfork /* defined in libiberty, if needed */
+#endif
 extern _IO_pid_t _IO_fork __P ((void));
 #endif
 
 #endif /* _IO_HAVE_SYS_WAIT */
 
 #ifndef _IO_pipe
+#ifdef _LIBC
+#define _IO_pipe __pipe
+#else
 #define _IO_pipe pipe
+#endif
 extern int _IO_pipe __P ((int des[2]));
 #endif
 
 #ifndef _IO_dup2
+#ifdef _LIBC
+#define _IO_dup2 __dup2
+#else
 #define _IO_dup2 dup2
+#endif
 extern int _IO_dup2 __P ((int fd, int fd2));
 #endif
 
 #ifndef _IO_waitpid
+#ifdef _LIBC
+#define _IO_waitpid __waitpid
+#else
 #define _IO_waitpid waitpid
 #endif
+#endif
 
 #ifndef _IO_execl
 #define _IO_execl execl
@@ -69,8 +85,12 @@ extern int _IO_dup2 __P ((int fd, int fd2));
 #endif
 
 #ifndef _IO_close
+#ifdef _LIBC
+#define _IO_close __close
+#else
 #define _IO_close close
 #endif
+#endif
 
 struct _IO_proc_file
 {
diff --git a/libio/stdio.h b/libio/stdio.h
index eb0d98d7d2..87ca35b068 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -516,6 +516,12 @@ getline (char **__lineptr, size_t *__n, FILE *__stream)
 /* Write a string to STREAM.  */
 extern int fputs __P ((__const char *__restrict __s,
 		       FILE *__restrict __stream));
+
+#ifdef __USE_GNU
+/* This function does the same as `fgets' but does not lock the stream.  */
+extern int fputs_unlocked __P ((__const char *__restrict __s,
+				FILE *__restrict __stream));
+#endif
 /* Write a string, followed by a newline, to stdout.  */
 extern int puts __P ((__const char *__s));
 
diff --git a/linuxthreads/ChangeLog b/linuxthreads/ChangeLog
index ef0634d459..4a0cf33aa1 100644
--- a/linuxthreads/ChangeLog
+++ b/linuxthreads/ChangeLog
@@ -1,3 +1,17 @@
+1998-07-16 10:52  Ulrich Drepper  <drepper@cygnus.com>
+
+	* manager.c (pthread_handle_create): Check whether sched_setscheduler
+	call can succeed here.
+
+	* mutex.c: Define __pthread_mutexattr_settype and make
+	__pthread_mutexattr_setkind_np an alias.
+	Likewise for __pthread_mutexattr_gettype.
+
+1998-07-15 11:00 -0400  Zack Weinberg  <zack@rabi.phys.columbia.edu>
+
+	* attr.c (pthread_attr_setschedpolicy): Don't check whether caller
+	is root.
+
 1998-07-14 19:38  Ulrich Drepper  <drepper@cygnus.com>
 
 	* sysdeps/pthread/bits/libc-lock.h: Define __libc_cleanup_end.
diff --git a/linuxthreads/attr.c b/linuxthreads/attr.c
index b5610030b5..7a099857aa 100644
--- a/linuxthreads/attr.c
+++ b/linuxthreads/attr.c
@@ -96,8 +96,6 @@ int pthread_attr_setschedpolicy(pthread_attr_t *attr, int policy)
 {
   if (policy != SCHED_OTHER && policy != SCHED_FIFO && policy != SCHED_RR)
     return EINVAL;
-  if (policy != SCHED_OTHER && geteuid() != 0)
-    return ENOTSUP;
   attr->schedpolicy = policy;
   return 0;
 }
diff --git a/linuxthreads/manager.c b/linuxthreads/manager.c
index 7d48489f76..d14a57ccd7 100644
--- a/linuxthreads/manager.c
+++ b/linuxthreads/manager.c
@@ -217,6 +217,12 @@ static int pthread_handle_create(pthread_t *thread, const pthread_attr_t *attr,
   void *guardaddr = NULL;
   size_t guardsize = 0;
 
+  /* First check whether we have to change the policy and if yes, whether
+     we can  do this.  Normally this should be done by examining the
+     return value of the __sched_setscheduler call in pthread_start_thread
+     but this is hard to implement.  FIXME  */
+  if (attr != NULL && attr->schedpolicy != SCHED_OTHER && geteuid () != 0)
+    return EPERM;
   /* Find a free stack segment for the current stack */
   for (sseg = 1; ; sseg++)
     {
diff --git a/linuxthreads/mutex.c b/linuxthreads/mutex.c
index a337bad758..74b0922210 100644
--- a/linuxthreads/mutex.c
+++ b/linuxthreads/mutex.c
@@ -144,7 +144,7 @@ int __pthread_mutexattr_destroy(pthread_mutexattr_t *attr)
 }
 weak_alias (__pthread_mutexattr_destroy, pthread_mutexattr_destroy)
 
-int __pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind)
+int __pthread_mutexattr_settype(pthread_mutexattr_t *attr, int kind)
 {
   if (kind != PTHREAD_MUTEX_FAST_NP
       && kind != PTHREAD_MUTEX_RECURSIVE_NP
@@ -153,18 +153,18 @@ int __pthread_mutexattr_setkind_np(pthread_mutexattr_t *attr, int kind)
   attr->mutexkind = kind;
   return 0;
 }
-weak_alias (__pthread_mutexattr_setkind_np, pthread_mutexattr_setkind_np)
-strong_alias (__pthread_mutexattr_setkind_np, __pthread_mutexattr_settype)
 weak_alias (__pthread_mutexattr_settype, pthread_mutexattr_settype)
+strong_alias ( __pthread_mutexattr_settype, __pthread_mutexattr_setkind_np)
+weak_alias (__pthread_mutexattr_setkind_np, pthread_mutexattr_setkind_np)
 
-int __pthread_mutexattr_getkind_np(const pthread_mutexattr_t *attr, int *kind)
+int __pthread_mutexattr_gettype(const pthread_mutexattr_t *attr, int *kind)
 {
   *kind = attr->mutexkind;
   return 0;
 }
-weak_alias (__pthread_mutexattr_getkind_np, pthread_mutexattr_getkind_np)
-strong_alias (__pthread_mutexattr_getkind_np, __pthread_mutexattr_gettype)
 weak_alias (__pthread_mutexattr_gettype, pthread_mutexattr_gettype)
+strong_alias (__pthread_mutexattr_gettype, __pthread_mutexattr_getkind_np)
+weak_alias (__pthread_mutexattr_getkind_np, pthread_mutexattr_getkind_np)
 
 /* Once-only execution */
 
diff --git a/login/utmp_daemon.c b/login/utmp_daemon.c
index 6b4686ddd7..95e5d4241b 100644
--- a/login/utmp_daemon.c
+++ b/login/utmp_daemon.c
@@ -77,8 +77,8 @@ static int send_request (int sock, const request_header *request,
 static int
 setutent_daemon (void)
 {
-  if (access (_PATH_UTMPD_RW, F_OK) == -1
-      && access (_PATH_UTMPD_RO, F_OK) == -1)
+  if (__access (_PATH_UTMPD_RW, F_OK) == -1
+      && __access (_PATH_UTMPD_RO, F_OK) == -1)
     return 0;
 
   if (daemon_sock < 0)
@@ -175,7 +175,7 @@ endutent_daemon (void)
   /* Send request to the daemon.  */
   do_endutent (daemon_sock);
 
-  close (daemon_sock);
+  __close (daemon_sock);
   daemon_sock = -1;
 }
 
@@ -193,11 +193,11 @@ updwtmp_daemon (const char *file, const struct utmp *utmp)
   /* Send request to the daemon.  */
   if (do_updwtmp (sock, file, utmp) < 0)
     {
-      close (sock);
+      __close (sock);
       return -1;
     }
 
-  close (sock);
+  __close (sock);
   return 0;
 }
 
@@ -417,7 +417,7 @@ open_socket (const char *name)
   strcpy (addr.sun_path, name);
   if (__connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
     {
-      close (sock);
+      __close (sock);
       return -1;
     }
 
@@ -433,11 +433,11 @@ send_request (int sock, const request_header *request,
   reply_header header;
   ssize_t nbytes;
 
-  nbytes = write (sock, request, request->size);
+  nbytes = __write (sock, request, request->size);
   if (nbytes != (ssize_t) request->size)
     return -1;
 
-  nbytes = read (sock, &header, sizeof (reply_header));
+  nbytes = __read (sock, &header, sizeof (reply_header));
   if (nbytes != sizeof (reply_header))
     return -1;
 
@@ -446,7 +446,7 @@ send_request (int sock, const request_header *request,
       || reply->type != header.type)
     return -1;
 
-  nbytes = read (sock, reply + 1, reply->size - sizeof (reply_header));
+  nbytes = __read (sock, reply + 1, reply->size - sizeof (reply_header));
   if (nbytes != (ssize_t) (reply->size - sizeof (reply_header)))
     return -1;
 
diff --git a/malloc/mtrace.c b/malloc/mtrace.c
index 64fb62a131..40b3d74f3c 100644
--- a/malloc/mtrace.c
+++ b/malloc/mtrace.c
@@ -40,6 +40,10 @@ extern char *getenv ();
 #include <stdlib.h>
 #endif
 
+#if defined _LIBC && defined USE_IN_LIBIO
+# define setvbuf(s, b, f, l) _IO_setvbuf (s, b, f, l)
+#endif
+
 #define TRACE_BUFFER_SIZE 512
 
 static FILE *mallstream;
diff --git a/malloc/obstack.c b/malloc/obstack.c
index cc18dc1a9b..f39b638f58 100644
--- a/malloc/obstack.c
+++ b/malloc/obstack.c
@@ -1,5 +1,5 @@
 /* obstack.c - subroutines used implicitly by object stack macros
-   Copyright (C) 1988,89,90,91,92,93,94,96,97 Free Software Foundation, Inc.
+   Copyright (C) 1988,89,90,91,92,93,94,96,97,98 Free Software Foundation, Inc.
 
    This file is part of the GNU C Library.  Its master source is NOT part of
    the C library, however.  The master source lives in /gd/gnu/lib.
@@ -459,6 +459,9 @@ _obstack_memory_used (h)
 #  define _(Str) (Str)
 # endif
 #endif
+#if defined _LIBC && defined USE_IN_LIBIO
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
 
 static void
 print_and_abort ()
diff --git a/misc/daemon.c b/misc/daemon.c
index 6b3409cced..7bab9f5965 100644
--- a/misc/daemon.c
+++ b/misc/daemon.c
@@ -45,7 +45,7 @@ daemon(nochdir, noclose)
 {
 	int fd;
 
-	switch (fork()) {
+	switch (__fork()) {
 	case -1:
 		return (-1);
 	case 0:
@@ -54,18 +54,18 @@ daemon(nochdir, noclose)
 		_exit(0);
 	}
 
-	if (setsid() == -1)
+	if (__setsid() == -1)
 		return (-1);
 
 	if (!nochdir)
-		(void)chdir("/");
+		(void)__chdir("/");
 
-	if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
-		(void)dup2(fd, STDIN_FILENO);
-		(void)dup2(fd, STDOUT_FILENO);
-		(void)dup2(fd, STDERR_FILENO);
+	if (!noclose && (fd = __open(_PATH_DEVNULL, O_RDWR, 0)) != -1) {
+		(void)__dup2(fd, STDIN_FILENO);
+		(void)__dup2(fd, STDOUT_FILENO);
+		(void)__dup2(fd, STDERR_FILENO);
 		if (fd > 2)
-			(void)close (fd);
+			(void)__close (fd);
 	}
 	return (0);
 }
diff --git a/misc/efgcvt_r.c b/misc/efgcvt_r.c
index 6434b9deea..64dcfcd7e9 100644
--- a/misc/efgcvt_r.c
+++ b/misc/efgcvt_r.c
@@ -87,7 +87,7 @@ APPEND (FUNC_PREFIX, fcvt_r) (value, ndigit, decpt, sign, buf, len)
     /* Value is Inf or NaN.  */
     *sign = 0;
 
-  n = snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", ndigit, value);
+  n = __snprintf (buf, len, "%.*" FLOAT_FMT_FLAG "f", ndigit, value);
   if (n < 0)
     return -1;
 
diff --git a/misc/err.c b/misc/err.c
index 56ca808bcd..3482944271 100644
--- a/misc/err.c
+++ b/misc/err.c
@@ -1,5 +1,5 @@
 /* err.c --- 4.4BSD utility functions for error messages.
-   Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -24,6 +24,11 @@
 #include <string.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
 extern char *__progname;
 
 #define VA(call)							      \
@@ -37,11 +42,13 @@ extern char *__progname;
 void
 vwarnx (const char *format, __gnuc_va_list ap)
 {
+  flockfile (stderr);
   if (__progname)
     fprintf (stderr, "%s: ", __progname);
   if (format)
     vfprintf (stderr, format, ap);
-  putc ('\n', stderr);
+  putc_unlocked ('\n', stderr);
+  funlockfile (stderr);
 }
 
 void
@@ -49,15 +56,17 @@ vwarn (const char *format, __gnuc_va_list ap)
 {
   int error = errno;
 
+  flockfile (stderr);
   if (__progname)
     fprintf (stderr, "%s: ", __progname);
   if (format)
     {
       vfprintf (stderr, format, ap);
-      fputs (": ", stderr);
+      fputs_unlocked (": ", stderr);
     }
   __set_errno (error);
   fprintf (stderr, "%m\n");
+  funlockfile (stderr);
 }
 
 
diff --git a/misc/error.c b/misc/error.c
index 83998bb08b..ac6de324dd 100644
--- a/misc/error.c
+++ b/misc/error.c
@@ -76,6 +76,10 @@ unsigned int error_message_count;
 # define error __error
 # define error_at_line __error_at_line
 
+# ifdef USE_IN_LIBIO
+#  define fflush(s) _IO_fflush (s)
+# endif
+
 #else /* not _LIBC */
 
 /* The calling program should define program_name and set it to the
diff --git a/misc/fstab.c b/misc/fstab.c
index d241051ec9..a4d7aae0ca 100644
--- a/misc/fstab.c
+++ b/misc/fstab.c
@@ -102,7 +102,7 @@ endfsent ()
   state = &fstab_state;
   if (state->fs_fp != NULL)
     {
-      (void) endmntent (state->fs_fp);
+      (void) __endmntent (state->fs_fp);
       state->fs_fp = NULL;
     }
 }
@@ -134,7 +134,7 @@ fstab_init (int opt_rewind)
     }
   else
     {
-      fp = setmntent (_PATH_FSTAB, "r");
+      fp = __setmntent (_PATH_FSTAB, "r");
       if (fp == NULL)
 	return NULL;
       state->fs_fp = fp;
@@ -165,11 +165,11 @@ fstab_convert (struct fstab_state *state)
   f->fs_file = m->mnt_dir;
   f->fs_vfstype = m->mnt_type;
   f->fs_mntops = m->mnt_opts;
-  f->fs_type = (hasmntopt (m, FSTAB_RW) ? FSTAB_RW :
-		hasmntopt (m, FSTAB_RQ) ? FSTAB_RQ :
-		hasmntopt (m, FSTAB_RO) ? FSTAB_RO :
-		hasmntopt (m, FSTAB_SW) ? FSTAB_SW :
-		hasmntopt (m, FSTAB_XX) ? FSTAB_XX :
+  f->fs_type = (__hasmntopt (m, FSTAB_RW) ? FSTAB_RW :
+		__hasmntopt (m, FSTAB_RQ) ? FSTAB_RQ :
+		__hasmntopt (m, FSTAB_RO) ? FSTAB_RO :
+		__hasmntopt (m, FSTAB_SW) ? FSTAB_SW :
+		__hasmntopt (m, FSTAB_XX) ? FSTAB_XX :
 		"??");
   f->fs_freq = m->mnt_freq;
   f->fs_passno = m->mnt_passno;
diff --git a/misc/getpass.c b/misc/getpass.c
index 2caeb18668..0187ac4957 100644
--- a/misc/getpass.c
+++ b/misc/getpass.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992, 93, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1992, 93, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -20,6 +20,11 @@
 #include <termios.h>
 #include <unistd.h>
 
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
 /* It is desirable to use this bit on systems that have it.
    The only bit of terminal state we want to twiddle is echoing, which is
    done in software; there is no need to change the state of the terminal
@@ -52,9 +57,11 @@ getpass (prompt)
   else
     out = in;
 
+  flockfile (out);
+
   /* Turn echoing off if it is on now.  */
 
-  if (tcgetattr (fileno (in), &t) == 0)
+  if (__tcgetattr (fileno (in), &t) == 0)
     {
       /* Save the old one. */
       s = t;
@@ -66,8 +73,8 @@ getpass (prompt)
     tty_changed = 0;
 
   /* Write the prompt.  */
-  fputs (prompt, out);
-  fflush (out);
+  fputs_unlocked (prompt, out);
+  fflush_unlocked (out);
 
   /* Read the password.  */
   nread = __getline (&buf, &bufsize, in);
@@ -80,13 +87,15 @@ getpass (prompt)
 	buf[nread - 1] = '\0';
 	if (tty_changed)
 	  /* Write the newline that was not echoed.  */
-	  putc ('\n', out);
+	  putc_unlocked ('\n', out);
       }
 
   /* Restore the original setting.  */
   if (tty_changed)
     (void) tcsetattr (fileno (in), TCSAFLUSH|TCSASOFT, &s);
 
+  funlockfile (out);
+
   if (in != stdin)
     /* We opened the terminal; now close it.  */
     fclose (in);
diff --git a/misc/getttyent.c b/misc/getttyent.c
index e886e58b8e..dc4b9fadcb 100644
--- a/misc/getttyent.c
+++ b/misc/getttyent.c
@@ -40,6 +40,11 @@ static char sccsid[] = "@(#)getttyent.c	8.1 (Berkeley) 6/4/93";
 #include <ctype.h>
 #include <string.h>
 
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
 static char zapchar;
 static FILE *tf;
 
diff --git a/misc/mntent_r.c b/misc/mntent_r.c
index 94b1d15c71..0ee74e5d9b 100644
--- a/misc/mntent_r.c
+++ b/misc/mntent_r.c
@@ -22,6 +22,11 @@
 #include <string.h>
 #include <sys/types.h>
 
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+# define funlockfile(s) _IO_funlockfile (s)
+#endif
+
 /* Prepare to begin reading and/or writing mount table entries from the
    beginning of FILE.  MODE is as for `fopen'.  */
 FILE *
diff --git a/misc/search.h b/misc/search.h
index 2e11d8fb1c..323bb217c6 100644
--- a/misc/search.h
+++ b/misc/search.h
@@ -160,7 +160,7 @@ extern void twalk __PMT ((__const void *__root, __action_fn_t action));
 #ifdef __USE_GNU
 /* Callback type for function to free a tree node.  If the keys are atomic
    data this function should do nothing.  */
-typedef void (*__free_fn_t) __P ((void *__nodep));
+typedef void (*__free_fn_t) __PMT ((void *__nodep));
 
 /* Destroy the whole tree, call FREEFCT for each node or leaf.  */
 extern void __tdestroy __PMT ((void *__root, __free_fn_t freefct));
diff --git a/misc/syslog.c b/misc/syslog.c
index a1d6f5ce5b..d025f672e0 100644
--- a/misc/syslog.c
+++ b/misc/syslog.c
@@ -58,6 +58,10 @@ static char sccsid[] = "@(#)syslog.c	8.4 (Berkeley) 3/18/94";
 #include <varargs.h>
 #endif
 
+#ifdef USE_IN_LIBIO
+# define ftell(s) _IO_ftell (s)
+#endif
+
 static int	LogType = SOCK_DGRAM;	/* type of socket connection */
 static int	LogFile = -1;		/* fd for log */
 static int	connected;		/* have done connect */
@@ -152,11 +156,11 @@ vsyslog(pri, fmt, ap)
 	if (LogTag == NULL)
 	  LogTag = __progname;
 	if (LogTag != NULL)
-	  fputs (LogTag, f);
+	  fputs_unlocked (LogTag, f);
 	if (LogStat & LOG_PID)
-	  fprintf (f, "[%d]", getpid ());
+	  fprintf (f, "[%d]", __getpid ());
 	if (LogTag != NULL)
-	  putc (':', f), putc (' ', f);
+	  putc_unlocked (':', f), putc_unlocked (' ', f);
 
 	/* We have the header.  Print the user's format into the buffer.  */
 	vfprintf (f, fmt, ap);
@@ -175,7 +179,7 @@ vsyslog(pri, fmt, ap)
 		++v;
 		v->iov_base = (char *) "\n";
 		v->iov_len = 1;
-		(void)writev(STDERR_FILENO, iov, 2);
+		(void)__writev(STDERR_FILENO, iov, 2);
 	}
 
 	/* Prepare for multiple users.  We have to take care: open and
@@ -188,7 +192,7 @@ vsyslog(pri, fmt, ap)
  	memset (&action, 0, sizeof (action));
  	action.sa_handler = sigpipe_handler;
  	sigemptyset (&action.sa_mask);
- 	sigpipe = sigaction (SIGPIPE, &action, &oldaction);
+ 	sigpipe = __sigaction (SIGPIPE, &action, &oldaction);
 	if (sigpipe == 0)
 	  oldaction_ptr = &oldaction;
 
@@ -210,15 +214,15 @@ vsyslog(pri, fmt, ap)
 	     * is the one from the syslogd failure.
 	     */
 	    if (LogStat & LOG_CONS &&
-		(fd = open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)
+		(fd = __open(_PATH_CONSOLE, O_WRONLY|O_NOCTTY, 0)) >= 0)
 	      {
 		dprintf (fd, "%s\r\n", buf + msgoff);
-		(void)close(fd);
+		(void)__close(fd);
 	      }
 	  }
 
 	if (sigpipe == 0)
-		sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);
+		__sigaction (SIGPIPE, &oldaction, (struct sigaction *) NULL);
 
 	/* End of critical section.  */
 	__libc_cleanup_region_end (0);
@@ -248,7 +252,7 @@ openlog_internal(const char *ident, int logstat, int logfac)
 				if ((LogFile = __socket(AF_UNIX, LogType, 0))
 				    == -1)
 					return;
-				(void)fcntl(LogFile, F_SETFD, 1);
+				(void)__fcntl(LogFile, F_SETFD, 1);
 			}
 		}
 		if (LogFile != -1 && !connected)
@@ -258,7 +262,7 @@ openlog_internal(const char *ident, int logstat, int logfac)
 			    == -1)
 			{
 				int saved_errno = errno;
-				(void)close(LogFile);
+				(void)__close(LogFile);
 				LogFile = -1;
 				if (LogType == SOCK_DGRAM
 				    && saved_errno == EPROTOTYPE)
@@ -301,7 +305,7 @@ closelog_internal()
   if (!connected)
     return;
 
-  close (LogFile);
+  __close (LogFile);
   LogFile = -1;
   connected = 0;
   LogTag = NULL;
@@ -329,7 +333,7 @@ cancel_handler (void *ptr)
   struct sigaction *oldaction = *((struct sigaction **) ptr);
 
   if (oldaction != (struct sigaction *) NULL)
-    sigaction (SIGPIPE, oldaction, (struct sigaction *) NULL);
+    __sigaction (SIGPIPE, oldaction, (struct sigaction *) NULL);
 
   /* Free the lock.  */
   __libc_lock_unlock (syslog_lock);
diff --git a/nscd/nscd_getgr_r.c b/nscd/nscd_getgr_r.c
index decfa3dad7..ec4b8f21c4 100644
--- a/nscd/nscd_getgr_r.c
+++ b/nscd/nscd_getgr_r.c
@@ -82,7 +82,7 @@ nscd_open_socket (void)
   strcpy (addr.sun_path, _PATH_NSCDSOCKET);
   if (__connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
     {
-      close (sock);
+      __close (sock);
       __set_errno (saved_errno);
       return -1;
     }
@@ -108,31 +108,31 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
   req.version = NSCD_VERSION;
   req.type = type;
   req.key_len = strlen (key);
-  nbytes = write (sock, &req, sizeof (request_header));
+  nbytes = __write (sock, &req, sizeof (request_header));
   if (nbytes != sizeof (request_header))
     {
-      close (sock);
+      __close (sock);
       return 1;
     }
 
-  nbytes = write (sock, key, req.key_len);
+  nbytes = __write (sock, key, req.key_len);
   if (nbytes != req.key_len)
     {
-      close (sock);
+      __close (sock);
       return 1;
     }
 
-  nbytes = read (sock, &gr_resp, sizeof (gr_response_header));
+  nbytes = __read (sock, &gr_resp, sizeof (gr_response_header));
   if (nbytes != sizeof (gr_response_header))
     {
-      close (sock);
+      __close (sock);
       return 1;
     }
 
   if (gr_resp.found == -1)
     {
       /* The daemon does not cache this database.  */
-      close (sock);
+      __close (sock);
       __nss_not_use_nscd_group = 1;
       return 1;
     }
@@ -145,16 +145,16 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
       if (buflen < gr_resp.gr_name_len + 1)
 	{
 	  __set_errno (ERANGE);
-	  close (sock);
+	  __close (sock);
 	  return -1;
 	}
       resultbuf->gr_name = p;
       p += gr_resp.gr_name_len + 1;
       buflen -= (gr_resp.gr_name_len + 1);
-      nbytes = read (sock, resultbuf->gr_name, gr_resp.gr_name_len);
+      nbytes = __read (sock, resultbuf->gr_name, gr_resp.gr_name_len);
       if (nbytes != gr_resp.gr_name_len)
 	{
-	  close (sock);
+	  __close (sock);
 	  return 1;
 	}
       resultbuf->gr_name[gr_resp.gr_name_len] = '\0';
@@ -162,16 +162,16 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
       if (buflen < gr_resp.gr_passwd_len + 1)
 	{
 	  __set_errno (ERANGE);
-	  close (sock);
+	  __close (sock);
 	  return -1;
 	}
       resultbuf->gr_passwd = p;
       p += gr_resp.gr_passwd_len + 1;
       buflen -= (gr_resp.gr_passwd_len + 1);
-      nbytes = read (sock, resultbuf->gr_passwd, gr_resp.gr_passwd_len);
+      nbytes = __read (sock, resultbuf->gr_passwd, gr_resp.gr_passwd_len);
       if (nbytes != gr_resp.gr_passwd_len)
 	{
-	  close (sock);
+	  __close (sock);
 	  return 1;
 	}
       resultbuf->gr_passwd[gr_resp.gr_passwd_len] = '\0';
@@ -181,7 +181,7 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
       if (buflen < ((gr_resp.gr_mem_len + 1) * sizeof (char *)))
 	{
 	  __set_errno (ERANGE);
-	  close (sock);
+	  __close (sock);
 	  return -1;
 	}
       resultbuf->gr_mem = (char **)p;
@@ -193,36 +193,36 @@ __nscd_getgr_r (const char *key, request_type type, struct group *resultbuf,
       for (i = 0; i < gr_resp.gr_mem_len; ++i)
 	{
 	  size_t len;
-	  nbytes = read (sock, &len, sizeof (len));
+	  nbytes = __read (sock, &len, sizeof (len));
 	  if (nbytes != sizeof (len))
 	    {
-	      close (sock);
+	      __close (sock);
 	      return 1;
 	    }
 
 	  if (buflen < (len + 1))
 	    {
 	      __set_errno (ERANGE);
-	      close (sock);
+	      __close (sock);
 	      return -1;
 	    }
 	  resultbuf->gr_mem[i] = p;
 	  p += len + 1;
 	  buflen -= (len + 1);
-	  nbytes = read (sock, resultbuf->gr_mem[i], len);
+	  nbytes = __read (sock, resultbuf->gr_mem[i], len);
 	  resultbuf->gr_mem[i][len] = '\0';
 	  if (nbytes != len)
 	    {
-	      close (sock);
+	      __close (sock);
 	      return 1;
 	    }
 	}
-      close (sock);
+      __close (sock);
       return 0;
     }
   else
     {
-      close (sock);
+      __close (sock);
       return -1;
     }
 }
diff --git a/nscd/nscd_getpw_r.c b/nscd/nscd_getpw_r.c
index d075c8523a..a24d33b789 100644
--- a/nscd/nscd_getpw_r.c
+++ b/nscd/nscd_getpw_r.c
@@ -82,7 +82,7 @@ nscd_open_socket (void)
   strcpy (addr.sun_path, _PATH_NSCDSOCKET);
   if (__connect (sock, (struct sockaddr *) &addr, sizeof (addr)) < 0)
     {
-      close (sock);
+      __close (sock);
       __set_errno (saved_errno);
       return -1;
     }
@@ -108,31 +108,31 @@ __nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
   req.version = NSCD_VERSION;
   req.type = type;
   req.key_len = strlen (key);
-  nbytes = write (sock, &req, sizeof (request_header));
+  nbytes = __write (sock, &req, sizeof (request_header));
   if (nbytes != sizeof (request_header))
     {
-      close (sock);
+      __close (sock);
       return 1;
     }
 
-  nbytes = write (sock, key, req.key_len);
+  nbytes = __write (sock, key, req.key_len);
   if (nbytes != req.key_len)
     {
-      close (sock);
+      __close (sock);
       return 1;
     }
 
-  nbytes = read (sock, &pw_resp, sizeof (pw_response_header));
+  nbytes = __read (sock, &pw_resp, sizeof (pw_response_header));
   if (nbytes != sizeof (pw_response_header))
     {
-      close (sock);
+      __close (sock);
       return 1;
     }
 
   if (pw_resp.found == -1)
     {
       /* The daemon does not cache this database.  */
-      close (sock);
+      __close (sock);
       __nss_not_use_nscd_passwd = 1;
       return 1;
     }
@@ -147,7 +147,7 @@ __nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
 		    + pw_resp.pw_shell_len + 1))
 	{
 	  __set_errno (ERANGE);
-	  close (sock);
+	  __close (sock);
 	  return -1;
 	}
 
@@ -182,7 +182,7 @@ __nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
 		      + pw_resp.pw_gecos_len + pw_resp.pw_dir_len
 		      + pw_resp.pw_shell_len))
 	{
-	  close (sock);
+	  __close (sock);
 	  return 1;
 	}
 
@@ -199,12 +199,12 @@ __nscd_getpw_r (const char *key, request_type type, struct passwd *resultbuf,
       resultbuf->pw_shell = vec[4].iov_base;
       resultbuf->pw_shell[pw_resp.pw_shell_len] = '\0';
 
-      close (sock);
+      __close (sock);
       return 0;
     }
   else
     {
-      close (sock);
+      __close (sock);
       return -1;
     }
 }
diff --git a/posix/setpgrp.c b/posix/setpgrp.c
index e3451e13e6..a511e058b9 100644
--- a/posix/setpgrp.c
+++ b/posix/setpgrp.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -21,5 +21,5 @@
 int
 setpgrp ()
 {
-  return setpgid (0, 0);
+  return __setpgid (0, 0);
 }
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 4991406ad1..fe3e2b2cea 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -291,7 +291,7 @@ parse_tilde (char **word, size_t *word_length, size_t *max_length,
       char* buffer = __alloca (buflen);
       int result;
 
-      uid = getuid ();
+      uid = __getuid ();
 
       while ((result = __getpwuid_r (uid, &pwd, buffer, buflen, &tpwd)) != 0
 	     && errno == ERANGE)
@@ -801,11 +801,11 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
   if (!comm || !*comm)
     return 0;
 
-  if (pipe (fildes))
+  if (__pipe (fildes))
     /* Bad */
     return WRDE_NOSPACE;
 
-  if ((pid = fork ()) < 0)
+  if ((pid = __fork ()) < 0)
     {
       /* Bad */
       return WRDE_NOSPACE;
@@ -817,23 +817,23 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
       const char *args[4] = { _PATH_BSHELL, "-c", comm, NULL };
 
       /* Redirect output.  */
-      dup2 (fildes[1], 1);
-      close (fildes[1]);
+      __dup2 (fildes[1], 1);
+      __close (fildes[1]);
 
       /* Redirect stderr to /dev/null if we have to.  */
       if ((flags & WRDE_SHOWERR) == 0)
 	{
 	  int fd;
-	  close (2);
-	  fd = open (_PATH_DEVNULL, O_WRONLY);
+	  __close (2);
+	  fd = __open (_PATH_DEVNULL, O_WRONLY);
 	  if (fd >= 0 && fd != 2)
 	    {
-	      dup2 (fd, 2);
-	      close (fd);
+	      __dup2 (fd, 2);
+	      __close (fd);
 	    }
 	}
 
-      close (fildes[0]);
+      __close (fildes[0]);
       __execve (_PATH_BSHELL, (char *const *) args, __environ);
 
       /* Bad.  What now?  */
@@ -842,7 +842,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
 
   /* Parent */
 
-  close (fildes[1]);
+  __close (fildes[1]);
   buffer = __alloca (bufsize);
 
   if (!pwordexp)
@@ -850,20 +850,20 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
 
       while (1)
 	{
-	  if ((buflen = read (fildes[0], buffer, bufsize)) < 1)
+	  if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
 	    {
 	      if (__waitpid (pid, NULL, WNOHANG) == 0)
 		continue;
-	      if ((buflen = read (fildes[0], buffer, bufsize)) < 1)
+	      if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
 		break;
 	    }
 
 	  *word = w_addmem (*word, word_length, max_length, buffer, buflen);
 	  if (*word == NULL)
 	    {
-	      kill (pid, SIGKILL);
+	      __kill (pid, SIGKILL);
 	      __waitpid (pid, NULL, 0);
-	      close (fildes[0]);
+	      __close (fildes[0]);
 	      return WRDE_NOSPACE;
 	    }
 	}
@@ -880,11 +880,11 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
 
       while (1)
 	{
-	  if ((buflen = read (fildes[0], buffer, bufsize)) < 1)
+	  if ((buflen = __read (fildes[0], buffer, bufsize)) < 1)
 	    {
 	      if (__waitpid (pid, NULL, WNOHANG) == 0)
 		continue;
-	      if ((read (fildes[0], buffer, bufsize)) < 1)
+	      if ((__read (fildes[0], buffer, bufsize)) < 1)
 		break;
 	    }
 
@@ -932,18 +932,18 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
 		      *word = w_addchar (*word, word_length, max_length, 0);
 		      if (*word == NULL)
 			{
-			  kill (pid, SIGKILL);
+			  __kill (pid, SIGKILL);
 			  __waitpid (pid, NULL, 0);
-			  close (fildes[0]);
+			  __close (fildes[0]);
 			  return WRDE_NOSPACE;
 			}
 		    }
 
 		  if (w_addword (pwordexp, *word) == WRDE_NOSPACE)
 		    {
-		      kill (pid, SIGKILL);
+		      __kill (pid, SIGKILL);
 		      __waitpid (pid, NULL, 0);
-		      close (fildes[0]);
+		      __close (fildes[0]);
 		      return WRDE_NOSPACE;
 		    }
 
@@ -958,9 +958,9 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
 				     buffer[i]);
 		  if (*word == NULL)
 		    {
-		      kill (pid, SIGKILL);
+		      __kill (pid, SIGKILL);
 		      __waitpid (pid, NULL, 0);
-		      close (fildes[0]);
+		      __close (fildes[0]);
 		      return WRDE_NOSPACE;
 		    }
 		}
@@ -972,7 +972,7 @@ exec_comm (char *comm, char **word, size_t *word_length, size_t *max_length,
   while (*word_length > 0 && (*word)[*word_length - 1] == '\n')
     (*word)[--*word_length] = '\0';
 
-  close (fildes[0]);
+  __close (fildes[0]);
   return 0;
 }
 
@@ -1280,7 +1280,7 @@ envsubst:
       if (*env == '$')
 	{
 	  buffer[20] = '\0';
-	  value = _itoa_word (getpid (), &buffer[20], 10, 0);
+	  value = _itoa_word (__getpid (), &buffer[20], 10, 0);
 	}
       /* Is it `${#*}' or `${#@}'? */
       else if ((*env == '*' || *env == '@') && seen_hash)
diff --git a/pwd/fgetpwent_r.c b/pwd/fgetpwent_r.c
index 87ea1dedda..78b491d386 100644
--- a/pwd/fgetpwent_r.c
+++ b/pwd/fgetpwent_r.c
@@ -21,6 +21,10 @@
 #include <stdio.h>
 #include <pwd.h>
 
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+#endif
+
 /* Define a line parsing function using the common code
    used in the nss_files module.  */
 
@@ -72,17 +76,20 @@ __fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer,
 {
   char *p;
 
+  flockfile (stream);
   do
     {
       buffer[buflen - 1] = '\xff';
-      p = fgets (buffer, buflen, stream);
-      if (p == NULL && feof (stream))
+      p = fgets_unlocked (buffer, buflen, stream);
+      if (p == NULL && feof_unlocked (stream))
 	{
+	  funlockfile (stream);
 	  *result = NULL;
 	  return errno;
 	}
       if (p == NULL || buffer[buflen - 1] != '\xff')
 	{
+	  funlockfile (stream);
 	  *result = NULL;
 	  return errno = ERANGE;
 	}
@@ -95,6 +102,8 @@ __fgetpwent_r (FILE *stream, struct passwd *resbuf, char *buffer,
 		get the next line of the file to parse.  */
 	     ! parse_line (p, resbuf, (void *) buffer, buflen, &errno));
 
+  funlockfile (stream);
+
   *result = resbuf;
   return 0;
 }
diff --git a/pwd/getpw.c b/pwd/getpw.c
index 9c2e4afd0a..5f738724a9 100644
--- a/pwd/getpw.c
+++ b/pwd/getpw.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1992, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1992, 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -47,7 +47,7 @@ __getpw (uid, buf)
   buflen = __sysconf (_SC_GETPW_R_SIZE_MAX);
   tmpbuf = alloca (buflen);
 
-  if (getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) < 0)
+  if (__getpwuid_r (uid, &resbuf, tmpbuf, buflen, &p) < 0)
     return -1;
 
   if (sprintf (buf, "%s:%s:%u:%u:%s:%s:%s", p->pw_name, p->pw_passwd,
diff --git a/resolv/herror.c b/resolv/herror.c
index 571d1a0478..95cf4164b0 100644
--- a/resolv/herror.c
+++ b/resolv/herror.c
@@ -106,7 +106,7 @@ herror(s)
 	v++;
 	v->iov_base = "\n";
 	v->iov_len = 1;
-	writev(STDERR_FILENO, iov, (v - iov) + 1);
+	__writev(STDERR_FILENO, iov, (v - iov) + 1);
 }
 
 const char *
diff --git a/resolv/res_init.c b/resolv/res_init.c
index b22611b087..906a2b1571 100644
--- a/resolv/res_init.c
+++ b/resolv/res_init.c
@@ -386,7 +386,7 @@ res_init()
 	    (void) fclose(fp);
 	}
 	if (_res.defdname[0] == 0 &&
-	    gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
+	    __gethostname(buf, sizeof(_res.defdname) - 1) == 0 &&
 	    (cp = strchr(buf, '.')) != NULL)
 		strcpy(_res.defdname, cp + 1);
 
@@ -651,6 +651,6 @@ res_randomid()
 {
 	struct timeval now;
 
-	gettimeofday(&now, NULL);
-	return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
+	__gettimeofday(&now, NULL);
+	return (0xffff & (now.tv_sec ^ now.tv_usec ^ __getpid()));
 }
diff --git a/shadow/fgetspent_r.c b/shadow/fgetspent_r.c
index bf4a3f8c08..bedc36182e 100644
--- a/shadow/fgetspent_r.c
+++ b/shadow/fgetspent_r.c
@@ -21,6 +21,10 @@
 #include <shadow.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define flockfile(s) _IO_flockfile (s)
+#endif
+
 /* Define a line parsing function using the common code
    used in the nss_files module.  */
 
@@ -39,17 +43,20 @@ __fgetspent_r (FILE *stream, struct spwd *resbuf, char *buffer, size_t buflen,
 {
   char *p;
 
+  flockfile (stream);
   do
     {
       buffer[buflen - 1] = '\xff';
-      p = fgets (buffer, buflen, stream);
-      if (p == NULL && feof (stream))
+      p = fgets_unlocked (buffer, buflen, stream);
+      if (p == NULL && feof_unlocked (stream))
 	{
+	  funlockfile (stream);
 	  *result = NULL;
 	  return errno;
 	}
       if (p == NULL || buffer[buflen - 1] != '\xff')
 	{
+	  funlockfile (stream);
 	  *result = NULL;
 	  return errno = ERANGE;
 	}
@@ -62,6 +69,8 @@ __fgetspent_r (FILE *stream, struct spwd *resbuf, char *buffer, size_t buflen,
 		get the next line of the file to parse.  */
 	     ! parse_line (buffer, (void *) resbuf, NULL, 0, &errno));
 
+  funlockfile (stream);
+
   *result = resbuf;
   return 0;
 }
diff --git a/shadow/lckpwdf.c b/shadow/lckpwdf.c
index 885ac54bf6..861e0e0cd2 100644
--- a/shadow/lckpwdf.c
+++ b/shadow/lckpwdf.c
@@ -1,5 +1,5 @@
 /* Handle locking of password file.
-   Copyright (C) 1996 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -52,7 +52,7 @@ static void noop_handler __P ((int __sig));
   do {									      \
     if ((code) < 0 && lock_fd >= 0)					      \
       {									      \
-	close (lock_fd);						      \
+	__close (lock_fd);						      \
 	lock_fd = -1;							      \
       }									      \
     __libc_lock_unlock (lock);						      \
@@ -63,7 +63,7 @@ static void noop_handler __P ((int __sig));
   do {									      \
     /* Restore old action handler for alarm.  We don't need to know	      \
        about the current one.  */					      \
-    sigaction (SIGALRM, &saved_act, NULL);				      \
+    __sigaction (SIGALRM, &saved_act, NULL);				      \
     RETURN_CLOSE_FD (code);						      \
   } while (0)
 
@@ -73,7 +73,7 @@ static void noop_handler __P ((int __sig));
     alarm (0);								      \
     /* Restore old set of handled signals.  We don't need to know	      \
        about the current one.*/						      \
-    sigprocmask (SIG_SETMASK, &saved_set, NULL);			      \
+    __sigprocmask (SIG_SETMASK, &saved_set, NULL);			      \
     RETURN_RESTORE_HANDLER (code);					      \
   } while (0)
 
@@ -96,18 +96,18 @@ __lckpwdf ()
   /* Prevent problems caused by multiple threads.  */
   __libc_lock_lock (lock);
 
-  lock_fd = open (PWD_LOCKFILE, O_WRONLY | O_CREAT, 0600);
+  lock_fd = __open (PWD_LOCKFILE, O_WRONLY | O_CREAT, 0600);
   if (lock_fd == -1)
     /* Cannot create lock file.  */
     RETURN_CLOSE_FD (-1);
 
   /* Make sure file gets correctly closed when process finished.  */
-  flags = fcntl (lock_fd, F_GETFD, 0);
+  flags = __fcntl (lock_fd, F_GETFD, 0);
   if (flags == -1)
     /* Cannot get file flags.  */
     RETURN_CLOSE_FD (-1);
   flags |= FD_CLOEXEC;		/* Close on exit.  */
-  if (fcntl (lock_fd, F_SETFD, flags) < 0)
+  if (__fcntl (lock_fd, F_SETFD, flags) < 0)
     /* Cannot set new flags.  */
     RETURN_CLOSE_FD (-1);
 
@@ -125,14 +125,14 @@ __lckpwdf ()
   new_act.sa_flags = 0ul;
 
   /* Install new action handler for alarm and save old.  */
-  if (sigaction (SIGALRM, &new_act, &saved_act) < 0)
+  if (__sigaction (SIGALRM, &new_act, &saved_act) < 0)
     /* Cannot install signal handler.  */
     RETURN_CLOSE_FD (-1);
 
   /* Now make sure the alarm signal is not blocked.  */
   sigemptyset (&new_set);
   sigaddset (&new_set, SIGALRM);
-  if (sigprocmask (SIG_UNBLOCK, &new_set, &saved_set) < 0)
+  if (__sigprocmask (SIG_UNBLOCK, &new_set, &saved_set) < 0)
     RETURN_RESTORE_HANDLER (-1);
 
   /* Start timer.  If we cannot get the lock in the specified time we
@@ -143,7 +143,7 @@ __lckpwdf ()
   memset (&fl, '\0', sizeof (struct flock));
   fl.l_type = F_WRLCK;
   fl.l_whence = SEEK_SET;
-  result = fcntl (lock_fd, F_SETLKW, &fl);
+  result = __fcntl (lock_fd, F_SETLKW, &fl);
 
   RETURN_CLEAR_ALARM (result);
 }
@@ -163,7 +163,7 @@ __ulckpwdf ()
       /* Prevent problems caused by multiple threads.  */
       __libc_lock_lock (lock);
 
-      result = close (lock_fd);
+      result = __close (lock_fd);
 
       /* Mark descriptor as unused.  */
       lock_fd = -1;
diff --git a/signal/sigrelse.c b/signal/sigrelse.c
index 971d60ffdf..56bafaa906 100644
--- a/signal/sigrelse.c
+++ b/signal/sigrelse.c
@@ -29,7 +29,7 @@ sigrelse (sig)
   sigset_t set;
 
   /* Retrieve current signal set.  */
-  if (sigprocmask (SIG_SETMASK, NULL, &set) < 0)
+  if (__sigprocmask (SIG_SETMASK, NULL, &set) < 0)
     return -1;
 
   /* Remove the specified signal.  */
@@ -37,5 +37,5 @@ sigrelse (sig)
     return -1;
 
   /* Set the new mask.  */
-  return sigprocmask (SIG_SETMASK, &set, NULL);
+  return __sigprocmask (SIG_SETMASK, &set, NULL);
 }
diff --git a/stdio-common/asprintf.c b/stdio-common/asprintf.c
index bfc4d215a2..56c49de4e1 100644
--- a/stdio-common/asprintf.c
+++ b/stdio-common/asprintf.c
@@ -19,6 +19,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define vasprintf(s, f, a) _IO_vasprintf (s, f, a)
+#endif
+
 /* Write formatted output from FORMAT to a string which is
    allocated with malloc and stored in *STRING_PTR.  */
 /* VARARGS2 */
diff --git a/stdio-common/dprintf.c b/stdio-common/dprintf.c
index 0aa12d9dfc..eddaea8cf8 100644
--- a/stdio-common/dprintf.c
+++ b/stdio-common/dprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define vdprintf(d, f, a) _IO_vdprintf (d, f, a)
+#endif
+
 /* Write formatted output to D, according to the format string FORMAT.  */
 /* VARARGS2 */
 int
diff --git a/stdio-common/getw.c b/stdio-common/getw.c
index a1629db438..03da6c3906 100644
--- a/stdio-common/getw.c
+++ b/stdio-common/getw.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -18,6 +18,9 @@
 
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define fread(p, m, n, s) _IO_fread (p, m, n, s)
+#endif
 
 /* Read a word (int) from STREAM.  */
 int
diff --git a/stdio-common/putw.c b/stdio-common/putw.c
index c9d0d5dcc4..31cc00f41d 100644
--- a/stdio-common/putw.c
+++ b/stdio-common/putw.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -18,6 +18,9 @@
 
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define fwrite(p, n, m, s) _IO_fwrite (p, n, m, s)
+#endif
 
 /* Write the word (int) W to STREAM.  */
 int
diff --git a/stdio-common/snprintf.c b/stdio-common/snprintf.c
index 3e6950dc47..08aaf88f18 100644
--- a/stdio-common/snprintf.c
+++ b/stdio-common/snprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define __vsnprintf(s, l, f, a) _IO_vsnprintf (s, l, f, a)
+#endif
+
 /* Write formatted output into S, according to the format
    string FORMAT, writing no more than MAXLEN characters.  */
 /* VARARGS3 */
diff --git a/stdio-common/sprintf.c b/stdio-common/sprintf.c
index 6ea13661a1..0a0259ef0c 100644
--- a/stdio-common/sprintf.c
+++ b/stdio-common/sprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define vsprintf(s, f, a) _IO_vsprintf (s, f, a)
+#endif
+
 /* Write formatted output into S, according to the format string FORMAT.  */
 /* VARARGS2 */
 int
diff --git a/stdio-common/sscanf.c b/stdio-common/sscanf.c
index c1061523cb..809f059ef3 100644
--- a/stdio-common/sscanf.c
+++ b/stdio-common/sscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -19,6 +19,10 @@
 #include <stdarg.h>
 #include <stdio.h>
 
+#ifdef USE_IN_LIBIO
+# define __vsscanf(s, f, a) _IO_vsscanf (s, f, a)
+#endif
+
 /* Read formatted input from S, according to the format string FORMAT.  */
 /* VARARGS2 */
 int
diff --git a/stdlib/lrand48_r.c b/stdlib/lrand48_r.c
index 40df2941c1..4890923a74 100644
--- a/stdlib/lrand48_r.c
+++ b/stdlib/lrand48_r.c
@@ -28,5 +28,5 @@ lrand48_r (buffer, result)
   if (buffer == NULL)
    return -1;
 
-  return nrand48_r (buffer->x, buffer, result);
+  return __nrand48_r (buffer->x, buffer, result);
 }
diff --git a/stdlib/mrand48_r.c b/stdlib/mrand48_r.c
index f3bab4070e..3ed5643e00 100644
--- a/stdlib/mrand48_r.c
+++ b/stdlib/mrand48_r.c
@@ -28,5 +28,5 @@ mrand48_r (buffer, result)
   if (buffer == NULL)
    return -1;
 
-  return jrand48_r (buffer->x, buffer, result);
+  return __jrand48_r (buffer->x, buffer, result);
 }
diff --git a/string/argz-replace.c b/string/argz-replace.c
index 4540cba58f..aeec5f5db3 100644
--- a/string/argz-replace.c
+++ b/string/argz-replace.c
@@ -1,5 +1,5 @@
 /* String replacement in an argz vector
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    Written by Miles Bader <miles@gnu.ai.mit.edu>
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -69,7 +69,7 @@ __argz_replace (char **argz, size_t *argz_len, const char *str, const char *with
 	    {
 	      char *from = match + str_len;
 	      size_t to_len = match - arg;
-	      char *to = strndup (arg, to_len);
+	      char *to = __strndup (arg, to_len);
 
 	      while (to && from)
 		{
@@ -98,11 +98,11 @@ __argz_replace (char **argz, size_t *argz_len, const char *str, const char *with
                        of SRC.  */
 		    {
 		      if (arg > src)
-			err = argz_append (&dst, &dst_len, src, (arg - src));
+			err = __argz_append (&dst, &dst_len, src, (arg - src));
 		      delayed_copy = 0;
 		    }
 		  if (! err)
-		    err = argz_add (&dst, &dst_len, to);
+		    err = __argz_add (&dst, &dst_len, to);
 		  free (to);
 		}
 	      else
@@ -112,7 +112,7 @@ __argz_replace (char **argz, size_t *argz_len, const char *str, const char *with
 		(*replace_count)++;
 	    }
 	  else if (! delayed_copy)
-	    err = argz_add (&dst, &dst_len, arg);
+	    err = __argz_add (&dst, &dst_len, arg);
 	}
 
       if (! err)
diff --git a/string/envz.c b/string/envz.c
index 535f42e864..6b2fedcf15 100644
--- a/string/envz.c
+++ b/string/envz.c
@@ -1,5 +1,5 @@
 /* Routines for dealing with '\0' separated environment vectors
-   Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Miles Bader <miles@gnu.ai.mit.edu>
 
@@ -119,7 +119,7 @@ envz_add (char **envz, size_t *envz_len, const char *name, const char *value)
     }
   else
     /* Add a null entry.  */
-    return argz_add (envz, envz_len, name);
+    return __argz_add (envz, envz_len, name);
 }
 
 /* Adds each entry in ENVZ2 to ENVZ & ENVZ_LEN, as if with envz_add().  If
@@ -137,11 +137,11 @@ envz_merge (char **envz, size_t *envz_len, const char *envz2,
       size_t new_len = strlen (envz2) + 1;
 
       if (! old)
-	err = argz_append (envz, envz_len, envz2, new_len);
+	err = __argz_append (envz, envz_len, envz2, new_len);
       else if (override)
 	{
 	  argz_delete (envz, envz_len, old);
-	  err = argz_append (envz, envz_len, envz2, new_len);
+	  err = __argz_append (envz, envz_len, envz2, new_len);
 	}
 
       envz2 += new_len;
diff --git a/sunrpc/auth_des.c b/sunrpc/auth_des.c
index 8536e62b79..cd68c22ee9 100644
--- a/sunrpc/auth_des.c
+++ b/sunrpc/auth_des.c
@@ -243,7 +243,7 @@ authdes_marshal (AUTH * auth, XDR * xdrs)
    * Figure out the "time", accounting for any time difference
    * with the server if necessary.
    */
-  gettimeofday (&ad->ad_timestamp, (struct timezone *) NULL);
+  __gettimeofday (&ad->ad_timestamp, (struct timezone *) NULL);
   ad->ad_timestamp.tv_sec += ad->ad_timediff.tv_sec;
   ad->ad_timestamp.tv_usec += ad->ad_timediff.tv_usec;
   if (ad->ad_timestamp.tv_usec >= MILLION)
@@ -371,8 +371,8 @@ authdes_validate (AUTH * auth, struct opaque_auth *rverf)
   /*
    * validate
    */
-  if (bcmp ((char *) &ad->ad_timestamp, (char *) &verf.adv_timestamp,
-	    sizeof (struct timeval)) != 0)
+  if (memcmp ((char *) &ad->ad_timestamp, (char *) &verf.adv_timestamp,
+	      sizeof (struct timeval)) != 0)
     {
       debug ("authdes_validate: verifier mismatch\n");
       return (FALSE);
@@ -449,7 +449,7 @@ synchronize (struct sockaddr *syncaddr, struct timeval *timep)
   if (rtime ((struct sockaddr_in *) syncaddr, timep, &timeout) < 0)
     return (FALSE);
 
-  gettimeofday (&mytime, (struct timezone *) NULL);
+  __gettimeofday (&mytime, (struct timezone *) NULL);
   timep->tv_sec -= mytime.tv_sec;
   if (mytime.tv_usec > timep->tv_usec)
     {
diff --git a/sunrpc/auth_unix.c b/sunrpc/auth_unix.c
index c4c001abf5..9314119a70 100644
--- a/sunrpc/auth_unix.c
+++ b/sunrpc/auth_unix.c
@@ -130,7 +130,7 @@ authunix_create (machname, uid, gid, len, aup_gids)
   /*
    * fill in param struct from the given params
    */
-  (void) gettimeofday (&now, (struct timezone *) 0);
+  (void) __gettimeofday (&now, (struct timezone *) 0);
   aup.aup_time = now.tv_sec;
   aup.aup_machname = machname;
   aup.aup_uid = uid;
@@ -175,13 +175,13 @@ authunix_create_default (void)
   int max_nr_groups = __sysconf (_SC_NGROUPS_MAX);
   gid_t gids[max_nr_groups];
 
-  if (gethostname (machname, MAX_MACHINE_NAME) == -1)
+  if (__gethostname (machname, MAX_MACHINE_NAME) == -1)
     abort ();
   machname[MAX_MACHINE_NAME] = 0;
-  uid = geteuid ();
-  gid = getegid ();
+  uid = __geteuid ();
+  gid = __getegid ();
 
-  if ((len = getgroups (max_nr_groups, gids)) < 0)
+  if ((len = __getgroups (max_nr_groups, gids)) < 0)
     abort ();
   /* This braindamaged Sun code forces us here to truncate the
      list of groups to NGRPS members since the code in
@@ -267,7 +267,7 @@ authunix_refresh (AUTH *auth)
     goto done;
 
   /* update the time and serialize in place */
-  (void) gettimeofday (&now, (struct timezone *) 0);
+  (void) __gettimeofday (&now, (struct timezone *) 0);
   aup.aup_time = now.tv_sec;
   xdrs.x_op = XDR_ENCODE;
   XDR_SETPOS (&xdrs, 0);
diff --git a/sunrpc/bindrsvprt.c b/sunrpc/bindrsvprt.c
index e1d53ce950..f646ffda70 100644
--- a/sunrpc/bindrsvprt.c
+++ b/sunrpc/bindrsvprt.c
@@ -61,7 +61,7 @@ bindresvport (int sd, struct sockaddr_in *sin)
   if (sin == (struct sockaddr_in *) 0)
     {
       sin = &myaddr;
-      bzero (sin, sizeof (*sin));
+      __bzero (sin, sizeof (*sin));
       sin->sin_family = AF_INET;
     }
   else if (sin->sin_family != AF_INET)
@@ -71,7 +71,7 @@ bindresvport (int sd, struct sockaddr_in *sin)
     }
   if (port == 0)
     {
-      port = (getpid () % NPORTS) + STARTPORT;
+      port = (__getpid () % NPORTS) + STARTPORT;
     }
   res = -1;
   __set_errno (EADDRINUSE);
diff --git a/sunrpc/clnt_gen.c b/sunrpc/clnt_gen.c
index c24442cb36..b1b35ca50a 100644
--- a/sunrpc/clnt_gen.c
+++ b/sunrpc/clnt_gen.c
@@ -89,7 +89,7 @@ clnt_create (const char *hostname, u_long prog, u_long vers,
     }
   sin.sin_family = h->h_addrtype;
   sin.sin_port = 0;
-  bzero (sin.sin_zero, sizeof (sin.sin_zero));
+  __bzero (sin.sin_zero, sizeof (sin.sin_zero));
   bcopy (h->h_addr, (char *) &sin.sin_addr, h->h_length);
 
   prtbuflen = 1024;
diff --git a/sunrpc/clnt_perr.c b/sunrpc/clnt_perr.c
index af0fe4313c..d756cb12ba 100644
--- a/sunrpc/clnt_perr.c
+++ b/sunrpc/clnt_perr.c
@@ -43,6 +43,11 @@ static char sccsid[] = "@(#)clnt_perror.c 1.15 87/10/07 Copyr 1984 Sun Micro";
 #include <rpc/auth.h>
 #include <rpc/clnt.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
+
 static char *auth_errmsg (enum auth_stat stat) internal_function;
 
 static char *buf;
@@ -96,8 +101,8 @@ clnt_sperror (CLIENT * rpch, const char *msg)
 
     case RPC_CANTSEND:
     case RPC_CANTRECV:
-      len = sprintf (str, "; errno = %s", strerror_r (e.re_errno,
-						      buf, sizeof buf));
+      len = sprintf (str, "; errno = %s", __strerror_r (e.re_errno,
+							buf, sizeof buf));
       str += len;
       break;
 
@@ -233,21 +238,14 @@ clnt_spcreateerror (const char *msg)
   switch (rpc_createerr.cf_stat)
     {
     case RPC_PMAPFAILURE:
-      cp = stpcpy (cp, " - ");
-      cp = stpcpy (cp, clnt_sperrno (rpc_createerr.cf_error.re_status));
+      cp = stpcpy (stpcpy (cp, " - "),
+		   clnt_sperrno (rpc_createerr.cf_error.re_status));
       break;
 
     case RPC_SYSTEMERROR:
-      cp = stpcpy (str, " - ");
-      if (rpc_createerr.cf_error.re_errno > 0
-	  && rpc_createerr.cf_error.re_errno < sys_nerr)
-	cp = stpcpy (str, strerror_r (rpc_createerr.cf_error.re_errno,
-				      buf, sizeof buf));
-      else
-	{
-	  len = sprintf (cp, _("Error %d"), rpc_createerr.cf_error.re_errno);
-	  cp += len;
-	}
+      cp = stpcpy (stpcpy (cp, " - "),
+		   __strerror_r (rpc_createerr.cf_error.re_errno,
+				 buf, sizeof buf));
       break;
     default:
       break;
diff --git a/sunrpc/clnt_simp.c b/sunrpc/clnt_simp.c
index f528c3018b..bf9f690573 100644
--- a/sunrpc/clnt_simp.c
+++ b/sunrpc/clnt_simp.c
@@ -93,7 +93,7 @@ callrpc (const char *host, u_long prognum, u_long versnum, u_long procnum,
       crp->valid = 0;
       if (crp->socket != RPC_ANYSOCK)
 	{
-	  (void) close (crp->socket);
+	  (void) __close (crp->socket);
 	  crp->socket = RPC_ANYSOCK;
 	}
       if (crp->client)
diff --git a/sunrpc/clnt_tcp.c b/sunrpc/clnt_tcp.c
index be74f0dc0e..07224e313b 100644
--- a/sunrpc/clnt_tcp.c
+++ b/sunrpc/clnt_tcp.c
@@ -155,16 +155,16 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
    */
   if (*sockp < 0)
     {
-      *sockp = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
+      *sockp = __socket (AF_INET, SOCK_STREAM, IPPROTO_TCP);
       (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
       if ((*sockp < 0)
-	  || (connect (*sockp, (struct sockaddr *) raddr,
-		       sizeof (*raddr)) < 0))
+	  || (__connect (*sockp, (struct sockaddr *) raddr,
+			 sizeof (*raddr)) < 0))
 	{
 	  rpc_createerr.cf_stat = RPC_SYSTEMERROR;
 	  rpc_createerr.cf_error.re_errno = errno;
 	  if (*sockp >= 0)
-	    (void) close (*sockp);
+	    (void) __close (*sockp);
 	  goto fooy;
 	}
       ct->ct_closeit = TRUE;
@@ -185,8 +185,8 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
   /*
    * Initialize call message
    */
-  (void) gettimeofday (&now, (struct timezone *) 0);
-  call_msg.rm_xid = getpid () ^ now.tv_sec ^ now.tv_usec;
+  (void) __gettimeofday (&now, (struct timezone *) 0);
+  call_msg.rm_xid = __getpid () ^ now.tv_sec ^ now.tv_usec;
   call_msg.rm_direction = CALL;
   call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
   call_msg.rm_call.cb_prog = prog;
@@ -201,7 +201,7 @@ clnttcp_create (struct sockaddr_in *raddr, u_long prog, u_long vers,
     {
       if (ct->ct_closeit)
 	{
-	  (void) close (*sockp);
+	  (void) __close (*sockp);
 	}
       goto fooy;
     }
@@ -454,7 +454,7 @@ clnttcp_destroy (CLIENT *h)
 
   if (ct->ct_closeit)
     {
-      (void) close (ct->ct_sock);
+      (void) __close (ct->ct_sock);
     }
   XDR_DESTROY (&(ct->ct_xdrs));
   mem_free ((caddr_t) ct, sizeof (struct ct_data));
@@ -496,7 +496,7 @@ readtcp (char *ctptr, char *buf, int len)
 	}
       break;
     }
-  switch (len = read (ct->ct_sock, buf, len))
+  switch (len = __read (ct->ct_sock, buf, len))
     {
 
     case 0:
@@ -522,7 +522,7 @@ writetcp (char *ctptr, char *buf, int len)
 
   for (cnt = len; cnt > 0; cnt -= i, buf += i)
     {
-      if ((i = write (ct->ct_sock, buf, cnt)) == -1)
+      if ((i = __write (ct->ct_sock, buf, cnt)) == -1)
 	{
 	  ct->ct_error.re_errno = errno;
 	  ct->ct_error.re_status = RPC_CANTSEND;
diff --git a/sunrpc/clnt_udp.c b/sunrpc/clnt_udp.c
index 1e2fe657d9..0842e5ac1a 100644
--- a/sunrpc/clnt_udp.c
+++ b/sunrpc/clnt_udp.c
@@ -143,7 +143,7 @@ clntudp_bufcreate (raddr, program, version, wait, sockp, sendsz, recvsz)
     }
   cu->cu_outbuf = &cu->cu_inbuf[recvsz];
 
-  (void) gettimeofday (&now, (struct timezone *) 0);
+  (void) __gettimeofday (&now, (struct timezone *) 0);
   if (raddr->sin_port == 0)
     {
       u_short port;
@@ -163,7 +163,7 @@ clntudp_bufcreate (raddr, program, version, wait, sockp, sendsz, recvsz)
   cu->cu_total.tv_usec = -1;
   cu->cu_sendsz = sendsz;
   cu->cu_recvsz = recvsz;
-  call_msg.rm_xid = getpid () ^ now.tv_sec ^ now.tv_usec;
+  call_msg.rm_xid = __getpid () ^ now.tv_sec ^ now.tv_usec;
   call_msg.rm_direction = CALL;
   call_msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
   call_msg.rm_call.cb_prog = program;
@@ -179,7 +179,7 @@ clntudp_bufcreate (raddr, program, version, wait, sockp, sendsz, recvsz)
     {
       int dontblock = 1;
 
-      *sockp = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
+      *sockp = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP);
       if (*sockp < 0)
 	{
 	  rpc_createerr.cf_stat = RPC_SYSTEMERROR;
@@ -189,7 +189,7 @@ clntudp_bufcreate (raddr, program, version, wait, sockp, sendsz, recvsz)
       /* attempt to bind to prov port */
       (void) bindresvport (*sockp, (struct sockaddr_in *) 0);
       /* the sockets rpc controls are non-blocking */
-      (void) ioctl (*sockp, FIONBIO, (char *) &dontblock);
+      (void) __ioctl (*sockp, FIONBIO, (char *) &dontblock);
       cu->cu_closeit = TRUE;
     }
   else
@@ -511,7 +511,7 @@ clntudp_destroy (CLIENT *cl)
 
   if (cu->cu_closeit)
     {
-      (void) close (cu->cu_sock);
+      (void) __close (cu->cu_sock);
     }
   XDR_DESTROY (&(cu->cu_outxdrs));
   mem_free ((caddr_t) cu, (sizeof (*cu) + cu->cu_sendsz + cu->cu_recvsz));
diff --git a/sunrpc/get_myaddr.c b/sunrpc/get_myaddr.c
index 86277d2390..820c7b3109 100644
--- a/sunrpc/get_myaddr.c
+++ b/sunrpc/get_myaddr.c
@@ -65,14 +65,14 @@ get_myaddress (struct sockaddr_in *addr)
   struct ifreq ifreq, *ifr;
   int len, loopback = 0;
 
-  if ((s = socket (AF_INET, SOCK_DGRAM, 0)) < 0)
+  if ((s = __socket (AF_INET, SOCK_DGRAM, 0)) < 0)
     {
       perror ("get_myaddress: socket");
       exit (1);
     }
   ifc.ifc_len = sizeof (buf);
   ifc.ifc_buf = buf;
-  if (ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
+  if (__ioctl (s, SIOCGIFCONF, (char *) &ifc) < 0)
     {
       perror (_("get_myaddress: ioctl (get interface configuration)"));
       exit (1);
@@ -83,7 +83,7 @@ get_myaddress (struct sockaddr_in *addr)
   for (len = ifc.ifc_len; len; len -= sizeof ifreq)
     {
       ifreq = *ifr;
-      if (ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+      if (__ioctl (s, SIOCGIFFLAGS, (char *) &ifreq) < 0)
 	{
           perror ("get_myaddress: ioctl");
           exit (1);
@@ -94,7 +94,7 @@ get_myaddress (struct sockaddr_in *addr)
 	{
 	  *addr = *((struct sockaddr_in *) &ifr->ifr_addr);
 	  addr->sin_port = htons (PMAPPORT);
-	  close (s);
+	  __close (s);
 	  return;
 	}
       ifr++;
@@ -104,5 +104,5 @@ get_myaddress (struct sockaddr_in *addr)
       loopback = 1;
       goto again;
     }
-  close (s);
+  __close (s);
 }
diff --git a/sunrpc/key_call.c b/sunrpc/key_call.c
index a497bc7cad..e59a8b7a37 100644
--- a/sunrpc/key_call.c
+++ b/sunrpc/key_call.c
@@ -200,7 +200,7 @@ key_gendes (des_block *key)
   sin.sin_family = AF_INET;
   sin.sin_port = 0;
   sin.sin_addr.s_addr = htonl (INADDR_LOOPBACK);
-  bzero (sin.sin_zero, sizeof (sin.sin_zero));
+  __bzero (sin.sin_zero, sizeof (sin.sin_zero));
   socket = RPC_ANYSOCK;
   client = clntudp_bufcreate (&sin, (u_long) KEY_PROG, (u_long) KEY_VERS,
 			      trytimeout, &socket, RPCSMALLMSGSIZE,
@@ -211,7 +211,7 @@ key_gendes (des_block *key)
   stat = clnt_call (client, KEY_GEN, (xdrproc_t) xdr_void, NULL,
 		    (xdrproc_t) xdr_des_block, (caddr_t) key, tottimeout);
   clnt_destroy (client);
-  close (socket);
+  __close (socket);
   if (stat != RPC_SUCCESS)
     return -1;
 
@@ -286,21 +286,21 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
   if (proc == KEY_ENCRYPT_PK && __key_encryptsession_pk_LOCAL)
     {
       cryptkeyres *res;
-      res = (*__key_encryptsession_pk_LOCAL) (geteuid (), arg);
+      res = (*__key_encryptsession_pk_LOCAL) (__geteuid (), arg);
       *(cryptkeyres *) rslt = *res;
       return 1;
     }
   else if (proc == KEY_DECRYPT_PK && __key_decryptsession_pk_LOCAL)
     {
       cryptkeyres *res;
-      res = (*__key_decryptsession_pk_LOCAL) (geteuid (), arg);
+      res = (*__key_decryptsession_pk_LOCAL) (__geteuid (), arg);
       *(cryptkeyres *) rslt = *res;
       return 1;
     }
   else if (proc == KEY_GEN && __key_gendes_LOCAL)
     {
       des_block *res;
-      res = (*__key_gendes_LOCAL) (geteuid (), 0);
+      res = (*__key_gendes_LOCAL) (__geteuid (), 0);
       *(des_block *) rslt = *res;
       return 1;
     }
@@ -308,7 +308,7 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
   success = 1;
   sigemptyset (&mask);
   sigaddset (&mask, SIGCHLD);
-  sigprocmask (SIG_BLOCK, &mask, &oldmask);
+  __sigprocmask (SIG_BLOCK, &mask, &oldmask);
 
   /*
    * We are going to exec a set-uid program which makes our effective uid
@@ -316,15 +316,15 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
    * effective uid be the real uid for the setuid program, and
    * the real uid be the effective uid so that we can change things back.
    */
-  euid = geteuid ();
-  ruid = getuid ();
-  setreuid (euid, ruid);
+  euid = __geteuid ();
+  ruid = __getuid ();
+  __setreuid (euid, ruid);
   pid = _openchild (MESSENGER, &fargs, &frslt);
-  setreuid (ruid, euid);
+  __setreuid (ruid, euid);
   if (pid < 0)
     {
       debug ("open_streams");
-      sigprocmask(SIG_SETMASK, &oldmask, NULL);
+      __sigprocmask (SIG_SETMASK, &oldmask, NULL);
       return (0);
     }
   xdrstdio_create (&xdrargs, fargs, XDR_ENCODE);
@@ -345,23 +345,23 @@ key_call (u_long proc, xdrproc_t xdr_arg, char *arg,
   fclose(frslt);
 
  wait_again:
-  if (wait4(pid, &status, 0, NULL) < 0)
+  if (__wait4 (pid, &status, 0, NULL) < 0)
     {
       if (errno == EINTR)
 	goto wait_again;
-      debug("wait4");
+      debug ("wait4");
       if (errno == ECHILD || errno == ESRCH)
-	perror("wait");
+	perror ("wait");
       else
 	success = 0;
     }
   else
     if (status.w_retcode)
       {
-	debug("wait4 1");
+	debug ("wait4 1");
 	success = 0;
       }
-  sigprocmask(SIG_SETMASK, &oldmask, NULL);
+  __sigprocmask (SIG_SETMASK, &oldmask, NULL);
 
-  return (success);
+  return success;
 }
diff --git a/sunrpc/netname.c b/sunrpc/netname.c
index 176967a905..1578108194 100644
--- a/sunrpc/netname.c
+++ b/sunrpc/netname.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Thorsten Kukuk <kukuk@vt.uni-paderborn.de>, 1997.
 
@@ -69,7 +69,7 @@ host2netname (char netname[MAXNETNAMELEN + 1], const char *host,
   netname[0] = '\0';		/* make null first (no need for memset) */
 
   if (host == NULL)
-    gethostname (hostname, MAXHOSTNAMELEN);
+    __gethostname (hostname, MAXHOSTNAMELEN);
   else
     {
       strncpy (hostname, host, MAXHOSTNAMELEN);
@@ -122,7 +122,7 @@ getnetname (char name[MAXNETNAMELEN + 1])
   uid_t uid;
   int dummy;
 
-  uid = geteuid ();
+  uid = __geteuid ();
   if (uid == 0)
     dummy = host2netname (name, NULL, NULL);
   else
diff --git a/sunrpc/openchild.c b/sunrpc/openchild.c
index 11e06006b3..e30e5cc872 100644
--- a/sunrpc/openchild.c
+++ b/sunrpc/openchild.c
@@ -43,6 +43,11 @@
 #include <rpc/rpc.h>
 #include <rpc/clnt.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define fflush(s) _IO_fflush (s)
+#endif
+
 /*
  * returns pid, or -1 for failure
  */
@@ -54,11 +59,11 @@ _openchild (char *command, FILE ** fto, FILE ** ffrom)
   int pdto[2];
   int pdfrom[2];
 
-  if (pipe (pdto) < 0)
+  if (__pipe (pdto) < 0)
     goto error1;
-  if (pipe (pdfrom) < 0)
+  if (__pipe (pdfrom) < 0)
     goto error2;
-  switch (pid = fork ())
+  switch (pid = __fork ())
     {
     case -1:
       goto error3;
@@ -67,13 +72,13 @@ _openchild (char *command, FILE ** fto, FILE ** ffrom)
       /*
        * child: read from pdto[0], write into pdfrom[1]
        */
-      close (0);
-      dup (pdto[0]);
-      close (1);
-      dup (pdfrom[1]);
+      __close (0);
+      __dup (pdto[0]);
+      __close (1);
+      __dup (pdfrom[1]);
       fflush (stderr);
       for (i = _rpc_dtablesize () - 1; i >= 3; i--)
-	close (i);
+	__close (i);
       fflush (stderr);
       execlp (command, command, 0);
       perror ("exec");
@@ -84,9 +89,9 @@ _openchild (char *command, FILE ** fto, FILE ** ffrom)
        * parent: write into pdto[1], read from pdfrom[0]
        */
       *fto = fdopen (pdto[1], "w");
-      close (pdto[0]);
+      __close (pdto[0]);
       *ffrom = fdopen (pdfrom[0], "r");
-      close (pdfrom[1]);
+      __close (pdfrom[1]);
       break;
     }
   return pid;
@@ -95,11 +100,11 @@ _openchild (char *command, FILE ** fto, FILE ** ffrom)
    * error cleanup and return
    */
 error3:
-  close (pdfrom[0]);
-  close (pdfrom[1]);
+  __close (pdfrom[0]);
+  __close (pdfrom[1]);
 error2:
-  close (pdto[0]);
-  close (pdto[1]);
+  __close (pdto[0]);
+  __close (pdto[1]);
 error1:
   return -1;
 }
diff --git a/sunrpc/pmap_rmt.c b/sunrpc/pmap_rmt.c
index b3c8fcba5e..768387c798 100644
--- a/sunrpc/pmap_rmt.c
+++ b/sunrpc/pmap_rmt.c
@@ -101,7 +101,7 @@ pmap_rmtcall (addr, prog, vers, proc, xdrargs, argsp, xdrres, resp, tout, port_p
     {
       stat = RPC_FAILED;
     }
-  /* (void)close(socket); CLNT_DESTROY already closed it */
+  /* (void)__close(socket); CLNT_DESTROY already closed it */
   addr->sin_port = 0;
   return stat;
 }
@@ -180,7 +180,7 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
 
   ifc.ifc_len = UDPMSGSIZE;
   ifc.ifc_buf = buf;
-  if (ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
+  if (__ioctl (sock, SIOCGIFCONF, (char *) &ifc) < 0)
     {
       perror (_("broadcast: ioctl (get interface configuration)"));
       return (0);
@@ -189,7 +189,7 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
   for (i = 0, n = ifc.ifc_len / sizeof (struct ifreq); n > 0; n--, ifr++)
     {
       ifreq = *ifr;
-      if (ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
+      if (__ioctl (sock, SIOCGIFFLAGS, (char *) &ifreq) < 0)
 	{
 	  perror (_("broadcast: ioctl (get interface flags)"));
 	  continue;
@@ -200,7 +200,7 @@ getbroadcastnets (struct in_addr *addrs, int sock, char *buf)
 	{
 	  sin = (struct sockaddr_in *) &ifr->ifr_addr;
 #ifdef SIOCGIFBRDADDR		/* 4.3BSD */
-	  if (ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
+	  if (__ioctl (sock, SIOCGIFBRDADDR, (char *) &ifreq) < 0)
 	    {
 	      addrs[i++] = inet_makeaddr (inet_netof
 	      /* Changed to pass struct instead of s_addr member
@@ -259,7 +259,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
    * initialization: create a socket, a broadcast address, and
    * preserialize the arguments into a send buffer.
    */
-  if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+  if ((sock = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
     {
       perror (_("Cannot create socket for broadcast rpc"));
       stat = RPC_CANTSEND;
@@ -276,13 +276,13 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
   fd.fd = sock;
   fd.events = POLLIN;
   nets = getbroadcastnets (addrs, sock, inbuf);
-  bzero ((char *) &baddr, sizeof (baddr));
+  __bzero ((char *) &baddr, sizeof (baddr));
   baddr.sin_family = AF_INET;
   baddr.sin_port = htons (PMAPPORT);
   baddr.sin_addr.s_addr = htonl (INADDR_ANY);
 /*      baddr.sin_addr.S_un.S_addr = htonl(INADDR_ANY); */
-  (void) gettimeofday (&t, (struct timezone *) 0);
-  msg.rm_xid = xid = getpid () ^ t.tv_sec ^ t.tv_usec;
+  (void) __gettimeofday (&t, (struct timezone *) 0);
+  msg.rm_xid = xid = __getpid () ^ t.tv_sec ^ t.tv_usec;
   t.tv_usec = 0;
   msg.rm_direction = CALL;
   msg.rm_call.cb_rpcvers = RPC_MSG_VERSION;
@@ -405,7 +405,7 @@ clnt_broadcast (prog, vers, proc, xargs, argsp, xresults, resultsp, eachresult)
 	}
     }
 done_broad:
-  (void) close (sock);
+  (void) __close (sock);
   AUTH_DESTROY (unix_auth);
   return stat;
 }
diff --git a/sunrpc/rpc/auth.h b/sunrpc/rpc/auth.h
index aa2c6144a1..ae1346da0f 100644
--- a/sunrpc/rpc/auth.h
+++ b/sunrpc/rpc/auth.h
@@ -97,12 +97,12 @@ struct AUTH {
   struct opaque_auth ah_verf;
   union des_block ah_key;
   struct auth_ops {
-    void (*ah_nextverf) __P ((AUTH *));
-    int  (*ah_marshal) __P ((AUTH *, XDR *));	/* nextverf & serialize */
-    int  (*ah_validate) __P ((AUTH *, struct opaque_auth *));
+    void (*ah_nextverf) __PMT ((AUTH *));
+    int  (*ah_marshal) __PMT ((AUTH *, XDR *));	/* nextverf & serialize */
+    int  (*ah_validate) __PMT ((AUTH *, struct opaque_auth *));
 						/* validate verifier */
-    int  (*ah_refresh) __P ((AUTH *));		/* refresh credentials */
-    void (*ah_destroy) __P ((AUTH *));     	/* destroy this structure */
+    int  (*ah_refresh) __PMT ((AUTH *));	/* refresh credentials */
+    void (*ah_destroy) __PMT ((AUTH *));     	/* destroy this structure */
   } *ah_ops;
   caddr_t ah_private;
 };
diff --git a/sunrpc/rpc/clnt.h b/sunrpc/rpc/clnt.h
index ed12add102..1570cba4c2 100644
--- a/sunrpc/rpc/clnt.h
+++ b/sunrpc/rpc/clnt.h
@@ -132,17 +132,17 @@ typedef struct CLIENT CLIENT;
 struct CLIENT {
   AUTH	*cl_auth;		 /* authenticator */
   struct clnt_ops {
-    enum clnt_stat (*cl_call) __P ((CLIENT *, u_long, xdrproc_t,
-				    caddr_t, xdrproc_t,
-				    caddr_t, struct timeval));
+    enum clnt_stat (*cl_call) __PMT ((CLIENT *, u_long, xdrproc_t,
+				      caddr_t, xdrproc_t,
+				      caddr_t, struct timeval));
 			       	/* call remote procedure */
-    void (*cl_abort) __P ((void));  /* abort a call */
-    void (*cl_geterr) __P ((CLIENT *, struct rpc_err *));
+    void (*cl_abort) __PMT ((void));  /* abort a call */
+    void (*cl_geterr) __PMT ((CLIENT *, struct rpc_err *));
 				/* get specific error code */
-    bool_t (*cl_freeres) __P ((CLIENT *, xdrproc_t, caddr_t));
+    bool_t (*cl_freeres) __PMT ((CLIENT *, xdrproc_t, caddr_t));
 				/* frees results */
-    void (*cl_destroy) __P ((CLIENT *)); /* destroy this structure */
-    bool_t (*cl_control) __P ((CLIENT *, int, char *));
+    void (*cl_destroy) __PMT ((CLIENT *)); /* destroy this structure */
+    bool_t (*cl_control) __PMT ((CLIENT *, int, char *));
 				/* the ioctl() of rpc */
   } *cl_ops;
   caddr_t cl_private;		/* private stuff */
diff --git a/sunrpc/rpc/pmap_clnt.h b/sunrpc/rpc/pmap_clnt.h
index bef4be109e..d9800d4006 100644
--- a/sunrpc/rpc/pmap_clnt.h
+++ b/sunrpc/rpc/pmap_clnt.h
@@ -45,7 +45,8 @@
 
 __BEGIN_DECLS
 
-typedef bool_t (*resultproc_t) __P ((caddr_t resp, struct sockaddr_in *raddr));
+typedef bool_t (*resultproc_t) __PMT ((caddr_t resp,
+				       struct sockaddr_in *raddr));
 
 /*
  * Usage:
diff --git a/sunrpc/rpc/svc.h b/sunrpc/rpc/svc.h
index 81366aedb6..a53bc1015f 100644
--- a/sunrpc/rpc/svc.h
+++ b/sunrpc/rpc/svc.h
@@ -78,18 +78,18 @@ struct SVCXPRT {
   int xp_sock;
   u_short xp_port;		/* associated port number */
   const struct xp_ops {
-    bool_t	(*xp_recv) __P ((SVCXPRT *__xprt, struct rpc_msg *__msg));
+    bool_t	(*xp_recv) __PMT ((SVCXPRT *__xprt, struct rpc_msg *__msg));
 				/* receive incoming requests */
-    enum xprt_stat (*xp_stat) __P ((SVCXPRT *__xprt));
+    enum xprt_stat (*xp_stat) __PMT ((SVCXPRT *__xprt));
 				/* get transport status */
-    bool_t	(*xp_getargs) __P ((SVCXPRT *__xprt, xdrproc_t __xdr_args,
-				    caddr_t args_ptr)); /* get arguments */
-    bool_t	(*xp_reply) __P ((SVCXPRT *__xprt, struct rpc_msg *__msg));
+    bool_t	(*xp_getargs) __PMT ((SVCXPRT *__xprt, xdrproc_t __xdr_args,
+				      caddr_t args_ptr)); /* get arguments */
+    bool_t	(*xp_reply) __PMT ((SVCXPRT *__xprt, struct rpc_msg *__msg));
 				/* send reply */
-    bool_t	(*xp_freeargs) __P ((SVCXPRT *__xprt, xdrproc_t __xdr_args,
-				     caddr_t args_ptr));
+    bool_t	(*xp_freeargs) __PMT ((SVCXPRT *__xprt, xdrproc_t __xdr_args,
+				       caddr_t args_ptr));
 				/* free mem allocated for args */
-    void	(*xp_destroy) __P ((SVCXPRT *__xprt));
+    void	(*xp_destroy) __PMT ((SVCXPRT *__xprt));
 				/* destroy this struct */
   } *xp_ops;
   int		xp_addrlen;	 /* length of remote address */
@@ -156,9 +156,9 @@ struct svc_req {
 };
 
 #ifndef __DISPATCH_FN_T
-#define __DISPATCH_FN_T                                                 
-typedef void (*__dispatch_fn_t) __P((struct svc_req*, SVCXPRT*));
-#endif                                                               
+#define __DISPATCH_FN_T
+typedef void (*__dispatch_fn_t) __PMT ((struct svc_req*, SVCXPRT*));
+#endif
 
 /*
  * Service registration
diff --git a/sunrpc/rpc/xdr.h b/sunrpc/rpc/xdr.h
index bf8c2c4081..a4e66c9fc2 100644
--- a/sunrpc/rpc/xdr.h
+++ b/sunrpc/rpc/xdr.h
@@ -117,22 +117,23 @@ struct XDR
     enum xdr_op x_op;		/* operation; fast additional param */
     struct xdr_ops
       {
-	bool_t (*x_getlong) __P ((XDR * __xdrs, long *__lp));
+	bool_t (*x_getlong) __PMT ((XDR * __xdrs, long *__lp));
 	/* get a long from underlying stream */
-	bool_t (*x_putlong) __P ((XDR * __xdrs, __const long *__lp));
+	bool_t (*x_putlong) __PMT ((XDR * __xdrs, __const long *__lp));
 	/* put a long to " */
-	bool_t (*x_getbytes) __P ((XDR * __xdrs, caddr_t __addr, u_int __len));
+	bool_t (*x_getbytes) __PMT ((XDR * __xdrs, caddr_t __addr,
+				     u_int __len));
 	/* get some bytes from " */
-	bool_t (*x_putbytes) __P ((XDR * __xdrs, __const char *__addr,
-				   u_int __len));
+	bool_t (*x_putbytes) __PMT ((XDR * __xdrs, __const char *__addr,
+				     u_int __len));
 	/* put some bytes to " */
-	u_int (*x_getpostn) __P ((__const XDR * __xdrs));
+	u_int (*x_getpostn) __PMT ((__const XDR * __xdrs));
 	/* returns bytes off from beginning */
-	bool_t (*x_setpostn) __P ((XDR * __xdrs, u_int pos));
+	bool_t (*x_setpostn) __PMT ((XDR * __xdrs, u_int pos));
 	/* lets you reposition the stream */
-	long *(*x_inline) __P ((XDR * __xdrs, int len));
+	long *(*x_inline) __PMT ((XDR * __xdrs, int len));
 	/* buf quick ptr to buffered data */
-	void (*x_destroy) __P ((XDR * __xdrs));
+	void (*x_destroy) __PMT ((XDR * __xdrs));
 	/* free privates of this xdr_stream */
       }
      *x_ops;
@@ -151,8 +152,7 @@ struct XDR
  * allocate dynamic storage of the appropriate size and return it.
  * bool_t       (*xdrproc_t)(XDR *, caddr_t *);
  */
-typedef
-bool_t (*xdrproc_t) __P ((XDR *, void *,...));
+typedef bool_t (*xdrproc_t) __PMT ((XDR *, void *,...));
 
 /*
  * Operations defined on a XDR handle
diff --git a/sunrpc/rpc_dtable.c b/sunrpc/rpc_dtable.c
index 26bf1a204a..90e5b1e9cb 100644
--- a/sunrpc/rpc_dtable.c
+++ b/sunrpc/rpc_dtable.c
@@ -6,23 +6,23 @@
  * may copy or modify Sun RPC without charge, but are not authorized
  * to license or distribute it to anyone else except as part of a product or
  * program developed by the user.
- * 
+ *
  * SUN RPC IS PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND INCLUDING THE
  * WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A PARTICULAR
  * PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE PRACTICE.
- * 
+ *
  * Sun RPC is provided with no support and without any obligation on the
  * part of Sun Microsystems, Inc. to assist in its use, correction,
  * modification or enhancement.
- * 
+ *
  * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE
  * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY SUN RPC
  * OR ANY PART THEREOF.
- * 
+ *
  * In no event will Sun Microsystems, Inc. be liable for any lost revenue
  * or profits or other special, indirect and consequential damages, even if
  * Sun has been advised of the possibility of such damages.
- * 
+ *
  * Sun Microsystems, Inc.
  * 2550 Garcia Avenue
  * Mountain View, California  94043
@@ -43,7 +43,7 @@ _rpc_dtablesize (void)
   static int size;
 
   if (size == 0)
-    size = getdtablesize ();
+    size = __getdtablesize ();
 
   return size;
 }
diff --git a/sunrpc/rtime.c b/sunrpc/rtime.c
index ca2790a2dc..09a8948624 100644
--- a/sunrpc/rtime.c
+++ b/sunrpc/rtime.c
@@ -65,7 +65,7 @@ do_close (int s)
   int save;
 
   save = errno;
-  close (s);
+  __close (s);
   __set_errno (save);
 }
 
@@ -87,7 +87,7 @@ rtime (struct sockaddr_in *addrp, struct timeval *timep,
   else
     type = SOCK_DGRAM;
 
-  s = socket (AF_INET, type, 0);
+  s = __socket (AF_INET, type, 0);
   if (s < 0)
     return (-1);
 
@@ -124,12 +124,12 @@ rtime (struct sockaddr_in *addrp, struct timeval *timep,
     }
   else
     {
-      if (connect (s, (struct sockaddr *) addrp, sizeof (*addrp)) < 0)
+      if (__connect (s, (struct sockaddr *) addrp, sizeof (*addrp)) < 0)
 	{
 	  do_close (s);
 	  return -1;
 	}
-      res = read (s, (char *) &thetime, sizeof (thetime));
+      res = __read (s, (char *) &thetime, sizeof (thetime));
       do_close (s);
       if (res < 0)
 	return (-1);
diff --git a/sunrpc/svc_run.c b/sunrpc/svc_run.c
index 021484d864..1a76b10183 100644
--- a/sunrpc/svc_run.c
+++ b/sunrpc/svc_run.c
@@ -70,8 +70,8 @@ svc_run (void)
 #else
       readfds = svc_fds;
 #endif /* def FD_SETSIZE */
-      switch (select (_rpc_dtablesize (), &readfds, (fd_set *)NULL,
-		      (fd_set *)NULL, (struct timeval *) 0))
+      switch (__select (_rpc_dtablesize (), &readfds, (fd_set *)NULL,
+			(fd_set *)NULL, (struct timeval *) 0))
 	{
 	case -1:
 	  if (errno == EINTR)
diff --git a/sunrpc/svc_simple.c b/sunrpc/svc_simple.c
index cc28f6a7e3..405860e6c0 100644
--- a/sunrpc/svc_simple.c
+++ b/sunrpc/svc_simple.c
@@ -45,6 +45,10 @@ static char sccsid[] = "@(#)svc_simple.c 1.18 87/08/11 Copyr 1984 Sun Micro";
 #include <sys/socket.h>
 #include <netdb.h>
 
+#ifdef USE_IN_LIBIO
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
+
 static struct proglst
   {
     char *(*p_progname) (char *);
@@ -129,7 +133,7 @@ universal (struct svc_req *rqstp, SVCXPRT *transp)
     if (pl->p_prognum == prog && pl->p_procnum == proc)
       {
 	/* decode arguments into a CLEAN buffer */
-	bzero (xdrbuf, sizeof (xdrbuf));	/* required ! */
+	__bzero (xdrbuf, sizeof (xdrbuf));	/* required ! */
 	if (!svc_getargs (transp, pl->p_inproc, xdrbuf))
 	  {
 	    svcerr_decode (transp);
diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c
index e162c02751..75fa8705b6 100644
--- a/sunrpc/svc_tcp.c
+++ b/sunrpc/svc_tcp.c
@@ -49,6 +49,11 @@ static char sccsid[] = "@(#)svc_tcp.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 #include <errno.h>
 #include <stdlib.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
+
 /*
  * Ops vector for TCP/IP based rpc service handle
  */
@@ -134,14 +139,14 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
 
   if (sock == RPC_ANYSOCK)
     {
-      if ((sock = socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
+      if ((sock = __socket (AF_INET, SOCK_STREAM, IPPROTO_TCP)) < 0)
 	{
 	  perror (_("svctcp_.c - udp socket creation problem"));
 	  return (SVCXPRT *) NULL;
 	}
       madesock = TRUE;
     }
-  bzero ((char *) &addr, sizeof (addr));
+  __bzero ((char *) &addr, sizeof (addr));
   addr.sin_family = AF_INET;
   if (bindresvport (sock, &addr))
     {
@@ -153,7 +158,7 @@ svctcp_create (int sock, u_int sendsize, u_int recvsize)
     {
       perror (_("svctcp_.c - cannot getsockname or listen"));
       if (madesock)
-	(void) close (sock);
+	(void) __close (sock);
       return (SVCXPRT *) NULL;
     }
   r = (struct tcp_rendezvous *) mem_alloc (sizeof (*r));
@@ -237,8 +242,7 @@ rendezvous_request (SVCXPRT *xprt, struct rpc_msg *errmsg)
   r = (struct tcp_rendezvous *) xprt->xp_p1;
 again:
   len = sizeof (struct sockaddr_in);
-  if ((sock = accept (xprt->xp_sock, (struct sockaddr *) &addr,
-		      &len)) < 0)
+  if ((sock = accept (xprt->xp_sock, (struct sockaddr *) &addr, &len)) < 0)
     {
       if (errno == EINTR)
 	goto again;
@@ -265,7 +269,7 @@ svctcp_destroy (SVCXPRT *xprt)
   struct tcp_conn *cd = (struct tcp_conn *) xprt->xp_p1;
 
   xprt_unregister (xprt);
-  (void) close (xprt->xp_sock);
+  (void) __close (xprt->xp_sock);
   if (xprt->xp_port != 0)
     {
       /* a rendezvouser socket */
@@ -318,8 +322,8 @@ readtcp (char *xprtptr, char *buf, int len)
 #else
       readfds |= (1 << sock);
 #endif /* def FD_SETSIZE */
-      if (select (_rpc_dtablesize (), &readfds, (fd_set *) NULL,
-		  (fd_set *) NULL, &timeout) <= 0)
+      if (__select (_rpc_dtablesize (), &readfds, (fd_set *) NULL,
+		    (fd_set *) NULL, &timeout) <= 0)
 	{
 	  if (errno == EINTR)
 	    continue;
@@ -336,7 +340,7 @@ readtcp (char *xprtptr, char *buf, int len)
       svc_getreqset (&readfds);
     }
 
-  if ((len = read (sock, buf, len)) > 0)
+  if ((len = __read (sock, buf, len)) > 0)
     return len;
 
 fatal_err:
@@ -356,7 +360,7 @@ writetcp (char *xprtptr, char * buf, int len)
 
   for (cnt = len; cnt > 0; cnt -= i, buf += i)
     {
-      if ((i = write (xprt->xp_sock, buf, cnt)) < 0)
+      if ((i = __write (xprt->xp_sock, buf, cnt)) < 0)
 	{
 	  ((struct tcp_conn *) (xprt->xp_p1))->strm_stat =
 	    XPRT_DIED;
diff --git a/sunrpc/svc_udp.c b/sunrpc/svc_udp.c
index 39ecbb0b50..4ea421a7b2 100644
--- a/sunrpc/svc_udp.c
+++ b/sunrpc/svc_udp.c
@@ -46,6 +46,10 @@ static char sccsid[] = "@(#)svc_udp.c 1.24 87/08/11 Copyr 1984 Sun Micro";
 #include <sys/socket.h>
 #include <errno.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
 
 #define rpc_buffer(xprt) ((xprt)->xp_p1)
 #ifndef MAX
@@ -112,14 +116,14 @@ svcudp_bufcreate (sock, sendsz, recvsz)
 
   if (sock == RPC_ANYSOCK)
     {
-      if ((sock = socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
+      if ((sock = __socket (AF_INET, SOCK_DGRAM, IPPROTO_UDP)) < 0)
 	{
 	  perror (_("svcudp_create: socket creation problem"));
 	  return (SVCXPRT *) NULL;
 	}
       madesock = TRUE;
     }
-  bzero ((char *) &addr, sizeof (addr));
+  __bzero ((char *) &addr, sizeof (addr));
   addr.sin_family = AF_INET;
   if (bindresvport (sock, &addr))
     {
@@ -130,7 +134,7 @@ svcudp_bufcreate (sock, sendsz, recvsz)
     {
       perror (_("svcudp_create - cannot getsockname"));
       if (madesock)
-	(void) close (sock);
+	(void) __close (sock);
       return (SVCXPRT *) NULL;
     }
   xprt = (SVCXPRT *) mem_alloc (sizeof (SVCXPRT));
@@ -276,7 +280,7 @@ svcudp_destroy (xprt)
   struct svcudp_data *su = su_data (xprt);
 
   xprt_unregister (xprt);
-  (void) close (xprt->xp_sock);
+  (void) __close (xprt->xp_sock);
   XDR_DESTROY (&(su->su_xdrs));
   mem_free (rpc_buffer (xprt), su->su_iosz);
   mem_free ((caddr_t) su, sizeof (struct svcudp_data));
@@ -301,7 +305,7 @@ svcudp_destroy (xprt)
 	(type *) mem_alloc((unsigned) (sizeof(type) * (size)))
 
 #define BZERO(addr, type, size)	 \
-	bzero((char *) addr, sizeof(type) * (int) (size))
+	__bzero((char *) addr, sizeof(type) * (int) (size))
 
 /*
  * An entry in the cache
@@ -479,7 +483,7 @@ cache_get (xprt, msg, replyp, replylenp)
   struct svcudp_data *su = su_data (xprt);
   struct udp_cache *uc = (struct udp_cache *) su->su_cache;
 
-#define EQADDR(a1, a2)	(bcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0)
+#define EQADDR(a1, a2)	(memcmp((char*)&a1, (char*)&a2, sizeof(a1)) == 0)
 
   loc = CACHE_LOC (xprt, su->su_xid);
   for (ent = uc->uc_entries[loc]; ent != NULL; ent = ent->cache_next)
diff --git a/sunrpc/svcauth_des.c b/sunrpc/svcauth_des.c
index c74e06b5c1..f73c2d1461 100644
--- a/sunrpc/svcauth_des.c
+++ b/sunrpc/svcauth_des.c
@@ -282,7 +282,7 @@ _svcauth_des (register struct svc_req *rqst, register struct rpc_msg *msg)
 	debug ("timestamp before last seen");
 	return (AUTH_REJECTEDVERF);	/* replay */
       }
-    gettimeofday (&current, (struct timezone *) NULL);
+    __gettimeofday (&current, (struct timezone *) NULL);
     current.tv_sec -= window;	/* allow for expiration */
     if (!BEFORE (&current, &timestamp))
       {
@@ -385,8 +385,8 @@ cache_init (void)
 
   authdes_cache = (struct cache_entry *)
     mem_alloc (sizeof (struct cache_entry) * AUTHDES_CACHESZ);
-  bzero ((char *) authdes_cache,
-	 sizeof (struct cache_entry) * AUTHDES_CACHESZ);
+  __bzero ((char *) authdes_cache,
+	   sizeof (struct cache_entry) * AUTHDES_CACHESZ);
 
   authdes_lru = (short *) mem_alloc (sizeof (short) * AUTHDES_CACHESZ);
   /*
@@ -449,7 +449,7 @@ cache_spot (register des_block * key, char *name, struct timeval *timestamp)
       if (cp->key.key.high == hi &&
 	  cp->key.key.low == key->key.low &&
 	  cp->rname != NULL &&
-	  bcmp (cp->rname, name, strlen (name) + 1) == 0)
+	  memcmp (cp->rname, name, strlen (name) + 1) == 0)
 	{
 	  if (BEFORE (timestamp, &cp->laststamp))
 	    {
diff --git a/sunrpc/xdr_array.c b/sunrpc/xdr_array.c
index a58fade734..a049b2d27d 100644
--- a/sunrpc/xdr_array.c
+++ b/sunrpc/xdr_array.c
@@ -99,7 +99,7 @@ xdr_array (xdrs, addrp, sizep, maxsize, elsize, elproc)
 			    "xdr_array: out of memory\n");
 	    return FALSE;
 	  }
-	bzero (target, nodesize);
+	__bzero (target, nodesize);
 	break;
 
       case XDR_FREE:
diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c
index b2ab2faabc..30be6393a2 100644
--- a/sunrpc/xdr_rec.c
+++ b/sunrpc/xdr_rec.c
@@ -53,6 +53,11 @@ static char sccsid[] = "@(#)xdr_rec.c 1.21 87/08/11 Copyr 1984 Sun Micro";
 #include <unistd.h>
 #include <rpc/rpc.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
+
 static bool_t xdrrec_getlong (XDR *, long *);
 static bool_t xdrrec_putlong (XDR *, const long *);
 static bool_t xdrrec_getbytes (XDR *, caddr_t, u_int);
@@ -309,7 +314,7 @@ xdrrec_getpos (const XDR *xdrs)
   RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private;
   long pos;
 
-  pos = lseek ((int) rstrm->tcp_handle, (long) 0, 1);
+  pos = __lseek ((int) rstrm->tcp_handle, (long) 0, 1);
   if (pos != -1)
     switch (xdrs->x_op)
       {
diff --git a/sunrpc/xdr_ref.c b/sunrpc/xdr_ref.c
index 911892ef2d..090925d0d7 100644
--- a/sunrpc/xdr_ref.c
+++ b/sunrpc/xdr_ref.c
@@ -45,6 +45,11 @@ static char sccsid[] = "@(#)xdr_reference.c 1.11 87/08/11 SMI";
 #include <rpc/types.h>
 #include <rpc/xdr.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.h>
+# define fputs(s, f) _IO_fputs (s, f)
+#endif
+
 #define LASTUNSIGNED	((u_int)0-1)
 
 /*
@@ -79,7 +84,7 @@ xdr_reference (xdrs, pp, size, proc)
 	    (void) fputs (_("xdr_reference: out of memory\n"), stderr);
 	    return FALSE;
 	  }
-	bzero (loc, (int) size);
+	__bzero (loc, (int) size);
 	break;
       default:
 	break;
diff --git a/sunrpc/xdr_stdio.c b/sunrpc/xdr_stdio.c
index 8c3c5c7bb3..8588042eeb 100644
--- a/sunrpc/xdr_stdio.c
+++ b/sunrpc/xdr_stdio.c
@@ -45,6 +45,14 @@ static char sccsid[] = "@(#)xdr_stdio.c 1.16 87/08/11 Copyr 1984 Sun Micro";
 #include <stdio.h>
 #include <rpc/xdr.h>
 
+#ifdef USE_IN_LIBIO
+# include <libio/iolibio.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)
+#endif
+
 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/generic/abort.c b/sysdeps/generic/abort.c
index a38022a1a9..91c504607a 100644
--- a/sysdeps/generic/abort.c
+++ b/sysdeps/generic/abort.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 93, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,6 +31,10 @@
 # define ABORT_INSTRUCTION
 #endif
 
+#ifdef USE_IN_LIBIO
+# define fflush(s) _IO_fflush (s)
+#endif
+
 /* We must avoid to run in circles.  Therefore we remember how far we
    already got.  */
 static int stage;
diff --git a/sysdeps/generic/dl-environ.c b/sysdeps/generic/dl-environ.c
new file mode 100644
index 0000000000..433102757c
--- /dev/null
+++ b/sysdeps/generic/dl-environ.c
@@ -0,0 +1,69 @@
+/*Environment handling for dynamic loader.
+   Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Library General Public License as
+   published by the Free Software Foundation; either version 2 of the
+   License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Library General Public License for more details.
+
+   You should have received a copy of the GNU Library General Public
+   License along with the GNU C Library; see the file COPYING.LIB.  If not,
+   write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+#include <string.h>
+
+
+extern char **_environ;
+
+/* Walk through the environment of the process and return all entries
+   starting with `LD_'.  */
+char *
+internal_function
+_dl_next_ld_env_entry (char ***position)
+{
+  char **current = *position;
+  char *result = NULL;
+
+  if (current == NULL)
+    /* We start over.  */
+    current = _environ;
+
+  while (result == NULL && *current != NULL)
+    {
+      if ((*current)[0] == 'L' && (*current)[1] == 'D' && (*current)[2] == '_')
+	result = *current;
+
+      ++current;
+    }
+
+  /* Save current position for next visit.  */
+  *position = current;
+
+  return result;
+}
+
+void
+unsetenv (const char *name)
+{
+  const size_t len = strlen (name);
+  char **ep;
+
+  for (ep = _environ; *ep != NULL; ++ep)
+    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
+      {
+	/* Found it.  Remove this pointer by moving later ones back.  */
+	char **dp = ep;
+
+	do
+	  dp[0] = dp[1];
+	while (*dp++);
+	/* Continue the loop in case NAME appears again.  */
+      }
+}
diff --git a/sysdeps/generic/dl-sysdep.c b/sysdeps/generic/dl-sysdep.c
index 6516ba9b1a..15f85550fe 100644
--- a/sysdeps/generic/dl-sysdep.c
+++ b/sysdeps/generic/dl-sysdep.c
@@ -252,52 +252,6 @@ _dl_show_auxv (void)
       }
 }
 
-/* Walk through the environment of the process and return all entries
-   starting with `LD_'.  */
-char *
-internal_function
-_dl_next_ld_env_entry (char ***position)
-{
-  char **current = *position;
-  char *result = NULL;
-
-  if (current == NULL)
-    /* We start over.  */
-    current = _environ;
-
-  while (result == NULL && *current != NULL)
-    {
-      if ((*current)[0] == 'L' && (*current)[1] == 'D' && (*current)[2] == '_')
-	result = *current;
-
-      ++current;
-    }
-
-  /* Save current position for next visit.  */
-  *position = current;
-
-  return result;
-}
-
-void
-unsetenv (const char *name)
-{
-  const size_t len = strlen (name);
-  char **ep;
-
-  for (ep = __environ; *ep != NULL; ++ep)
-    if (!strncmp (*ep, name, len) && (*ep)[len] == '=')
-      {
-	/* Found it.  Remove this pointer by moving later ones back.  */
-	char **dp = ep;
-
-	do
-	  dp[0] = dp[1];
-	while (*dp++);
-	/* Continue the loop in case NAME appears again.  */
-      }
-}
-
 
 /* Return an array of useful/necessary hardware capability names.  */
 const struct r_strlenpair *
diff --git a/sysdeps/generic/fstatfs64.c b/sysdeps/generic/fstatfs64.c
index e34af2aa45..5ffdf9cd84 100644
--- a/sysdeps/generic/fstatfs64.c
+++ b/sysdeps/generic/fstatfs64.c
@@ -1,5 +1,5 @@
 /* Return information about the filesystem on which FD resides.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -27,7 +27,7 @@ fstatfs64 (int fd, struct statfs64 *buf)
 {
   struct statfs buf32;
 
-  if (fstatfs (fd, &buf32) < 0)
+  if (__fstatfs (fd, &buf32) < 0)
     return -1;
 
   buf->f_type = buf32.f_type;
diff --git a/sysdeps/generic/ftruncate64.c b/sysdeps/generic/ftruncate64.c
index 40c312c21b..a85293baf6 100644
--- a/sysdeps/generic/ftruncate64.c
+++ b/sysdeps/generic/ftruncate64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -31,5 +31,5 @@ ftruncate64 (fd, length)
       __set_errno (EINVAL);
       return -1;
     }
-  return ftruncate (fd, (off_t) length);
+  return __ftruncate (fd, (off_t) length);
 }
diff --git a/sysdeps/generic/getrlimit64.c b/sysdeps/generic/getrlimit64.c
index 742505f4b5..20b06d2154 100644
--- a/sysdeps/generic/getrlimit64.c
+++ b/sysdeps/generic/getrlimit64.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -27,7 +27,7 @@ getrlimit64 (enum __rlimit_resource resource, struct rlimit64 *rlimits)
 {
   struct rlimit rlimits32;
 
-  if (getrlimit (resource, &rlimits32) < 0)
+  if (__getrlimit (resource, &rlimits32) < 0)
     return -1;
 
   if (rlimits32.rlim_cur == RLIM_INFINITY)
diff --git a/sysdeps/generic/glob.c b/sysdeps/generic/glob.c
index bc32d99359..70d125c200 100644
--- a/sysdeps/generic/glob.c
+++ b/sysdeps/generic/glob.c
@@ -239,6 +239,13 @@ extern char *alloca ();
 # endif
 #endif
 
+#ifdef _LIBC
+# define sysconf(id) __sysconf (id)
+# define closedir(dir) __closedir (dir)
+# define opendir(name) __opendir (name)
+# define readdir(str) __readdir (str)
+#endif
+
 #if !(defined STDC_HEADERS || defined __GNU_LIBRARY__)
 # undef	size_t
 # define size_t	unsigned int
diff --git a/sysdeps/generic/prof-freq.c b/sysdeps/generic/prof-freq.c
index ff085145b5..2755c1f9a2 100644
--- a/sysdeps/generic/prof-freq.c
+++ b/sysdeps/generic/prof-freq.c
@@ -49,8 +49,8 @@ __profile_frequency (void)
   tim.it_interval.tv_usec = 1;
   tim.it_value.tv_sec = 0;
   tim.it_value.tv_usec = 0;
-  setitimer(ITIMER_REAL, &tim, 0);
-  setitimer(ITIMER_REAL, 0, &tim);
+  __setitimer(ITIMER_REAL, &tim, 0);
+  __setitimer(ITIMER_REAL, 0, &tim);
   if (tim.it_interval.tv_usec < 2)
     return 0;
   return (1000000 / tim.it_interval.tv_usec);
diff --git a/sysdeps/generic/putenv.c b/sysdeps/generic/putenv.c
index d059c2f78c..3fcd5f93a8 100644
--- a/sysdeps/generic/putenv.c
+++ b/sysdeps/generic/putenv.c
@@ -45,9 +45,6 @@
 extern char *alloca ();
 #  endif /* __GNUC__ */
 # endif /* HAVE_ALLOCA_H */
-
-# define setenv __setenv
-# define unsetenv __unsetenv
 #endif /* _LIBC */
 
 
@@ -67,9 +64,9 @@ putenv (string)
       memcpy (name, string, name_end - string);
       name[name_end - string] = '\0';
 #endif
-      return setenv (name, name_end + 1, 1);
+      return __setenv (name, name_end + 1, 1);
     }
 
-  unsetenv (string);
+  __unsetenv (string);
   return 0;
 }
diff --git a/sysdeps/generic/statfs64.c b/sysdeps/generic/statfs64.c
index 050c05d659..01640e3c4e 100644
--- a/sysdeps/generic/statfs64.c
+++ b/sysdeps/generic/statfs64.c
@@ -1,5 +1,5 @@
 /* Return information about the filesystem on which FILE resides.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -27,7 +27,7 @@ statfs64 (const char *file, struct statfs64 *buf)
 {
   struct statfs buf32;
 
-  if (statfs (file, &buf32) < 0)
+  if (__statfs (file, &buf32) < 0)
     return -1;
 
   buf->f_type = buf32.f_type;
diff --git a/sysdeps/generic/ttyname_r.c b/sysdeps/generic/ttyname_r.c
index 6e8a9d6179..2a09b685d1 100644
--- a/sysdeps/generic/ttyname_r.c
+++ b/sysdeps/generic/ttyname_r.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -23,7 +23,7 @@
 /* Store at most BUFLEN characters the pathname of the terminal FD is
    open on in BUF.  Return 0 on success,  otherwise an error number.  */
 int
-ttyname_r (fd, buf, buflen)
+__ttyname_r (fd, buf, buflen)
      int fd;
      char *buf;
      size_t buflen;
@@ -31,7 +31,7 @@ ttyname_r (fd, buf, buflen)
   __set_errno (ENOSYS);
   return ENOSYS;
 }
-
+weak_alias (__ttyname_r, ttyname_r)
 
 stub_warning (ttyname_r)
 #include <stub-tag.h>
diff --git a/sysdeps/generic/utmp_file.c b/sysdeps/generic/utmp_file.c
index 1f7abb088b..ddf49467ef 100644
--- a/sysdeps/generic/utmp_file.c
+++ b/sysdeps/generic/utmp_file.c
@@ -59,23 +59,23 @@ static void timeout_handler (int signum) {};
   action.sa_handler = timeout_handler;                                  \
   sigemptyset (&action.sa_mask);                                        \
   action.sa_flags = 0;                                                  \
-  sigaction (SIGALRM, &action, &old_action);                            \
+  __sigaction (SIGALRM, &action, &old_action);                          \
                                                                         \
   alarm (TIMEOUT);                                                      \
                                                                         \
   /* Try to get the lock.  */                                           \
   memset (&fl, '\0', sizeof (struct flock));                            \
-  fl.l_type = (type);                                                 \
+  fl.l_type = (type);                                                   \
   fl.l_whence = SEEK_SET;                                               \
-  fcntl ((fd), F_SETLKW, &fl)
+  __fcntl ((fd), F_SETLKW, &fl)
 
 #define UNLOCK_FILE(fd) \
   /* Unlock the file.  */                                               \
   fl.l_type = F_UNLCK;                                                  \
-  fcntl ((fd), F_SETLKW, &fl);                                          \
+  __fcntl ((fd), F_SETLKW, &fl);                                        \
                                                                         \
   /* Reset the signal handler and alarm.  */                            \
-  sigaction (SIGALRM, &old_action, NULL);                               \
+  __sigaction (SIGALRM, &old_action, NULL);                             \
   alarm (old_timeout);                                                  \
 } while (0)
 
@@ -117,17 +117,17 @@ setutent_file (void)
 
       file_name = TRANSFORM_UTMP_FILE_NAME (__libc_utmp_file_name);
 
-      file_fd = open (file_name, O_RDWR);
+      file_fd = __open (file_name, O_RDWR);
       if (file_fd == -1)
 	{
 	  /* Hhm, read-write access did not work.  Try read-only.  */
-	  file_fd = open (file_name, O_RDONLY);
+	  file_fd = __open (file_name, O_RDONLY);
 	  if (file_fd == -1)
 	    return 0;
 	}
     }
 
-  lseek (file_fd, 0, SEEK_SET);
+  __lseek (file_fd, 0, SEEK_SET);
   file_offset = 0;
 
 #if _HAVE_UT_TYPE - 0
@@ -156,7 +156,7 @@ getutent_r_file (struct utmp *buffer, struct utmp **result)
   LOCK_FILE (file_fd, F_RDLCK);
 
   /* Read the next entry.  */
-  nbytes = read (file_fd, &last_entry, sizeof (struct utmp));
+  nbytes = __read (file_fd, &last_entry, sizeof (struct utmp));
 
   UNLOCK_FILE (file_fd);
 
@@ -221,7 +221,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer)
       while (1)
 	{
 	  /* Read the next entry.  */
-	  if (read (file_fd, buffer, sizeof (struct utmp))
+	  if (__read (file_fd, buffer, sizeof (struct utmp))
 	      != sizeof (struct utmp))
 	    {
 	      __set_errno (ESRCH);
@@ -243,7 +243,7 @@ internal_getut_r (const struct utmp *id, struct utmp *buffer)
       while (1)
 	{
 	  /* Read the next entry.  */
-	  if (read (file_fd, buffer, sizeof (struct utmp))
+	  if (__read (file_fd, buffer, sizeof (struct utmp))
 	      != sizeof (struct utmp))
 	    {
 	      __set_errno (ESRCH);
@@ -312,7 +312,7 @@ getutline_r_file (const struct utmp *line, struct utmp *buffer,
   while (1)
     {
       /* Read the next entry.  */
-      if (read (file_fd, &last_entry, sizeof (struct utmp))
+      if (__read (file_fd, &last_entry, sizeof (struct utmp))
 	  != sizeof (struct utmp))
 	{
 	  __set_errno (ESRCH);
@@ -373,13 +373,13 @@ pututline_file (const struct utmp *data)
   if (found < 0)
     {
       /* We append the next entry.  */
-      file_offset = lseek (file_fd, 0, SEEK_END);
+      file_offset = __lseek (file_fd, 0, SEEK_END);
       if (file_offset % sizeof (struct utmp) != 0)
 	{
 	  file_offset -= file_offset % sizeof (struct utmp);
 	  __ftruncate (file_fd, file_offset);
 
-	  if (lseek (file_fd, 0, SEEK_END) < 0)
+	  if (__lseek (file_fd, 0, SEEK_END) < 0)
 	    {
 	      pbuf = NULL;
 	      goto unlock_return;
@@ -390,11 +390,11 @@ pututline_file (const struct utmp *data)
     {
       /* We replace the just read entry.  */
       file_offset -= sizeof (struct utmp);
-      lseek (file_fd, file_offset, SEEK_SET);
+      __lseek (file_fd, file_offset, SEEK_SET);
     }
 
   /* Write the new data.  */
-  if (write (file_fd, data, sizeof (struct utmp)) != sizeof (struct utmp))
+  if (__write (file_fd, data, sizeof (struct utmp)) != sizeof (struct utmp))
     {
       /* If we appended a new record this is only partially written.
 	 Remove it.  */
@@ -420,7 +420,7 @@ endutent_file (void)
 {
   assert (file_fd >= 0);
 
-  close (file_fd);
+  __close (file_fd);
   file_fd = -1;
 }
 
@@ -433,27 +433,27 @@ updwtmp_file (const char *file, const struct utmp *utmp)
   int fd;
 
   /* Open WTMP file.  */
-  fd = open (file, O_WRONLY);
+  fd = __open (file, O_WRONLY);
   if (fd < 0)
     return -1;
 
   LOCK_FILE (fd, F_WRLCK);
 
   /* Remember original size of log file.  */
-  offset = lseek (fd, 0, SEEK_END);
+  offset = __lseek (fd, 0, SEEK_END);
   if (offset % sizeof (struct utmp) != 0)
     {
       offset -= offset % sizeof (struct utmp);
       __ftruncate (fd, offset);
 
-      if (lseek (fd, 0, SEEK_END) < 0)
+      if (__lseek (fd, 0, SEEK_END) < 0)
 	goto unlock_return;
     }
 
   /* Write the entry.  If we can't write all the bytes, reset the file
      size back to the original size.  That way, no partial entries
      will remain.  */
-  if (write (fd, utmp, sizeof (struct utmp)) != sizeof (struct utmp))
+  if (__write (fd, utmp, sizeof (struct utmp)) != sizeof (struct utmp))
     {
       __ftruncate (fd, offset);
       goto unlock_return;
@@ -465,7 +465,7 @@ unlock_return:
   UNLOCK_FILE (fd);
 
   /* Close WTMP file.  */
-  close (fd);
+  __close (fd);
 
   return result;
 }
diff --git a/sysdeps/generic/vlimit.c b/sysdeps/generic/vlimit.c
index 5654be1205..68addbce7a 100644
--- a/sysdeps/generic/vlimit.c
+++ b/sysdeps/generic/vlimit.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -39,7 +39,7 @@ vlimit (resource, value)
 	(enum __rlimit_resource) ((int) resource - 1);
       struct rlimit lims;
 
-      if (getrlimit (rlimit_res, &lims) < 0)
+      if (__getrlimit (rlimit_res, &lims) < 0)
 	return -1;
 
       lims.rlim_cur = value;
diff --git a/sysdeps/generic/vtimes.c b/sysdeps/generic/vtimes.c
index e448da6de1..0af59ca342 100644
--- a/sysdeps/generic/vtimes.c
+++ b/sysdeps/generic/vtimes.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -35,7 +35,7 @@ vtimes_one (struct vtimes *vt, enum __rusage_who who)
     {
       struct rusage usage;
 
-      if (getrusage (who, &usage) < 0)
+      if (__getrusage (who, &usage) < 0)
 	return -1;
 
       vt->vm_utime = TIMEVAL_TO_VTIMES (usage.ru_utime);
diff --git a/sysdeps/i386/fpu/bits/mathinline.h b/sysdeps/i386/fpu/bits/mathinline.h
index 465592c764..b188026cdb 100644
--- a/sysdeps/i386/fpu/bits/mathinline.h
+++ b/sysdeps/i386/fpu/bits/mathinline.h
@@ -307,7 +307,7 @@ __sincosl (long double __x, long double *__sinx, long double *__cosx)
   __asm __volatile__							      \
     ("fldl2e			# e^x - 1 = 2^(x * log2(e)) - 1\n\t"	      \
      "fmul	%%st(1)		# x * log2(e)\n\t"			      \
-     "fstl	%%st(1)\n\t"						      \
+     "fst	%%st(1)\n\t"						      \
      "frndint			# int(x * log2(e))\n\t"			      \
      "fxch\n\t"								      \
      "fsub	%%st(1)		# fract(x * log2(e))\n\t"		      \
@@ -328,7 +328,7 @@ __inline_mathcode_ (long double, __expm1l, __x, __expm1_code)
   __asm __volatile__							      \
     ("fldl2e			# e^x = 2^(x * log2(e))\n\t"		      \
      "fmul	%%st(1)		# x * log2(e)\n\t"			      \
-     "fstl	%%st(1)\n\t"						      \
+     "fst	%%st(1)\n\t"						      \
      "frndint			# int(x * log2(e))\n\t"			      \
      "fxch\n\t"								      \
      "fsub	%%st(1)		# fract(x * log2(e))\n\t"		      \
diff --git a/sysdeps/i386/memchr.S b/sysdeps/i386/memchr.S
index c4dcef1a6c..1750aa8e26 100644
--- a/sysdeps/i386/memchr.S
+++ b/sysdeps/i386/memchr.S
@@ -1,7 +1,7 @@
 /* memchr (str, ch, n) -- Return pointer to first occurrence of CH in STR less
    than N.
    For Intel 80x86, x>=3.
-   Copyright (C) 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1994, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>
    Optimised a little by Alan Modra <Alan@SPRI.Levels.UniSA.Edu.Au>
@@ -70,7 +70,7 @@ ENTRY (memchr)
 	   So process first bytes one by one until boundary is
 	   reached. Don't use a loop for better performance.  */
 
-	testb $3, %eax		/* correctly aligned ? */
+	testb $3, %al		/* correctly aligned ? */
 	je L(2)			/* yes => begin loop */
 	cmpb %dl, (%eax)	/* compare byte */
 	je L(9)			/* target found => return */
@@ -78,7 +78,7 @@ ENTRY (memchr)
 	decl %esi		/* decrement length counter */
 	je L(4)			/* len==0 => return NULL */
 
-	testb $3, %eax		/* correctly aligned ? */
+	testb $3, %al		/* correctly aligned ? */
 	je L(2)			/* yes => begin loop */
 	cmpb %dl, (%eax)	/* compare byte */
 	je L(9)			/* target found => return */
@@ -86,7 +86,7 @@ ENTRY (memchr)
 	decl %esi		/* decrement length counter */
 	je L(4)			/* len==0 => return NULL */
 
-	testb $3, %eax		/* correctly aligned ? */
+	testb $3, %al		/* correctly aligned ? */
 	je L(2)			/* yes => begin loop */
 	cmpb %dl, (%eax)	/* compare byte */
 	je L(9)			/* target found => return */
diff --git a/sysdeps/libm-i387/i686/s_fdim.S b/sysdeps/libm-i387/i686/s_fdim.S
index 3f9f61b57d..6f722c5b07 100644
--- a/sysdeps/libm-i387/i686/s_fdim.S
+++ b/sysdeps/libm-i387/i686/s_fdim.S
@@ -28,7 +28,7 @@ ENTRY(__fdim)
 	fucomi	%st(1), %st
 	jp	1f
 
-	fsubp	%st(1), %st
+	fsubrp	%st, %st(1)
 	fldz
 	fcomi	%st(1), %st
 	fcmovb	%st(1), %st
diff --git a/sysdeps/libm-i387/i686/s_fdimf.S b/sysdeps/libm-i387/i686/s_fdimf.S
index 8b5cec6a3b..1bcaf0012e 100644
--- a/sysdeps/libm-i387/i686/s_fdimf.S
+++ b/sysdeps/libm-i387/i686/s_fdimf.S
@@ -28,7 +28,7 @@ ENTRY(__fdimf)
 	fucomi	%st(1), %st
 	jp	1f
 
-	fsubp	%st(1), %st
+	fsubrp	%st, %st(1)
 	fldz
 	fcomi	%st(1), %st
 	fcmovb	%st(1), %st
diff --git a/sysdeps/libm-i387/i686/s_fdiml.S b/sysdeps/libm-i387/i686/s_fdiml.S
index e9f0535a3a..9e909ba60e 100644
--- a/sysdeps/libm-i387/i686/s_fdiml.S
+++ b/sysdeps/libm-i387/i686/s_fdiml.S
@@ -28,7 +28,7 @@ ENTRY(__fdiml)
 	fucomi	%st(1), %st
 	jp	1f
 
-	fsubp	%st(1), %st
+	fsubrp	%st, %st(1)
 	fldz
 	fcomi	%st(1), %st
 	fcmovb	%st(1), %st
diff --git a/sysdeps/posix/cuserid.c b/sysdeps/posix/cuserid.c
index 3108a46c21..68de92ae64 100644
--- a/sysdeps/posix/cuserid.c
+++ b/sysdeps/posix/cuserid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -34,7 +34,7 @@ cuserid (s)
   struct passwd pwent;
   struct passwd *pwptr;
 
-  if (__getpwuid_r (geteuid (), &pwent, buf, sizeof (buf), &pwptr))
+  if (__getpwuid_r (__geteuid (), &pwent, buf, sizeof (buf), &pwptr))
     {
       if (s != NULL)
 	s[0] = '\0';
diff --git a/sysdeps/posix/euidaccess.c b/sysdeps/posix/euidaccess.c
index ed59582154..d38e7cc71b 100644
--- a/sysdeps/posix/euidaccess.c
+++ b/sysdeps/posix/euidaccess.c
@@ -1,5 +1,5 @@
 /* Check if effective user id can access file
-   Copyright (C) 1990, 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1990, 91, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -139,7 +139,7 @@ euidaccess (path, mode)
 #ifdef	_LIBC
   if (! __libc_enable_secure)
     /* If we are not set-uid or set-gid, access does the same.  */
-    return access (path, mode);
+    return __access (path, mode);
 #else
   if (have_ids == 0)
     {
@@ -171,8 +171,8 @@ euidaccess (path, mode)
   if (have_ids == 0)
     {
       have_ids = 1;
-      euid = geteuid ();
-      egid = getegid ();
+      euid = __geteuid ();
+      egid = __getegid ();
     }
 #endif
 
diff --git a/sysdeps/posix/mkstemp.c b/sysdeps/posix/mkstemp.c
index 2c9c96bdcc..d380935c42 100644
--- a/sysdeps/posix/mkstemp.c
+++ b/sysdeps/posix/mkstemp.c
@@ -53,7 +53,7 @@ mkstemp (template)
 
   /* Get some more or less random data.  */
   __gettimeofday (&tv, NULL);
-  value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
+  value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ __getpid ();
 
   for (count = 0; count < TMP_MAX; ++count)
     {
@@ -73,7 +73,7 @@ mkstemp (template)
       v /= 62;
       XXXXXX[5] = letters[v % 62];
 
-      fd = open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
+      fd = __open (template, O_RDWR|O_CREAT|O_EXCL, 0600);
       if (fd >= 0)
 	/* The file does not exist.  */
 	return fd;
diff --git a/sysdeps/posix/mktemp.c b/sysdeps/posix/mktemp.c
index ad5cb1daf5..e9a576c16f 100644
--- a/sysdeps/posix/mktemp.c
+++ b/sysdeps/posix/mktemp.c
@@ -53,7 +53,7 @@ mktemp (template)
 
   /* Get some more or less random data.  */
   __gettimeofday (&tv, NULL);
-  value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ getpid ();
+  value += ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec ^ __getpid ();
 
   for (count = 0; count < TMP_MAX; ++count)
     {
diff --git a/sysdeps/posix/pread.c b/sysdeps/posix/pread.c
index 22b8ca82bd..5ad5acbd2a 100644
--- a/sysdeps/posix/pread.c
+++ b/sysdeps/posix/pread.c
@@ -1,6 +1,6 @@
 /* Read block from given position in file without changing file pointer.
    POSIX version.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -29,22 +29,22 @@ __pread (int fd, void *buf, size_t nbyte, off_t offset)
      we can restore it later.  */
   int save_errno;
   ssize_t result;
-  off_t old_offset = lseek (fd, 0, SEEK_CUR);
+  off_t old_offset = __lseek (fd, 0, SEEK_CUR);
   if (old_offset == (off_t) -1)
     return -1;
 
   /* Set to wanted position.  */
-  if (lseek (fd, offset, SEEK_SET) == (off_t) -1)
+  if (__lseek (fd, offset, SEEK_SET) == (off_t) -1)
     return -1;
 
   /* Write out the data.  */
-  result = read (fd, buf, nbyte);
+  result = __read (fd, buf, nbyte);
 
   /* Now we have to restore the position.  If this fails we have to
      return this as an error.  But if the writing also failed we
      return this error.  */
   save_errno = errno;
-  if (lseek (fd, old_offset, SEEK_SET) == (off_t) -1)
+  if (__lseek (fd, old_offset, SEEK_SET) == (off_t) -1)
     {
       if (result == -1)
 	__set_errno (save_errno);
diff --git a/sysdeps/posix/pread64.c b/sysdeps/posix/pread64.c
index 00b1f33bf2..16fb3df142 100644
--- a/sysdeps/posix/pread64.c
+++ b/sysdeps/posix/pread64.c
@@ -1,6 +1,6 @@
 /* Read block from given position in file without changing file pointer.
    POSIX version.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -29,22 +29,22 @@ __pread64 (int fd, void *buf, size_t nbyte, off64_t offset)
      we can restore it later.  */
   int save_errno;
   ssize_t result;
-  off64_t old_offset = lseek64 (fd, 0, SEEK_CUR);
+  off64_t old_offset = __lseek64 (fd, 0, SEEK_CUR);
   if (old_offset == (off64_t) -1)
     return -1;
 
   /* Set to wanted position.  */
-  if (lseek64 (fd, offset, SEEK_SET) == (off64_t) -1)
+  if (__lseek64 (fd, offset, SEEK_SET) == (off64_t) -1)
     return -1;
 
   /* Write out the data.  */
-  result = read (fd, buf, nbyte);
+  result = __read (fd, buf, nbyte);
 
   /* Now we have to restore the position.  If this fails we have to
      return this as an error.  But if the writing also failed we
      return this error.  */
   save_errno = errno;
-  if (lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1)
+  if (__lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1)
     {
       if (result == -1)
 	__set_errno (save_errno);
diff --git a/sysdeps/posix/profil.c b/sysdeps/posix/profil.c
index 30481465fb..beb5ae47cd 100644
--- a/sysdeps/posix/profil.c
+++ b/sysdeps/posix/profil.c
@@ -74,7 +74,7 @@ __profil (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
 	/* Wasn't turned on.  */
 	return 0;
 
-      if (setitimer (ITIMER_PROF, &otimer, NULL) < 0)
+      if (__setitimer (ITIMER_PROF, &otimer, NULL) < 0)
 	return -1;
       samples = NULL;
       return sigaction (SIGPROF, &oact, NULL);
@@ -84,7 +84,7 @@ __profil (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
     {
       /* Was already turned on.  Restore old timer and signal handler
 	 first.  */
-      if (setitimer (ITIMER_PROF, &otimer, NULL) < 0
+      if (__setitimer (ITIMER_PROF, &otimer, NULL) < 0
 	  || sigaction (SIGPROF, &oact, NULL) < 0)
 	return -1;
     }
@@ -103,7 +103,7 @@ __profil (u_short *sample_buffer, size_t size, size_t offset, u_int scale)
   timer.it_value.tv_sec = 0;
   timer.it_value.tv_usec = 1;
   timer.it_interval = timer.it_value;
-  return setitimer (ITIMER_PROF, &timer, &otimer);
+  return __setitimer (ITIMER_PROF, &timer, &otimer);
 }
 weak_alias (__profil, profil)
 
diff --git a/sysdeps/posix/pwrite.c b/sysdeps/posix/pwrite.c
index ef4a021881..6558eb5c9d 100644
--- a/sysdeps/posix/pwrite.c
+++ b/sysdeps/posix/pwrite.c
@@ -1,6 +1,6 @@
 /* Write block to given position in file without changing file pointer.
    POSIX version.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -29,22 +29,22 @@ __pwrite (int fd, const void *buf, size_t nbyte, off_t offset)
      we can restore it later.  */
   int save_errno;
   ssize_t result;
-  off_t old_offset = lseek (fd, 0, SEEK_CUR);
+  off_t old_offset = __lseek (fd, 0, SEEK_CUR);
   if (old_offset == (off_t) -1)
     return -1;
 
   /* Set to wanted position.  */
-  if (lseek (fd, offset, SEEK_SET) == (off_t) -1)
+  if (__lseek (fd, offset, SEEK_SET) == (off_t) -1)
     return -1;
 
   /* Write out the data.  */
-  result = write (fd, buf, nbyte);
+  result = __write (fd, buf, nbyte);
 
   /* Now we have to restore the position.  If this fails we have to
      return this as an error.  But if the writing also failed we
      return this error.  */
   save_errno = errno;
-  if (lseek (fd, old_offset, SEEK_SET) == (off_t) -1)
+  if (__lseek (fd, old_offset, SEEK_SET) == (off_t) -1)
     {
       if (result == -1)
 	__set_errno (save_errno);
diff --git a/sysdeps/posix/pwrite64.c b/sysdeps/posix/pwrite64.c
index 4045ed4344..89ec261b76 100644
--- a/sysdeps/posix/pwrite64.c
+++ b/sysdeps/posix/pwrite64.c
@@ -1,6 +1,6 @@
 /* Write block to given position in file without changing file pointer.
    POSIX version.
-   Copyright (C) 1997 Free Software Foundation, Inc.
+   Copyright (C) 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -29,22 +29,22 @@ __pwrite64 (int fd, const void *buf, size_t nbyte, off64_t offset)
      we can restore it later.  */
   int save_errno;
   ssize_t result;
-  off64_t old_offset = lseek64 (fd, 0, SEEK_CUR);
+  off64_t old_offset = __lseek64 (fd, 0, SEEK_CUR);
   if (old_offset == (off64_t) -1)
     return -1;
 
   /* Set to wanted position.  */
-  if (lseek64 (fd, offset, SEEK_SET) == (off64_t) -1)
+  if (__lseek64 (fd, offset, SEEK_SET) == (off64_t) -1)
     return -1;
 
   /* Write out the data.  */
-  result = write (fd, buf, nbyte);
+  result = __write (fd, buf, nbyte);
 
   /* Now we have to restore the position.  If this fails we have to
      return this as an error.  But if the writing also failed we
      return this error.  */
   save_errno = errno;
-  if (lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1)
+  if (__lseek64 (fd, old_offset, SEEK_SET) == (off64_t) -1)
     {
       if (result == -1)
 	__set_errno (save_errno);
diff --git a/sysdeps/posix/sigblock.c b/sysdeps/posix/sigblock.c
index efc559dcbc..b652cf7c31 100644
--- a/sysdeps/posix/sigblock.c
+++ b/sysdeps/posix/sigblock.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -39,7 +39,7 @@ __sigblock (mask)
       if ((mask & sigmask (sig)) && __sigaddset (&set, sig) < 0)
 	return -1;
 
-  if (sigprocmask (SIG_BLOCK, &set, &oset) < 0)
+  if (__sigprocmask (SIG_BLOCK, &set, &oset) < 0)
     return -1;
 
   if (sizeof (mask) == sizeof (oset))
diff --git a/sysdeps/posix/sigpause.c b/sysdeps/posix/sigpause.c
index d954125ee4..eced47e42a 100644
--- a/sysdeps/posix/sigpause.c
+++ b/sysdeps/posix/sigpause.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 92, 94, 95, 96, 97 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 92, 94, 95, 96, 97, 98 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -33,7 +33,7 @@ __sigpause (sig_or_mask, is_sig)
   if (is_sig != 0)
     {
       /* The modern X/Open implementation is requested.  */
-      if (sigprocmask (0, NULL, &set) < 0
+      if (__sigprocmask (0, NULL, &set) < 0
 	  /* Yes, we call `sigdelset' and not `__sigdelset'.  */
 	  || sigdelset (&set, sig_or_mask) < 0)
 	return -1;
@@ -53,7 +53,7 @@ __sigpause (sig_or_mask, is_sig)
 	    return -1;
     }
 
-  return sigsuspend (&set);
+  return __sigsuspend (&set);
 }
 
 
diff --git a/sysdeps/posix/ttyname.c b/sysdeps/posix/ttyname.c
index 5ad45ae2a6..a865ded9f5 100644
--- a/sysdeps/posix/ttyname.c
+++ b/sysdeps/posix/ttyname.c
@@ -47,14 +47,14 @@ getttyname (fd, mydev, myino, save, dostat)
   DIR *dirstream;
   struct dirent *d;
 
-  dirstream = opendir (dev);
+  dirstream = __opendir (dev);
   if (dirstream == NULL)
     {
       *dostat = -1;
       return NULL;
     }
 
-  while ((d = readdir (dirstream)) != NULL)
+  while ((d = __readdir (dirstream)) != NULL)
     if (((ino_t) d->d_fileno == myino || *dostat)
 	&& strcmp (d->d_name, "stdin")
 	&& strcmp (d->d_name, "stdout")
@@ -70,7 +70,7 @@ getttyname (fd, mydev, myino, save, dostat)
 	      {
 		*dostat = -1;
 		/* Perhaps it helps to free the directory stream buffer.  */
-		(void) closedir (dirstream);
+		(void) __closedir (dirstream);
 		return NULL;
 	      }
 	    *((char *) __mempcpy (name, dev, sizeof (dev) - 1)) = '/';
@@ -84,14 +84,14 @@ getttyname (fd, mydev, myino, save, dostat)
 #endif
 	   )
 	  {
-	    (void) closedir (dirstream);
+	    (void) __closedir (dirstream);
 	    __ttyname = name;
 	    __set_errno (save);
 	    return name;
 	  }
       }
 
-  (void) closedir (dirstream);
+  (void) __closedir (dirstream);
   __set_errno (save);
   return NULL;
 }
diff --git a/sysdeps/posix/ttyname_r.c b/sysdeps/posix/ttyname_r.c
index ae427f1aef..d4c6e0468a 100644
--- a/sysdeps/posix/ttyname_r.c
+++ b/sysdeps/posix/ttyname_r.c
@@ -51,14 +51,14 @@ getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
   DIR *dirstream;
   struct dirent *d;
 
-  dirstream = opendir (dev);
+  dirstream = __opendir (dev);
   if (dirstream == NULL)
     {
       *dostat = -1;
       return errno;
     }
 
-  while ((d = readdir (dirstream)) != NULL)
+  while ((d = __readdir (dirstream)) != NULL)
     if (((ino_t) d->d_fileno == myino || *dostat)
 	&& strcmp (d->d_name, "stdin")
 	&& strcmp (d->d_name, "stdout")
@@ -70,7 +70,7 @@ getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
 	if (needed > buflen)
 	  {
 	    *dostat = -1;
-	    (void) closedir (dirstream);
+	    (void) __closedir (dirstream);
 	    __set_errno (ERANGE);
 	    return ERANGE;
 	  }
@@ -86,13 +86,13 @@ getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
 #endif
 	   )
 	  {
-	    (void) closedir (dirstream);
+	    (void) __closedir (dirstream);
 	    __set_errno (save);
 	    return 0;
 	  }
       }
 
-  (void) closedir (dirstream);
+  (void) __closedir (dirstream);
   __set_errno (save);
   /* It is not clear what to return in this case.  `isatty' says FD
      refers to a TTY but no entry in /dev has this inode.  */
diff --git a/sysdeps/posix/waitid.c b/sysdeps/posix/waitid.c
index fa9021115f..7bb3bbeb47 100644
--- a/sysdeps/posix/waitid.c
+++ b/sysdeps/posix/waitid.c
@@ -69,7 +69,7 @@ waitid (idtype, id, infop, options)
       return -1;
     }
 
-  child = waitpid (pid, &status, options);
+  child = __waitpid (pid, &status, options);
 
   if (child == -1)
     /* `waitpid' set `errno' for us.  */
diff --git a/sysdeps/unix/getlogin_r.c b/sysdeps/unix/getlogin_r.c
index 8ec2fae754..cb0545e08a 100644
--- a/sysdeps/unix/getlogin_r.c
+++ b/sysdeps/unix/getlogin_r.c
@@ -1,5 +1,5 @@
 /* Reentrant function to return the current login name.  Unix version.
-   Copyright (C) 1991, 1992, 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1991, 1992, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -45,8 +45,8 @@ getlogin_r (name, name_len)
     if (d < 0)
       return errno;
 
-    result = ttyname_r (d, real_tty_path, sizeof (tty_pathname));
-    (void) close (d);
+    result = __ttyname_r (d, real_tty_path, sizeof (tty_pathname));
+    (void) __close (d);
 
     if (result != 0)
       {
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
index 24f0e17792..5d33a515f1 100644
--- a/sysdeps/unix/grantpt.c
+++ b/sysdeps/unix/grantpt.c
@@ -52,12 +52,12 @@ grantpt (fd)
   if (__xstat (_STAT_VER, namebuf, &st) != 0)
     return -1;
 
-  if (st.st_uid == getuid ())
+  if (st.st_uid == __getuid ())
     return 0;
 
   /* We have to do it in user space.  */
 
-  pid = fork ();
+  pid = __fork ();
   if (pid == -1)
     return -1;
   else if (pid == 0)
@@ -68,15 +68,15 @@ grantpt (fd)
 
       /* The helper does its thing on fd PTY_FD.  */
       if (fd != PTY_FD)
-	if (dup2 (fd, PTY_FD) == -1)
+	if (__dup2 (fd, PTY_FD) == -1)
 	  _exit (FAIL_EBADF);
 
-      execve (helper, (char *const *) argv, 0);
+      __execve (helper, (char *const *) argv, 0);
       _exit (FAIL_EXEC);
     }
   else
     {
-      if (waitpid (pid, &w, 0) == -1)
+      if (__waitpid (pid, &w, 0) == -1)
 	return -1;
       if (!WIFEXITED (w))
 	{
diff --git a/sysdeps/unix/rewinddir.c b/sysdeps/unix/rewinddir.c
index 07be1c6543..ded449410f 100644
--- a/sysdeps/unix/rewinddir.c
+++ b/sysdeps/unix/rewinddir.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -29,7 +29,7 @@ rewinddir (dirp)
      DIR *dirp;
 {
   __libc_lock_lock (dirp->lock);
-  (void) lseek (dirp->fd, (off_t) 0, SEEK_SET);
+  (void) __lseek (dirp->fd, (off_t) 0, SEEK_SET);
   dirp->offset = 0;
   dirp->size = 0;
   __libc_lock_unlock (dirp->lock);
diff --git a/sysdeps/unix/sysv/linux/accept.S b/sysdeps/unix/sysv/linux/accept.S
index 196634d46a..431dec0324 100644
--- a/sysdeps/unix/sysv/linux/accept.S
+++ b/sysdeps/unix/sysv/linux/accept.S
@@ -2,4 +2,3 @@
 #define	__socket __libc_accept
 #define	NARGS	3
 #include <socket.S>
-weak_alias (__libc_accept, __accept)
diff --git a/sysdeps/unix/sysv/linux/bind.S b/sysdeps/unix/sysv/linux/bind.S
index 61fb5ebff8..25ff7ecbfd 100644
--- a/sysdeps/unix/sysv/linux/bind.S
+++ b/sysdeps/unix/sysv/linux/bind.S
@@ -1,3 +1,4 @@
 #define	socket	bind
 #define	NARGS	3
+#define NO_WEAK_ALIAS	1
 #include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/gethostid.c b/sysdeps/unix/sysv/linux/gethostid.c
index 67e64208b3..f8a3b80481 100644
--- a/sysdeps/unix/sysv/linux/gethostid.c
+++ b/sysdeps/unix/sysv/linux/gethostid.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1998 Free Software Foundation, Inc.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public License as
@@ -81,7 +81,7 @@ gethostid ()
 
   /* Getting from the file was not successful.  An intelligent guess for
      a unique number of a host is its IP address.  Return this.  */
-  if (gethostname (hostname, MAXHOSTNAMELEN) < 0 || hostname[0] == '\0')
+  if (__gethostname (hostname, MAXHOSTNAMELEN) < 0 || hostname[0] == '\0')
     /* This also fails.  Return and arbitrary value.  */
     return 0;
 
diff --git a/sysdeps/unix/sysv/linux/getpt.c b/sysdeps/unix/sysv/linux/getpt.c
index 3c0b7a9399..0f5949d1bc 100644
--- a/sysdeps/unix/sysv/linux/getpt.c
+++ b/sysdeps/unix/sysv/linux/getpt.c
@@ -43,7 +43,7 @@ __getpt ()
   /* The new way:  */
   if (have_dev_ptmx)
     {
-      fd = open ("/dev/ptmx", O_RDWR);
+      fd = __open ("/dev/ptmx", O_RDWR);
       if (fd != -1)
 	return fd;
       else
@@ -64,7 +64,7 @@ __getpt ()
       for (j = __ptyname2; *j; ++j)
         {
 	  namebuf[9] = *j;
-	  fd = open (namebuf, O_RDWR);
+	  fd = __open (namebuf, O_RDWR);
 	  if (fd != -1)
 	    return fd;
 	  if (errno != EIO)
diff --git a/sysdeps/unix/sysv/linux/getsockname.S b/sysdeps/unix/sysv/linux/getsockname.S
index c138be9da5..31d37a4f0a 100644
--- a/sysdeps/unix/sysv/linux/getsockname.S
+++ b/sysdeps/unix/sysv/linux/getsockname.S
@@ -1,3 +1,4 @@
 #define	socket	getsockname
 #define	NARGS	3
+#define NO_WEAK_ALIAS	1
 #include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/i386/socket.S b/sysdeps/unix/sysv/linux/i386/socket.S
index 245d37a17f..c25b5b82cc 100644
--- a/sysdeps/unix/sysv/linux/i386/socket.S
+++ b/sysdeps/unix/sysv/linux/i386/socket.S
@@ -32,7 +32,11 @@
    The .S files for the other calls just #define socket and #include this.  */
 
 #ifndef __socket
+#ifndef NO_WEAK_ALIAS
 #define __socket P(__,socket)
+#else
+#define __socket socket
+#endif
 #endif
 
 .globl __socket
@@ -63,4 +67,6 @@ L(pseudo_end):
 
 PSEUDO_END (__socket)
 
+#ifndef NO_WEAK_ALIAS
 weak_alias (__socket, socket)
+#endif
diff --git a/sysdeps/unix/sysv/linux/if_index.c b/sysdeps/unix/sysv/linux/if_index.c
index de66b5cb21..aa89a38e69 100644
--- a/sysdeps/unix/sysv/linux/if_index.c
+++ b/sysdeps/unix/sysv/linux/if_index.c
@@ -40,7 +40,7 @@ opensock (void)
 
   if (sock_af != -1)
     {
-      fd = socket (sock_af, SOCK_DGRAM, 0);
+      fd = __socket (sock_af, SOCK_DGRAM, 0);
       if (fd != -1)
         return fd;
     }
@@ -48,19 +48,19 @@ opensock (void)
   __libc_lock_lock (lock);
 
   if (sock_af != -1)
-    fd = socket (sock_af, SOCK_DGRAM, 0);
+    fd = __socket (sock_af, SOCK_DGRAM, 0);
 
   if (fd == -1)
     {
-      fd = socket (sock_af = AF_INET6, SOCK_DGRAM, 0);
+      fd = __socket (sock_af = AF_INET6, SOCK_DGRAM, 0);
       if (fd < 0)
-	fd = socket (sock_af = AF_INET, SOCK_DGRAM, 0);
+	fd = __socket (sock_af = AF_INET, SOCK_DGRAM, 0);
       if (fd < 0)
-	fd = socket (sock_af = AF_IPX, SOCK_DGRAM, 0);
+	fd = __socket (sock_af = AF_IPX, SOCK_DGRAM, 0);
       if (fd < 0)
-	fd = socket (sock_af = AF_AX25, SOCK_DGRAM, 0);
+	fd = __socket (sock_af = AF_AX25, SOCK_DGRAM, 0);
       if (fd < 0)
-	fd = socket (sock_af = AF_APPLETALK, SOCK_DGRAM, 0);
+	fd = __socket (sock_af = AF_APPLETALK, SOCK_DGRAM, 0);
     }
 
   __libc_lock_unlock (lock);
@@ -82,15 +82,15 @@ if_nametoindex (const char *ifname)
     return 0;
 
   strncpy (ifr.ifr_name, ifname, sizeof (ifr.ifr_name));
-  if (ioctl (fd, SIOGIFINDEX, &ifr) < 0)
+  if (__ioctl (fd, SIOGIFINDEX, &ifr) < 0)
     {
       int saved_errno = errno;
-      close (fd);
+      __close (fd);
       if (saved_errno == EINVAL)
 	__set_errno (ENOSYS);
       return 0;
     }
-  close (fd);
+  __close (fd);
   return ifr.ifr_ifindex;
 #endif
 }
@@ -134,7 +134,7 @@ if_nameindex (void)
     {
       ifc.ifc_buf = NULL;
       ifc.ifc_len = 0;
-      if (ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)
+      if (__ioctl (fd, SIOCGIFCONF, &ifc) < 0 || ifc.ifc_len == 0)
 	{
 	  new_siocgifconf = 0;
 	  rq_len = RQ_IFS * sizeof (struct ifreq);
@@ -149,9 +149,9 @@ if_nameindex (void)
   do
     {
       ifc.ifc_buf = alloca (ifc.ifc_len = rq_len);
-      if ((ifc.ifc_buf == NULL) || (ioctl (fd, SIOCGIFCONF, &ifc) < 0))
+      if (ifc.ifc_buf == NULL || __ioctl (fd, SIOCGIFCONF, &ifc) < 0)
 	{
-	  close (fd);
+	  __close (fd);
 	  return NULL;
 	}
       rq_len *= 2;
@@ -163,7 +163,7 @@ if_nameindex (void)
   idx = malloc ((nifs + 1) * sizeof (struct if_nameindex));
   if (idx == NULL)
     {
-      close (fd);
+      __close (fd);
       return NULL;
     }
 
@@ -172,7 +172,7 @@ if_nameindex (void)
       struct ifreq *ifr = &ifc.ifc_req[i];
       idx[i].if_name = __strdup (ifr->ifr_name);
       if (idx[i].if_name == NULL
-	  || ioctl (fd, SIOGIFINDEX, ifr) < 0)
+	  || __ioctl (fd, SIOGIFINDEX, ifr) < 0)
 	{
 	  int saved_errno = errno;
 	  unsigned int j;
@@ -180,7 +180,7 @@ if_nameindex (void)
 	  for (j =  0; j < i; ++j)
 	    free (idx[j].if_name);
 	  free (idx);
-	  close (fd);
+	  __close (fd);
 	  if (saved_errno == EINVAL)
 	    __set_errno (ENOSYS);
 	  return NULL;
@@ -191,7 +191,7 @@ if_nameindex (void)
   idx[i].if_index = 0;
   idx[i].if_name = NULL;
 
-  close (fd);
+  __close (fd);
   return idx;
 #endif
 }
@@ -224,18 +224,18 @@ if_indextoname (unsigned int ifindex, char *ifname)
 	return NULL;
 
       ifr.ifr_ifindex = ifindex;
-      if (ioctl (fd, SIOGIFNAME, &ifr) < 0)
+      if (__ioctl (fd, SIOGIFNAME, &ifr) < 0)
 	{
 	  if (errno == EINVAL)
 	    siogifname_works = 0;   /* Don't make the same mistake twice. */
 	}
       else
 	{
-	  close (fd);
+	  __close (fd);
 	  return strncpy (ifname, ifr.ifr_name, IFNAMSIZ);
 	}
 
-      close (fd);
+      __close (fd);
 
       __set_errno (serrno);
     }
diff --git a/sysdeps/unix/sysv/linux/listen.S b/sysdeps/unix/sysv/linux/listen.S
index 4c7e435196..115bf2b2d0 100644
--- a/sysdeps/unix/sysv/linux/listen.S
+++ b/sysdeps/unix/sysv/linux/listen.S
@@ -1,3 +1,4 @@
 #define	socket	listen
 #define	NARGS	2
+#define NO_WEAK_ALIAS	1
 #include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/ptsname.c b/sysdeps/unix/sysv/linux/ptsname.c
index 2db8f8d08a..052516c7ac 100644
--- a/sysdeps/unix/sysv/linux/ptsname.c
+++ b/sysdeps/unix/sysv/linux/ptsname.c
@@ -75,7 +75,7 @@ __ptsname_r (fd, buf, buflen)
 #ifdef TIOCGPTN
   if (tiocgptn_works)
     {
-      if (ioctl (fd, TIOCGPTN, &ptyno) == 0)
+      if (__ioctl (fd, TIOCGPTN, &ptyno) == 0)
 	goto gotit;
       else
 	{
diff --git a/sysdeps/unix/sysv/linux/recvfrom.S b/sysdeps/unix/sysv/linux/recvfrom.S
index 93a3110d0a..7d0e2b0ea8 100644
--- a/sysdeps/unix/sysv/linux/recvfrom.S
+++ b/sysdeps/unix/sysv/linux/recvfrom.S
@@ -2,4 +2,3 @@
 #define	__socket __libc_recvfrom
 #define	NARGS	6
 #include <socket.S>
-weak_alias (__libc_recvfrom, __recvfrom)
diff --git a/sysdeps/unix/sysv/linux/sendmsg.c b/sysdeps/unix/sysv/linux/sendmsg.c
index 273add903e..16774c48b1 100644
--- a/sysdeps/unix/sysv/linux/sendmsg.c
+++ b/sysdeps/unix/sysv/linux/sendmsg.c
@@ -63,12 +63,12 @@ __libc_sendmsg (int fd, const struct msghdr *message, int flags)
 	     You can send real, effective, or set- uid and gid.
 	     If the user hasn't filled in the buffer, we default to
 	     real uid and gid. */
-	  pid = getpid ();
+	  pid = __getpid ();
 	  if (cc->cmcred_pid != pid)
 	  {
 	      u->pid = pid;
-	      u->uid = getuid ();
-	      u->gid = getgid ();
+	      u->uid = __getuid ();
+	      u->gid = __getgid ();
 	  }
 	  else
 	  {
diff --git a/sysdeps/unix/sysv/linux/sendto.S b/sysdeps/unix/sysv/linux/sendto.S
index 8717b2bac1..f0acb88465 100644
--- a/sysdeps/unix/sysv/linux/sendto.S
+++ b/sysdeps/unix/sysv/linux/sendto.S
@@ -2,4 +2,3 @@
 #define	__socket __libc_sendto
 #define	NARGS	6
 #include <socket.S>
-weak_alias (__libc_sendto, __sendto)
diff --git a/sysdeps/unix/sysv/linux/setsockopt.S b/sysdeps/unix/sysv/linux/setsockopt.S
index 01b2799ae8..09d9109be2 100644
--- a/sysdeps/unix/sysv/linux/setsockopt.S
+++ b/sysdeps/unix/sysv/linux/setsockopt.S
@@ -1,3 +1,4 @@
 #define	socket	setsockopt
 #define	NARGS	5
+#define NO_WEAK_ALIAS	1
 #include <socket.S>
diff --git a/sysdeps/unix/sysv/linux/statvfs.c b/sysdeps/unix/sysv/linux/statvfs.c
index c3df2e6a49..74c4985fe1 100644
--- a/sysdeps/unix/sysv/linux/statvfs.c
+++ b/sysdeps/unix/sysv/linux/statvfs.c
@@ -30,7 +30,7 @@ statvfs (const char *file, struct statvfs *buf)
   int retval;
   int fd;
 
-  fd = open (file, O_RDONLY);
+  fd = __open (file, O_RDONLY);
   if (fd < 0)
     return -1;
 
@@ -39,7 +39,7 @@ statvfs (const char *file, struct statvfs *buf)
 
   /* Close the file while preserving the error number.  */
   save_errno = errno;
-  close (fd);
+  __close (fd);
   __set_errno (save_errno);
 
   return retval;
diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c
index 7f276b6130..91f0d7a40f 100644
--- a/sysdeps/unix/sysv/linux/ttyname.c
+++ b/sysdeps/unix/sysv/linux/ttyname.c
@@ -72,7 +72,7 @@ getttyname (dev, fd, mydev, myino, save, dostat)
 	      {
 		*dostat = -1;
 		/* Perhaps it helps to free the directory stream buffer.  */
-		(void) closedir (dirstream);
+		(void) __closedir (dirstream);
 		return NULL;
 	      }
 	    *((char *) __mempcpy (name, dev, devlen - 1)) = '/';
@@ -86,14 +86,14 @@ getttyname (dev, fd, mydev, myino, save, dostat)
 #endif
 	   )
 	  {
-	    (void) closedir (dirstream);
+	    (void) __closedir (dirstream);
 	    __ttyname = name;
 	    __set_errno (save);
 	    return name;
 	  }
       }
 
-  (void) closedir (dirstream);
+  (void) __closedir (dirstream);
   __set_errno (save);
   return NULL;
 }
diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c
index 9f22f71f31..9c859caa25 100644
--- a/sysdeps/unix/sysv/linux/ttyname_r.c
+++ b/sysdeps/unix/sysv/linux/ttyname_r.c
@@ -46,14 +46,14 @@ getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
   struct dirent *d;
   size_t devlen = strlen (buf);
 
-  dirstream = opendir (buf);
+  dirstream = __opendir (buf);
   if (dirstream == NULL)
     {
       *dostat = -1;
       return errno;
     }
 
-  while ((d = readdir (dirstream)) != NULL)
+  while ((d = __readdir (dirstream)) != NULL)
     if (((ino_t) d->d_fileno == myino || *dostat)
 	&& strcmp (d->d_name, "stdin")
 	&& strcmp (d->d_name, "stdout")
@@ -65,7 +65,7 @@ getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
 	if (needed > buflen)
 	  {
 	    *dostat = -1;
-	    (void) closedir (dirstream);
+	    (void) __closedir (dirstream);
 	    __set_errno (ERANGE);
 	    return ERANGE;
 	  }
@@ -81,13 +81,13 @@ getttyname_r (fd, buf, buflen, mydev, myino, save, dostat)
 #endif
 	   )
 	  {
-	    (void) closedir (dirstream);
+	    (void) __closedir (dirstream);
 	    __set_errno (save);
 	    return 0;
 	  }
       }
 
-  (void) closedir (dirstream);
+  (void) __closedir (dirstream);
   __set_errno (save);
   /* It is not clear what to return in this case.  `isatty' says FD
      refers to a TTY but no entry in /dev has this inode.  */
diff --git a/sysdeps/unix/sysv/linux/ulimit.c b/sysdeps/unix/sysv/linux/ulimit.c
index 2d9e86a63a..ec0337428d 100644
--- a/sysdeps/unix/sysv/linux/ulimit.c
+++ b/sysdeps/unix/sysv/linux/ulimit.c
@@ -45,7 +45,7 @@ __ulimit (int cmd, ...)
     {
     case UL_GETFSIZE:
       /* Get limit on file size.  */
-      if (getrlimit (RLIMIT_FSIZE, &limit) == 0)
+      if (__getrlimit (RLIMIT_FSIZE, &limit) == 0)
 	/* Convert from bytes to 512 byte units.  */
 	result =  limit.rlim_cur / 512;
       break;
@@ -63,7 +63,7 @@ __ulimit (int cmd, ...)
       break;
 
     case __UL_GETOPENMAX:
-      result = sysconf (_SC_OPEN_MAX);
+      result = __sysconf (_SC_OPEN_MAX);
       break;
 
     default:
diff --git a/sysdeps/unix/sysv/linux/unlockpt.c b/sysdeps/unix/sysv/linux/unlockpt.c
index a5f0b2a484..e20545fe80 100644
--- a/sysdeps/unix/sysv/linux/unlockpt.c
+++ b/sysdeps/unix/sysv/linux/unlockpt.c
@@ -33,7 +33,7 @@ unlockpt (fd)
   int serrno = errno;
   int unlock = 0;
 
-  if (ioctl (fd, TIOCSPTLCK, &unlock))
+  if (__ioctl (fd, TIOCSPTLCK, &unlock))
     {
       if (errno == EINVAL)
 	{
diff --git a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
index 1530ff64d5..a21672b115 100644
--- a/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
+++ b/sysdeps/unix/sysv/sysv4/solaris2/sparc/sysdep.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993, 1994, 1995, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Brendan Kehoe (brendan@zen.org).
 
@@ -51,4 +51,6 @@
 #define	r1		%o1
 #define	MOVE(x,y)	mov x, y
 
+#define LOC(name)	.##L##name
+
 #endif	/* __ASSEMBLER__ */
diff --git a/sysvipc/sys/shm.h b/sysvipc/sys/shm.h
index 6a3a34247b..47e0f496a2 100644
--- a/sysvipc/sys/shm.h
+++ b/sysvipc/sys/shm.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -32,7 +32,7 @@
 
 
 /* Segment low boundary address multiple.  */
-#define SHMLBA		getpagesize ()
+#define SHMLBA		(__getpagesize ())
 
 /* The following System V style IPC functions implement a shared memory
    facility.  The definition is found in XPG4.2.  */
diff --git a/time/ctime_r.c b/time/ctime_r.c
index d695c7c2e2..f9a198d6b3 100644
--- a/time/ctime_r.c
+++ b/time/ctime_r.c
@@ -1,5 +1,5 @@
-/* ctime_r - return in BUF representation of time T in form of asctime
-   Copyright (C) 1996 Free Software Foundation, Inc.
+/* Return in BUF representation of time T in form of asctime
+   Copyright (C) 1996, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -26,5 +26,5 @@ char *
 ctime_r (const time_t *t, char *buf)
 {
   struct tm tm;
-  return asctime_r (localtime_r (t, &tm), buf);
+  return __asctime_r (__localtime_r (t, &tm), buf);
 }
diff --git a/time/strptime.c b/time/strptime.c
index 36f42c9355..48761075e2 100644
--- a/time/strptime.c
+++ b/time/strptime.c
@@ -1,5 +1,5 @@
 /* Convert a string representation of time to a time value.
-   Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1996.
 
@@ -148,6 +148,8 @@ extern const struct locale_data _nl_C_LC_TIME;
 # define HERE_T_FMT_AMPM \
   (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT_AMPM)].string)
 # define HERE_T_FMT (_nl_C_LC_TIME.values[_NL_ITEM_INDEX (T_FMT)].string)
+
+# define strncasecmp(s1, s2, n) __strncasecmp (s1, s2, n)
 #else
 static char const weekday_name[][10] =
   {
diff --git a/wcsmbs/mbrlen.c b/wcsmbs/mbrlen.c
index 5dd3a49a9e..efb061b7f7 100644
--- a/wcsmbs/mbrlen.c
+++ b/wcsmbs/mbrlen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper, <drepper@gnu.ai.mit.edu>
 
@@ -31,6 +31,6 @@ __mbrlen (s, n, ps)
      size_t n;
      mbstate_t *ps;
 {
-  return mbrtowc (NULL, s, n, ps ?: &internal);
+  return __mbrtowc (NULL, s, n, ps ?: &internal);
 }
 weak_alias (__mbrlen, mbrlen)
diff --git a/wcsmbs/wcsdup.c b/wcsmbs/wcsdup.c
index 3d676ca704..626e222942 100644
--- a/wcsmbs/wcsdup.c
+++ b/wcsmbs/wcsdup.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1995.
 
@@ -27,7 +27,7 @@ wchar_t *
 wcsdup (s)
      const wchar_t *s;
 {
-  size_t len = (wcslen (s) + 1) * sizeof (wchar_t);
+  size_t len = (__wcslen (s) + 1) * sizeof (wchar_t);
   void *new = malloc (len);
 
   if (new == NULL)
diff --git a/wcsmbs/wcsxfrm.c b/wcsmbs/wcsxfrm.c
index d3687c37e1..e41251f559 100644
--- a/wcsmbs/wcsxfrm.c
+++ b/wcsmbs/wcsxfrm.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@gnu.ai.mit.edu>, 1996.
 
@@ -28,7 +28,7 @@
 #else
 # define STRXFRM wcsxfrm
 #endif
-#define STRLEN wcslen
+#define STRLEN __wcslen
 #define STPNCPY __wcpncpy
 
 #include <string/strxfrm.c>
diff --git a/wctype/wcfuncs.c b/wctype/wcfuncs.c
index fc5e824202..3adb9b015e 100644
--- a/wctype/wcfuncs.c
+++ b/wctype/wcfuncs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
 
    The GNU C Library is free software; you can redistribute it and/or
@@ -23,7 +23,7 @@
 /* Provide real-function versions of all the wctype macros.  */
 
 #define	func(name, type) \
-  int name (wc) wint_t wc; { return iswctype (wc, type); }
+  int name (wc) wint_t wc; { return __iswctype (wc, type); }
 
 func (iswalnum, _ISwalnum)
 func (iswalpha, _ISwalpha)
@@ -41,12 +41,12 @@ wint_t
 towlower (wc)
      wint_t wc;
 {
-  return towctrans (wc, __ctype_tolower);
+  return __towctrans (wc, __ctype_tolower);
 }
 
 wint_t
 towupper (wc)
      wint_t wc;
 {
-  return towctrans (wc, __ctype_toupper);
+  return __towctrans (wc, __ctype_toupper);
 }