From 6ea3c4ed2337dbfcbb88ab29c05bbd7d5b6f6b30 Mon Sep 17 00:00:00 2001
From: Augustin Cavalier <waddlesplash@gmail.com>
Date: Tue, 8 Apr 2025 16:38:13 -0400
Subject: [PATCH] WIP: libroot/glibc: Synchronize libio with upstream glibc
 2.20.

Includes changes/adjustments for integration with Haiku's libroot
as well as C89 fixes for GCC2 compatibility. Also imports one
patch from glibc trunk to fix ungetc+fflush behavior.

Fixes #19039.

Change-Id: I73ebde80d314460174d344ba1e2960807ad4717b

2	0	src/system/libroot/posix/glibc/include/bits/libc-lock.h
13	5	src/system/libroot/posix/glibc/include/bits/stdio-lock.h
55	34	src/system/libroot/posix/glibc/include/bits/stdio.h
3	0	src/system/libroot/posix/glibc/include/fcntl.h
169	24	src/system/libroot/posix/glibc/include/misc/sys/cdefs.h
54	0	src/system/libroot/posix/glibc/include/not-cancel.h
1	0	src/system/libroot/posix/glibc/include/string.h
0	2	src/system/libroot/posix/glibc/libio/Jamfile
1	14	src/system/libroot/posix/glibc/libio/_G_config.h
3	4	src/system/libroot/posix/glibc/libio/__fbufsize.c
3	4	src/system/libroot/posix/glibc/libio/__flbf.c
3	4	src/system/libroot/posix/glibc/libio/__fpending.c
5	6	src/system/libroot/posix/glibc/libio/__fpurge.c
3	4	src/system/libroot/posix/glibc/libio/__freadable.c
2	2	src/system/libroot/posix/glibc/libio/__freading.c
4	5	src/system/libroot/posix/glibc/libio/__fsetlocking.c
3	4	src/system/libroot/posix/glibc/libio/__fwritable.c
3	4	src/system/libroot/posix/glibc/libio/__fwriting.c
3	4	src/system/libroot/posix/glibc/libio/clearerr.c
3	4	src/system/libroot/posix/glibc/libio/clearerr_u.c
3	6	src/system/libroot/posix/glibc/libio/fcloseall.c
3	4	src/system/libroot/posix/glibc/libio/feof.c
3	4	src/system/libroot/posix/glibc/libio/feof_u.c
3	4	src/system/libroot/posix/glibc/libio/ferror.c
3	4	src/system/libroot/posix/glibc/libio/ferror_u.c
20	12	src/system/libroot/posix/glibc/libio/filedoalloc.c
3	4	src/system/libroot/posix/glibc/libio/fileno.c
408	372	src/system/libroot/posix/glibc/libio/fileops.c
18	11	src/system/libroot/posix/glibc/libio/flockfile.c
35	17	src/system/libroot/posix/glibc/libio/fmemopen.c
5	8	src/system/libroot/posix/glibc/libio/fputc.c
3	4	src/system/libroot/posix/glibc/libio/fputc_u.c
6	9	src/system/libroot/posix/glibc/libio/fputwc.c
4	5	src/system/libroot/posix/glibc/libio/fputwc_u.c
63	31	src/system/libroot/posix/glibc/libio/freopen.c
5	8	src/system/libroot/posix/glibc/libio/fseek.c
9	8	src/system/libroot/posix/glibc/libio/fseeko.c
12	10	src/system/libroot/posix/glibc/libio/ftello.c
18	25	src/system/libroot/posix/glibc/libio/fwide.c
4	4	src/system/libroot/posix/glibc/libio/fwprintf.c
6	5	src/system/libroot/posix/glibc/libio/fwscanf.c
235	160	src/system/libroot/posix/glibc/libio/genops.c
5	8	src/system/libroot/posix/glibc/libio/getc.c
3	6	src/system/libroot/posix/glibc/libio/getc_u.c
6	10	src/system/libroot/posix/glibc/libio/getchar.c
4	5	src/system/libroot/posix/glibc/libio/getchar_u.c
5	8	src/system/libroot/posix/glibc/libio/getwc.c
4	5	src/system/libroot/posix/glibc/libio/getwc_u.c
6	10	src/system/libroot/posix/glibc/libio/getwchar.c
4	5	src/system/libroot/posix/glibc/libio/getwchar_u.c
12	18	src/system/libroot/posix/glibc/libio/iofclose.c
42	28	src/system/libroot/posix/glibc/libio/iofdopen.c
7	10	src/system/libroot/posix/glibc/libio/iofflush.c
23	9	src/system/libroot/posix/glibc/libio/iofgetpos.c
14	9	src/system/libroot/posix/glibc/libio/iofgets.c
13	6	src/system/libroot/posix/glibc/libio/iofgets_u.c
13	8	src/system/libroot/posix/glibc/libio/iofgetws.c
12	5	src/system/libroot/posix/glibc/libio/iofgetws_u.c
14	12	src/system/libroot/posix/glibc/libio/iofopen.c
61	37	src/system/libroot/posix/glibc/libio/iofopncook.c
6	10	src/system/libroot/posix/glibc/libio/iofputs.c
3	4	src/system/libroot/posix/glibc/libio/iofputs_u.c
5	8	src/system/libroot/posix/glibc/libio/iofputws.c
3	4	src/system/libroot/posix/glibc/libio/iofputws_u.c
7	10	src/system/libroot/posix/glibc/libio/iofread.c
4	5	src/system/libroot/posix/glibc/libio/iofread_u.c
22	8	src/system/libroot/posix/glibc/libio/iofsetpos.c
9	12	src/system/libroot/posix/glibc/libio/ioftell.c
83	59	src/system/libroot/posix/glibc/libio/iofwide.c
12	11	src/system/libroot/posix/glibc/libio/iofwrite.c
8	5	src/system/libroot/posix/glibc/libio/iofwrite_u.c
20	13	src/system/libroot/posix/glibc/libio/iogetdelim.c
34	39	src/system/libroot/posix/glibc/libio/iogetline.c
7	11	src/system/libroot/posix/glibc/libio/iogets.c
5	10	src/system/libroot/posix/glibc/libio/iogetwline.c
62	68	src/system/libroot/posix/glibc/libio/iolibio.h
4	5	src/system/libroot/posix/glibc/libio/iopadn.c
160	78	src/system/libroot/posix/glibc/libio/iopopen.c
21	25	src/system/libroot/posix/glibc/libio/ioputs.c
15	14	src/system/libroot/posix/glibc/libio/ioseekoff.c
31	32	src/system/libroot/posix/glibc/libio/ioseekpos.c
7	10	src/system/libroot/posix/glibc/libio/iosetbuffer.c
7	10	src/system/libroot/posix/glibc/libio/iosetvbuf.c
6	9	src/system/libroot/posix/glibc/libio/ioungetc.c
7	10	src/system/libroot/posix/glibc/libio/ioungetwc.c
17	18	src/system/libroot/posix/glibc/libio/iovdprintf.c
8	15	src/system/libroot/posix/glibc/libio/iovsprintf.c
6	10	src/system/libroot/posix/glibc/libio/iovsscanf.c
5	9	src/system/libroot/posix/glibc/libio/iovswscanf.c
3	4	src/system/libroot/posix/glibc/libio/iowpadn.c
68	72	src/system/libroot/posix/glibc/libio/libio.h
371	427	src/system/libroot/posix/glibc/libio/libioP.h
24	105	src/system/libroot/posix/glibc/libio/memstream.c
3	4	src/system/libroot/posix/glibc/libio/pclose.c
5	8	src/system/libroot/posix/glibc/libio/peekc.c
6	9	src/system/libroot/posix/glibc/libio/putc.c
3	4	src/system/libroot/posix/glibc/libio/putc_u.c
5	9	src/system/libroot/posix/glibc/libio/putchar.c
3	4	src/system/libroot/posix/glibc/libio/putchar_u.c
5	8	src/system/libroot/posix/glibc/libio/putwc.c
3	4	src/system/libroot/posix/glibc/libio/putwc_u.c
5	9	src/system/libroot/posix/glibc/libio/putwchar.c
3	4	src/system/libroot/posix/glibc/libio/putwchar_u.c
5	8	src/system/libroot/posix/glibc/libio/rewind.c
4	5	src/system/libroot/posix/glibc/libio/setbuf.c
4	5	src/system/libroot/posix/glibc/libio/setlinebuf.c
10	11	src/system/libroot/posix/glibc/libio/stdfiles.c
4	10	src/system/libroot/posix/glibc/libio/stdio.c
471	208	src/system/libroot/posix/glibc/libio/stdio.h
25	5	src/system/libroot/posix/glibc/libio/strfile.h
126	86	src/system/libroot/posix/glibc/libio/strops.c
6	6	src/system/libroot/posix/glibc/libio/swprintf.c
6	5	src/system/libroot/posix/glibc/libio/swscanf.c
12	14	src/system/libroot/posix/glibc/libio/vasprintf.c
4	8	src/system/libroot/posix/glibc/libio/vscanf.c
17	31	src/system/libroot/posix/glibc/libio/vsnprintf.c
16	29	src/system/libroot/posix/glibc/libio/vswprintf.c
6	7	src/system/libroot/posix/glibc/libio/vwprintf.c
5	7	src/system/libroot/posix/glibc/libio/vwscanf.c
14	32	src/system/libroot/posix/glibc/libio/wfiledoalloc.c
404	218	src/system/libroot/posix/glibc/libio/wfileops.c
36	42	src/system/libroot/posix/glibc/libio/wgenops.c
6	5	src/system/libroot/posix/glibc/libio/wprintf.c
6	5	src/system/libroot/posix/glibc/libio/wscanf.c
125	87	src/system/libroot/posix/glibc/libio/wstrops.c
1	1	src/system/libroot/posix/glibc/wcsmbs/wchar.h

diff --git a/src/system/libroot/posix/glibc/include/bits/libc-lock.h b/src/system/libroot/posix/glibc/include/bits/libc-lock.h
index 4ab2a1aaa8..8b965f5bb6 100644
--- a/src/system/libroot/posix/glibc/include/bits/libc-lock.h
+++ b/src/system/libroot/posix/glibc/include/bits/libc-lock.h
@@ -24,12 +24,14 @@
 #include <stddef.h>
 
 #define __libc_maybe_call(func, args, else) func args
+#define __sched_yield sched_yield
 #define __pthread_mutex_init pthread_mutex_init
 #define __pthread_mutex_destroy pthread_mutex_destroy
 #define __pthread_mutexattr_init pthread_mutexattr_init
 #define __pthread_mutexattr_destroy pthread_mutexattr_destroy
 #define __pthread_mutexattr_settype pthread_mutexattr_settype
 #define __pthread_mutex_lock pthread_mutex_lock
+#define __pthread_mutex_trylock pthread_mutex_trylock
 #define __pthread_mutex_unlock pthread_mutex_unlock
 #define PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP	PTHREAD_RECURSIVE_MUTEX_INITIALIZER
 #define PTHREAD_MUTEX_RECURSIVE_NP	PTHREAD_MUTEX_RECURSIVE
diff --git a/src/system/libroot/posix/glibc/include/bits/stdio-lock.h b/src/system/libroot/posix/glibc/include/bits/stdio-lock.h
index 8d865b63af..198cb67535 100644
--- a/src/system/libroot/posix/glibc/include/bits/stdio-lock.h
+++ b/src/system/libroot/posix/glibc/include/bits/stdio-lock.h
@@ -1,5 +1,5 @@
 /* Thread package specific definitions of stream lock type.  Generic version.
-   Copyright (C) 2000, 2001, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000-2014 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
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _BITS_STDIO_LOCK_H
 #define _BITS_STDIO_LOCK_H 1
@@ -27,7 +26,7 @@ __libc_lock_define_recursive (typedef, _IO_lock_t)
 /* We need recursive (counting) mutexes.  */
 #ifdef _LIBC_LOCK_RECURSIVE_INITIALIZER
 # define _IO_lock_initializer _LIBC_LOCK_RECURSIVE_INITIALIZER
-#elif defined _IO_MTSAFE_IO
+#elif _IO_MTSAFE_IO
  #error libio needs recursive mutexes for _IO_MTSAFE_IO
 #endif
 
@@ -45,5 +44,14 @@ __libc_lock_define_recursive (typedef, _IO_lock_t)
 #define _IO_cleanup_region_end(_doit) \
   __libc_cleanup_region_end (_doit)
 
+#if defined _LIBC && !defined NOT_IN_libc
+# define _IO_acquire_lock(_fp) \
+  _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, (_fp));      \
+  _IO_flockfile (_fp)
+
+# define _IO_release_lock(_fp) \
+  _IO_funlockfile (_fp);						      \
+  _IO_cleanup_region_end (0)
+#endif
 
 #endif /* bits/stdio-lock.h */
diff --git a/src/system/libroot/posix/glibc/include/bits/stdio.h b/src/system/libroot/posix/glibc/include/bits/stdio.h
index 387da3c4b0..4fd4b845db 100644
--- a/src/system/libroot/posix/glibc/include/bits/stdio.h
+++ b/src/system/libroot/posix/glibc/include/bits/stdio.h
@@ -1,5 +1,5 @@
 /* Optimizing macros and inline functions for stdio functions.
-   Copyright (C) 1998, 2000, 2001 Free Software Foundation, Inc.
+   Copyright (C) 1998-2014 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
@@ -13,15 +13,14 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef _STDIO_H
 # error "Never include <bits/stdio.h> directly; use <stdio.h> instead."
 #endif
 
-#ifdef __cplusplus
+#ifndef __extern_inline
 # define __STDIO_INLINE inline
 #else
 # define __STDIO_INLINE __extern_inline
@@ -29,41 +28,55 @@
 
 
 #ifdef __USE_EXTERN_INLINES
+/* For -D_FORTIFY_SOURCE{,=2} bits/stdio2.h will define a different
+   inline.  */
+# if !(__USE_FORTIFY_LEVEL > 0 && defined __fortify_function)
 /* Write formatted output to stdout from argument list ARG.  */
 __STDIO_INLINE int
-vprintf (__const char *__restrict __fmt, _G_va_list __arg) __THROW
+vprintf (const char *__restrict __fmt, _G_va_list __arg)
 {
   return vfprintf (stdout, __fmt, __arg);
 }
+# endif
 
 /* Read a character from stdin.  */
 __STDIO_INLINE int
-getchar (void) __THROW
+getchar (void)
 {
   return _IO_getc (stdin);
 }
 
 
-# if defined __USE_POSIX || defined __USE_MISC
+# ifdef __USE_MISC
+/* Faster version when locking is not necessary.  */
+__STDIO_INLINE int
+fgetc_unlocked (FILE *__fp)
+{
+  return _IO_getc_unlocked (__fp);
+}
+# endif /* misc */
+
+
+# ifdef __USE_POSIX
 /* This is defined in POSIX.1:1996.  */
 __STDIO_INLINE int
-getc_unlocked (FILE *__fp) __THROW
+getc_unlocked (FILE *__fp)
 {
   return _IO_getc_unlocked (__fp);
 }
 
 /* This is defined in POSIX.1:1996.  */
 __STDIO_INLINE int
-getchar_unlocked (void) __THROW
+getchar_unlocked (void)
 {
   return _IO_getc_unlocked (stdin);
 }
-# endif	/* POSIX || misc */
+# endif	/* POSIX */
 
 
 /* Write a character to stdout.  */
 __STDIO_INLINE int
-putchar (int __c) __THROW
+putchar (int __c)
 {
   return _IO_putc (__c, stdout);
 }
@@ -72,34 +85,34 @@ putchar (int __c) __THROW
 # ifdef __USE_MISC
 /* Faster version when locking is not necessary.  */
 __STDIO_INLINE int
-fputc_unlocked (int __c, FILE *__stream) __THROW
+fputc_unlocked (int __c, FILE *__stream)
 {
   return _IO_putc_unlocked (__c, __stream);
 }
 # endif /* misc */
 
 
-# if defined __USE_POSIX || defined __USE_MISC
+# ifdef __USE_POSIX
 /* This is defined in POSIX.1:1996.  */
 __STDIO_INLINE int
-putc_unlocked (int __c, FILE *__stream) __THROW
+putc_unlocked (int __c, FILE *__stream)
 {
   return _IO_putc_unlocked (__c, __stream);
 }
 
 /* This is defined in POSIX.1:1996.  */
 __STDIO_INLINE int
-putchar_unlocked (int __c) __THROW
+putchar_unlocked (int __c)
 {
   return _IO_putc_unlocked (__c, stdout);
 }
-# endif	/* POSIX || misc */
+# endif	/* POSIX */
 
 
-# ifdef	__USE_GNU
+# if defined(__USE_GNU) && !defined(__HAIKU__)
 /* Like `getdelim', but reads up to a newline.  */
 __STDIO_INLINE _IO_ssize_t
-getline (char **__lineptr, size_t *__n, FILE *__stream) __THROW
+getline (char **__lineptr, size_t *__n, FILE *__stream)
 {
   return __getdelim (__lineptr, __n, '\n', __stream);
 }
@@ -109,14 +122,14 @@ getline (char **__lineptr, size_t *__n, FILE *__stream) __THROW
 # ifdef __USE_MISC
 /* Faster versions when locking is not required.  */
 __STDIO_INLINE int
-feof_unlocked (FILE *__stream) __THROW
+__NTH (feof_unlocked (FILE *__stream))
 {
   return _IO_feof_unlocked (__stream);
 }
 
 /* Faster versions when locking is not required.  */
 __STDIO_INLINE int
-ferror_unlocked (FILE *__stream) __THROW
+__NTH (ferror_unlocked (FILE *__stream))
 {
   return _IO_ferror_unlocked (__stream);
 }
@@ -125,43 +138,51 @@ ferror_unlocked (FILE *__stream) __THROW
 #endif /* Use extern inlines.  */
 
 
-#if defined __USE_MISC && defined __GNUC__ && defined __OPTIMIZE__
+#if defined __USE_MISC && defined __GNUC__ && defined __OPTIMIZE__ \
+    && !defined __cplusplus
 /* Perform some simple optimizations.  */
 # define fread_unlocked(ptr, size, n, stream) \
   (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n)    \
-		   && (size_t) ((size) * (n)) <= 8 && (size) != 0)	      \
+		   && (size_t) (size) * (size_t) (n) <= 8		      \
+		   && (size_t) (size) != 0)				      \
 		  ? ({ char *__ptr = (char *) (ptr);			      \
 		       FILE *__stream = (stream);			      \
 		       size_t __cnt;					      \
-		       for (__cnt = (size) * (n); __cnt > 0; --__cnt)	      \
+		       for (__cnt = (size_t) (size) * (size_t) (n);	      \
+			    __cnt > 0; --__cnt)				      \
 			 {						      \
 			   int __c = _IO_getc_unlocked (__stream);	      \
 			   if (__c == EOF)				      \
 			     break;					      \
 			   *__ptr++ = __c;				      \
 			 }						      \
-		       ((size_t) ((size) * (n)) - __cnt) / (size); })	      \
-		  : (((__builtin_constant_p (size) && (size) == 0)	      \
-		      || (__builtin_constant_p (n) && (n) == 0))	      \
+		       ((size_t) (size) * (size_t) (n) - __cnt)		      \
+			/ (size_t) (size); })				      \
+		  : (((__builtin_constant_p (size) && (size_t) (size) == 0)   \
+		      || (__builtin_constant_p (n) && (size_t) (n) == 0))     \
 			/* Evaluate all parameters once.  */		      \
 		     ? ((void) (ptr), (void) (stream), (void) (size),	      \
-			(void) (n), 0)					      \
+			(void) (n), (size_t) 0)				      \
 		     : fread_unlocked (ptr, size, n, stream))))
 
 # define fwrite_unlocked(ptr, size, n, stream) \
   (__extension__ ((__builtin_constant_p (size) && __builtin_constant_p (n)    \
-		   && (size_t) ((size) * (n)) <= 8 && (size) != 0)	      \
+		   && (size_t) (size) * (size_t) (n) <= 8		      \
+		   && (size_t) (size) != 0)				      \
 		  ? ({ const char *__ptr = (const char *) (ptr);	      \
 		       FILE *__stream = (stream);			      \
 		       size_t __cnt;					      \
-		       for (__cnt = (size) * (n); __cnt > 0; --__cnt)	      \
+		       for (__cnt = (size_t) (size) * (size_t) (n);	      \
+			    __cnt > 0; --__cnt)				      \
 			 if (_IO_putc_unlocked (*__ptr++, __stream) == EOF)   \
 			   break;					      \
-		       ((size_t) ((size) * (n)) - __cnt) / (size); })	      \
-		  : (((__builtin_constant_p (size) && (size) == 0)	      \
-		      || (__builtin_constant_p (n) && (n) == 0))	      \
+		       ((size_t) (size) * (size_t) (n) - __cnt)		      \
+			/ (size_t) (size); })				      \
+		  : (((__builtin_constant_p (size) && (size_t) (size) == 0)   \
+		      || (__builtin_constant_p (n) && (size_t) (n) == 0))     \
 			/* Evaluate all parameters once.  */		      \
-		     ? ((void) (ptr), (void) (stream), (void) (size), n)      \
+		     ? ((void) (ptr), (void) (stream), (void) (size),	      \
+			(void) (n), (size_t) 0)				      \
 		     : fwrite_unlocked (ptr, size, n, stream))))
 #endif
 
diff --git a/src/system/libroot/posix/glibc/include/fcntl.h b/src/system/libroot/posix/glibc/include/fcntl.h
index 41b7516a7e..8fbc3c62f8 100644
--- a/src/system/libroot/posix/glibc/include/fcntl.h
+++ b/src/system/libroot/posix/glibc/include/fcntl.h
@@ -3,6 +3,9 @@
 #include_next <fcntl.h>
 #include <features.h>
 
+#define O_LARGEFILE 0
+#define __ASSUME_O_CLOEXEC
+
 /* Now define the internal interfaces.  */
 extern int __open64 (__const char *__file, int __oflag, ...);
 libc_hidden_proto (__open64)
diff --git a/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h b/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h
index f4aa3d76c6..56267df5e0 100644
--- a/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h
+++ b/src/system/libroot/posix/glibc/include/misc/sys/cdefs.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1992-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1992-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #ifndef	_SYS_CDEFS_H
 #define	_SYS_CDEFS_H	1
@@ -37,33 +36,52 @@
 
 #ifdef __GNUC__
 
+/* All functions, except those with callbacks or those that
+   synchronize memory, are leaf functions.  */
+# if __GNUC_PREREQ (4, 6) && !defined _LIBC
+#  define __LEAF , __leaf__
+#  define __LEAF_ATTR __attribute__ ((__leaf__))
+# else
+#  define __LEAF
+#  define __LEAF_ATTR
+# endif
+
 /* GCC can always grok prototypes.  For C++ programs we add throw()
    to help it optimize the function calls.  But this works only with
-   gcc 2.8.x and egcs.  */
-# if defined __cplusplus && __GNUC_PREREQ (2,8)
-#  define __THROW	throw ()
+   gcc 2.8.x and egcs.  For gcc 3.2 and up we even mark C functions
+   as non-throwing using a function attribute since programs can use
+   the -fexceptions options for C code as well.  */
+# if !defined __cplusplus && __GNUC_PREREQ (3, 3)
+#  define __THROW	__attribute__ ((__nothrow__ __LEAF))
+#  define __THROWNL	__attribute__ ((__nothrow__))
+#  define __NTH(fct)	__attribute__ ((__nothrow__ __LEAF)) fct
 # else
-#  define __THROW
+#  if defined __cplusplus && __GNUC_PREREQ (2,8)
+#   define __THROW	throw ()
+#   define __THROWNL	throw ()
+#   define __NTH(fct)	__LEAF_ATTR fct throw ()
+#  else
+#   define __THROW
+#   define __THROWNL
+#   define __NTH(fct)	fct
+#  endif
 # endif
-# define __P(args)	args __THROW
-/* This macro will be used for functions which might take C++ callback
-   functions.  */
-# define __PMT(args)	args
 
 #else	/* Not GCC.  */
 
 # define __inline		/* No inline functions.  */
 
 # define __THROW
-# define __P(args)	args
-# define __PMT(args)	args
-
-# define __const	const
-# define __signed	signed
-# define __volatile	volatile
+# define __THROWNL
+# define __NTH(fct)	fct
 
 #endif	/* GCC.  */
 
+/* These two macros are not used in glibc anymore.  They are kept here
+   only because some other projects expect the macros to be defined.  */
+#define __P(args)	args
+#define __PMT(args)	args
+
 /* For these things, GCC behaves the ANSI way normally,
    and the non-ANSI way under -traditional.  */
 
@@ -118,6 +136,23 @@
 #endif
 
 
+/* Fortify support.  */
+#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
+#define __bos0(ptr) __builtin_object_size (ptr, 0)
+#define __fortify_function __extern_always_inline __attribute_artificial__
+
+#if __GNUC_PREREQ (4,3)
+# define __warndecl(name, msg) \
+  extern void name (void) __attribute__((__warning__ (msg)))
+# define __warnattr(msg) __attribute__((__warning__ (msg)))
+# define __errordecl(name, msg) \
+  extern void name (void) __attribute__((__error__ (msg)))
+#else
+# define __warndecl(name, msg) extern void name (void)
+# define __warnattr(msg)
+# define __errordecl(name, msg) extern void name (void)
+#endif
+
 /* Support for flexible arrays.  */
 #if __GNUC_PREREQ (2,97)
 /* GCC 2.97 supports C99 flexible array members.  */
@@ -149,6 +184,17 @@
 #if defined __GNUC__ && __GNUC__ >= 2
 
 # define __REDIRECT(name, proto, alias) name proto __asm__ (__ASMNAME (#alias))
+# ifdef __cplusplus
+#  define __REDIRECT_NTH(name, proto, alias) \
+     name proto __THROW __asm__ (__ASMNAME (#alias))
+#  define __REDIRECT_NTHNL(name, proto, alias) \
+     name proto __THROWNL __asm__ (__ASMNAME (#alias))
+# else
+#  define __REDIRECT_NTH(name, proto, alias) \
+     name proto __asm__ (__ASMNAME (#alias)) __THROW
+#  define __REDIRECT_NTHNL(name, proto, alias) \
+     name proto __asm__ (__ASMNAME (#alias)) __THROWNL
+# endif
 # define __ASMNAME(cname)  __ASMNAME2 (__USER_LABEL_PREFIX__, cname)
 # define __ASMNAME2(prefix, cname) __STRING (prefix) cname
 
@@ -176,6 +222,15 @@
 # define __attribute_malloc__ /* Ignore */
 #endif
 
+/* Tell the compiler which arguments to an allocation function
+   indicate the size of the allocation.  */
+#if __GNUC_PREREQ (4, 3)
+# define __attribute_alloc_size__(params) \
+  __attribute__ ((__alloc_size__ params))
+#else
+# define __attribute_alloc_size__(params) /* Ignore.  */
+#endif
+
 /* At some point during the gcc 2.96 development the `pure' attribute
    for functions was introduced.  We don't want to use it unconditionally
    (although this would be possible) since it generates warnings.  */
@@ -185,6 +240,13 @@
 # define __attribute_pure__ /* Ignore */
 #endif
 
+/* This declaration tells the compiler that the value is constant.  */
+#if __GNUC_PREREQ (2,5)
+# define __attribute_const__ __attribute__ ((__const__))
+#else
+# define __attribute_const__ /* Ignore */
+#endif
+
 /* At some point during the gcc 3.1 development the `used' attribute
    for functions was introduced.  We don't want to use it unconditionally
    (although this would be possible) since it generates warnings.  */
@@ -226,6 +288,28 @@
 # define __attribute_format_strfmon__(a,b) /* Ignore */
 #endif
 
+/* The nonull function attribute allows to mark pointer parameters which
+   must not be NULL.  */
+#if __GNUC_PREREQ (3,3)
+# define __nonnull(params) __attribute__ ((__nonnull__ params))
+#else
+# define __nonnull(params)
+#endif
+
+/* If fortification mode, we warn about unused results of certain
+   function calls which can lead to problems.  */
+#if __GNUC_PREREQ (3,4)
+# define __attribute_warn_unused_result__ \
+   __attribute__ ((__warn_unused_result__))
+# if __USE_FORTIFY_LEVEL > 0
+#  define __wur __attribute_warn_unused_result__
+# endif
+#else
+# define __attribute_warn_unused_result__ /* empty */
+#endif
+#ifndef __wur
+# define __wur /* Ignore */
+#endif
 
 /* Forces a function to be always inlined.  */
 #if __GNUC_PREREQ (3,2)
@@ -242,10 +326,12 @@
 # define __attribute_artificial__ /* Ignore */
 #endif
 
-/* GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99
-   inline semantics, unless -fgnu89-inline is used.  */
-#if !defined __cplusplus || __GNUC_PREREQ (4,3)
-# if defined __GNUC_STDC_INLINE__ || defined __cplusplus
+#ifdef __GNUC__
+/* One of these will be defined if the __gnu_inline__ attribute is
+   available.  In C++, __GNUC_GNU_INLINE__ will be defined even though
+   __inline does not use the GNU inlining rules.  If neither macro is
+   defined, this version of GCC only supports GNU inline semantics. */
+# if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__
 #  define __extern_inline extern __inline __attribute__ ((__gnu_inline__))
 #  define __extern_always_inline \
   extern __always_inline __attribute__ ((__gnu_inline__))
@@ -253,10 +339,17 @@
 #  define __extern_inline extern __inline
 #  define __extern_always_inline extern __always_inline
 # endif
-#else
-#  define __extern_inline extern __inline
+#else /* Not GCC.  */
+# define __extern_inline  /* Ignore */
+# define __extern_always_inline /* Ignore */
 #endif
 
+/* GCC 4.3 and above allow passing all anonymous arguments of an
+   __extern_always_inline function to some other vararg function.  */
+#if __GNUC_PREREQ (4,3)
+# define __va_arg_pack() __builtin_va_arg_pack ()
+# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
+#endif
 
 /* It is possible to compile containing GCC extensions even if GCC is
    run in pedantic mode if the uses are carefully marked using the
@@ -289,4 +382,56 @@
 # endif
 #endif
 
+#if __GNUC__ >= 3
+# define __glibc_unlikely(cond)	__builtin_expect ((cond), 0)
+# define __glibc_likely(cond)	__builtin_expect ((cond), 1)
+#else
+# define __glibc_unlikely(cond)	(cond)
+# define __glibc_likely(cond)	(cond)
+#endif
+
+#if (!defined _Noreturn \
+     && (defined __STDC_VERSION__ ? __STDC_VERSION__ : 0) < 201112 \
+     &&  !__GNUC_PREREQ (4,7))
+# if __GNUC_PREREQ (2,8)
+#  define _Noreturn __attribute__ ((__noreturn__))
+# else
+#  define _Noreturn
+# endif
+#endif
+
+#include <bits/wordsize.h>
+
+#if defined __LONG_DOUBLE_MATH_OPTIONAL && defined __NO_LONG_DOUBLE_MATH
+# define __LDBL_COMPAT 1
+# ifdef __REDIRECT
+#  define __LDBL_REDIR1(name, proto, alias) __REDIRECT (name, proto, alias)
+#  define __LDBL_REDIR(name, proto) \
+  __LDBL_REDIR1 (name, proto, __nldbl_##name)
+#  define __LDBL_REDIR1_NTH(name, proto, alias) __REDIRECT_NTH (name, proto, alias)
+#  define __LDBL_REDIR_NTH(name, proto) \
+  __LDBL_REDIR1_NTH (name, proto, __nldbl_##name)
+#  define __LDBL_REDIR1_DECL(name, alias) \
+  extern __typeof (name) name __asm (__ASMNAME (#alias));
+#  define __LDBL_REDIR_DECL(name) \
+  extern __typeof (name) name __asm (__ASMNAME ("__nldbl_" #name));
+#  define __REDIRECT_LDBL(name, proto, alias) \
+  __LDBL_REDIR1 (name, proto, __nldbl_##alias)
+#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
+  __LDBL_REDIR1_NTH (name, proto, __nldbl_##alias)
+# endif
+#endif
+#if !defined __LDBL_COMPAT || !defined __REDIRECT
+# define __LDBL_REDIR1(name, proto, alias) name proto
+# define __LDBL_REDIR(name, proto) name proto
+# define __LDBL_REDIR1_NTH(name, proto, alias) name proto __THROW
+# define __LDBL_REDIR_NTH(name, proto) name proto __THROW
+# define __LDBL_REDIR_DECL(name)
+# ifdef __REDIRECT
+#  define __REDIRECT_LDBL(name, proto, alias) __REDIRECT (name, proto, alias)
+#  define __REDIRECT_NTH_LDBL(name, proto, alias) \
+  __REDIRECT_NTH (name, proto, alias)
+# endif
+#endif
+
 #endif	 /* sys/cdefs.h */
diff --git a/src/system/libroot/posix/glibc/include/not-cancel.h b/src/system/libroot/posix/glibc/include/not-cancel.h
new file mode 100644
index 0000000000..9f634c221d
--- /dev/null
+++ b/src/system/libroot/posix/glibc/include/not-cancel.h
@@ -0,0 +1,54 @@
+/* Uncancelable versions of cancelable interfaces.  Generic version.
+   Copyright (C) 2003-2014 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+   Contributed by Ulrich Drepper <drepper@redhat.com>, 2003.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+/* By default we have none.  Map the name to the normal functions.  */
+#define open_not_cancel(name, flags, mode) \
+  open (name, flags, mode)
+#define open_not_cancel_2(name, flags) \
+  open (name, flags)
+#define openat_not_cancel(fd, name, flags, mode) \
+  openat (fd, name, flags, mode)
+#define openat_not_cancel_3(fd, name, flags) \
+  openat (fd, name, flags, 0)
+#define openat64_not_cancel(fd, name, flags, mode) \
+  openat64 (fd, name, flags, mode)
+#define openat64_not_cancel_3(fd, name, flags) \
+  openat64 (fd, name, flags, 0)
+#define close_not_cancel(fd) \
+  close (fd)
+#define close_not_cancel_no_status(fd) \
+  (void) close (fd)
+#define read_not_cancel(fd, buf, n) \
+  read (fd, buf, n)
+#define write_not_cancel(fd, buf, n) \
+  write (fd, buf, n)
+#define writev_not_cancel_no_status(fd, iov, n) \
+  (void) writev (fd, iov, n)
+#define fcntl_not_cancel(fd, cmd, val) \
+  fcntl (fd, cmd, val)
+# define waitpid_not_cancel(pid, stat_loc, options) \
+  waitpid (pid, stat_loc, options)
+#define pause_not_cancel() \
+  pause ()
+#define nanosleep_not_cancel(requested_time, remaining) \
+  nanosleep (requested_time, remaining)
+#define sigsuspend_not_cancel(set) \
+  sigsuspend (set)
+
+#define NO_CANCELLATION 1
diff --git a/src/system/libroot/posix/glibc/include/string.h b/src/system/libroot/posix/glibc/include/string.h
index eb7cf24e8a..fa031be66c 100644
--- a/src/system/libroot/posix/glibc/include/string.h
+++ b/src/system/libroot/posix/glibc/include/string.h
@@ -1,6 +1,7 @@
 #ifndef _LIBC_STRING_H
 #define _LIBC_STRING_H
 
+#define _DEFAULT_SOURCE
 #include_next <string.h>
 
 /* map the internal glibc interface to the public one */
diff --git a/src/system/libroot/posix/glibc/libio/Jamfile b/src/system/libroot/posix/glibc/libio/Jamfile
index 974c934fd4..fcefe8d23d 100644
--- a/src/system/libroot/posix/glibc/libio/Jamfile
+++ b/src/system/libroot/posix/glibc/libio/Jamfile
@@ -94,7 +94,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
 			iovsprintf.c
 			iovsscanf.c
 			memstream.c
-#			obprintf.c
 			pclose.c
 			peekc.c
 			putc.c
@@ -112,7 +111,6 @@ for architectureObject in [ MultiArchSubDirSetup ] {
 			vsnprintf.c
 
 			# wide character
-
 			fputwc.c
 			fputwc_u.c
 			fwprintf.c
diff --git a/src/system/libroot/posix/glibc/libio/_G_config.h b/src/system/libroot/posix/glibc/libio/_G_config.h
index d8c7ecf073..6810d107b0 100644
--- a/src/system/libroot/posix/glibc/libio/_G_config.h
+++ b/src/system/libroot/posix/glibc/libio/_G_config.h
@@ -55,8 +55,6 @@ typedef struct
 #endif
 #undef __need_mbstate_t
 
-typedef size_t _G_size_t;
-
 
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 typedef struct
@@ -75,14 +73,7 @@ typedef off_t _G_fpos_t;
 typedef off_t _G_fpos64_t;
 #endif
 #define __off_t		off_t
-#define _G_ssize_t	ssize_t
-#define _G_off_t	off_t
-#define _G_off64_t	off_t
-#define	_G_pid_t	pid_t
-#define	_G_uid_t	uid_t
-#define _G_wchar_t	wchar_t
-#define _G_wint_t	wint_t
-#define _G_stat64	stat
+#define stat64		stat
 
 #include <iconv/gconv.h>
 typedef union
@@ -119,10 +110,6 @@ typedef unsigned int _G_uint32_t __attribute__ ((__mode__ (__SI__)));
 
 #define _G_IO_IO_FILE_VERSION 0x20001
 
-//#define _G_OPEN64	__open64
-//#define _G_LSEEK64	__lseek64
-//#define _G_FSTAT64(fd,buf) __fxstat64 (_STAT_VER, fd, buf)
-
 /* This is defined by <bits/stat.h> if `st_blksize' exists.  */
 /*#define _G_HAVE_ST_BLKSIZE defined (_STATBUF_ST_BLKSIZE)*/
 
diff --git a/src/system/libroot/posix/glibc/libio/__fbufsize.c b/src/system/libroot/posix/glibc/libio/__fbufsize.c
index f39c0136be..e5828849af 100644
--- a/src/system/libroot/posix/glibc/libio/__fbufsize.c
+++ b/src/system/libroot/posix/glibc/libio/__fbufsize.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/__flbf.c b/src/system/libroot/posix/glibc/libio/__flbf.c
index 70c6806aeb..7d4bcc954c 100644
--- a/src/system/libroot/posix/glibc/libio/__flbf.c
+++ b/src/system/libroot/posix/glibc/libio/__flbf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/__fpending.c b/src/system/libroot/posix/glibc/libio/__fpending.c
index c9be0f8ab8..0c4d329902 100644
--- a/src/system/libroot/posix/glibc/libio/__fpending.c
+++ b/src/system/libroot/posix/glibc/libio/__fpending.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/__fpurge.c b/src/system/libroot/posix/glibc/libio/__fpurge.c
index b167343561..c64f460654 100644
--- a/src/system/libroot/posix/glibc/libio/__fpurge.c
+++ b/src/system/libroot/posix/glibc/libio/__fpurge.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdlib.h>
 #include <stdio_ext.h>
@@ -27,7 +26,7 @@ __fpurge (FILE *fp)
     {
       /* Wide-char stream.  */
       if (_IO_in_backup (fp))
-	INTUSE(_IO_free_wbackup_area) (fp);
+	_IO_free_wbackup_area (fp);
 
       fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
@@ -36,7 +35,7 @@ __fpurge (FILE *fp)
     {
       /* Byte stream.  */
       if (_IO_in_backup (fp))
-	INTUSE(_IO_free_backup_area) (fp);
+	_IO_free_backup_area (fp);
 
       fp->_IO_read_end = fp->_IO_read_ptr;
       fp->_IO_write_ptr = fp->_IO_write_base;
diff --git a/src/system/libroot/posix/glibc/libio/__freadable.c b/src/system/libroot/posix/glibc/libio/__freadable.c
index ff14250829..1ef5511153 100644
--- a/src/system/libroot/posix/glibc/libio/__freadable.c
+++ b/src/system/libroot/posix/glibc/libio/__freadable.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/__freading.c b/src/system/libroot/posix/glibc/libio/__freading.c
index c5fa659e7e..834f4f9ab5 100644
--- a/src/system/libroot/posix/glibc/libio/__freading.c
+++ b/src/system/libroot/posix/glibc/libio/__freading.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000-2025 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -13,7 +13,7 @@
 
    You should have received a copy of the GNU Lesser General Public
    License along with the GNU C Library; if not, see
-   <https://www.gnu.org/licenses/>.  */
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/__fsetlocking.c b/src/system/libroot/posix/glibc/libio/__fsetlocking.c
index 0542e08dbe..b9c113a853 100644
--- a/src/system/libroot/posix/glibc/libio/__fsetlocking.c
+++ b/src/system/libroot/posix/glibc/libio/__fsetlocking.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
@@ -35,4 +34,4 @@ __fsetlocking (FILE *fp, int type)
 
   return result;
 }
-INTDEF(__fsetlocking)
+libc_hidden_def (__fsetlocking)
diff --git a/src/system/libroot/posix/glibc/libio/__fwritable.c b/src/system/libroot/posix/glibc/libio/__fwritable.c
index 60ceeb5cbd..b4190b03f2 100644
--- a/src/system/libroot/posix/glibc/libio/__fwritable.c
+++ b/src/system/libroot/posix/glibc/libio/__fwritable.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/__fwriting.c b/src/system/libroot/posix/glibc/libio/__fwriting.c
index c62884a5b1..a96503a456 100644
--- a/src/system/libroot/posix/glibc/libio/__fwriting.c
+++ b/src/system/libroot/posix/glibc/libio/__fwriting.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 2000-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include <stdio_ext.h>
 
diff --git a/src/system/libroot/posix/glibc/libio/clearerr.c b/src/system/libroot/posix/glibc/libio/clearerr.c
index c61c5a40d6..39c2ff8b37 100644
--- a/src/system/libroot/posix/glibc/libio/clearerr.c
+++ b/src/system/libroot/posix/glibc/libio/clearerr.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "stdio.h"
diff --git a/src/system/libroot/posix/glibc/libio/clearerr_u.c b/src/system/libroot/posix/glibc/libio/clearerr_u.c
index 7f8ec75324..134f419ec2 100644
--- a/src/system/libroot/posix/glibc/libio/clearerr_u.c
+++ b/src/system/libroot/posix/glibc/libio/clearerr_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "stdio.h"
diff --git a/src/system/libroot/posix/glibc/libio/fcloseall.c b/src/system/libroot/posix/glibc/libio/fcloseall.c
index f611e74428..9d1b1ac15c 100644
--- a/src/system/libroot/posix/glibc/libio/fcloseall.c
+++ b/src/system/libroot/posix/glibc/libio/fcloseall.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -28,8 +27,6 @@
 #include "libioP.h"
 #include <stdio.h>
 
-int __fcloseall(void);
-
 int
 __fcloseall (void)
 {
diff --git a/src/system/libroot/posix/glibc/libio/feof.c b/src/system/libroot/posix/glibc/libio/feof.c
index d4409814cd..28d256363a 100644
--- a/src/system/libroot/posix/glibc/libio/feof.c
+++ b/src/system/libroot/posix/glibc/libio/feof.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/feof_u.c b/src/system/libroot/posix/glibc/libio/feof_u.c
index 02e08f67ae..9437c5712a 100644
--- a/src/system/libroot/posix/glibc/libio/feof_u.c
+++ b/src/system/libroot/posix/glibc/libio/feof_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/ferror.c b/src/system/libroot/posix/glibc/libio/ferror.c
index 6d9169c191..74f3306cb2 100644
--- a/src/system/libroot/posix/glibc/libio/ferror.c
+++ b/src/system/libroot/posix/glibc/libio/ferror.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/ferror_u.c b/src/system/libroot/posix/glibc/libio/ferror_u.c
index e9ce67c404..944a661165 100644
--- a/src/system/libroot/posix/glibc/libio/ferror_u.c
+++ b/src/system/libroot/posix/glibc/libio/ferror_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/filedoalloc.c b/src/system/libroot/posix/glibc/libio/filedoalloc.c
index ca02dbeb34..79005773f9 100644
--- a/src/system/libroot/posix/glibc/libio/filedoalloc.c
+++ b/src/system/libroot/posix/glibc/libio/filedoalloc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -41,7 +40,7 @@
    4. Neither the name of the University nor the names of its contributors
       may be used to endorse or promote products derived from this software
       without specific prior written permission.
-   
+
    THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -62,10 +61,8 @@
 #include "libioP.h"
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef __STDC__
 #include <stdlib.h>
 #include <unistd.h>
-#endif
 
 #ifdef _LIBC
 # undef isatty
@@ -74,6 +71,17 @@
 # include <device-nrs.h>
 #endif
 
+
+static int
+local_isatty (int fd)
+{
+  int save_errno = errno;
+  int res = isatty (fd);
+  __set_errno (save_errno);
+  return res;
+}
+
+
 /*
  * Allocate a file buffer, or switch to unbuffered I/O.
  * Per the ANSI C standard, ALL tty devices default to line buffered.
@@ -88,14 +96,14 @@ _IO_file_doallocate (fp)
 {
   _IO_size_t size;
   char *p;
-  struct _G_stat64 st;
+  struct stat64 st;
 
 #ifndef _LIBC
   /* If _IO_cleanup_registration_needed is non-zero, we should call the
      function it points to.  This is to make sure _IO_cleanup gets called
      on exit.  We call it from _IO_file_doallocate, since that is likely
      to get called by any program that does buffered I/O. */
-  if (__builtin_expect (_IO_cleanup_registration_needed != NULL, 0))
+  if (__glibc_unlikely (_IO_cleanup_registration_needed != NULL))
     (*_IO_cleanup_registration_needed) ();
 #endif
 
@@ -109,7 +117,7 @@ _IO_file_doallocate (fp)
 #ifdef DEV_TTY_P
 	      DEV_TTY_P (&st) ||
 #endif
-	      isatty (fp->_fileno))
+	      local_isatty (fp->_fileno))
 	    fp->_flags |= _IO_LINE_BUF;
 	}
 #if _IO_HAVE_ST_BLKSIZE
@@ -118,7 +126,7 @@ _IO_file_doallocate (fp)
 #endif
     }
   ALLOC_BUF (p, size, EOF);
-  INTUSE(_IO_setb) (fp, p, p + size, 1);
+  _IO_setb (fp, p, p + size, 1);
   return 1;
 }
-INTDEF(_IO_file_doallocate)
+libc_hidden_def (_IO_file_doallocate)
diff --git a/src/system/libroot/posix/glibc/libio/fileno.c b/src/system/libroot/posix/glibc/libio/fileno.c
index cee6971b9a..92b0332c84 100644
--- a/src/system/libroot/posix/glibc/libio/fileno.c
+++ b/src/system/libroot/posix/glibc/libio/fileno.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,95,96,97,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/fileops.c b/src/system/libroot/posix/glibc/libio/fileops.c
index b83ea03139..c5d7684742 100644
--- a/src/system/libroot/posix/glibc/libio/fileops.c
+++ b/src/system/libroot/posix/glibc/libio/fileops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997-2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -39,17 +38,28 @@
 #include <string.h>
 #include <errno.h>
 #include <unistd.h>
-#ifdef __STDC__
 #include <stdlib.h>
+#if _LIBC
+# include "../wcsmbs/wcsmbsload.h"
+//# include "../iconv/gconv_charset.h"
+# include "../iconv/gconv_int.h"
+# include <shlib-compat.h>
+# include <not-cancel.h>
+//# include <kernel-features.h>
 #endif
+#ifndef errno
+extern int errno;
+#endif
+#ifndef __set_errno
+# define __set_errno(Val) errno = (Val)
+#endif
+
 
 #ifdef _LIBC
-/*# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
-# define close(FD) __close (FD)
-# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
-# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
-# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)*/
-# define _IO_do_write _IO_new_do_write /* For macro uses.  */
+# define open(Name, Flags, Prot) open (Name, Flags, Prot)
+# define lseek(FD, Offset, Whence) lseek (FD, Offset, Whence)
+# define read(FD, Buf, NBytes) read (FD, Buf, NBytes)
+# define write(FD, Buf, NBytes) write (FD, Buf, NBytes)
 #else
 # define _IO_new_do_write _IO_do_write
 # define _IO_new_file_attach _IO_file_attach
@@ -66,11 +76,11 @@
 # define _IO_new_file_xsputn _IO_file_xsputn
 #endif
 
-#if 0
+
 #ifdef _LIBC
 extern struct __gconv_trans_data __libio_translit attribute_hidden;
 #endif
-#endif
+
 
 /* An fstream can be in at most one of put mode, get mode, or putback mode.
    Putback mode is a variant of get mode.
@@ -81,7 +91,9 @@ extern struct __gconv_trans_data __libio_translit attribute_hidden;
 
    The position in the buffer that corresponds to the position
    in external file system is normally _IO_read_end, except in putback
-   mode, when it is _IO_save_end.
+   mode, when it is _IO_save_end and also when the file is in append mode,
+   since switching from read to write mode automatically sends the position in
+   the external file system to the end of file.
    If the field _fb._offset is >= 0, it gives the offset in
    the file as a whole corresponding to eGptr(). (?)
 
@@ -91,7 +103,7 @@ extern struct __gconv_trans_data __libio_translit attribute_hidden;
    to _IO_buf_base, though not necessarily if we have switched from
    get mode to put mode.  (The reason is to maintain the invariant
    that _IO_read_end corresponds to the external file position.)
-   _IO_write_base is non-NULL and usually equal to _IO_base_base.
+   _IO_write_base is non-NULL and usually equal to _IO_buf_base.
    We also have _IO_write_end == _IO_buf_end, but only in fully buffered mode.
    The un-flushed character are those between _IO_write_base and _IO_write_ptr.
 
@@ -136,10 +148,10 @@ _IO_new_file_init (fp)
   fp->file._offset = _IO_pos_BAD;
   fp->file._IO_file_flags |= CLOSED_FILEBUF_FLAGS;
 
-  INTUSE(_IO_link_in) (fp);
+  _IO_link_in (fp);
   fp->file._fileno = -1;
 }
-INTDEF2(_IO_new_file_init, _IO_file_init)
+libc_hidden_ver (_IO_new_file_init, _IO_file_init)
 
 int
 _IO_new_file_close_it (fp)
@@ -155,36 +167,34 @@ _IO_new_file_close_it (fp)
   else
     write_status = 0;
 
-  INTUSE(_IO_unsave_markers) (fp);
+  _IO_unsave_markers (fp);
 
-  close_status = _IO_SYSCLOSE (fp);
+  close_status = ((fp->_flags2 & _IO_FLAGS2_NOCLOSE) == 0
+		      ? _IO_SYSCLOSE (fp) : 0);
 
   /* Free buffer. */
-  if (fp->_mode <= 0)
-    {
-      INTUSE(_IO_setb) (fp, NULL, NULL, 0);
-      _IO_setg (fp, NULL, NULL, NULL);
-      _IO_setp (fp, NULL, NULL);
-    }
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-  else
+  if (fp->_mode > 0)
     {
       if (_IO_have_wbackup (fp))
-	INTUSE(_IO_free_wbackup_area) (fp);
-      INTUSE(_IO_wsetb) (fp, NULL, NULL, 0);
+	_IO_free_wbackup_area (fp);
+      _IO_wsetb (fp, NULL, NULL, 0);
       _IO_wsetg (fp, NULL, NULL, NULL);
       _IO_wsetp (fp, NULL, NULL);
     }
 #endif
+  _IO_setb (fp, NULL, NULL, 0);
+  _IO_setg (fp, NULL, NULL, NULL);
+  _IO_setp (fp, NULL, NULL);
 
-  INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
+  _IO_un_link ((struct _IO_FILE_plus *) fp);
   fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
   fp->_fileno = -1;
   fp->_offset = _IO_pos_BAD;
 
   return close_status ? close_status : write_status;
 }
-INTDEF2(_IO_new_file_close_it, _IO_file_close_it)
+libc_hidden_ver (_IO_new_file_close_it, _IO_file_close_it)
 
 void
 _IO_new_file_finish (fp, dummy)
@@ -197,13 +207,10 @@ _IO_new_file_finish (fp, dummy)
       if (!(fp->_flags & _IO_DELETE_DONT_CLOSE))
 	_IO_SYSCLOSE (fp);
     }
-  INTUSE(_IO_default_finish) (fp, 0);
+  _IO_default_finish (fp, 0);
 }
-INTDEF2(_IO_new_file_finish, _IO_file_finish)
+libc_hidden_ver (_IO_new_file_finish, _IO_file_finish)
 
-#if defined __GNUC__ && __GNUC__ >= 2
-__inline__
-#endif
 _IO_FILE *
 _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64)
      _IO_FILE *fp;
@@ -214,10 +221,12 @@ _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64)
      int is32not64;
 {
   int fdesc;
-#ifdef _G_OPEN64
-  fdesc = (is32not64
-	   ? open (filename, posix_mode, prot)
-	   : _G_OPEN64 (filename, posix_mode, prot));
+#ifdef _LIBC
+  if (__glibc_unlikely (fp->_flags2 & _IO_FLAGS2_NOTCANCEL))
+    fdesc = open_not_cancel (filename,
+			     posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
+  else
+    fdesc = open (filename, posix_mode | (is32not64 ? 0 : O_LARGEFILE), prot);
 #else
   fdesc = open (filename, posix_mode, prot);
 #endif
@@ -225,21 +234,29 @@ _IO_file_open (fp, filename, posix_mode, prot, read_write, is32not64)
     return NULL;
   fp->_fileno = fdesc;
   _IO_mask_flags (fp, read_write,_IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
-  if ((read_write & _IO_IS_APPENDING) && (read_write & _IO_NO_READS))
-    if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT)
-	== _IO_pos_BAD && errno != ESPIPE)
-      {
-	close (fdesc);
-	return NULL;
-      }
-  INTUSE(_IO_link_in) ((struct _IO_FILE_plus *) fp);
+  /* For append mode, send the file offset to the end of the file.  Don't
+     update the offset cache though, since the file handle is not active.  */
+  if ((read_write & (_IO_IS_APPENDING | _IO_NO_READS))
+      == (_IO_IS_APPENDING | _IO_NO_READS))
+    {
+      _IO_off64_t new_pos = _IO_SYSSEEK (fp, 0, _IO_seek_end);
+      if (new_pos == _IO_pos_BAD && errno != ESPIPE)
+	{
+	  close_not_cancel (fdesc);
+	  return NULL;
+	}
+    }
+  _IO_link_in ((struct _IO_FILE_plus *) fp);
   return fp;
 }
 libc_hidden_def (_IO_file_open)
 
-
 _IO_FILE *
-_IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is32not64)
+_IO_new_file_fopen (fp, filename, mode, is32not64)
+     _IO_FILE *fp;
+     const char *filename;
+     const char *mode;
+     int is32not64;
 {
   int oflags = 0, omode;
   int read_write;
@@ -247,7 +264,7 @@ _IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is3
   int i;
   _IO_FILE *result;
 #ifdef _LIBC
-//  const char *cs;
+  const char *cs;
   const char *last_recognized;
 #endif
 
@@ -276,7 +293,7 @@ _IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is3
 #ifdef _LIBC
   last_recognized = mode;
 #endif
-  for (i = 1; i < 5; ++i)
+  for (i = 1; i < 7; ++i)
     {
       switch (*++mode)
 	{
@@ -303,11 +320,15 @@ _IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is3
 	case 'm':
 	  fp->_flags2 |= _IO_FLAGS2_MMAP;
 	  continue;
-#ifdef O_CLOEXEC
+	case 'c':
+	  fp->_flags2 |= _IO_FLAGS2_NOTCANCEL;
+	  continue;
 	case 'e':
+#ifdef O_CLOEXEC
 	  oflags |= O_CLOEXEC;
-	  continue;
 #endif
+	  fp->_flags2 |= _IO_FLAGS2_CLOEXEC;
+	  continue;
 	default:
 	  /* Ignore.  */
 	  continue;
@@ -318,10 +339,23 @@ _IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is3
   result = _IO_file_open (fp, filename, omode|oflags, oprot, read_write,
 			  is32not64);
 
-#if 0
-#ifdef _LIBC
   if (result != NULL)
     {
+#ifndef __ASSUME_O_CLOEXEC
+      if ((fp->_flags2 & _IO_FLAGS2_CLOEXEC) != 0 && __have_o_cloexec <= 0)
+	{
+	  int fd = _IO_fileno (fp);
+	  if (__have_o_cloexec == 0)
+	    {
+	      int flags = __fcntl (fd, F_GETFD);
+	      __have_o_cloexec = (flags & FD_CLOEXEC) == 0 ? -1 : 1;
+	    }
+	  if (__have_o_cloexec < 0)
+	    __fcntl (fd, F_SETFD, FD_CLOEXEC);
+	}
+#endif
+
+#ifndef __HAIKU__
       /* Test whether the mode string specifies the conversion.  */
       cs = strstr (last_recognized + 1, ",ccs=");
       if (cs != NULL)
@@ -342,7 +376,7 @@ _IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is3
 	      /* Something went wrong, we cannot load the conversion modules.
 		 This means we cannot proceed since the user explicitly asked
 		 for these.  */
-	      (void) INTUSE(_IO_file_close_it) (fp);
+	      (void) _IO_file_close_it (fp);
 	      __set_errno (EINVAL);
 	      return NULL;
 	    }
@@ -385,26 +419,25 @@ _IO_new_file_fopen(_IO_FILE *fp, const char *filename, const char *mode, int is3
 	  /* And now the transliteration.  */
 	  cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
 
+	  /* From now on use the wide character callback functions.  */
+	  ((struct _IO_FILE_plus *) fp)->vtable = fp->_wide_data->_wide_vtable;
+
 	  /* Set the mode now.  */
 	  result->_mode = 1;
-
-	  /* We don't need the step data structure anymore.  */
-	  __gconv_release_cache (fcts.towc, fcts.towc_nsteps);
-	  __gconv_release_cache (fcts.tomb, fcts.tomb_nsteps);
 	}
-    }
-#endif	/* GNU libc */
 #endif
+    }
 
   return result;
 }
-INTDEF2(_IO_new_file_fopen, _IO_file_fopen)
+libc_hidden_ver (_IO_new_file_fopen, _IO_file_fopen)
 
 _IO_FILE *
 _IO_new_file_attach (fp, fd)
      _IO_FILE *fp;
      int fd;
 {
+  int save_errno;
   if (_IO_file_is_open (fp))
     return NULL;
   fp->_fileno = fd;
@@ -413,12 +446,14 @@ _IO_new_file_attach (fp, fd)
   /* Get the current position of the file. */
   /* We have to do that since that may be junk. */
   fp->_offset = _IO_pos_BAD;
+  save_errno = errno;
   if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT)
       == _IO_pos_BAD && errno != ESPIPE)
     return NULL;
+  __set_errno (save_errno);
   return fp;
 }
-INTDEF2(_IO_new_file_attach, _IO_file_attach)
+libc_hidden_ver (_IO_new_file_attach, _IO_file_attach)
 
 _IO_FILE *
 _IO_new_file_setbuf (fp, p, len)
@@ -435,33 +470,35 @@ _IO_new_file_setbuf (fp, p, len)
 
   return fp;
 }
-INTDEF2(_IO_new_file_setbuf, _IO_file_setbuf)
+libc_hidden_ver (_IO_new_file_setbuf, _IO_file_setbuf)
 
 
 _IO_FILE *
-_IO_file_setbuf_mmap(_IO_FILE *fp, char *p, _IO_ssize_t len)
+_IO_file_setbuf_mmap (fp, p, len)
+     _IO_FILE *fp;
+     char *p;
+     _IO_ssize_t len;
 {
-	_IO_FILE *result;
+  _IO_FILE *result;
 
-	/* Change the function table. */
-	_IO_JUMPS((struct _IO_FILE_plus *)fp) = &INTUSE(_IO_file_jumps);
-	fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
+  /* Change the function table.  */
+  _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps;
+  fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
 
-	/* And perform the normal operation. */
-	result = _IO_new_file_setbuf(fp, p, len);
+  /* And perform the normal operation.  */
+  result = _IO_new_file_setbuf (fp, p, len);
 
-#if HAVE_MMAP
-	/* If the call failed, restore to using mmap. */
-	if (result == NULL) {
-		_IO_JUMPS((struct _IO_FILE_plus *)fp) = &_IO_file_jumps_mmap;
-		fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
-	}
-#endif
+  /* If the call failed, restore to using mmap.  */
+  if (result == NULL)
+    {
+      _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps_mmap;
+      fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
+    }
 
-	return result;
+  return result;
 }
 
-static int new_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
+static _IO_size_t new_do_write (_IO_FILE *, const char *, _IO_size_t);
 
 /* Write TO_DO bytes from DATA to FP.
    Then mark FP as having empty buffers. */
@@ -475,10 +512,10 @@ _IO_new_do_write (fp, data, to_do)
   return (to_do == 0
 	  || (_IO_size_t) new_do_write (fp, data, to_do) == to_do) ? 0 : EOF;
 }
-INTDEF2(_IO_new_do_write, _IO_do_write)
+libc_hidden_ver (_IO_new_do_write, _IO_do_write)
 
 static
-int
+_IO_size_t
 new_do_write (fp, data, to_do)
      _IO_FILE *fp;
      const char *data;
@@ -488,7 +525,7 @@ new_do_write (fp, data, to_do)
   if (fp->_flags & _IO_IS_APPENDING)
     /* On a system without a proper O_APPEND implementation,
        you would need to sys_seek(0, SEEK_END) here, but is
-       is not needed nor desirable for Unix- or Posix-like systems.
+       not needed nor desirable for Unix- or Posix-like systems.
        Instead, just indicate that offset (before and after) is
        unpredictable. */
     fp->_offset = _IO_pos_BAD;
@@ -502,8 +539,7 @@ new_do_write (fp, data, to_do)
     }
   count = _IO_SYSWRITE (fp, data, to_do);
   if (fp->_cur_column && count)
-    fp->_cur_column = INTUSE(_IO_adjust_column) (fp->_cur_column - 1, data,
-						 count) + 1;
+    fp->_cur_column = _IO_adjust_column (fp->_cur_column - 1, data, count) + 1;
   _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
   fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_buf_base;
   fp->_IO_write_end = (fp->_mode <= 0
@@ -540,7 +576,7 @@ _IO_new_file_underflow (fp)
 	  free (fp->_IO_save_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
     }
 
   /* Flush all line buffered files before reading. */
@@ -548,27 +584,24 @@ _IO_new_file_underflow (fp)
   if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
     {
 #if 0
-      INTUSE(_IO_flush_all_linebuffered) ();
+      _IO_flush_all_linebuffered ();
 #else
       /* We used to flush all line-buffered stream.  This really isn't
 	 required by any standard.  My recollection is that
 	 traditional Unix systems did this for stdout.  stderr better
 	 not be line buffered.  So we do just that here
 	 explicitly.  --drepper */
-      _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-				_IO_stdout);
-      _IO_flockfile (_IO_stdout);
+      _IO_acquire_lock (_IO_stdout);
 
       if ((_IO_stdout->_flags & (_IO_LINKED | _IO_NO_WRITES | _IO_LINE_BUF))
 	  == (_IO_LINKED | _IO_LINE_BUF))
 	_IO_OVERFLOW (_IO_stdout, EOF);
 
-      _IO_funlockfile (_IO_stdout);
-      _IO_cleanup_region_end (0);
+      _IO_release_lock (_IO_stdout);
 #endif
     }
 
-  INTUSE(_IO_switch_to_get_mode) (fp);
+  _IO_switch_to_get_mode (fp);
 
   /* This is very tricky. We have to adjust those
      pointers before we call _IO_SYSREAD () since
@@ -595,9 +628,8 @@ _IO_new_file_underflow (fp)
     _IO_pos_adjust (fp->_offset, count);
   return *(unsigned char *) fp->_IO_read_ptr;
 }
-INTDEF2(_IO_new_file_underflow, _IO_file_underflow)
+libc_hidden_ver (_IO_new_file_underflow, _IO_file_underflow)
 
-#ifdef HAVE_MMAP
 /* Guts of underflow callback if we mmap the file.  This stats the file and
    updates the stream state to match.  In the normal case we return zero.
    If the file is no longer eligible for mmap, its jump tables are reset to
@@ -605,8 +637,9 @@ INTDEF2(_IO_new_file_underflow, _IO_file_underflow)
 static int
 mmap_remap_check (_IO_FILE *fp)
 {
-  struct _G_stat64 st;
+  struct stat64 st;
 
+#ifndef __HAIKU__
   if (_IO_SYSSTAT (fp, &st) == 0
       && S_ISREG (st.st_mode) && st.st_size != 0
       /* Limit the file size to 1MB for 32-bit machines.  */
@@ -628,7 +661,7 @@ mmap_remap_check (_IO_FILE *fp)
 	{
 	  /* The file added some pages.  We need to remap it.  */
 	  void *p;
-#if defined __linux__		/* XXX */
+#ifdef _G_HAVE_MREMAP
 	  p = __mremap (fp->_IO_buf_base, ROUNDED (fp->_IO_buf_end
 						   - fp->_IO_buf_base),
 			ROUNDED (st.st_size), MREMAP_MAYMOVE);
@@ -641,13 +674,8 @@ mmap_remap_check (_IO_FILE *fp)
 #else
 	  (void) __munmap (fp->_IO_buf_base,
 			   fp->_IO_buf_end - fp->_IO_buf_base);
-# ifdef _G_MMAP64
-	  p = _G_MMAP64 (NULL, st.st_size, PROT_READ, MAP_SHARED,
-			 fp->_fileno, 0);
-# else
-	  p = __mmap (NULL, st.st_size, PROT_READ, MAP_SHARED,
-		      fp->_fileno, 0);
-# endif
+	  p = __mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED,
+			fp->_fileno, 0);
 	  if (p == MAP_FAILED)
 	    goto punt;
 #endif
@@ -674,13 +702,8 @@ mmap_remap_check (_IO_FILE *fp)
 
       if (fp->_offset < fp->_IO_buf_end - fp->_IO_buf_base)
 	{
-	  if (
-# ifdef _G_LSEEK64
-	      _G_LSEEK64
-# else
-	      __lseek
-# endif
-	      (fp->_fileno, fp->_IO_buf_end - fp->_IO_buf_base, SEEK_SET)
+	  if (__lseek64 (fp->_fileno, fp->_IO_buf_end - fp->_IO_buf_base,
+			 SEEK_SET)
 	      != fp->_IO_buf_end - fp->_IO_buf_base)
 	    fp->_flags |= _IO_ERR_SEEN;
 	  else
@@ -691,25 +714,25 @@ mmap_remap_check (_IO_FILE *fp)
     }
   else
     {
-		/* Life is no longer good for mmap.  Punt it.  */
-		__munmap (fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base);
-
-punt:
-		fp->_IO_buf_base = fp->_IO_buf_end = NULL;
-		_IO_setg (fp, NULL, NULL, NULL);
-
-		if (fp->_mode <= 0)
-			_IO_JUMPS((struct _IO_FILE_plus *)fp) = &INTUSE(_IO_file_jumps);
-		else
-			_IO_JUMPS((struct _IO_FILE_plus *)fp) = &_IO_wfile_jumps;
-
-		fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
+      /* Life is no longer good for mmap.  Punt it.  */
+      (void) __munmap (fp->_IO_buf_base,
+		       fp->_IO_buf_end - fp->_IO_buf_base);
+    punt:
+#else
+    {
+#endif
+      fp->_IO_buf_base = fp->_IO_buf_end = NULL;
+      _IO_setg (fp, NULL, NULL, NULL);
+      if (fp->_mode <= 0)
+	_IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps;
+      else
+	_IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps;
+      fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
 
-		return 1;
-	}
+      return 1;
+    }
 }
 
-
 /* Special callback replacing the underflow callbacks if we mmap the file.  */
 int
 _IO_file_underflow_mmap (_IO_FILE *fp)
@@ -717,7 +740,7 @@ _IO_file_underflow_mmap (_IO_FILE *fp)
   if (fp->_IO_read_ptr < fp->_IO_read_end)
     return *(unsigned char *) fp->_IO_read_ptr;
 
-  if (__builtin_expect (mmap_remap_check (fp), 0))
+  if (__glibc_unlikely (mmap_remap_check (fp)))
     /* We punted to the regular file functions.  */
     return _IO_UNDERFLOW (fp);
 
@@ -728,80 +751,69 @@ _IO_file_underflow_mmap (_IO_FILE *fp)
   return EOF;
 }
 
-
 static void
-decide_maybe_mmap(_IO_FILE *fp)
+decide_maybe_mmap (_IO_FILE *fp)
 {
-	/* We use the file in read-only mode.  This could mean we can
-	 * mmap the file and use it without any copying.  But not all
-	 * file descriptors are for mmap-able objects and on 32-bit
-	 * machines we don't want to map files which are too large since
-	 * this would require too much virtual memory.
-	 */
-	struct _G_stat64 st;
-
-	if (_IO_SYSSTAT(fp, &st) == 0
-		&& S_ISREG (st.st_mode) && st.st_size != 0
-		/* Limit the file size to 1MB for 32-bit machines.  */
-		&& (sizeof(ptrdiff_t) > 4 || st.st_size < 1*1024*1024)
-		/* Sanity check.  */
-		&& (fp->_offset == _IO_pos_BAD || fp->_offset <= st.st_size))
+#ifndef __HAIKU__
+  /* We use the file in read-only mode.  This could mean we can
+     mmap the file and use it without any copying.  But not all
+     file descriptors are for mmap-able objects and on 32-bit
+     machines we don't want to map files which are too large since
+     this would require too much virtual memory.  */
+  struct stat64 st;
+
+  if (_IO_SYSSTAT (fp, &st) == 0
+      && S_ISREG (st.st_mode) && st.st_size != 0
+      /* Limit the file size to 1MB for 32-bit machines.  */
+      && (sizeof (ptrdiff_t) > 4 || st.st_size < 1*1024*1024)
+      /* Sanity check.  */
+      && (fp->_offset == _IO_pos_BAD || fp->_offset <= st.st_size))
+    {
+      /* Try to map the file.  */
+      void *p;
+
+      p = __mmap64 (NULL, st.st_size, PROT_READ, MAP_SHARED, fp->_fileno, 0);
+      if (p != MAP_FAILED)
 	{
-		/* Try to map the file.  */
-		void *p;
-
-# ifdef _G_MMAP64
-		p = _G_MMAP64(NULL, st.st_size, PROT_READ, MAP_SHARED, fp->_fileno, 0);
-# else
-		p = __mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fp->_fileno, 0);
-# endif
-
-		if (p != MAP_FAILED) {
-			/* OK, we managed to map the file.  Set the buffer up and use a
-			 * special jump table with simplified underflow functions which
-			 * never tries to read anything from the file.
-			 */
-
-			if (
-# ifdef _G_LSEEK64
-	      _G_LSEEK64
-# else
-	      __lseek
-# endif
-				(fp->_fileno, st.st_size, SEEK_SET) != st.st_size) {
-				(void) __munmap (p, st.st_size);
-				fp->_offset = _IO_pos_BAD;
-			} else {
-				INTUSE(_IO_setb) (fp, p, (char *) p + st.st_size, 0);
-
-				if (fp->_offset == _IO_pos_BAD)
-					fp->_offset = 0;
-
-				_IO_setg (fp, p, p + fp->_offset, p + st.st_size);
-				fp->_offset = st.st_size;
-
-				if (fp->_mode <= 0)
-					_IO_JUMPS((struct _IO_FILE_plus *)fp) = &_IO_file_jumps_mmap;
-				else
-					_IO_JUMPS((struct _IO_FILE_plus *)fp) = &_IO_wfile_jumps_mmap;
-
-				fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
-
-				return;
-			}
-		}
-	}
+	  /* OK, we managed to map the file.  Set the buffer up and use a
+	     special jump table with simplified underflow functions which
+	     never tries to read anything from the file.  */
 
-	/* We couldn't use mmap, so revert to the vanilla file operations. */
+	  if (__lseek64 (fp->_fileno, st.st_size, SEEK_SET) != st.st_size)
+	    {
+	      (void) __munmap (p, st.st_size);
+	      fp->_offset = _IO_pos_BAD;
+	    }
+	  else
+	    {
+	      _IO_setb (fp, p, (char *) p + st.st_size, 0);
 
-	if (fp->_mode <= 0)
-		_IO_JUMPS((struct _IO_FILE_plus *)fp) = &INTUSE(_IO_file_jumps);
-	else
-		_IO_JUMPS((struct _IO_FILE_plus *)fp) = &_IO_wfile_jumps;
+	      if (fp->_offset == _IO_pos_BAD)
+		fp->_offset = 0;
 
-	fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
-}
+	      _IO_setg (fp, p, p + fp->_offset, p + st.st_size);
+	      fp->_offset = st.st_size;
+
+	      if (fp->_mode <= 0)
+		_IO_JUMPS ((struct _IO_FILE_plus *)fp) = &_IO_file_jumps_mmap;
+	      else
+		_IO_JUMPS ((struct _IO_FILE_plus *)fp) = &_IO_wfile_jumps_mmap;
+	      fp->_wide_data->_wide_vtable = &_IO_wfile_jumps_mmap;
+
+	      return;
+	    }
+	}
+    }
+#endif
 
+  /* We couldn't use mmap, so revert to the vanilla file operations.  */
+
+  if (fp->_mode <= 0)
+    _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps;
+  else
+    _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_wfile_jumps;
+  fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
+}
 
 int
 _IO_file_underflow_maybe_mmap (_IO_FILE *fp)
@@ -811,7 +823,6 @@ _IO_file_underflow_maybe_mmap (_IO_FILE *fp)
   decide_maybe_mmap (fp);
   return _IO_UNDERFLOW (fp);
 }
-#endif	/* HAVE_MMAP */
 
 
 int
@@ -826,12 +837,12 @@ _IO_new_file_overflow (f, ch)
       return EOF;
     }
   /* If currently reading or no buffer allocated. */
-  if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == 0)
+  if ((f->_flags & _IO_CURRENTLY_PUTTING) == 0 || f->_IO_write_base == NULL)
     {
       /* Allocate a buffer if needed. */
-      if (f->_IO_write_base == 0)
+      if (f->_IO_write_base == NULL)
 	{
-	  INTUSE(_IO_doallocbuf) (f);
+	  _IO_doallocbuf (f);
 	  _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
 	}
       /* Otherwise must be currently reading.
@@ -841,6 +852,15 @@ _IO_new_file_overflow (f, ch)
 	 makes room for subsequent output.
 	 Otherwise, set the read pointers to _IO_read_end (leaving that
 	 alone, so it can continue to correspond to the external position). */
+      if (__glibc_unlikely (_IO_in_backup (f)))
+	{
+	  size_t nbackup = f->_IO_read_end - f->_IO_read_ptr;
+	  _IO_free_backup_area (f);
+	  f->_IO_read_base -= MIN (nbackup,
+				   f->_IO_read_base - f->_IO_buf_base);
+	  f->_IO_read_ptr = f->_IO_read_base;
+	}
+
       if (f->_IO_read_ptr == f->_IO_buf_end)
 	f->_IO_read_end = f->_IO_read_ptr = f->_IO_buf_base;
       f->_IO_write_ptr = f->_IO_read_ptr;
@@ -853,20 +873,20 @@ _IO_new_file_overflow (f, ch)
 	f->_IO_write_end = f->_IO_write_ptr;
     }
   if (ch == EOF)
-    return INTUSE(_IO_do_write) (f, f->_IO_write_base,
-				 f->_IO_write_ptr - f->_IO_write_base);
+    return _IO_do_write (f, f->_IO_write_base,
+			 f->_IO_write_ptr - f->_IO_write_base);
   if (f->_IO_write_ptr == f->_IO_buf_end ) /* Buffer is really full */
     if (_IO_do_flush (f) == EOF)
       return EOF;
   *f->_IO_write_ptr++ = ch;
   if ((f->_flags & _IO_UNBUFFERED)
       || ((f->_flags & _IO_LINE_BUF) && ch == '\n'))
-    if (INTUSE(_IO_do_write) (f, f->_IO_write_base,
-			      f->_IO_write_ptr - f->_IO_write_base) == EOF)
+    if (_IO_do_write (f, f->_IO_write_base,
+		      f->_IO_write_ptr - f->_IO_write_base) == EOF)
       return EOF;
   return (unsigned char) ch;
 }
-INTDEF2(_IO_new_file_overflow, _IO_file_overflow)
+libc_hidden_ver (_IO_new_file_overflow, _IO_file_overflow)
 
 int
 _IO_new_file_sync (fp)
@@ -879,6 +899,13 @@ _IO_new_file_sync (fp)
   if (fp->_IO_write_ptr > fp->_IO_write_base)
     if (_IO_do_flush(fp)) return EOF;
   delta = fp->_IO_read_ptr - fp->_IO_read_end;
+#ifdef __HAIKU__ /* imported from upstream 2.42 */
+  if (_IO_in_backup (fp))
+    {
+      _IO_switch_to_main_get_area (fp);
+      delta += fp->_IO_read_ptr - fp->_IO_read_end;
+    }
+#endif
   if (delta != 0)
     {
 #ifdef TODO
@@ -901,9 +928,8 @@ _IO_new_file_sync (fp)
   /*    setg(base(), ptr, ptr); */
   return retval;
 }
-INTDEF2(_IO_new_file_sync, _IO_file_sync)
+libc_hidden_ver (_IO_new_file_sync, _IO_file_sync)
 
-#ifdef HAVE_MMAP
 static int
 _IO_file_sync_mmap (_IO_FILE *fp)
 {
@@ -913,13 +939,8 @@ _IO_file_sync_mmap (_IO_FILE *fp)
       if (_IO_in_backup (fp))
 	delta -= eGptr () - Gbase ();
 #endif
-      if (
-# ifdef _G_LSEEK64
-	  _G_LSEEK64
-# else
-	  __lseek
-# endif
-	  (fp->_fileno, fp->_IO_read_ptr - fp->_IO_buf_base, SEEK_SET)
+      if (lseek (fp->_fileno, fp->_IO_read_ptr - fp->_IO_buf_base,
+		     SEEK_SET)
 	  != fp->_IO_read_ptr - fp->_IO_buf_base)
 	{
 	  fp->_flags |= _IO_ERR_SEEN;
@@ -930,8 +951,69 @@ _IO_file_sync_mmap (_IO_FILE *fp)
   fp->_IO_read_end = fp->_IO_read_ptr = fp->_IO_read_base;
   return 0;
 }
-#endif	/* HAVE_MMAP */
 
+/* ftell{,o} implementation.  The only time we modify the state of the stream
+   is when we have unflushed writes.  In that case we seek to the end and
+   record that offset in the stream object.  */
+static _IO_off64_t
+do_ftell (_IO_FILE *fp)
+{
+  _IO_off64_t result, offset = 0;
+
+  /* No point looking at unflushed data if we haven't allocated buffers
+     yet.  */
+  if (fp->_IO_buf_base != NULL)
+    {
+      int was_writing = (fp->_IO_write_ptr > fp->_IO_write_base
+			  || _IO_in_put_mode (fp));
+
+      int append_mode = (fp->_flags & _IO_IS_APPENDING) == _IO_IS_APPENDING;
+
+      /* When we have unflushed writes in append mode, seek to the end of the
+	 file and record that offset.  This is the only time we change the file
+	 stream state and it is safe since the file handle is active.  */
+      if (was_writing && append_mode)
+	{
+	  result = _IO_SYSSEEK (fp, 0, _IO_seek_end);
+	  if (result == _IO_pos_BAD)
+	    return EOF;
+	  else
+	    fp->_offset = result;
+	}
+
+      /* Adjust for unflushed data.  */
+      if (!was_writing)
+	offset -= fp->_IO_read_end - fp->_IO_read_ptr;
+      /* We don't trust _IO_read_end to represent the current file offset when
+	 writing in append mode because the value would have to be shifted to
+	 the end of the file during a flush.  Use the write base instead, along
+	 with the new offset we got above when we did a seek to the end of the
+	 file.  */
+      else if (append_mode)
+	offset += fp->_IO_write_ptr - fp->_IO_write_base;
+      /* For all other modes, _IO_read_end represents the file offset.  */
+      else
+	offset += fp->_IO_write_ptr - fp->_IO_read_end;
+    }
+
+  if (fp->_offset != _IO_pos_BAD)
+    result = fp->_offset;
+  else
+    result = _IO_SYSSEEK (fp, 0, _IO_seek_cur);
+
+  if (result == EOF)
+    return result;
+
+  result += offset;
+
+  if (result < 0)
+    {
+      __set_errno (EINVAL);
+      return EOF;
+    }
+
+  return result;
+}
 
 _IO_off64_t
 _IO_new_file_seekoff (fp, offset, dir, mode)
@@ -943,25 +1025,31 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
   _IO_off64_t result;
   _IO_off64_t delta, new_offset;
   long count;
+  int must_be_exact, was_writing;
+
+  /* Short-circuit into a separate function.  We don't want to mix any
+     functionality and we don't want to touch anything inside the FILE
+     object. */
+  if (mode == 0)
+    return do_ftell (fp);
+
   /* POSIX.1 8.2.3.7 says that after a call the fflush() the file
      offset of the underlying file must be exact.  */
-  int must_be_exact = (fp->_IO_read_base == fp->_IO_read_end
+  must_be_exact = (fp->_IO_read_base == fp->_IO_read_end
 		       && fp->_IO_write_base == fp->_IO_write_ptr);
 
-  if (mode == 0)
-    dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */
+  was_writing = (fp->_IO_write_ptr > fp->_IO_write_base
+		      || _IO_in_put_mode (fp));
 
   /* Flush unwritten characters.
      (This may do an unneeded write if we seek within the buffer.
      But to be able to switch to reading, we would need to set
-     egptr to ptr.  That can't be done in the current design,
+     egptr to pptr.  That can't be done in the current design,
      which assumes file_ptr() is eGptr.  Anyway, since we probably
      end up flushing when we close(), it doesn't make much difference.)
-     FIXME: simulate mem-papped files. */
-
-  if (fp->_IO_write_ptr > fp->_IO_write_base || _IO_in_put_mode (fp))
-    if (INTUSE(_IO_switch_to_get_mode) (fp))
-      return EOF;
+     FIXME: simulate mem-mapped files. */
+  if (was_writing && _IO_switch_to_get_mode (fp))
+    return EOF;
 
   if (fp->_IO_buf_base == NULL)
     {
@@ -971,7 +1059,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
 	  free (fp->_IO_read_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
       _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
       _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
     }
@@ -981,6 +1069,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
     case _IO_seek_cur:
       /* Adjust for read-ahead (bytes is buffer). */
       offset -= fp->_IO_read_end - fp->_IO_read_ptr;
+
       if (fp->_offset == _IO_pos_BAD)
 	goto dumb;
       /* Make offset absolute, assuming current pointer is file_ptr(). */
@@ -997,7 +1086,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
       break;
     case _IO_seek_end:
       {
-	struct _G_stat64 st;
+	struct stat64 st;
 	if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
 	  {
 	    offset += st.st_size;
@@ -1009,62 +1098,24 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
     }
   /* At this point, dir==_IO_seek_set. */
 
-  /* If we are only interested in the current position we've found it now.  */
-  if (mode == 0)
-    return offset;
-
   /* If destination is within current buffer, optimize: */
   if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
       && !_IO_in_backup (fp))
     {
-      /* Offset relative to start of main get area. */
-      _IO_off64_t rel_offset = (offset - fp->_offset
-				+ (fp->_IO_read_end - fp->_IO_buf_base));
-      if (rel_offset >= 0)
+      _IO_off64_t start_offset = (fp->_offset
+				  - (fp->_IO_read_end - fp->_IO_buf_base));
+      if (offset >= start_offset && offset < fp->_offset)
 	{
-#if 0
-	  if (_IO_in_backup (fp))
-	    _IO_switch_to_main_get_area (fp);
-#endif
-	  if (rel_offset <= fp->_IO_read_end - fp->_IO_buf_base)
-	    {
-	      _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + rel_offset,
-			fp->_IO_read_end);
-	      _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
-	      {
-		_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
-		goto resync;
-	      }
-	    }
-#ifdef TODO
-	    /* If we have streammarkers, seek forward by reading ahead. */
-	    if (_IO_have_markers (fp))
-	      {
-		int to_skip = rel_offset
-		  - (fp->_IO_read_ptr - fp->_IO_read_base);
-		if (ignore (to_skip) != to_skip)
-		  goto dumb;
-		_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
-		goto resync;
-	      }
-#endif
-	}
-#ifdef TODO
-      if (rel_offset < 0 && rel_offset >= Bbase () - Bptr ())
-	{
-	  if (!_IO_in_backup (fp))
-	    _IO_switch_to_backup_area (fp);
-	  gbump (fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
+	  _IO_setg (fp, fp->_IO_buf_base,
+		    fp->_IO_buf_base + (offset - start_offset),
+		    fp->_IO_read_end);
+	  _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+
 	  _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
 	  goto resync;
 	}
-#endif
     }
 
-#ifdef TODO
-  INTUSE(_IO_unsave_markers) (fp);
-#endif
-
   if (fp->_flags & _IO_NO_READS)
     goto dumb;
 
@@ -1102,7 +1153,7 @@ _IO_new_file_seekoff (fp, offset, dir, mode)
   return offset;
  dumb:
 
-  INTUSE(_IO_unsave_markers) (fp);
+  _IO_unsave_markers (fp);
   result = _IO_SYSSEEK (fp, offset, dir);
   if (result != EOF)
     {
@@ -1117,13 +1168,13 @@ resync:
   /* We need to do it since it is possible that the file offset in
      the kernel may be changed behind our back. It may happen when
      we fopen a file and then do a fork. One process may access the
-     the file and the kernel file offset will be changed. */
+     file and the kernel file offset will be changed. */
   if (fp->_offset >= 0)
     _IO_SYSSEEK (fp, fp->_offset, 0);
 
   return offset;
 }
-INTDEF2(_IO_new_file_seekoff, _IO_file_seekoff)
+libc_hidden_ver (_IO_new_file_seekoff, _IO_file_seekoff)
 
 _IO_off64_t
 _IO_file_seekoff_mmap (fp, offset, dir, mode)
@@ -1184,7 +1235,6 @@ _IO_file_seekoff_mmap (fp, offset, dir, mode)
   return offset;
 }
 
-#ifdef HAVE_MMAP
 static _IO_off64_t
 _IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir,
 			     int mode)
@@ -1200,7 +1250,6 @@ _IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir,
   fp->_offset = result;
   return result;
 }
-#endif	/* HAVE_MMAP */
 
 _IO_ssize_t
 _IO_file_read (fp, buf, size)
@@ -1208,9 +1257,11 @@ _IO_file_read (fp, buf, size)
      void *buf;
      _IO_ssize_t size;
 {
-  return read (fp->_fileno, buf, size);
+  return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0)
+	  ? read_not_cancel (fp->_fileno, buf, size)
+	  : read (fp->_fileno, buf, size));
 }
-INTDEF(_IO_file_read)
+libc_hidden_def (_IO_file_read)
 
 _IO_off64_t
 _IO_file_seek (fp, offset, dir)
@@ -1218,46 +1269,42 @@ _IO_file_seek (fp, offset, dir)
      _IO_off64_t offset;
      int dir;
 {
-#ifdef _G_LSEEK64
-  return _G_LSEEK64 (fp->_fileno, offset, dir);
-#else
   return lseek (fp->_fileno, offset, dir);
-#endif
 }
-INTDEF(_IO_file_seek)
+libc_hidden_def (_IO_file_seek)
 
 int
 _IO_file_stat (fp, st)
      _IO_FILE *fp;
      void *st;
 {
-#ifdef _G_FSTAT64
-  return _G_FSTAT64 (fp->_fileno, (struct _G_stat64 *) st);
-#else
-  return fstat (fp->_fileno, (struct stat *) st);
-#endif
+  return fstat (fp->_fileno, (struct stat64 *) st);
 }
-INTDEF(_IO_file_stat)
+libc_hidden_def (_IO_file_stat)
 
-#ifdef HAVE_MMAP
 int
 _IO_file_close_mmap (fp)
      _IO_FILE *fp;
 {
+#ifndef __HAIKU__
   /* In addition to closing the file descriptor we have to unmap the file.  */
   (void) __munmap (fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base);
+#endif
   fp->_IO_buf_base = fp->_IO_buf_end = NULL;
-  return close (fp->_fileno);
+  /* Cancelling close should be avoided if possible since it leaves an
+     unrecoverable state behind.  */
+  return close_not_cancel (fp->_fileno);
 }
-#endif
 
 int
 _IO_file_close (fp)
      _IO_FILE *fp;
 {
-  return close (fp->_fileno);
+  /* Cancelling close should be avoided if possible since it leaves an
+     unrecoverable state behind.  */
+  return close_not_cancel (fp->_fileno);
 }
-INTDEF(_IO_file_close)
+libc_hidden_def (_IO_file_close)
 
 _IO_ssize_t
 _IO_new_file_write (f, data, n)
@@ -1268,12 +1315,15 @@ _IO_new_file_write (f, data, n)
   _IO_ssize_t to_do = n;
   while (to_do > 0)
     {
-      _IO_ssize_t count = write (f->_fileno, data, to_do);
+      _IO_ssize_t count = (__builtin_expect (f->_flags2
+					     & _IO_FLAGS2_NOTCANCEL, 0)
+			   ? write_not_cancel (f->_fileno, data, to_do)
+			   : write (f->_fileno, data, to_do));
       if (count < 0)
 	{
 	  f->_flags |= _IO_ERR_SEEN;
 	  break;
-        }
+	}
       to_do -= count;
       data = (void *) ((char *) data + count);
     }
@@ -1289,10 +1339,10 @@ _IO_new_file_xsputn (f, data, n)
      const void *data;
      _IO_size_t n;
 {
-  register const char *s = (const char *) data;
+  const char *s = (const char *) data;
   _IO_size_t to_do = n;
   int must_flush = 0;
-  _IO_size_t count;
+  _IO_size_t count = 0;
 
   if (n <= 0)
     return 0;
@@ -1301,13 +1351,12 @@ _IO_new_file_xsputn (f, data, n)
      (or the filebuf is unbuffered), use sys_write directly. */
 
   /* First figure out how much space is available in the buffer. */
-  count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
   if ((f->_flags & _IO_LINE_BUF) && (f->_flags & _IO_CURRENTLY_PUTTING))
     {
       count = f->_IO_buf_end - f->_IO_write_ptr;
       if (count >= n)
 	{
-	  register const char *p;
+	  const char *p;
 	  for (p = s + n; p > s; )
 	    {
 	      if (*--p == '\n')
@@ -1319,29 +1368,21 @@ _IO_new_file_xsputn (f, data, n)
 	    }
 	}
     }
+  else if (f->_IO_write_end > f->_IO_write_ptr)
+    count = f->_IO_write_end - f->_IO_write_ptr; /* Space available. */
+
   /* Then fill the buffer. */
   if (count > 0)
     {
       if (count > to_do)
 	count = to_do;
-      if (count > 20)
-	{
 #ifdef _LIBC
-	  f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
+      f->_IO_write_ptr = __mempcpy (f->_IO_write_ptr, s, count);
 #else
-	  memcpy (f->_IO_write_ptr, s, count);
-	  f->_IO_write_ptr += count;
+      memcpy (f->_IO_write_ptr, s, count);
+      f->_IO_write_ptr += count;
 #endif
-	  s += count;
-	}
-      else
-	{
-	  register char *p = f->_IO_write_ptr;
-	  register int i = (int) count;
-	  while (--i >= 0)
-	    *p++ = *s++;
-	  f->_IO_write_ptr = p;
-	}
+      s += count;
       to_do -= count;
     }
   if (to_do + must_flush > 0)
@@ -1349,30 +1390,31 @@ _IO_new_file_xsputn (f, data, n)
       _IO_size_t block_size, do_write;
       /* Next flush the (full) buffer. */
       if (_IO_OVERFLOW (f, EOF) == EOF)
-	return n - to_do;
+	/* If nothing else has to be written we must not signal the
+	   caller that everything has been written.  */
+	return to_do == 0 ? EOF : n - to_do;
 
-      /* Try to maintain alignment: write a whole number of blocks.
-	 dont_write is what gets left over. */
+      /* Try to maintain alignment: write a whole number of blocks.  */
       block_size = f->_IO_buf_end - f->_IO_buf_base;
       do_write = to_do - (block_size >= 128 ? to_do % block_size : 0);
 
       if (do_write)
-        {
+	{
 	  count = new_do_write (f, s, do_write);
 	  to_do -= count;
 	  if (count < do_write)
 	    return n - to_do;
-        }
+	}
 
       /* Now write out the remainder.  Normally, this will fit in the
 	 buffer, but it's somewhat messier for line-buffered files,
 	 so we let _IO_default_xsputn handle the general case. */
       if (to_do)
-	to_do -= INTUSE(_IO_default_xsputn) (f, s+do_write, to_do);
+	to_do -= _IO_default_xsputn (f, s+do_write, to_do);
     }
   return n - to_do;
 }
-INTDEF2(_IO_new_file_xsputn, _IO_file_xsputn)
+libc_hidden_ver (_IO_new_file_xsputn, _IO_file_xsputn)
 
 _IO_size_t
 _IO_file_xsgetn (fp, data, n)
@@ -1380,9 +1422,9 @@ _IO_file_xsgetn (fp, data, n)
      void *data;
      _IO_size_t n;
 {
-  register _IO_size_t want, have;
-  register _IO_ssize_t count;
-  register char *s = data;
+  _IO_size_t want, have;
+  _IO_ssize_t count;
+  char *s = data;
 
   want = n;
 
@@ -1394,7 +1436,7 @@ _IO_file_xsgetn (fp, data, n)
 	  free (fp->_IO_save_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
     }
 
   while (want > 0)
@@ -1473,25 +1515,24 @@ _IO_file_xsgetn (fp, data, n)
 
   return n - want;
 }
-INTDEF(_IO_file_xsgetn)
+libc_hidden_def (_IO_file_xsgetn)
 
-#ifdef HAVE_MMAP
-static _IO_size_t _IO_file_xsgetn_mmap __P ((_IO_FILE *, void *, _IO_size_t));
+static _IO_size_t _IO_file_xsgetn_mmap (_IO_FILE *, void *, _IO_size_t);
 static _IO_size_t
 _IO_file_xsgetn_mmap (fp, data, n)
      _IO_FILE *fp;
      void *data;
      _IO_size_t n;
 {
-  register _IO_size_t have;
+  _IO_size_t have;
   char *read_ptr = fp->_IO_read_ptr;
-  register char *s = (char *) data;
+  char *s = (char *) data;
 
   have = fp->_IO_read_end - fp->_IO_read_ptr;
 
   if (have < n)
     {
-      if (__builtin_expect (_IO_in_backup (fp), 0))
+      if (__glibc_unlikely (_IO_in_backup (fp)))
 	{
 #ifdef _LIBC
 	  s = __mempcpy (s, read_ptr, have);
@@ -1508,7 +1549,7 @@ _IO_file_xsgetn_mmap (fp, data, n)
       if (have < n)
 	{
 	  /* Check that we are mapping all of the file, in case it grew.  */
-	  if (__builtin_expect (mmap_remap_check (fp), 0))
+	  if (__glibc_unlikely (mmap_remap_check (fp)))
 	    /* We punted mmap, so complete with the vanilla code.  */
 	    return s - (char *) data + _IO_XSGETN (fp, data, n);
 
@@ -1535,8 +1576,7 @@ _IO_file_xsgetn_mmap (fp, data, n)
   return s - (char *) data;
 }
 
-static _IO_size_t _IO_file_xsgetn_maybe_mmap __P ((_IO_FILE *, void *,
-						   _IO_size_t));
+static _IO_size_t _IO_file_xsgetn_maybe_mmap (_IO_FILE *, void *, _IO_size_t);
 static _IO_size_t
 _IO_file_xsgetn_maybe_mmap (fp, data, n)
      _IO_FILE *fp;
@@ -1549,10 +1589,8 @@ _IO_file_xsgetn_maybe_mmap (fp, data, n)
   decide_maybe_mmap (fp);
   return _IO_XSGETN (fp, data, n);
 }
-#endif	/* HAVE_MMAP */
 
 #ifdef _LIBC
-# undef _IO_do_write
 versioned_symbol (libc, _IO_new_do_write, _IO_do_write, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_attach, _IO_file_attach, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_close_it, _IO_file_close_it, GLIBC_2_1);
@@ -1568,77 +1606,75 @@ versioned_symbol (libc, _IO_new_file_write, _IO_file_write, GLIBC_2_1);
 versioned_symbol (libc, _IO_new_file_xsputn, _IO_file_xsputn, GLIBC_2_1);
 #endif
 
-struct _IO_jump_t _IO_file_jumps =
+const struct _IO_jump_t _IO_file_jumps =
 {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, INTUSE(_IO_file_finish)),
-  JUMP_INIT(overflow, INTUSE(_IO_file_overflow)),
-  JUMP_INIT(underflow, INTUSE(_IO_file_underflow)),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_file_xsgetn)),
+  JUMP_INIT(finish, _IO_file_finish),
+  JUMP_INIT(overflow, _IO_file_overflow),
+  JUMP_INIT(underflow, _IO_file_underflow),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
+  JUMP_INIT(xsputn, _IO_file_xsputn),
+  JUMP_INIT(xsgetn, _IO_file_xsgetn),
   JUMP_INIT(seekoff, _IO_new_file_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_new_file_setbuf),
   JUMP_INIT(sync, _IO_new_file_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
-  JUMP_INIT(close, INTUSE(_IO_file_close)),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(seek, _IO_file_seek),
+  JUMP_INIT(close, _IO_file_close),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
-INTVARDEF(_IO_file_jumps)
+libc_hidden_data_def (_IO_file_jumps)
 
-#ifdef HAVE_MMAP
-struct _IO_jump_t _IO_file_jumps_mmap =
+const struct _IO_jump_t _IO_file_jumps_mmap =
 {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, INTUSE(_IO_file_finish)),
-  JUMP_INIT(overflow, INTUSE(_IO_file_overflow)),
+  JUMP_INIT(finish, _IO_file_finish),
+  JUMP_INIT(overflow, _IO_file_overflow),
   JUMP_INIT(underflow, _IO_file_underflow_mmap),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
   JUMP_INIT(xsputn, _IO_new_file_xsputn),
   JUMP_INIT(xsgetn, _IO_file_xsgetn_mmap),
   JUMP_INIT(seekoff, _IO_file_seekoff_mmap),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, (_IO_setbuf_t) _IO_file_setbuf_mmap),
   JUMP_INIT(sync, _IO_file_sync_mmap),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
+  JUMP_INIT(seek, _IO_file_seek),
   JUMP_INIT(close, _IO_file_close_mmap),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
 
-struct _IO_jump_t _IO_file_jumps_maybe_mmap =
+const struct _IO_jump_t _IO_file_jumps_maybe_mmap =
 {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, INTUSE(_IO_file_finish)),
-  JUMP_INIT(overflow, INTUSE(_IO_file_overflow)),
+  JUMP_INIT(finish, _IO_file_finish),
+  JUMP_INIT(overflow, _IO_file_overflow),
   JUMP_INIT(underflow, _IO_file_underflow_maybe_mmap),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
   JUMP_INIT(xsputn, _IO_new_file_xsputn),
   JUMP_INIT(xsgetn, _IO_file_xsgetn_maybe_mmap),
   JUMP_INIT(seekoff, _IO_file_seekoff_maybe_mmap),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, (_IO_setbuf_t) _IO_file_setbuf_mmap),
   JUMP_INIT(sync, _IO_new_file_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
+  JUMP_INIT(seek, _IO_file_seek),
   JUMP_INIT(close, _IO_file_close),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
-#endif	/* HAVE_MMAP */
diff --git a/src/system/libroot/posix/glibc/libio/flockfile.c b/src/system/libroot/posix/glibc/libio/flockfile.c
index e51ad51b1c..5f3effe604 100644
--- a/src/system/libroot/posix/glibc/libio/flockfile.c
+++ b/src/system/libroot/posix/glibc/libio/flockfile.c
@@ -1,8 +1,19 @@
-/* 
- * Copyright 2003-2007, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
- * Distributed under the terms of the MIT License.
- */
+/* Copyright (C) 1996-2014 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 Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 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
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 
@@ -14,23 +25,19 @@
 void
 _IO_flockfile(_IO_FILE *stream)
 {
-	__libc_lock_lock_recursive(*stream->_lock);
+	_IO_lock_lock (*stream->_lock);
 }
 
-
 void
 _IO_funlockfile(_IO_FILE *stream)
 {
-	__libc_lock_unlock_recursive(*stream->_lock);
+	_IO_lock_unlock (*stream->_lock);
 }
 
-
 int
 _IO_ftrylockfile(_IO_FILE *stream)
 {
-	// ToDo: that code has probably never been tested!
-	//return __libc_lock_trylock_recursive(*stream->_lock);
-	return 1;
+	return _IO_lock_trylock (*stream->_lock);
 }
 
 weak_alias (_IO_flockfile, flockfile);
diff --git a/src/system/libroot/posix/glibc/libio/fmemopen.c b/src/system/libroot/posix/glibc/libio/fmemopen.c
index ab6ffdd678..aee26963a3 100644
--- a/src/system/libroot/posix/glibc/libio/fmemopen.c
+++ b/src/system/libroot/posix/glibc/libio/fmemopen.c
@@ -1,7 +1,7 @@
 /* Fmemopen implementation.
-   Copyright (C) 2000, 2002 Free Software Foundation, Inc.
+   Copyright (C) 2000-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
-   Contributed by  Hanno Mueller, kontakt@hanno.de, 2000.
+   Contributed by Hanno Mueller, kontakt@hanno.de, 2000.
 
    The GNU C Library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
@@ -14,9 +14,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 /*
  * fmemopen() - "my" version of a string stream
@@ -27,8 +26,6 @@
  * but couldn't find it in libio. The following snippet of code is an
  * attempt to implement what glibc's documentation describes.
  *
- * No, it isn't really tested yet. :-)
- *
  *
  *
  * I already see some potential problems:
@@ -73,6 +70,7 @@
 #include <libio.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <stdint.h>
 #include <string.h>
 #include <sys/types.h>
 #include "libioP.h"
@@ -83,6 +81,7 @@ struct fmemopen_cookie_struct
 {
   char *buffer;
   int mybuffer;
+  int binmode;
   size_t size;
   _IO_off64_t pos;
   size_t maxpos;
@@ -121,14 +120,14 @@ fmemopen_write (void *cookie, const char *b, size_t s)
 
   c = (fmemopen_cookie_t *) cookie;
 
-  addnullc = s == 0 || b[s - 1] != '\0';
+  addnullc = c->binmode == 0 && (s == 0 || b[s - 1] != '\0');
 
   if (c->pos + s + addnullc > c->size)
     {
       if ((size_t) (c->pos + addnullc) == c->size)
 	{
 	  __set_errno (ENOSPC);
-	  return -1;
+	  return 0;
 	}
       s = c->size - c->pos - addnullc;
     }
@@ -166,7 +165,7 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w)
       break;
 
     case SEEK_END:
-      np = c->size - *p;
+      np = (c->binmode ? c->size : c->maxpos) - *p;
       break;
 
     default:
@@ -176,9 +175,9 @@ fmemopen_seek (void *cookie, _IO_off64_t *p, int w)
   if (np < 0 || (size_t) np > c->size)
     return -1;
 
-  c->pos = np;
+  *p = c->pos = np;
 
-  return np;
+  return 0;
 }
 
 
@@ -203,6 +202,13 @@ fmemopen (void *buf, size_t len, const char *mode)
   cookie_io_functions_t iof;
   fmemopen_cookie_t *c;
 
+  if (__glibc_unlikely (len == 0))
+    {
+    einval:
+      __set_errno (EINVAL);
+      return NULL;
+    }
+
   c = (fmemopen_cookie_t *) malloc (sizeof (fmemopen_cookie_t));
   if (c == NULL)
     return NULL;
@@ -218,22 +224,33 @@ fmemopen (void *buf, size_t len, const char *mode)
 	  return NULL;
 	}
       c->buffer[0] = '\0';
+      c->maxpos = 0;
     }
   else
-    c->buffer = buf;
+    {
+      if (__glibc_unlikely ((uintptr_t) len > -(uintptr_t) buf))
+	{
+	  free (c);
+	  goto einval;
+	}
 
-  c->size = len;
+      c->buffer = buf;
 
-  if (mode[0] == 'w')
-    c->buffer[0] = '\0';
+      if (mode[0] == 'w')
+	c->buffer[0] = '\0';
 
-  c->maxpos = strlen (c->buffer);
+      c->maxpos = strnlen (c->buffer, len);
+    }
+
+  c->size = len;
 
   if (mode[0] == 'a')
     c->pos = c->maxpos;
   else
     c->pos = 0;
 
+  c->binmode = mode[0] != '\0' && mode[1] == 'b';
+
   iof.read = fmemopen_read;
   iof.write = fmemopen_write;
   iof.seek = fmemopen_seek;
@@ -241,3 +258,4 @@ fmemopen (void *buf, size_t len, const char *mode)
 
   return _IO_fopencookie (c, mode, iof);
 }
+libc_hidden_def (fmemopen)
diff --git a/src/system/libroot/posix/glibc/libio/fputc.c b/src/system/libroot/posix/glibc/libio/fputc.c
index 5ef048ff41..ba30854ebd 100644
--- a/src/system/libroot/posix/glibc/libio/fputc.c
+++ b/src/system/libroot/posix/glibc/libio/fputc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -35,11 +34,9 @@ fputc (c, fp)
 {
   int result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_putc_unlocked (c, fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/fputc_u.c b/src/system/libroot/posix/glibc/libio/fputc_u.c
index 406b7da2c4..236526c31d 100644
--- a/src/system/libroot/posix/glibc/libio/fputc_u.c
+++ b/src/system/libroot/posix/glibc/libio/fputc_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/fputwc.c b/src/system/libroot/posix/glibc/libio/fputwc.c
index 600d7307c7..563b6864fb 100644
--- a/src/system/libroot/posix/glibc/libio/fputwc.c
+++ b/src/system/libroot/posix/glibc/libio/fputwc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,15 +32,13 @@ fputwc (wc, fp)
      wchar_t wc;
      _IO_FILE *fp;
 {
-  int result;
+  wint_t result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   if (_IO_fwide (fp, 1) < 0)
     result = WEOF;
   else
     result = _IO_putwc_unlocked (wc, fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/fputwc_u.c b/src/system/libroot/posix/glibc/libio/fputwc_u.c
index 93cbcab3d3..e80cf24234 100644
--- a/src/system/libroot/posix/glibc/libio/fputwc_u.c
+++ b/src/system/libroot/posix/glibc/libio/fputwc_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -35,7 +34,7 @@ fputwc_unlocked (wc, fp)
      wchar_t wc;
      _IO_FILE *fp;
 {
-  CHECK_FILE (fp, EOF);
+  CHECK_FILE (fp, WEOF);
   if (_IO_fwide (fp, 1) < 0)
     return WEOF;
   return _IO_putwc_unlocked (wc, fp);
diff --git a/src/system/libroot/posix/glibc/libio/freopen.c b/src/system/libroot/posix/glibc/libio/freopen.c
index 0b4e889cd0..a787967b2d 100644
--- a/src/system/libroot/posix/glibc/libio/freopen.c
+++ b/src/system/libroot/posix/glibc/libio/freopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,95,96,97,98,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -27,9 +26,13 @@
 
 #include "libioP.h"
 #include "stdio.h"
+#include <fcntl.h>
+#include <stdlib.h>
+#include <unistd.h>
 
 #include <shlib-compat.h>
 
+
 FILE*
 freopen (filename, mode, fp)
      const char* filename;
@@ -40,8 +43,7 @@ freopen (filename, mode, fp)
   CHECK_FILE (fp, NULL);
   if (!(fp->_flags & _IO_IS_FILEBUF))
     return NULL;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
   if (&_IO_stdin_used == NULL)
     /* If the shared C library is used by the application binary which
@@ -56,14 +58,15 @@ freopen (filename, mode, fp)
   if (result != NULL)
     /* unbound stream orientation */
     result->_mode = 0;
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
 #if 0
 #include <fd_to_filename.h>
 
+#include <kernel-features.h>
+
 FILE*
 freopen (filename, mode, fp)
      const char* filename;
@@ -71,18 +74,14 @@ freopen (filename, mode, fp)
      FILE* fp;
 {
   FILE *result;
-  int fd = -1;
   CHECK_FILE (fp, NULL);
   if (!(fp->_flags & _IO_IS_FILEBUF))
     return NULL;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
-  if (filename == NULL && _IO_fileno (fp) >= 0)
-    {
-      fd = __dup (_IO_fileno (fp));
-      if (fd != -1)
-	filename = fd_to_filename (fd);
-    }
+  _IO_acquire_lock (fp);
+  int fd = _IO_fileno (fp);
+  const char *gfilename = (filename == NULL && fd >= 0
+			   ? fd_to_filename (fd) : filename);
+  fp->_flags2 |= _IO_FLAGS2_NOCLOSE;
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
   if (&_IO_stdin_used == NULL)
     {
@@ -93,30 +92,63 @@ freopen (filename, mode, fp)
 	 up here. */
       _IO_old_file_close_it (fp);
       _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_old_file_jumps;
-      result = _IO_old_file_fopen (fp, filename, mode);
+      result = _IO_old_file_fopen (fp, gfilename, mode);
     }
   else
 #endif
     {
-      INTUSE(_IO_file_close_it) (fp);
-      _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &INTUSE(_IO_file_jumps);
-//      if (fp->_vtable_offset == 0 && fp->_wide_data != NULL)
-//	fp->_wide_data->_wide_vtable = &INTUSE(_IO_wfile_jumps);
-      result = INTUSE(_IO_file_fopen) (fp, filename, mode, 1);
+      _IO_file_close_it (fp);
+      _IO_JUMPS ((struct _IO_FILE_plus *) fp) = &_IO_file_jumps;
+      if (_IO_vtable_offset (fp) == 0 && fp->_wide_data != NULL)
+	fp->_wide_data->_wide_vtable = &_IO_wfile_jumps;
+      result = _IO_file_fopen (fp, gfilename, mode, 1);
       if (result != NULL)
 	result = __fopen_maybe_mmap (result);
     }
+  fp->_flags2 &= ~_IO_FLAGS2_NOCLOSE;
   if (result != NULL)
-    /* unbound stream orientation */
-    result->_mode = 0;
-  if (fd != -1)
     {
-      __close (fd);
-      if (filename != NULL)
-	free ((char *) filename);
+      /* unbound stream orientation */
+      result->_mode = 0;
+
+      if (fd != -1)
+	{
+#ifdef O_CLOEXEC
+# ifndef __ASSUME_DUP3
+	  int newfd;
+	  if (__have_dup3 < 0)
+	    newfd = -1;
+	  else
+	    newfd =
+# endif
+	      __dup3 (_IO_fileno (result), fd,
+                      (result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0
+                      ? O_CLOEXEC : 0);
+#else
+# define newfd 1
+#endif
+
+#ifndef __ASSUME_DUP3
+	  if (newfd < 0)
+	    {
+	      if (errno == ENOSYS)
+		__have_dup3 = -1;
+
+	      __dup2 (_IO_fileno (result), fd);
+	      if ((result->_flags2 & _IO_FLAGS2_CLOEXEC) != 0)
+		__fcntl (fd, F_SETFD, FD_CLOEXEC);
+	    }
+#endif
+	  __close (_IO_fileno (result));
+	  _IO_fileno (result) = fd;
+	}
     }
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  else if (fd != -1)
+    __close (fd);
+  if (filename == NULL)
+    free ((char *) gfilename);
+
+  _IO_release_lock (fp);
   return result;
 }
 #endif
diff --git a/src/system/libroot/posix/glibc/libio/fseek.c b/src/system/libroot/posix/glibc/libio/fseek.c
index 831a4d497b..ab85c0d525 100644
--- a/src/system/libroot/posix/glibc/libio/fseek.c
+++ b/src/system/libroot/posix/glibc/libio/fseek.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1998,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,11 +35,9 @@ fseek (fp, offset, whence)
 {
   int result;
   CHECK_FILE (fp, -1);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_fseek (fp, offset, whence);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 libc_hidden_def (fseek)
diff --git a/src/system/libroot/posix/glibc/libio/fseeko.c b/src/system/libroot/posix/glibc/libio/fseeko.c
index 8087b957d2..7c76f56fc7 100644
--- a/src/system/libroot/posix/glibc/libio/fseeko.c
+++ b/src/system/libroot/posix/glibc/libio/fseeko.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,10 +35,12 @@ fseeko (fp, offset, whence)
 {
   int result;
   CHECK_FILE (fp, -1);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_fseek (fp, offset, whence);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias (fseeko, fseeko64)
+#endif
diff --git a/src/system/libroot/posix/glibc/libio/ftello.c b/src/system/libroot/posix/glibc/libio/ftello.c
index 3e6f2761b8..208ff8cfce 100644
--- a/src/system/libroot/posix/glibc/libio/ftello.c
+++ b/src/system/libroot/posix/glibc/libio/ftello.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -27,8 +26,8 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <errno.h>
 #include <libioP.h>
+#include <errno.h>
 
 
 off_t
@@ -37,16 +36,14 @@ ftello (fp)
 {
   _IO_off64_t pos;
   CHECK_FILE (fp, -1L);
-  _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
-  if (_IO_in_backup (fp))
+  if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
     {
       if (fp->_mode <= 0)
 	pos -= fp->_IO_save_end - fp->_IO_save_base;
     }
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   if (pos == _IO_pos_BAD)
     {
 #ifdef EIO
@@ -64,3 +61,8 @@ ftello (fp)
     }
   return pos;
 }
+libc_hidden_def (ftello)
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+weak_alias (ftello, ftello64)
+#endif
diff --git a/src/system/libroot/posix/glibc/libio/fwide.c b/src/system/libroot/posix/glibc/libio/fwide.c
index 8574fddf5f..985728dd25 100644
--- a/src/system/libroot/posix/glibc/libio/fwide.c
+++ b/src/system/libroot/posix/glibc/libio/fwide.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -23,36 +22,30 @@
    however invalidate any other reasons why the executable file
    might be covered by the GNU Lesser General Public License.
    This exception applies to code released by its copyright holders
-   in files containing the exception.
-*/
-
+   in files containing the exception.  */
 
 #include <libioP.h>
 #include <stdio.h>
 #include <wchar.h>
 
-
 int
-fwide(_IO_FILE *fp, int mode)
+fwide (fp, mode)
+     _IO_FILE *fp;
+     int mode;
 {
-	int result;
-
-	/* Normalize the value.  */
-	mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
-
-	if (mode == 0 || fp->_mode != 0) {
-		// The caller simply wants to know about the current orientation
-		// or the orientation already has been determined.
-		return fp->_mode;
-	}
+  int result;
 
-	_IO_cleanup_region_start((void (*) __P ((void *)))_IO_funlockfile, fp);
-	_IO_flockfile(fp);
+  /* Normalize the value.  */
+  mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
 
-	result = _IO_fwide(fp, mode);
+  if (mode == 0 || fp->_mode != 0)
+    /* The caller simply wants to know about the current orientation
+       or the orientation already has been determined.  */
+    return fp->_mode;
 
-	_IO_funlockfile(fp);
-	_IO_cleanup_region_end(0);
+  _IO_acquire_lock (fp);
+  result = _IO_fwide (fp, mode);
+  _IO_release_lock (fp);
 
-	return result;
+  return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/fwprintf.c b/src/system/libroot/posix/glibc/libio/fwprintf.c
index cadeda04ab..ed6e4ae791 100644
--- a/src/system/libroot/posix/glibc/libio/fwprintf.c
+++ b/src/system/libroot/posix/glibc/libio/fwprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997, 1999, 2000, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,10 +12,10 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
diff --git a/src/system/libroot/posix/glibc/libio/fwscanf.c b/src/system/libroot/posix/glibc/libio/fwscanf.c
index 411e1825c0..007c290357 100644
--- a/src/system/libroot/posix/glibc/libio/fwscanf.c
+++ b/src/system/libroot/posix/glibc/libio/fwscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1997, 1999, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,10 +12,10 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
@@ -23,7 +23,7 @@
 /* Read formatted input from STREAM according to the format string FORMAT.  */
 /* VARARGS2 */
 int
-fwscanf (FILE *stream, const wchar_t *format, ...)
+__fwscanf (FILE *stream, const wchar_t *format, ...)
 {
   va_list arg;
   int done;
@@ -34,3 +34,4 @@ fwscanf (FILE *stream, const wchar_t *format, ...)
 
   return done;
 }
+weak_alias (__fwscanf, fwscanf)
diff --git a/src/system/libroot/posix/glibc/libio/genops.c b/src/system/libroot/posix/glibc/libio/genops.c
index 7fa0a224c4..b727b8ae56 100644
--- a/src/system/libroot/posix/glibc/libio/genops.c
+++ b/src/system/libroot/posix/glibc/libio/genops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1997-2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -23,14 +22,17 @@
    however invalidate any other reasons why the executable file
    might be covered by the GNU Lesser General Public License.
    This exception applies to code released by its copyright holders
-   in files containing the exception.
-*/
+   in files containing the exception.  */
 
 /* Generic or default I/O operations. */
 
 #include "libioP.h"
 #include <stdlib.h>
 #include <string.h>
+#include <stdbool.h>
+#ifdef _LIBC
+#include <sched.h>
+#endif
 
 #ifdef _IO_MTSAFE_IO
 static _IO_lock_t list_all_lock = _IO_lock_initializer;
@@ -42,41 +44,44 @@ static int _IO_list_all_stamp;
 
 static _IO_FILE *run_fp;
 
-#if 0
+#ifdef _IO_MTSAFE_IO
 static void
 flush_cleanup (void *not_used)
 {
   if (run_fp != NULL)
     _IO_funlockfile (run_fp);
-#ifdef _IO_MTSAFE_IO
   _IO_lock_unlock (list_all_lock);
-#endif
 }
 #endif
 
-
 void
-_IO_un_link(struct _IO_FILE_plus *fp)
+_IO_un_link (fp)
+     struct _IO_FILE_plus *fp;
 {
   if (fp->file._flags & _IO_LINKED)
     {
-      struct _IO_FILE_plus **f;
+      struct _IO_FILE **f;
 #ifdef _IO_MTSAFE_IO
       _IO_cleanup_region_start_noarg (flush_cleanup);
       _IO_lock_lock (list_all_lock);
       run_fp = (_IO_FILE *) fp;
       _IO_flockfile ((_IO_FILE *) fp);
 #endif
-      for (f = &INTUSE(_IO_list_all); *f;
-	   f = (struct _IO_FILE_plus **) &(*f)->file._chain)
+      if (_IO_list_all == NULL)
+	;
+      else if (fp == _IO_list_all)
 	{
-	  if (*f == fp)
+	  _IO_list_all = (struct _IO_FILE_plus *) _IO_list_all->file._chain;
+	  ++_IO_list_all_stamp;
+	}
+      else
+	for (f = &_IO_list_all->file._chain; *f; f = &(*f)->_chain)
+	  if (*f == (_IO_FILE *) fp)
 	    {
-	      *f = (struct _IO_FILE_plus *) fp->file._chain;
+	      *f = fp->file._chain;
 	      ++_IO_list_all_stamp;
 	      break;
 	    }
-	}
       fp->file._flags &= ~_IO_LINKED;
 #ifdef _IO_MTSAFE_IO
       _IO_funlockfile ((_IO_FILE *) fp);
@@ -86,7 +91,7 @@ _IO_un_link(struct _IO_FILE_plus *fp)
 #endif
     }
 }
-INTDEF(_IO_un_link)
+libc_hidden_def (_IO_un_link)
 
 void
 _IO_link_in (fp)
@@ -101,8 +106,8 @@ _IO_link_in (fp)
       run_fp = (_IO_FILE *) fp;
       _IO_flockfile ((_IO_FILE *) fp);
 #endif
-      fp->file._chain = (_IO_FILE *) INTUSE(_IO_list_all);
-      INTUSE(_IO_list_all) = fp;
+      fp->file._chain = (_IO_FILE *) _IO_list_all;
+      _IO_list_all = fp;
       ++_IO_list_all_stamp;
 #ifdef _IO_MTSAFE_IO
       _IO_funlockfile ((_IO_FILE *) fp);
@@ -112,11 +117,11 @@ _IO_link_in (fp)
 #endif
     }
 }
-INTDEF(_IO_link_in)
+libc_hidden_def (_IO_link_in)
 
 /* Return minimum _pos markers
    Assumes the current get area is the main get area. */
-_IO_ssize_t _IO_least_marker __P ((_IO_FILE *fp, char *end_p));
+_IO_ssize_t _IO_least_marker (_IO_FILE *fp, char *end_p);
 
 _IO_ssize_t
 _IO_least_marker (fp, end_p)
@@ -193,7 +198,7 @@ _IO_switch_to_get_mode (fp)
   fp->_flags &= ~_IO_CURRENTLY_PUTTING;
   return 0;
 }
-INTDEF(_IO_switch_to_get_mode)
+libc_hidden_def (_IO_switch_to_get_mode)
 
 void
 _IO_free_backup_area (fp)
@@ -206,7 +211,7 @@ _IO_free_backup_area (fp)
   fp->_IO_save_end = NULL;
   fp->_IO_backup_base = NULL;
 }
-INTDEF(_IO_free_backup_area)
+libc_hidden_def (_IO_free_backup_area)
 
 #if 0
 int
@@ -227,20 +232,19 @@ _IO_switch_to_put_mode (fp)
 }
 #endif
 
-
 int
-__overflow(_IO_FILE *file, int character)
+__overflow (f, ch)
+     _IO_FILE *f;
+     int ch;
 {
-	/* This is a single-byte stream.  */
-	if (file->_mode == 0)
-		_IO_fwide(file, -1);
-
-	return _IO_OVERFLOW(file, character);
+  /* This is a single-byte stream.  */
+  if (f->_mode == 0)
+    _IO_fwide (f, -1);
+  return _IO_OVERFLOW (f, ch);
 }
-libc_hidden_def(__overflow)
-
+libc_hidden_def (__overflow)
 
-static int save_for_backup __P ((_IO_FILE *fp, char *end_p))
+static int save_for_backup (_IO_FILE *fp, char *end_p)
 #ifdef _LIBC
      internal_function
 #endif
@@ -291,8 +295,7 @@ save_for_backup (fp, end_p)
 	memcpy (new_buffer + avail,
 		fp->_IO_read_base + least_mark,
 		needed_size);
-      if (fp->_IO_save_base)
-	free (fp->_IO_save_base);
+      free (fp->_IO_save_base);
       fp->_IO_save_base = new_buffer;
       fp->_IO_save_end = new_buffer + avail + needed_size;
     }
@@ -321,75 +324,71 @@ save_for_backup (fp, end_p)
   return 0;
 }
 
-
 int
-__underflow(_IO_FILE *file)
+__underflow (fp)
+     _IO_FILE *fp;
 {
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-	if (file->_vtable_offset == 0 && _IO_fwide(file, -1) != -1)
-		return EOF;
+  if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
+    return EOF;
 #endif
 
-	if (file->_mode == 0)
-		_IO_fwide(file, -1);
-
-	if (_IO_in_put_mode(file) && INTUSE(_IO_switch_to_get_mode)(file) == EOF)
-		return EOF;
-
-	if (file->_IO_read_ptr < file->_IO_read_end)
-		return *(unsigned char *)file->_IO_read_ptr;
-
-	if (_IO_in_backup(file)) {
-		_IO_switch_to_main_get_area(file);
-
-		if (file->_IO_read_ptr < file->_IO_read_end)
-			return *(unsigned char *)file->_IO_read_ptr;
+  if (fp->_mode == 0)
+    _IO_fwide (fp, -1);
+  if (_IO_in_put_mode (fp))
+    if (_IO_switch_to_get_mode (fp) == EOF)
+      return EOF;
+  if (fp->_IO_read_ptr < fp->_IO_read_end)
+    return *(unsigned char *) fp->_IO_read_ptr;
+  if (_IO_in_backup (fp))
+    {
+      _IO_switch_to_main_get_area (fp);
+      if (fp->_IO_read_ptr < fp->_IO_read_end)
+	return *(unsigned char *) fp->_IO_read_ptr;
     }
-	if (_IO_have_markers(file)) {
-		if (save_for_backup(file, file->_IO_read_end))
-			return EOF;
-    } else if (_IO_have_backup(file))
-		INTUSE(_IO_free_backup_area)(file);
-
-	return _IO_UNDERFLOW(file);
+  if (_IO_have_markers (fp))
+    {
+      if (save_for_backup (fp, fp->_IO_read_end))
+	return EOF;
+    }
+  else if (_IO_have_backup (fp))
+    _IO_free_backup_area (fp);
+  return _IO_UNDERFLOW (fp);
 }
-libc_hidden_def(__underflow)
-
+libc_hidden_def (__underflow)
 
 int
-__uflow(_IO_FILE *file)
+__uflow (fp)
+     _IO_FILE *fp;
 {
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-	if (file->_vtable_offset == 0 && _IO_fwide(file, -1) != -1)
-		return EOF;
+  if (_IO_vtable_offset (fp) == 0 && _IO_fwide (fp, -1) != -1)
+    return EOF;
 #endif
 
-	if (file->_mode == 0)
-		_IO_fwide(file, -11);
-
-	if (_IO_in_put_mode(file) && INTUSE(_IO_switch_to_get_mode)(file) == EOF)
-		return EOF;
-
-	if (file->_IO_read_ptr < file->_IO_read_end)
-		return *(unsigned char *)file->_IO_read_ptr++;
-
-	if (_IO_in_backup(file)) {
-		_IO_switch_to_main_get_area(file);
-
-		if (file->_IO_read_ptr < file->_IO_read_end)
-			return *(unsigned char *)file->_IO_read_ptr++;
-	}
-
-	if (_IO_have_markers(file)) {
-		if (save_for_backup(file, file->_IO_read_end))
-			return EOF;
-	} else if (_IO_have_backup(file))
-		INTUSE(_IO_free_backup_area)(file);
-
-	return _IO_UFLOW(file);
+  if (fp->_mode == 0)
+    _IO_fwide (fp, -1);
+  if (_IO_in_put_mode (fp))
+    if (_IO_switch_to_get_mode (fp) == EOF)
+      return EOF;
+  if (fp->_IO_read_ptr < fp->_IO_read_end)
+    return *(unsigned char *) fp->_IO_read_ptr++;
+  if (_IO_in_backup (fp))
+    {
+      _IO_switch_to_main_get_area (fp);
+      if (fp->_IO_read_ptr < fp->_IO_read_end)
+	return *(unsigned char *) fp->_IO_read_ptr++;
+    }
+  if (_IO_have_markers (fp))
+    {
+      if (save_for_backup (fp, fp->_IO_read_end))
+	return EOF;
+    }
+  else if (_IO_have_backup (fp))
+    _IO_free_backup_area (fp);
+  return _IO_UFLOW (fp);
 }
-libc_hidden_def(__uflow)
-
+libc_hidden_def (__uflow)
 
 void
 _IO_setb (f, b, eb, a)
@@ -399,7 +398,7 @@ _IO_setb (f, b, eb, a)
      int a;
 {
   if (f->_IO_buf_base && !(f->_flags & _IO_USER_BUF))
-	  FREE_BUF (f->_IO_buf_base, _IO_blen (f));
+    FREE_BUF (f->_IO_buf_base, _IO_blen (f));
   f->_IO_buf_base = b;
   f->_IO_buf_end = eb;
   if (a)
@@ -407,7 +406,7 @@ _IO_setb (f, b, eb, a)
   else
     f->_flags |= _IO_USER_BUF;
 }
-INTDEF(_IO_setb)
+libc_hidden_def (_IO_setb)
 
 void
 _IO_doallocbuf (fp)
@@ -418,9 +417,9 @@ _IO_doallocbuf (fp)
   if (!(fp->_flags & _IO_UNBUFFERED) || fp->_mode > 0)
     if (_IO_DOALLOCATE (fp) != EOF)
       return;
-  INTUSE(_IO_setb) (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
+  _IO_setb (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
 }
-INTDEF(_IO_doallocbuf)
+libc_hidden_def (_IO_doallocbuf)
 
 int
 _IO_default_underflow (fp)
@@ -438,7 +437,7 @@ _IO_default_uflow (fp)
     return EOF;
   return *(unsigned char *) fp->_IO_read_ptr++;
 }
-INTDEF(_IO_default_uflow)
+libc_hidden_def (_IO_default_uflow)
 
 _IO_size_t
 _IO_default_xsputn (f, data, n)
@@ -453,10 +452,10 @@ _IO_default_xsputn (f, data, n)
   for (;;)
     {
       /* Space available. */
-      _IO_ssize_t count = f->_IO_write_end - f->_IO_write_ptr;
-      if (count > 0)
+      if (f->_IO_write_ptr < f->_IO_write_end)
 	{
-	  if ((_IO_size_t) count > more)
+	  _IO_size_t count = f->_IO_write_end - f->_IO_write_ptr;
+	  if (count > more)
 	    count = more;
 	  if (count > 20)
 	    {
@@ -467,26 +466,24 @@ _IO_default_xsputn (f, data, n)
 	      f->_IO_write_ptr += count;
 #endif
 	      s += count;
-            }
-	  else if (count <= 0)
-	    count = 0;
-	  else
+	    }
+	  else if (count)
 	    {
 	      char *p = f->_IO_write_ptr;
 	      _IO_ssize_t i;
 	      for (i = count; --i >= 0; )
 		*p++ = *s++;
 	      f->_IO_write_ptr = p;
-            }
+	    }
 	  more -= count;
-        }
+	}
       if (more == 0 || _IO_OVERFLOW (f, (unsigned char) *s++) == EOF)
 	break;
       more--;
     }
   return n - more;
 }
-INTDEF(_IO_default_xsputn)
+libc_hidden_def (_IO_default_xsputn)
 
 _IO_size_t
 _IO_sgetn (fp, data, n)
@@ -497,7 +494,7 @@ _IO_sgetn (fp, data, n)
   /* FIXME handle putback buffer here! */
   return _IO_XSGETN (fp, data, n);
 }
-INTDEF(_IO_sgetn)
+libc_hidden_def (_IO_sgetn)
 
 _IO_size_t
 _IO_default_xsgetn (fp, data, n)
@@ -510,10 +507,10 @@ _IO_default_xsgetn (fp, data, n)
   for (;;)
     {
       /* Data available. */
-      _IO_ssize_t count = fp->_IO_read_end - fp->_IO_read_ptr;
-      if (count > 0)
+      if (fp->_IO_read_ptr < fp->_IO_read_end)
 	{
-	  if ((_IO_size_t) count > more)
+	  _IO_size_t count = fp->_IO_read_end - fp->_IO_read_ptr;
+	  if (count > more)
 	    count = more;
 	  if (count > 20)
 	    {
@@ -525,24 +522,22 @@ _IO_default_xsgetn (fp, data, n)
 #endif
 	      fp->_IO_read_ptr += count;
 	    }
-	  else if (count <= 0)
-	    count = 0;
-	  else
+	  else if (count)
 	    {
 	      char *p = fp->_IO_read_ptr;
 	      int i = (int) count;
 	      while (--i >= 0)
 		*s++ = *p++;
 	      fp->_IO_read_ptr = p;
-            }
-            more -= count;
-        }
+	    }
+	    more -= count;
+	}
       if (more == 0 || __underflow (fp) == EOF)
 	break;
     }
   return n - more;
 }
-INTDEF(_IO_default_xsgetn)
+libc_hidden_def (_IO_default_xsgetn)
 
 #if 0
 /* Seems not to be needed. --drepper */
@@ -565,12 +560,12 @@ _IO_default_setbuf (fp, p, len)
     if (p == NULL || len == 0)
       {
 	fp->_flags |= _IO_UNBUFFERED;
-	INTUSE(_IO_setb) (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
+	_IO_setb (fp, fp->_shortbuf, fp->_shortbuf+1, 0);
       }
     else
       {
 	fp->_flags &= ~_IO_UNBUFFERED;
-	INTUSE(_IO_setb) (fp, p, p+len, 0);
+	_IO_setb (fp, p, p+len, 0);
       }
     fp->_IO_write_base = fp->_IO_write_ptr = fp->_IO_write_end = 0;
     fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end = 0;
@@ -593,10 +588,10 @@ _IO_default_doallocate (fp)
   char *buf;
 
   ALLOC_BUF (buf, _IO_BUFSIZ, EOF);
-  INTUSE(_IO_setb) (fp, buf, buf+_IO_BUFSIZ, 1);
+  _IO_setb (fp, buf, buf+_IO_BUFSIZ, 1);
   return 1;
 }
-INTDEF(_IO_default_doallocate)
+libc_hidden_def (_IO_default_doallocate)
 
 void
 _IO_init (fp, flags)
@@ -605,15 +600,12 @@ _IO_init (fp, flags)
 {
   _IO_no_init (fp, flags, -1, NULL, NULL);
 }
-INTDEF(_IO_init)
+libc_hidden_def (_IO_init)
 
 void
-_IO_no_init (fp, flags, orientation, wd, jmp)
+_IO_old_init (fp, flags)
      _IO_FILE *fp;
      int flags;
-     int orientation;
-     struct _IO_wide_data *wd;
-     struct _IO_jump_t *jmp;
 {
   fp->_flags = _IO_MAGIC|flags;
   fp->_flags2 = 0;
@@ -639,6 +631,17 @@ _IO_no_init (fp, flags, orientation, wd, jmp)
   if (fp->_lock != NULL)
     _IO_lock_init (*fp->_lock);
 #endif
+}
+
+void
+_IO_no_init (fp, flags, orientation, wd, jmp)
+     _IO_FILE *fp;
+     int flags;
+     int orientation;
+     struct _IO_wide_data *wd;
+     const struct _IO_jump_t *jmp;
+{
+  _IO_old_init (fp, flags);
   fp->_mode = orientation;
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
   if (orientation >= 0)
@@ -658,6 +661,13 @@ _IO_no_init (fp, flags, orientation, wd, jmp)
 
       fp->_wide_data->_wide_vtable = jmp;
     }
+  else
+    /* Cause predictable crash when a wide function is called on a byte
+       stream.  */
+    fp->_wide_data = (struct _IO_wide_data *) -1L;
+#endif
+#ifndef __HAIKU__
+  fp->_freeres_list = NULL;
 #endif
 }
 
@@ -677,8 +687,7 @@ _IO_default_finish (fp, dummy)
      int dummy;
 {
   struct _IO_marker *mark;
-  if (fp->_IO_buf_base && fp->_IO_buf_base != fp->_shortbuf
-	  && !(fp->_flags & _IO_USER_BUF))
+  if (fp->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
     {
       FREE_BUF (fp->_IO_buf_base, _IO_blen (fp));
       fp->_IO_buf_base = fp->_IO_buf_end = NULL;
@@ -693,14 +702,14 @@ _IO_default_finish (fp, dummy)
       fp->_IO_save_base = NULL;
     }
 
+  _IO_un_link ((struct _IO_FILE_plus *) fp);
+
 #ifdef _IO_MTSAFE_IO
   if (fp->_lock != NULL)
     _IO_lock_fini (*fp->_lock);
 #endif
-
-  INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
 }
-INTDEF(_IO_default_finish)
+libc_hidden_def (_IO_default_finish)
 
 _IO_off64_t
 _IO_default_seekoff (fp, offset, dir, mode)
@@ -733,7 +742,7 @@ _IO_sputbackc (fp, c)
 
   return result;
 }
-INTDEF(_IO_sputbackc)
+libc_hidden_def (_IO_sputbackc)
 
 int
 _IO_sungetc (fp)
@@ -793,7 +802,7 @@ _IO_adjust_column (start, line, count)
       return line + count - ptr - 1;
   return start + count;
 }
-INTDEF(_IO_adjust_column)
+libc_hidden_def (_IO_adjust_column)
 
 #if 0
 /* Seems not to be needed. --drepper */
@@ -818,13 +827,13 @@ _IO_flush_all_lockp (int do_lock)
   int last_stamp;
 
 #ifdef _IO_MTSAFE_IO
-  _IO_cleanup_region_start_noarg (flush_cleanup);
+  __libc_cleanup_region_start (do_lock, flush_cleanup, NULL);
   if (do_lock)
     _IO_lock_lock (list_all_lock);
 #endif
 
   last_stamp = _IO_list_all_stamp;
-  fp = (_IO_FILE *) INTUSE(_IO_list_all);
+  fp = (_IO_FILE *) _IO_list_all;
   while (fp != NULL)
     {
       run_fp = fp;
@@ -833,7 +842,7 @@ _IO_flush_all_lockp (int do_lock)
 
       if (((fp->_mode <= 0 && fp->_IO_write_ptr > fp->_IO_write_base)
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-	   || (fp->_vtable_offset == 0
+	   || (_IO_vtable_offset (fp) == 0
 	       && fp->_mode > 0 && (fp->_wide_data->_IO_write_ptr
 				    > fp->_wide_data->_IO_write_base))
 #endif
@@ -848,7 +857,7 @@ _IO_flush_all_lockp (int do_lock)
       if (last_stamp != _IO_list_all_stamp)
 	{
 	  /* Something was added to the list.  Start all over again.  */
-	  fp = (_IO_FILE *) INTUSE(_IO_list_all);
+	  fp = (_IO_FILE *) _IO_list_all;
 	  last_stamp = _IO_list_all_stamp;
 	}
       else
@@ -858,7 +867,7 @@ _IO_flush_all_lockp (int do_lock)
 #ifdef _IO_MTSAFE_IO
   if (do_lock)
     _IO_lock_unlock (list_all_lock);
-  _IO_cleanup_region_end (0);
+  __libc_cleanup_region_end (0);
 #endif
 
   return result;
@@ -866,15 +875,15 @@ _IO_flush_all_lockp (int do_lock)
 
 
 int
-_IO_flush_all ()
+_IO_flush_all (void)
 {
   /* We want locking.  */
   return _IO_flush_all_lockp (1);
 }
-INTDEF(_IO_flush_all)
+libc_hidden_def (_IO_flush_all)
 
 void
-_IO_flush_all_linebuffered ()
+_IO_flush_all_linebuffered (void)
 {
   struct _IO_FILE *fp;
   int last_stamp;
@@ -885,7 +894,7 @@ _IO_flush_all_linebuffered ()
 #endif
 
   last_stamp = _IO_list_all_stamp;
-  fp = (_IO_FILE *) INTUSE(_IO_list_all);
+  fp = (_IO_FILE *) _IO_list_all;
   while (fp != NULL)
     {
       run_fp = fp;
@@ -900,7 +909,7 @@ _IO_flush_all_linebuffered ()
       if (last_stamp != _IO_list_all_stamp)
 	{
 	  /* Something was added to the list.  Start all over again.  */
-	  fp = (_IO_FILE *) INTUSE(_IO_list_all);
+	  fp = (_IO_FILE *) _IO_list_all;
 	  last_stamp = _IO_list_all_stamp;
 	}
       else
@@ -912,25 +921,75 @@ _IO_flush_all_linebuffered ()
   _IO_cleanup_region_end (0);
 #endif
 }
-INTDEF(_IO_flush_all_linebuffered)
+libc_hidden_def (_IO_flush_all_linebuffered)
 #ifdef _LIBC
 weak_alias (_IO_flush_all_linebuffered, _flushlbf)
 #endif
 
-static void _IO_unbuffer_write __P ((void));
+
+/* The following is a bit tricky.  In general, we want to unbuffer the
+   streams so that all output which follows is seen.  If we are not
+   looking for memory leaks it does not make much sense to free the
+   actual buffer because this will happen anyway once the program
+   terminated.  If we do want to look for memory leaks we have to free
+   the buffers.  Whether something is freed is determined by the
+   function sin the libc_freeres section.  Those are called as part of
+   the atexit routine, just like _IO_cleanup.  The problem is we do
+   not know whether the freeres code is called first or _IO_cleanup.
+   if the former is the case, we set the DEALLOC_BUFFER variable to
+   true and _IO_unbuffer_write will take care of the rest.  If
+   _IO_unbuffer_write is called first we add the streams to a list
+   which the freeres function later can walk through.  */
+static void _IO_unbuffer_write (void);
+
+#ifndef __HAIKU__
+static bool dealloc_buffers;
+static _IO_FILE *freeres_list;
+#endif
 
 static void
-_IO_unbuffer_write ()
+_IO_unbuffer_write (void)
 {
   struct _IO_FILE *fp;
-  for (fp = (_IO_FILE *) INTUSE(_IO_list_all); fp; fp = fp->_chain)
+  for (fp = (_IO_FILE *) _IO_list_all; fp; fp = fp->_chain)
     {
       if (! (fp->_flags & _IO_UNBUFFERED)
 	  && (! (fp->_flags & _IO_NO_WRITES)
 	      || (fp->_flags & _IO_IS_APPENDING))
 	  /* Iff stream is un-orientated, it wasn't used. */
 	  && fp->_mode != 0)
-	_IO_SETBUF (fp, NULL, 0);
+	{
+#ifdef _IO_MTSAFE_IO
+	  int cnt;
+#define MAXTRIES 2
+	  for (cnt = 0; cnt < MAXTRIES; ++cnt)
+	    if (fp->_lock == NULL || _IO_lock_trylock (*fp->_lock) == 0)
+	      break;
+	    else
+	      /* Give the other thread time to finish up its use of the
+		 stream.  */
+	      __sched_yield ();
+#endif
+
+#ifndef __HAIKU__
+	  if (! dealloc_buffers && !(fp->_flags & _IO_USER_BUF))
+	    {
+	      fp->_flags |= _IO_USER_BUF;
+
+	      fp->_freeres_list = freeres_list;
+	      freeres_list = fp;
+	      fp->_freeres_buf = fp->_IO_buf_base;
+	      fp->_freeres_size = _IO_blen (fp);
+	    }
+#endif
+
+	  _IO_SETBUF (fp, NULL, 0);
+
+#ifdef _IO_MTSAFE_IO
+	  if (cnt < MAXTRIES && fp->_lock != NULL)
+	    _IO_lock_unlock (*fp->_lock);
+#endif
+	}
 
       /* Make sure that never again the wide char functions can be
 	 used.  */
@@ -938,11 +997,27 @@ _IO_unbuffer_write ()
     }
 }
 
+
+#ifndef __HAIKU__
+libc_freeres_fn (buffer_free)
+{
+  dealloc_buffers = true;
+
+  while (freeres_list != NULL)
+    {
+      FREE_BUF (freeres_list->_freeres_buf, freeres_list->_freeres_size);
+
+      freeres_list = freeres_list->_freeres_list;
+    }
+}
+#endif
+
+
 int
-_IO_cleanup ()
+_IO_cleanup (void)
 {
   /* We do *not* want locking.  Some threads might use streams but
-     that is there problem, we flush them underneath them.  */
+     that is their problem, we flush them underneath them.  */
   int result = _IO_flush_all_lockp (0);
 
   /* We currently don't have a reliable mechanism for making sure that
@@ -965,7 +1040,7 @@ _IO_init_marker (marker, fp)
 {
   marker->_sbuf = fp;
   if (_IO_in_put_mode (fp))
-    INTUSE(_IO_switch_to_get_mode) (fp);
+    _IO_switch_to_get_mode (fp);
   if (_IO_in_backup (fp))
     marker->_pos = fp->_IO_read_ptr - fp->_IO_read_end;
   else
@@ -1071,9 +1146,9 @@ _IO_unsave_markers (fp)
     }
 
   if (_IO_have_backup (fp))
-    INTUSE(_IO_free_backup_area) (fp);
+    _IO_free_backup_area (fp);
 }
-INTDEF(_IO_unsave_markers)
+libc_hidden_def (_IO_unsave_markers)
 
 #if 0
 /* Seems not to be needed. --drepper */
@@ -1147,7 +1222,7 @@ _IO_default_pbackfail (fp, c)
     }
   return (unsigned char) c;
 }
-INTDEF(_IO_default_pbackfail)
+libc_hidden_def (_IO_default_pbackfail)
 
 _IO_off64_t
 _IO_default_seek (fp, offset, dir)
@@ -1199,14 +1274,14 @@ _IO_default_imbue (fp, locale)
 }
 
 _IO_ITER
-_IO_iter_begin()
+_IO_iter_begin (void)
 {
-  return (_IO_ITER) INTUSE(_IO_list_all);
+  return (_IO_ITER) _IO_list_all;
 }
 libc_hidden_def (_IO_iter_begin)
 
 _IO_ITER
-_IO_iter_end()
+_IO_iter_end (void)
 {
   return NULL;
 }
@@ -1229,7 +1304,7 @@ _IO_iter_file(iter)
 libc_hidden_def (_IO_iter_file)
 
 void
-_IO_list_lock()
+_IO_list_lock (void)
 {
 #ifdef _IO_MTSAFE_IO
   _IO_lock_lock (list_all_lock);
@@ -1238,7 +1313,7 @@ _IO_list_lock()
 libc_hidden_def (_IO_list_lock)
 
 void
-_IO_list_unlock()
+_IO_list_unlock (void)
 {
 #ifdef _IO_MTSAFE_IO
   _IO_lock_unlock (list_all_lock);
@@ -1247,7 +1322,7 @@ _IO_list_unlock()
 libc_hidden_def (_IO_list_unlock)
 
 void
-_IO_list_resetlock()
+_IO_list_resetlock (void)
 {
 #ifdef _IO_MTSAFE_IO
   _IO_lock_init (list_all_lock);
diff --git a/src/system/libroot/posix/glibc/libio/getc.c b/src/system/libroot/posix/glibc/libio/getc.c
index a35dcb9f8d..ed88d7e264 100644
--- a/src/system/libroot/posix/glibc/libio/getc.c
+++ b/src/system/libroot/posix/glibc/libio/getc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,11 +35,9 @@ _IO_getc (fp)
 {
   int result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_getc_unlocked (fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/getc_u.c b/src/system/libroot/posix/glibc/libio/getc_u.c
index f0c19b4fa5..4fdaafb28a 100644
--- a/src/system/libroot/posix/glibc/libio/getc_u.c
+++ b/src/system/libroot/posix/glibc/libio/getc_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1999,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -30,8 +29,6 @@
 
 #undef getc_unlocked
 
-int __getc_unlocked(FILE *fp);
-
 int
 __getc_unlocked (FILE *fp)
 {
diff --git a/src/system/libroot/posix/glibc/libio/getchar.c b/src/system/libroot/posix/glibc/libio/getchar.c
index 8ce67fea52..7dec9a05c1 100644
--- a/src/system/libroot/posix/glibc/libio/getchar.c
+++ b/src/system/libroot/posix/glibc/libio/getchar.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -31,15 +30,12 @@
 #undef getchar
 
 int
-getchar ()
+getchar (void)
 {
   int result;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-			    _IO_stdin);
-  _IO_flockfile (_IO_stdin);
+  _IO_acquire_lock (_IO_stdin);
   result = _IO_getc_unlocked (_IO_stdin);
-  _IO_funlockfile (_IO_stdin);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (_IO_stdin);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/getchar_u.c b/src/system/libroot/posix/glibc/libio/getchar_u.c
index 080c3998a4..41a89e0f79 100644
--- a/src/system/libroot/posix/glibc/libio/getchar_u.c
+++ b/src/system/libroot/posix/glibc/libio/getchar_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -31,7 +30,7 @@
 #undef getchar_unlocked
 
 int
-getchar_unlocked ()
+getchar_unlocked (void)
 {
   return _IO_getc_unlocked (_IO_stdin);
 }
diff --git a/src/system/libroot/posix/glibc/libio/getwc.c b/src/system/libroot/posix/glibc/libio/getwc.c
index 0617e2d713..a490154547 100644
--- a/src/system/libroot/posix/glibc/libio/getwc.c
+++ b/src/system/libroot/posix/glibc/libio/getwc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -37,11 +36,9 @@ _IO_getwc (fp)
 {
   wint_t result;
   CHECK_FILE (fp, WEOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_getwc_unlocked (fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/getwc_u.c b/src/system/libroot/posix/glibc/libio/getwc_u.c
index bdad3c8bf3..21b617b456 100644
--- a/src/system/libroot/posix/glibc/libio/getwc_u.c
+++ b/src/system/libroot/posix/glibc/libio/getwc_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1999,2000  Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,7 +32,7 @@
 wint_t
 __getwc_unlocked (FILE *fp)
 {
-  CHECK_FILE (fp, EOF);
+  CHECK_FILE (fp, WEOF);
   return _IO_getwc_unlocked (fp);
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/getwchar.c b/src/system/libroot/posix/glibc/libio/getwchar.c
index 0298e22ead..d2e2613e1f 100644
--- a/src/system/libroot/posix/glibc/libio/getwchar.c
+++ b/src/system/libroot/posix/glibc/libio/getwchar.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -31,14 +30,11 @@
 #undef getwchar
 
 wint_t
-getwchar ()
+getwchar (void)
 {
   wint_t result;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-			    _IO_stdin);
-  _IO_flockfile (_IO_stdin);
+  _IO_acquire_lock (_IO_stdin);
   result = _IO_getwc_unlocked (_IO_stdin);
-  _IO_funlockfile (_IO_stdin);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (_IO_stdin);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/getwchar_u.c b/src/system/libroot/posix/glibc/libio/getwchar_u.c
index 9dbf1ac6e0..4f2573594f 100644
--- a/src/system/libroot/posix/glibc/libio/getwchar_u.c
+++ b/src/system/libroot/posix/glibc/libio/getwchar_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -31,7 +30,7 @@
 #undef getwchar_unlocked
 
 wint_t
-getwchar_unlocked ()
+getwchar_unlocked (void)
 {
   return _IO_getwc_unlocked (_IO_stdin);
 }
diff --git a/src/system/libroot/posix/glibc/libio/iofclose.c b/src/system/libroot/posix/glibc/libio/iofclose.c
index d345a150c3..d3e3ca9139 100644
--- a/src/system/libroot/posix/glibc/libio/iofclose.c
+++ b/src/system/libroot/posix/glibc/libio/iofclose.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1997-2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -26,9 +25,7 @@
    in files containing the exception.  */
 
 #include "libioP.h"
-#ifdef __STDC__
 #include <stdlib.h>
-#endif
 #if _LIBC
 # include "../iconv/gconv_int.h"
 # include <shlib-compat.h>
@@ -43,49 +40,46 @@ _IO_new_fclose (fp)
 {
   int status;
 
-  if (fp == NULL)
-    return -1;
-
   CHECK_FILE(fp, EOF);
 
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
   /* We desperately try to help programs which are using streams in a
      strange way and mix old and new functions.  Detect old streams
      here.  */
-  if (fp->_vtable_offset != 0)
+  if (_IO_vtable_offset (fp) != 0)
     return _IO_old_fclose (fp);
 #endif
 
   /* First unlink the stream.  */
   if (fp->_IO_file_flags & _IO_IS_FILEBUF)
-    INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
+    _IO_un_link ((struct _IO_FILE_plus *) fp);
 
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   if (fp->_IO_file_flags & _IO_IS_FILEBUF)
-    status = INTUSE(_IO_file_close_it) (fp);
+    status = _IO_file_close_it (fp);
   else
     status = fp->_flags & _IO_ERR_SEEN ? -1 : 0;
+  _IO_release_lock (fp);
   _IO_FINISH (fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
   if (fp->_mode > 0)
     {
-#if 0
+#ifndef __HAIKU__
 #if _LIBC
       /* This stream has a wide orientation.  This means we have to free
 	 the conversion functions.  */
       struct _IO_codecvt *cc = fp->_codecvt;
 
+      __libc_lock_lock (__gconv_lock);
       __gconv_release_step (cc->__cd_in.__cd.__steps);
       __gconv_release_step (cc->__cd_out.__cd.__steps);
+      __libc_lock_unlock (__gconv_lock);
 #endif
 #endif
     }
   else
     {
       if (_IO_have_backup (fp))
-	INTUSE(_IO_free_backup_area) (fp);
+	_IO_free_backup_area (fp);
     }
   if (fp != _IO_stdin && fp != _IO_stdout && fp != _IO_stderr)
     {
diff --git a/src/system/libroot/posix/glibc/libio/iofdopen.c b/src/system/libroot/posix/glibc/libio/iofdopen.c
index 56256b5141..81cec37e95 100644
--- a/src/system/libroot/posix/glibc/libio/iofdopen.c
+++ b/src/system/libroot/posix/glibc/libio/iofdopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1994,1997-1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -23,21 +22,25 @@
    however invalidate any other reasons why the executable file
    might be covered by the GNU Lesser General Public License.
    This exception applies to code released by its copyright holders
-   in files containing the exception.
-*/
+   in files containing the exception.  */
 
-
-#include "libioP.h"
 #include <stdlib.h>
+#include <stdbool.h>
+#include "libioP.h"
 #include <fcntl.h>
 
 #ifdef _LIBC
 # include <shlib-compat.h>
 #endif
 
+#ifndef _IO_fcntl
+#define _IO_fcntl fcntl
+#endif
 
 _IO_FILE *
-_IO_new_fdopen (int fd, const char *mode)
+_IO_new_fdopen (fd, mode)
+     int fd;
+     const char *mode;
 {
   int read_write;
   int posix_mode = 0;
@@ -53,6 +56,11 @@ _IO_new_fdopen (int fd, const char *mode)
   int i;
   int use_mmap = 0;
 
+  /* Decide whether we modify the offset of the file we attach to and seek to
+     the end of file.  We only do this if the mode is 'a' and if the file
+     descriptor did not have O_APPEND in its flags already.  */
+  bool do_seek = false;
+
   switch (*mode)
     {
     case 'r':
@@ -90,7 +98,7 @@ _IO_new_fdopen (int fd, const char *mode)
       break;
     }
 #ifdef F_GETFL
-  fd_flags = fcntl(fd, F_GETFL);
+  fd_flags = _IO_fcntl (fd, F_GETFL);
 #ifndef O_ACCMODE
 #define O_ACCMODE (O_RDONLY|O_WRONLY|O_RDWR)
 #endif
@@ -122,8 +130,9 @@ _IO_new_fdopen (int fd, const char *mode)
      */
   if ((posix_mode & O_APPEND) && !(fd_flags & O_APPEND))
     {
+      do_seek = true;
 #ifdef F_SETFL
-      if (fcntl(fd, F_SETFL, fd_flags | O_APPEND) == -1)
+      if (_IO_fcntl (fd, F_SETFL, fd_flags | O_APPEND) == -1)
 #endif
 	return NULL;
     }
@@ -135,40 +144,45 @@ _IO_new_fdopen (int fd, const char *mode)
 #ifdef _IO_MTSAFE_IO
   new_f->fp.file._lock = &new_f->lock;
 #endif
-  /* Set up initially to use the `maybe_mmap' jump tables rather than using
-     __fopen_maybe_mmap to do it, because we need them in place before we
-     call _IO_file_attach or else it will allocate a buffer immediately.  */
   _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd,
 #ifdef _G_HAVE_MMAP
 	       (use_mmap && (read_write & _IO_NO_WRITES))
 	       ? &_IO_wfile_jumps_maybe_mmap :
 #endif
-	       &INTUSE(_IO_wfile_jumps));
+	       &_IO_wfile_jumps);
   _IO_JUMPS (&new_f->fp) =
 #ifdef _G_HAVE_MMAP
     (use_mmap && (read_write & _IO_NO_WRITES)) ? &_IO_file_jumps_maybe_mmap :
 #endif
-      &INTUSE(_IO_file_jumps);
-  INTUSE(_IO_file_init) (&new_f->fp);
+      &_IO_file_jumps;
+  _IO_file_init (&new_f->fp);
 #if  !_IO_UNIFIED_JUMPTABLES
   new_f->fp.vtable = NULL;
 #endif
-  if (INTUSE(_IO_file_attach) ((_IO_FILE *) &new_f->fp, fd) == NULL)
-    {
-      INTUSE(_IO_setb) (&new_f->fp.file, NULL, NULL, 0);
-      INTUSE(_IO_un_link) (&new_f->fp);
-      free (new_f);
-      return NULL;
-    }
+  /* We only need to record the fd because _IO_file_init will have unset the
+     offset.  It is important to unset the cached offset because the real
+     offset in the file could change between now and when the handle is
+     activated and we would then mislead ftell into believing that we have a
+     valid offset.  */
+  new_f->fp.file._fileno = fd;
   new_f->fp.file._flags &= ~_IO_DELETE_DONT_CLOSE;
 
-  new_f->fp.file._IO_file_flags =
-    _IO_mask_flags (&new_f->fp.file, read_write,
-		    _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+  _IO_mask_flags (&new_f->fp.file, read_write,
+		  _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
 
+  /* For append mode, set the file offset to the end of the file if we added
+     O_APPEND to the file descriptor flags.  Don't update the offset cache
+     though, since the file handle is not active.  */
+  if (do_seek && ((read_write & (_IO_IS_APPENDING | _IO_NO_READS))
+		  == (_IO_IS_APPENDING | _IO_NO_READS)))
+    {
+      _IO_off64_t new_pos = _IO_SYSSEEK (&new_f->fp.file, 0, _IO_seek_end);
+      if (new_pos == _IO_pos_BAD && errno != ESPIPE)
+	return NULL;
+    }
   return &new_f->fp.file;
 }
-INTDEF2(_IO_new_fdopen, _IO_fdopen)
+libc_hidden_ver (_IO_new_fdopen, _IO_fdopen)
 
 strong_alias (_IO_new_fdopen, __new_fdopen)
 versioned_symbol (libc, _IO_new_fdopen, _IO_fdopen, GLIBC_2_1);
diff --git a/src/system/libroot/posix/glibc/libio/iofflush.c b/src/system/libroot/posix/glibc/libio/iofflush.c
index eb2393782e..1ccda72233 100644
--- a/src/system/libroot/posix/glibc/libio/iofflush.c
+++ b/src/system/libroot/posix/glibc/libio/iofflush.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1998,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,20 +32,18 @@ _IO_fflush (fp)
      _IO_FILE *fp;
 {
   if (fp == NULL)
-    return INTUSE(_IO_flush_all) ();
+    return _IO_flush_all ();
   else
     {
       int result;
       CHECK_FILE (fp, EOF);
-      _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-      _IO_flockfile (fp);
+      _IO_acquire_lock (fp);
       result = _IO_SYNC (fp) ? EOF : 0;
-      _IO_funlockfile (fp);
-      _IO_cleanup_region_end (0);
+      _IO_release_lock (fp);
       return result;
     }
 }
-INTDEF(_IO_fflush)
+libc_hidden_def (_IO_fflush)
 
 #ifdef weak_alias
 weak_alias(_IO_fflush, fflush)
diff --git a/src/system/libroot/posix/glibc/libio/iofgetpos.c b/src/system/libroot/posix/glibc/libio/iofgetpos.c
index 0c80b2fae5..cd5a5d4f1e 100644
--- a/src/system/libroot/posix/glibc/libio/iofgetpos.c
+++ b/src/system/libroot/posix/glibc/libio/iofgetpos.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995-2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,7 +24,17 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
+/* We need to avoid the header declarations of these, because
+   the types don't match _IO_fgetpos and then the compiler will
+   complain about the mismatch when we do the alias below.  */
+#define _IO_new_fgetpos64 __renamed__IO_new_fgetpos64
+#define _IO_fgetpos64 __renamed__IO_fgetpos64
+
 #include "libioP.h"
+
+#undef _IO_new_fgetpos64
+#undef _IO_fgetpos64
+
 #include <errno.h>
 #include <stdlib.h>
 #include <shlib-compat.h>
@@ -38,10 +47,9 @@ _IO_new_fgetpos (fp, posp)
   _IO_off64_t pos;
   int result = 0;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
-  if (_IO_in_backup (fp))
+  if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
     {
       if (fp->_mode <= 0)
 	pos -= fp->_IO_save_end - fp->_IO_save_base;
@@ -72,11 +80,17 @@ _IO_new_fgetpos (fp, posp)
 	posp->__state = fp->_wide_data->_IO_state;
     }
 
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
 strong_alias (_IO_new_fgetpos, __new_fgetpos)
 versioned_symbol (libc, _IO_new_fgetpos, _IO_fgetpos, GLIBC_2_2);
 versioned_symbol (libc, __new_fgetpos, fgetpos, GLIBC_2_2);
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (_IO_new_fgetpos, _IO_new_fgetpos64)
+strong_alias (_IO_new_fgetpos64, __new_fgetpos64)
+versioned_symbol (libc, _IO_new_fgetpos64, _IO_fgetpos64, GLIBC_2_2);
+versioned_symbol (libc, __new_fgetpos64, fgetpos64, GLIBC_2_2);
+#endif
diff --git a/src/system/libroot/posix/glibc/libio/iofgets.c b/src/system/libroot/posix/glibc/libio/iofgets.c
index ea1d3ed53b..1b708cad0d 100644
--- a/src/system/libroot/posix/glibc/libio/iofgets.c
+++ b/src/system/libroot/posix/glibc/libio/iofgets.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,14 +39,21 @@ _IO_fgets (buf, n, fp)
   CHECK_FILE (fp, NULL);
   if (n <= 0)
     return NULL;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  if (__glibc_unlikely (n == 1))
+    {
+      /* Another irregular case: since we have to store a NUL byte and
+	 there is only room for exactly one byte, we don't have to
+	 read anything.  */
+      buf[0] = '\0';
+      return buf;
+    }
+  _IO_acquire_lock (fp);
   /* This is very tricky since a file descriptor may be in the
      non-blocking mode. The error flag doesn't mean much in this
      case. We return an error only when there is a new error. */
   old_error = fp->_IO_file_flags & _IO_ERR_SEEN;
   fp->_IO_file_flags &= ~_IO_ERR_SEEN;
-  count = INTUSE(_IO_getline) (fp, buf, n - 1, '\n', 1);
+  count = _IO_getline (fp, buf, n - 1, '\n', 1);
   /* If we read in some bytes and errno is EAGAIN, that error will
      be reported for next read. */
   if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN)
@@ -59,8 +65,7 @@ _IO_fgets (buf, n, fp)
       result = buf;
     }
   fp->_IO_file_flags |= old_error;
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/iofgets_u.c b/src/system/libroot/posix/glibc/libio/iofgets_u.c
index ded2a7c83c..b2d4d8fe2b 100644
--- a/src/system/libroot/posix/glibc/libio/iofgets_u.c
+++ b/src/system/libroot/posix/glibc/libio/iofgets_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1996,1997,1998,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,16 +39,24 @@ fgets_unlocked (buf, n, fp)
   CHECK_FILE (fp, NULL);
   if (n <= 0)
     return NULL;
+  if (__glibc_unlikely (n == 1))
+    {
+      /* Another irregular case: since we have to store a NUL byte and
+	 there is only room for exactly one byte, we don't have to
+	 read anything.  */
+      buf[0] = '\0';
+      return buf;
+    }
   /* This is very tricky since a file descriptor may be in the
      non-blocking mode. The error flag doesn't mean much in this
      case. We return an error only when there is a new error. */
   old_error = fp->_IO_file_flags & _IO_ERR_SEEN;
   fp->_IO_file_flags &= ~_IO_ERR_SEEN;
-  count = INTUSE(_IO_getline) (fp, buf, n - 1, '\n', 1);
+  count = _IO_getline (fp, buf, n - 1, '\n', 1);
   /* If we read in some bytes and errno is EAGAIN, that error will
      be reported for next read. */
   if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN)
-  		     && errno != EAGAIN))
+		     && errno != EAGAIN))
     result = NULL;
   else
     {
diff --git a/src/system/libroot/posix/glibc/libio/iofgetws.c b/src/system/libroot/posix/glibc/libio/iofgetws.c
index 741bb49e6f..fcbdda8765 100644
--- a/src/system/libroot/posix/glibc/libio/iofgetws.c
+++ b/src/system/libroot/posix/glibc/libio/iofgetws.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 95, 96, 97, 98, 99, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,8 +39,15 @@ fgetws (buf, n, fp)
   CHECK_FILE (fp, NULL);
   if (n <= 0)
     return NULL;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  if (__glibc_unlikely (n == 1))
+    {
+      /* Another irregular case: since we have to store a NUL byte and
+	 there is only room for exactly one byte, we don't have to
+	 read anything.  */
+      buf[0] = L'\0';
+      return buf;
+    }
+  _IO_acquire_lock (fp);
   /* This is very tricky since a file descriptor may be in the
      non-blocking mode. The error flag doesn't mean much in this
      case. We return an error only when there is a new error. */
@@ -58,7 +64,6 @@ fgetws (buf, n, fp)
       result = buf;
     }
   fp->_IO_file_flags |= old_error;
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/iofgetws_u.c b/src/system/libroot/posix/glibc/libio/iofgetws_u.c
index 1253564566..1126d7bd3b 100644
--- a/src/system/libroot/posix/glibc/libio/iofgetws_u.c
+++ b/src/system/libroot/posix/glibc/libio/iofgetws_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,6 +39,14 @@ fgetws_unlocked (buf, n, fp)
   CHECK_FILE (fp, NULL);
   if (n <= 0)
     return NULL;
+  if (__glibc_unlikely (n == 1))
+    {
+      /* Another irregular case: since we have to store a NUL byte and
+	 there is only room for exactly one byte, we don't have to
+	 read anything.  */
+      buf[0] = L'\0';
+      return buf;
+    }
   /* This is very tricky since a file descriptor may be in the
      non-blocking mode. The error flag doesn't mean much in this
      case. We return an error only when there is a new error. */
@@ -49,7 +56,7 @@ fgetws_unlocked (buf, n, fp)
   /* If we read in some bytes and errno is EAGAIN, that error will
      be reported for next read. */
   if (count == 0 || ((fp->_IO_file_flags & _IO_ERR_SEEN)
-  		     && errno != EAGAIN))
+		     && errno != EAGAIN))
     result = NULL;
   else
     {
diff --git a/src/system/libroot/posix/glibc/libio/iofopen.c b/src/system/libroot/posix/glibc/libio/iofopen.c
index 8cd68a3690..4fbf4864de 100644
--- a/src/system/libroot/posix/glibc/libio/iofopen.c
+++ b/src/system/libroot/posix/glibc/libio/iofopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -26,10 +25,9 @@
    in files containing the exception.  */
 
 #include "libioP.h"
-#ifdef __STDC__
+#include <fcntl.h>
 #include <stdlib.h>
 #include <stddef.h>
-#endif
 #ifdef _LIBC
 # include <shlib-compat.h>
 #else
@@ -80,20 +78,19 @@ __fopen_internal (filename, mode, is32)
   new_f->fp.file._lock = &new_f->lock;
 #endif
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-  _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &INTUSE(_IO_wfile_jumps));
+  _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps);
 #else
   _IO_no_init (&new_f->fp.file, 1, 0, NULL, NULL);
 #endif
-  _IO_JUMPS (&new_f->fp) = &INTUSE(_IO_file_jumps);
-  INTUSE(_IO_file_init) (&new_f->fp);
+  _IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
+  _IO_file_init (&new_f->fp);
 #if  !_IO_UNIFIED_JUMPTABLES
   new_f->fp.vtable = NULL;
 #endif
-  if (INTUSE(_IO_file_fopen) ((_IO_FILE *) new_f, filename, mode, is32)
-      != NULL)
+  if (_IO_file_fopen ((_IO_FILE *) new_f, filename, mode, is32) != NULL)
     return __fopen_maybe_mmap (&new_f->fp.file);
 
-  INTUSE(_IO_un_link) (&new_f->fp);
+  _IO_un_link (&new_f->fp);
   free (new_f);
   return NULL;
 }
@@ -110,4 +107,9 @@ _IO_new_fopen (filename, mode)
 strong_alias (_IO_new_fopen, __new_fopen)
 versioned_symbol (libc, _IO_new_fopen, _IO_fopen, GLIBC_2_1);
 versioned_symbol (libc, __new_fopen, fopen, GLIBC_2_1);
+
+# if !defined O_LARGEFILE || O_LARGEFILE == 0
+weak_alias (_IO_new_fopen, _IO_fopen64)
+weak_alias (_IO_new_fopen, fopen64)
+# endif
 #endif
diff --git a/src/system/libroot/posix/glibc/libio/iofopncook.c b/src/system/libroot/posix/glibc/libio/iofopncook.c
index b35b56d24b..5211e64364 100644
--- a/src/system/libroot/posix/glibc/libio/iofopncook.c
+++ b/src/system/libroot/posix/glibc/libio/iofopncook.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,95,97,99,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -31,11 +30,13 @@
 #include <shlib-compat.h>
 
 /* Prototyped for local functions.  */
-static _IO_ssize_t _IO_cookie_read (register _IO_FILE* fp, void* buf,
+static _IO_ssize_t _IO_cookie_read (_IO_FILE* fp, void* buf,
 				    _IO_ssize_t size);
-static _IO_ssize_t _IO_cookie_write (register _IO_FILE* fp,
+static _IO_ssize_t _IO_cookie_write (_IO_FILE* fp,
 				     const void* buf, _IO_ssize_t size);
 static _IO_off64_t _IO_cookie_seek (_IO_FILE *fp, _IO_off64_t offset, int dir);
+static _IO_off64_t _IO_cookie_seekoff (_IO_FILE *fp, _IO_off64_t offset,
+				       int dir, int mode);
 static int _IO_cookie_close (_IO_FILE* fp);
 
 static _IO_ssize_t
@@ -59,11 +60,19 @@ _IO_cookie_write (fp, buf, size)
      _IO_ssize_t size;
 {
   struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp;
+  _IO_ssize_t n;
 
   if (cfile->__io_functions.write == NULL)
-    return -1;
+    {
+      fp->_flags |= _IO_ERR_SEEN;
+      return 0;
+    }
+
+  n = cfile->__io_functions.write (cfile->__cookie, buf, size);
+  if (n < size)
+    fp->_flags |= _IO_ERR_SEEN;
 
-  return cfile->__io_functions.write (cfile->__cookie, buf, size);
+  return n;
 }
 
 static _IO_off64_t
@@ -94,20 +103,34 @@ _IO_cookie_close (fp)
 }
 
 
-static struct _IO_jump_t _IO_cookie_jumps = {
+static _IO_off64_t
+_IO_cookie_seekoff (fp, offset, dir, mode)
+     _IO_FILE *fp;
+     _IO_off64_t offset;
+     int dir;
+     int mode;
+{
+  /* We must force the fileops code to always use seek to determine
+     the position.  */
+  fp->_offset = _IO_pos_BAD;
+  return _IO_file_seekoff (fp, offset, dir, mode);
+}
+
+
+static const struct _IO_jump_t _IO_cookie_jumps = {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, INTUSE(_IO_file_finish)),
-  JUMP_INIT(overflow, INTUSE(_IO_file_overflow)),
-  JUMP_INIT(underflow, INTUSE(_IO_file_underflow)),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)),
+  JUMP_INIT(finish, _IO_file_finish),
+  JUMP_INIT(overflow, _IO_file_overflow),
+  JUMP_INIT(underflow, _IO_file_underflow),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
+  JUMP_INIT(xsputn, _IO_file_xsputn),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
+  JUMP_INIT(seekoff, _IO_cookie_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)),
-  JUMP_INIT(sync, INTUSE(_IO_file_sync)),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
+  JUMP_INIT(setbuf, _IO_file_setbuf),
+  JUMP_INIT(sync, _IO_file_sync),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
   JUMP_INIT(read, _IO_cookie_read),
   JUMP_INIT(write, _IO_cookie_write),
   JUMP_INIT(seek, _IO_cookie_seek),
@@ -122,17 +145,16 @@ void
 _IO_cookie_init (struct _IO_cookie_file *cfile, int read_write,
 		 void *cookie, _IO_cookie_io_functions_t io_functions)
 {
-  INTUSE(_IO_init) (&cfile->__fp.file, 0);
+  _IO_init (&cfile->__fp.file, 0);
   _IO_JUMPS (&cfile->__fp) = &_IO_cookie_jumps;
 
   cfile->__cookie = cookie;
   cfile->__io_functions = io_functions;
 
-  INTUSE(_IO_file_init) (&cfile->__fp);
+  _IO_file_init (&cfile->__fp);
 
-  cfile->__fp.file._IO_file_flags =
-    _IO_mask_flags (&cfile->__fp.file, read_write,
-		    _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+  _IO_mask_flags (&cfile->__fp.file, read_write,
+		  _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
 
   /* We use a negative number different from -1 for _fileno to mark that
      this special stream is not associated with a real file, but still has
@@ -195,6 +217,7 @@ _IO_FILE * _IO_old_fopencookie (void *cookie, const char *mode,
 				_IO_cookie_io_functions_t io_functions);
 
 static _IO_off64_t
+attribute_compat_text_section
 _IO_old_cookie_seek (fp, offset, dir)
      _IO_FILE *fp;
      _IO_off64_t offset;
@@ -213,20 +236,20 @@ _IO_old_cookie_seek (fp, offset, dir)
   return (ret == -1) ? _IO_pos_BAD : ret;
 }
 
-static struct _IO_jump_t _IO_old_cookie_jumps = {
+static const struct _IO_jump_t _IO_old_cookie_jumps = {
   JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, INTUSE(_IO_file_finish)),
-  JUMP_INIT(overflow, INTUSE(_IO_file_overflow)),
-  JUMP_INIT(underflow, INTUSE(_IO_file_underflow)),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_file_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_file_seekoff)),
+  JUMP_INIT(finish, _IO_file_finish),
+  JUMP_INIT(overflow, _IO_file_overflow),
+  JUMP_INIT(underflow, _IO_file_underflow),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
+  JUMP_INIT(xsputn, _IO_file_xsputn),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
+  JUMP_INIT(seekoff, _IO_cookie_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, INTUSE(_IO_file_setbuf)),
-  JUMP_INIT(sync, INTUSE(_IO_file_sync)),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
+  JUMP_INIT(setbuf, _IO_file_setbuf),
+  JUMP_INIT(sync, _IO_file_sync),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
   JUMP_INIT(read, _IO_cookie_read),
   JUMP_INIT(write, _IO_cookie_write),
   JUMP_INIT(seek, _IO_old_cookie_seek),
@@ -237,6 +260,7 @@ static struct _IO_jump_t _IO_old_cookie_jumps = {
 };
 
 _IO_FILE *
+attribute_compat_text_section
 _IO_old_fopencookie (cookie, mode, io_functions)
      void *cookie;
      const char *mode;
diff --git a/src/system/libroot/posix/glibc/libio/iofputs.c b/src/system/libroot/posix/glibc/libio/iofputs.c
index 011a19acd8..ff4f132db3 100644
--- a/src/system/libroot/posix/glibc/libio/iofputs.c
+++ b/src/system/libroot/posix/glibc/libio/iofputs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1996,1997,1998,1999,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -35,15 +34,12 @@ _IO_fputs (str, fp)
 {
   _IO_size_t len = strlen (str);
   int result = EOF;
-
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
-  if ((fp->_vtable_offset != 0 || _IO_fwide (fp, -1) == -1)
+  _IO_acquire_lock (fp);
+  if ((_IO_vtable_offset (fp) != 0 || _IO_fwide (fp, -1) == -1)
       && _IO_sputn (fp, str, len) == len)
     result = 1;
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 libc_hidden_def (_IO_fputs)
diff --git a/src/system/libroot/posix/glibc/libio/iofputs_u.c b/src/system/libroot/posix/glibc/libio/iofputs_u.c
index 475e5334d2..dc2536742c 100644
--- a/src/system/libroot/posix/glibc/libio/iofputs_u.c
+++ b/src/system/libroot/posix/glibc/libio/iofputs_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1996,1997,1998,1999,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/iofputws.c b/src/system/libroot/posix/glibc/libio/iofputws.c
index c23156dceb..d502af46d8 100644
--- a/src/system/libroot/posix/glibc/libio/iofputws.c
+++ b/src/system/libroot/posix/glibc/libio/iofputws.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1996,1997,1998,1999,2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,12 +35,10 @@ fputws (str, fp)
   _IO_size_t len = __wcslen (str);
   int result = EOF;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   if (_IO_fwide (fp, 1) == 1
       && _IO_sputn (fp, (char *) str, len) == len)
     result = 1;
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/iofputws_u.c b/src/system/libroot/posix/glibc/libio/iofputws_u.c
index a73f6b529e..60fd349638 100644
--- a/src/system/libroot/posix/glibc/libio/iofputws_u.c
+++ b/src/system/libroot/posix/glibc/libio/iofputws_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996-2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/iofread.c b/src/system/libroot/posix/glibc/libio/iofread.c
index 6eb99da4ab..ca792a20bd 100644
--- a/src/system/libroot/posix/glibc/libio/iofread.c
+++ b/src/system/libroot/posix/glibc/libio/iofread.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1997,1998,1999,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -39,14 +38,12 @@ _IO_fread (buf, size, count, fp)
   CHECK_FILE (fp, 0);
   if (bytes_requested == 0)
     return 0;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
-  bytes_read = INTUSE(_IO_sgetn) (fp, (char *) buf, bytes_requested);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_acquire_lock (fp);
+  bytes_read = _IO_sgetn (fp, (char *) buf, bytes_requested);
+  _IO_release_lock (fp);
   return bytes_requested == bytes_read ? count : bytes_read / size;
 }
-INTDEF(_IO_fread)
+libc_hidden_def (_IO_fread)
 
 #ifdef weak_alias
 weak_alias (_IO_fread, fread)
diff --git a/src/system/libroot/posix/glibc/libio/iofread_u.c b/src/system/libroot/posix/glibc/libio/iofread_u.c
index 98c7ffdd16..5e462254a9 100644
--- a/src/system/libroot/posix/glibc/libio/iofread_u.c
+++ b/src/system/libroot/posix/glibc/libio/iofread_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -42,7 +41,7 @@ fread_unlocked (buf, size, count, fp)
   CHECK_FILE (fp, 0);
   if (bytes_requested == 0)
     return 0;
-  bytes_read = INTUSE(_IO_sgetn) (fp, (char *) buf, bytes_requested);
+  bytes_read = _IO_sgetn (fp, (char *) buf, bytes_requested);
   return bytes_requested == bytes_read ? count : bytes_read / size;
 }
 libc_hidden_def (fread_unlocked)
diff --git a/src/system/libroot/posix/glibc/libio/iofsetpos.c b/src/system/libroot/posix/glibc/libio/iofsetpos.c
index f3821e2fa5..3c89d682b3 100644
--- a/src/system/libroot/posix/glibc/libio/iofsetpos.c
+++ b/src/system/libroot/posix/glibc/libio/iofsetpos.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1997-2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,7 +24,17 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
+/* We need to avoid the header declarations of these, because
+   the types don't match _IO_fsetpos and then the compiler will
+   complain about the mismatch when we do the alias below.  */
+#define _IO_new_fsetpos64 __renamed__IO_new_fsetpos64
+#define _IO_fsetpos64 __renamed__IO_fsetpos64
+
 #include <libioP.h>
+
+#undef _IO_new_fsetpos64
+#undef _IO_fsetpos64
+
 #include <errno.h>
 #include <shlib-compat.h>
 
@@ -36,8 +45,7 @@ _IO_new_fsetpos (fp, posp)
 {
   int result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   if (_IO_seekpos_unlocked (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT)
       == _IO_pos_BAD)
     {
@@ -57,11 +65,17 @@ _IO_new_fsetpos (fp, posp)
 	/* This is a stateful encoding, restore the state.  */
 	fp->_wide_data->_IO_state = posp->__state;
     }
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
 strong_alias (_IO_new_fsetpos, __new_fsetpos)
 versioned_symbol (libc, _IO_new_fsetpos, _IO_fsetpos, GLIBC_2_2);
 versioned_symbol (libc, __new_fsetpos, fsetpos, GLIBC_2_2);
+
+#ifdef __OFF_T_MATCHES_OFF64_T
+strong_alias (_IO_new_fsetpos, _IO_new_fsetpos64)
+strong_alias (_IO_new_fsetpos64, __new_fsetpos64)
+versioned_symbol (libc, __new_fsetpos64, fsetpos64, GLIBC_2_2);
+versioned_symbol (libc, _IO_new_fsetpos64, _IO_fsetpos64, GLIBC_2_2);
+#endif
diff --git a/src/system/libroot/posix/glibc/libio/ioftell.c b/src/system/libroot/posix/glibc/libio/ioftell.c
index fd5da6b618..2bf38e0e32 100644
--- a/src/system/libroot/posix/glibc/libio/ioftell.c
+++ b/src/system/libroot/posix/glibc/libio/ioftell.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,16 +35,14 @@ _IO_ftell (fp)
 {
   _IO_off64_t pos;
   CHECK_FILE (fp, -1L);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0);
-  if (_IO_in_backup (fp))
+  if (_IO_in_backup (fp) && pos != _IO_pos_BAD)
     {
-      if (fp->_vtable_offset != 0 || fp->_mode <= 0)
+      if (_IO_vtable_offset (fp) != 0 || fp->_mode <= 0)
 	pos -= fp->_IO_save_end - fp->_IO_save_base;
     }
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   if (pos == _IO_pos_BAD)
     {
 #ifdef EIO
@@ -54,7 +51,7 @@ _IO_ftell (fp)
 #endif
       return -1L;
     }
-  if ((_IO_off64_t) (off_t) pos != pos)
+  if ((_IO_off64_t) (long int) pos != pos)
     {
 #ifdef EOVERFLOW
       __set_errno (EOVERFLOW);
@@ -63,7 +60,7 @@ _IO_ftell (fp)
     }
   return pos;
 }
-INTDEF(_IO_ftell)
+libc_hidden_def (_IO_ftell)
 
 #ifdef weak_alias
 weak_alias (_IO_ftell, ftell)
diff --git a/src/system/libroot/posix/glibc/libio/iofwide.c b/src/system/libroot/posix/glibc/libio/iofwide.c
index e62223a4eb..f14011bc64 100644
--- a/src/system/libroot/posix/glibc/libio/iofwide.c
+++ b/src/system/libroot/posix/glibc/libio/iofwide.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1999, 2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1999-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,8 +39,10 @@
 # include <wcsmbs/wcsmbsload.h>
 # include <iconv/gconv_int.h>
 # include <shlib-compat.h>
+# include <sysdep.h>
 #endif
 
+
 /* Prototypes of libio's codecvt functions.  */
 static enum __codecvt_result do_out (struct _IO_codecvt *codecvt,
 				     __mbstate_t *statep,
@@ -67,7 +68,7 @@ static int do_always_noconv (struct _IO_codecvt *codecvt);
 
 
 /* The functions used in `codecvt' for libio are always the same.  */
-struct _IO_codecvt __libio_codecvt =
+const struct _IO_codecvt __libio_codecvt =
 {
   .__codecvt_destr = NULL,		/* Destructor, never used.  */
   .__codecvt_do_out = do_out,
@@ -81,51 +82,48 @@ struct _IO_codecvt __libio_codecvt =
 
 
 #ifdef _LIBC
-struct __gconv_trans_data __libio_translit attribute_hidden =
+const struct __gconv_trans_data __libio_translit attribute_hidden =
 {
   .__trans_fct = NULL
 };
 #endif
 
-/* Return orientation of stream.  If mode is nonzero try to change
- * the orientation first.
- */
 
+/* Return orientation of stream.  If mode is nonzero try to change
+   the orientation first.  */
 #undef _IO_fwide
-
 int
-_IO_fwide(_IO_FILE *fp, int mode)
+_IO_fwide (fp, mode)
+     _IO_FILE *fp;
+     int mode;
 {
-	/* Normalize the value.  */
-	mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
-
-	if (mode == 0) {
-		/* The caller simply wants to know about the current orientation. */
-		return fp->_mode;
-	}
+  /* Normalize the value.  */
+  mode = mode < 0 ? -1 : (mode == 0 ? 0 : 1);
 
 #if defined SHARED && defined _LIBC \
     && SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
   if (__builtin_expect (&_IO_stdin_used == NULL, 0)
-      && (fp == _IO_stdin ||  fp == _IO_stdout || fp == _IO_stderr))
+      && (fp == _IO_stdin || fp == _IO_stdout || fp == _IO_stderr))
     /* This is for a stream in the glibc 2.0 format.  */
     return -1;
 #endif
 
-	if (fp->_mode != 0) {
-		/* The orientation already has been determined.  */
-		return fp->_mode;
-	}
+  /* The orientation already has been determined.  */
+  if (fp->_mode != 0
+      /* Or the caller simply wants to know about the current orientation.  */
+      || mode == 0)
+    return fp->_mode;
 
-	{
-		struct _IO_codecvt *cc = fp->_codecvt = &fp->_wide_data->_codecvt;
+  /* Set the orientation appropriately.  */
+  if (mode > 0)
+    {
+      struct _IO_codecvt *cc = fp->_codecvt = &fp->_wide_data->_codecvt;
 
-		fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
-		fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
+      fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
+      fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_write_base;
 
-		/* Get the character conversion functions based on the currently
-		 * selected locale for LC_CTYPE.
-		 */
+      /* Get the character conversion functions based on the currently
+	 selected locale for LC_CTYPE.  */
 #ifdef _LIBC
       {
 	struct gconv_fcts fcts;
@@ -161,7 +159,8 @@ _IO_fwide(_IO_FILE *fp, int mode)
 	cc->__cd_out.__cd.__data[0].__statep = &fp->_wide_data->_IO_state;
 
 	/* And now the transliteration.  */
-	cc->__cd_out.__cd.__data[0].__trans = &__libio_translit;
+	cc->__cd_out.__cd.__data[0].__trans
+	  = (struct __gconv_trans_data  *) &__libio_translit;
       }
 #else
 # ifdef _GLIBCPP_USE_WCHAR_T
@@ -201,19 +200,15 @@ _IO_fwide(_IO_FILE *fp, int mode)
 
       /* From now on use the wide character callback functions.  */
       ((struct _IO_FILE_plus *) fp)->vtable = fp->_wide_data->_wide_vtable;
-
-      /* One last twist: we get the current stream position.  The wide
-	 char streams have much more problems with not knowing the
-	 current position and so we should disable the optimization
-	 which allows the functions without knowing the position.  */
-      fp->_offset = _IO_SYSSEEK (fp, 0, _IO_seek_cur);
     }
-	/* Set the mode now.  */
-	fp->_mode = mode;
 
-	return mode;
+  /* Set the mode now.  */
+  fp->_mode = mode;
+
+  return mode;
 }
 
+
 static enum __codecvt_result
 do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
 	const wchar_t *from_start, const wchar_t *from_end,
@@ -227,18 +222,25 @@ do_out (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   int status;
   size_t dummy;
   const unsigned char *from_start_copy = (unsigned char *) from_start;
+  __gconv_fct fct;
 
-  codecvt->__cd_out.__cd.__data[0].__outbuf = to_start;
-  codecvt->__cd_out.__cd.__data[0].__outbufend = to_end;
+  codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start;
+  codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
   codecvt->__cd_out.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_out.__cd.__data, &from_start_copy,
 			 (const unsigned char *) from_end, NULL,
 			 &dummy, 0, 0));
 
   *from_stop = (wchar_t *) from_start_copy;
-  *to_stop = codecvt->__cd_out.__cd.__data[0].__outbuf;
+  *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf;
 
   switch (status)
     {
@@ -293,16 +295,23 @@ do_unshift (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   struct __gconv_step *gs = codecvt->__cd_out.__cd.__steps;
   int status;
   size_t dummy;
+  __gconv_fct fct;
 
-  codecvt->__cd_out.__cd.__data[0].__outbuf = to_start;
-  codecvt->__cd_out.__cd.__data[0].__outbufend = to_end;
+  codecvt->__cd_out.__cd.__data[0].__outbuf = (unsigned char *) to_start;
+  codecvt->__cd_out.__cd.__data[0].__outbufend = (unsigned char *) to_end;
   codecvt->__cd_out.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_out.__cd.__data, NULL, NULL,
 			 NULL, &dummy, 1, 0));
 
-  *to_stop = codecvt->__cd_out.__cd.__data[0].__outbuf;
+  *to_stop = (char *) codecvt->__cd_out.__cd.__data[0].__outbuf;
 
   switch (status)
     {
@@ -356,16 +365,24 @@ do_in (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   int status;
   size_t dummy;
   const unsigned char *from_start_copy = (unsigned char *) from_start;
+  __gconv_fct fct;
 
-  codecvt->__cd_in.__cd.__data[0].__outbuf = (char *) to_start;
-  codecvt->__cd_in.__cd.__data[0].__outbufend = (char *) to_end;
+  codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_start;
+  codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) to_end;
   codecvt->__cd_in.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
+  fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  status = DL_CALL_FCT (fct,
 			(gs, codecvt->__cd_in.__cd.__data, &from_start_copy,
-			 from_end, NULL, &dummy, 0, 0));
+			 (const unsigned char *) from_end, NULL,
+			 &dummy, 0, 0));
 
-  *from_stop = from_start_copy;
+  *from_stop = (const char *) from_start_copy;
   *to_stop = (wchar_t *) codecvt->__cd_in.__cd.__data[0].__outbuf;
 
   switch (status)
@@ -451,16 +468,23 @@ do_length (struct _IO_codecvt *codecvt, __mbstate_t *statep,
   const unsigned char *cp = (const unsigned char *) from_start;
   wchar_t to_buf[max];
   struct __gconv_step *gs = codecvt->__cd_in.__cd.__steps;
-  int status;
   size_t dummy;
+  __gconv_fct fct;
 
-  codecvt->__cd_in.__cd.__data[0].__outbuf = (char *) to_buf;
-  codecvt->__cd_in.__cd.__data[0].__outbufend = (char *) &to_buf[max];
+  codecvt->__cd_in.__cd.__data[0].__outbuf = (unsigned char *) to_buf;
+  codecvt->__cd_in.__cd.__data[0].__outbufend = (unsigned char *) &to_buf[max];
   codecvt->__cd_in.__cd.__data[0].__statep = statep;
 
-  status = DL_CALL_FCT (gs->__fct,
-			(gs, codecvt->__cd_in.__cd.__data, &cp, from_end,
-			 NULL, &dummy, 0, 0));
+  fct = gs->__fct;
+#ifdef PTR_DEMANGLE
+  if (gs->__shlib_handle != NULL)
+    PTR_DEMANGLE (fct);
+#endif
+
+  DL_CALL_FCT (fct,
+	       (gs, codecvt->__cd_in.__cd.__data, &cp,
+		(const unsigned char *) from_end, NULL,
+		&dummy, 0, 0));
 
   result = cp - (const unsigned char *) from_start;
 #else
diff --git a/src/system/libroot/posix/glibc/libio/iofwrite.c b/src/system/libroot/posix/glibc/libio/iofwrite.c
index 67ed6a1f12..cd11bb43ae 100644
--- a/src/system/libroot/posix/glibc/libio/iofwrite.c
+++ b/src/system/libroot/posix/glibc/libio/iofwrite.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,96,97,98,99,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -39,18 +38,20 @@ _IO_fwrite (buf, size, count, fp)
   CHECK_FILE (fp, 0);
   if (request == 0)
     return 0;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
-  if (fp->_vtable_offset != 0 || _IO_fwide (fp, -1) == -1)
+  _IO_acquire_lock (fp);
+  if (_IO_vtable_offset (fp) != 0 || _IO_fwide (fp, -1) == -1)
     written = _IO_sputn (fp, (const char *) buf, request);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
-  if (written == request)
+  _IO_release_lock (fp);
+  /* We have written all of the input in case the return value indicates
+     this or EOF is returned.  The latter is a special case where we
+     simply did not manage to flush the buffer.  But the data is in the
+     buffer and therefore written as far as fwrite is concerned.  */
+  if (written == request || written == EOF)
     return count;
   else
     return written / size;
 }
-INTDEF(_IO_fwrite)
+libc_hidden_def (_IO_fwrite)
 
 #ifdef weak_alias
 # include <stdio.h>
diff --git a/src/system/libroot/posix/glibc/libio/iofwrite_u.c b/src/system/libroot/posix/glibc/libio/iofwrite_u.c
index 738cc5b28f..157fed8c3a 100644
--- a/src/system/libroot/posix/glibc/libio/iofwrite_u.c
+++ b/src/system/libroot/posix/glibc/libio/iofwrite_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996-2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -45,7 +44,11 @@ fwrite_unlocked (buf, size, count, fp)
   if (_IO_fwide (fp, -1) == -1)
     {
       written = _IO_sputn (fp, (const char *) buf, request);
-      if (written == request)
+      /* We have written all of the input in case the return value indicates
+	 this or EOF is returned.  The latter is a special case where we
+	 simply did not manage to flush the buffer.  But the data is in the
+	 buffer and therefore written as far as fwrite is concerned.  */
+      if (written == request || written == EOF)
 	return count;
     }
 
diff --git a/src/system/libroot/posix/glibc/libio/iogetdelim.c b/src/system/libroot/posix/glibc/libio/iogetdelim.c
index d515e3b525..a817050d8f 100644
--- a/src/system/libroot/posix/glibc/libio/iogetdelim.c
+++ b/src/system/libroot/posix/glibc/libio/iogetdelim.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994, 1996, 1997, 1998, 2001 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -23,13 +22,13 @@
    however invalidate any other reasons why the executable file
    might be covered by the GNU Lesser General Public License.
    This exception applies to code released by its copyright holders
-   in files containing the exception.
-*/
+   in files containing the exception.  */
 
-#include "libioP.h"
 #include <stdlib.h>
+#include "libioP.h"
 #include <string.h>
 #include <errno.h>
+#include <limits.h>
 
 /* Read up to (and including) a TERMINATOR from FP into *LINEPTR
    (and null-terminate it).  *LINEPTR is a pointer returned from malloc (or
@@ -38,9 +37,13 @@
    null terminator), or -1 on error or EOF.  */
 
 _IO_ssize_t
-_IO_getdelim(char **lineptr, _IO_size_t *n, int delimiter, _IO_FILE *fp)
+_IO_getdelim (lineptr, n, delimiter, fp)
+     char **lineptr;
+     _IO_size_t *n;
+     int delimiter;
+     _IO_FILE *fp;
 {
-  int result;
+  _IO_ssize_t result;
   _IO_ssize_t cur_len = 0;
   _IO_ssize_t len;
 
@@ -50,8 +53,7 @@ _IO_getdelim(char **lineptr, _IO_size_t *n, int delimiter, _IO_FILE *fp)
       return -1;
     }
   CHECK_FILE (fp, -1);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   if (_IO_ferror_unlocked (fp))
     {
       result = -1;
@@ -87,6 +89,12 @@ _IO_getdelim(char **lineptr, _IO_size_t *n, int delimiter, _IO_FILE *fp)
       t = (char *) memchr ((void *) fp->_IO_read_ptr, delimiter, len);
       if (t != NULL)
 	len = (t - fp->_IO_read_ptr) + 1;
+      if (__glibc_unlikely (len >= SSIZE_MAX - cur_len))
+	{
+	  __set_errno (EOVERFLOW);
+	  result = -1;
+	  goto unlock_return;
+	}
       /* Make enough space for len+1 (for final NUL) bytes.  */
       needed = cur_len + len + 1;
       if (needed > *n)
@@ -115,8 +123,7 @@ _IO_getdelim(char **lineptr, _IO_size_t *n, int delimiter, _IO_FILE *fp)
   result = cur_len;
 
 unlock_return:
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/iogetline.c b/src/system/libroot/posix/glibc/libio/iogetline.c
index eca38cf773..3ca38606dc 100644
--- a/src/system/libroot/posix/glibc/libio/iogetline.c
+++ b/src/system/libroot/posix/glibc/libio/iogetline.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1997,1998,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -28,8 +27,6 @@
 #include "libioP.h"
 #include <string.h>
 
-#if defined _LIBC || !_G_HAVE_IO_GETLINE_INFO
-
 _IO_size_t
 _IO_getline (fp, buf, n, delim, extract_delim)
      _IO_FILE *fp;
@@ -38,10 +35,9 @@ _IO_getline (fp, buf, n, delim, extract_delim)
      int delim;
      int extract_delim;
 {
-  return INTUSE(_IO_getline_info) (fp, buf, n, delim, extract_delim,
-				   (int *) 0);
+  return _IO_getline_info (fp, buf, n, delim, extract_delim, (int *) 0);
 }
-INTDEF(_IO_getline)
+libc_hidden_def (_IO_getline)
 
 /* Algorithm based on that used by Berkeley pre-4.4 fgets implementation.
 
@@ -73,7 +69,8 @@ _IO_getline_info (fp, buf, n, delim, extract_delim, eof)
 	  int c = __uflow (fp);
 	  if (c == EOF)
 	    {
-	      if (eof) *eof = c;
+	      if (eof)
+		*eof = c;
 	      break;
 	    }
 	  if (c == delim)
@@ -81,7 +78,7 @@ _IO_getline_info (fp, buf, n, delim, extract_delim, eof)
  	      if (extract_delim > 0)
 		*ptr++ = c;
 	      else if (extract_delim < 0)
-		INTUSE(_IO_sputbackc) (fp, c);
+		_IO_sputbackc (fp, c);
 	      if (extract_delim > 0)
 		++len;
 	      return ptr - buf;
@@ -89,34 +86,32 @@ _IO_getline_info (fp, buf, n, delim, extract_delim, eof)
 	  *ptr++ = c;
 	  n--;
 	}
-	else
-	  {
-	    char *t;
-	    if ((_IO_size_t) len >= n)
-	      len = n;
-	    t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len);
-	    if (t != NULL)
-	      {
-		_IO_size_t old_len = ptr-buf;
-		len = t - fp->_IO_read_ptr;
-		if (extract_delim >= 0)
-		  {
-		    ++t;
-		    if (extract_delim > 0)
-		      ++len;
-		  }
-		memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len);
-		fp->_IO_read_ptr = t;
-		return old_len + len;
-	      }
-	    memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len);
-	    fp->_IO_read_ptr += len;
-	    ptr += len;
-	    n -= len;
-	  }
+      else
+	{
+	  char *t;
+	  if ((_IO_size_t) len >= n)
+	    len = n;
+	  t = (char *) memchr ((void *) fp->_IO_read_ptr, delim, len);
+	  if (t != NULL)
+	    {
+	      _IO_size_t old_len = ptr-buf;
+	      len = t - fp->_IO_read_ptr;
+	      if (extract_delim >= 0)
+		{
+		  ++t;
+		  if (extract_delim > 0)
+		    ++len;
+		}
+	      memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len);
+	      fp->_IO_read_ptr = t;
+	      return old_len + len;
+	    }
+	  memcpy ((void *) ptr, (void *) fp->_IO_read_ptr, len);
+	  fp->_IO_read_ptr += len;
+	  ptr += len;
+	  n -= len;
+	}
     }
   return ptr - buf;
 }
-INTDEF(_IO_getline_info)
-
-#endif /* Defined _LIBC || !_G_HAVE_IO_GETLINE_INFO */
+libc_hidden_def (_IO_getline_info)
diff --git a/src/system/libroot/posix/glibc/libio/iogets.c b/src/system/libroot/posix/glibc/libio/iogets.c
index 08a382278c..7d19c68204 100644
--- a/src/system/libroot/posix/glibc/libio/iogets.c
+++ b/src/system/libroot/posix/glibc/libio/iogets.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,9 +35,7 @@ _IO_gets (buf)
   int ch;
   char *retval;
 
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-			    _IO_stdin);
-  _IO_flockfile (_IO_stdin);
+  _IO_acquire_lock (_IO_stdin);
   ch = _IO_getc_unlocked (_IO_stdin);
   if (ch == EOF)
     {
@@ -55,7 +52,7 @@ _IO_gets (buf)
       int old_error = _IO_stdin->_IO_file_flags & _IO_ERR_SEEN;
       _IO_stdin->_IO_file_flags &= ~_IO_ERR_SEEN;
       buf[0] = (char) ch;
-      count = INTUSE(_IO_getline) (_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1;
+      count = _IO_getline (_IO_stdin, buf + 1, INT_MAX, '\n', 0) + 1;
       if (_IO_stdin->_IO_file_flags & _IO_ERR_SEEN)
 	{
 	  retval = NULL;
@@ -67,8 +64,7 @@ _IO_gets (buf)
   buf[count] = 0;
   retval = buf;
 unlock_return:
-  _IO_funlockfile (_IO_stdin);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (_IO_stdin);
   return retval;
 }
 
@@ -77,5 +73,5 @@ weak_alias (_IO_gets, gets)
 #endif
 
 #ifdef _LIBC
-//link_warning (gets, "the `gets' function is dangerous and should not be used.")
+link_warning (gets, "the `gets' function is dangerous and should not be used.")
 #endif
diff --git a/src/system/libroot/posix/glibc/libio/iogetwline.c b/src/system/libroot/posix/glibc/libio/iogetwline.c
index e529b7d832..b7c1196921 100644
--- a/src/system/libroot/posix/glibc/libio/iogetwline.c
+++ b/src/system/libroot/posix/glibc/libio/iogetwline.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1997,1998,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,8 +32,6 @@
 # define wmemcpy __wmemcpy
 #endif
 
-#if defined _LIBC || !_G_HAVE_IO_GETLINE_INFO
-
 _IO_size_t
 _IO_getwline (fp, buf, n, delim, extract_delim)
      _IO_FILE *fp;
@@ -86,10 +83,10 @@ _IO_getwline_info (fp, buf, n, delim, extract_delim, eof)
  	      if (extract_delim > 0)
 		*ptr++ = wc;
 	      else if (extract_delim < 0)
-		INTUSE(_IO_sputbackc) (fp, wc);
-	      return ptr - buf;
+		_IO_sputbackc (fp, wc);
 	      if (extract_delim > 0)
 		++len;
+	      return ptr - buf;
 	    }
 	  *ptr++ = wc;
 	  n--;
@@ -123,5 +120,3 @@ _IO_getwline_info (fp, buf, n, delim, extract_delim, eof)
     }
   return ptr - buf;
 }
-
-#endif /* Defined _LIBC || !_G_HAVE_IO_GETLINE_INFO */
diff --git a/src/system/libroot/posix/glibc/libio/iolibio.h b/src/system/libroot/posix/glibc/libio/iolibio.h
index db71be25c8..f215fcef01 100644
--- a/src/system/libroot/posix/glibc/libio/iolibio.h
+++ b/src/system/libroot/posix/glibc/libio/iolibio.h
@@ -7,50 +7,57 @@
 extern "C" {
 #endif
 
-extern int _IO_fclose __P((_IO_FILE*));
-extern int _IO_new_fclose __P((_IO_FILE*));
-extern int _IO_old_fclose __P((_IO_FILE*));
-extern _IO_FILE *_IO_fdopen __P((int, const char*));
-extern _IO_FILE *_IO_old_fdopen __P((int, const char*));
-extern _IO_FILE *_IO_new_fdopen __P((int, const char*));
-extern int _IO_fflush __P((_IO_FILE*));
-extern int _IO_fgetpos __P((_IO_FILE*, _IO_fpos_t*));
-extern int _IO_fgetpos64 __P((_IO_FILE*, _IO_fpos64_t*));
-extern char* _IO_fgets __P((char*, int, _IO_FILE*));
-extern _IO_FILE *_IO_fopen __P((const char*, const char*));
-extern _IO_FILE *_IO_old_fopen __P((const char*, const char*));
-extern _IO_FILE *_IO_new_fopen __P((const char*, const char*));
-extern _IO_FILE *_IO_fopen64 __P((const char*, const char*));
-extern _IO_FILE *__fopen_internal __P((const char*, const char*, int));
-extern _IO_FILE *__fopen_maybe_mmap __P((_IO_FILE *));
-extern int _IO_fprintf __P((_IO_FILE*, const char*, ...));
-extern int _IO_fputs __P((const char*, _IO_FILE*));
+extern int _IO_fclose (_IO_FILE*);
+extern int _IO_new_fclose (_IO_FILE*);
+extern int _IO_old_fclose (_IO_FILE*);
+extern _IO_FILE *_IO_fdopen (int, const char*) __THROW;
+libc_hidden_proto (_IO_fdopen)
+extern _IO_FILE *_IO_old_fdopen (int, const char*) __THROW;
+extern _IO_FILE *_IO_new_fdopen (int, const char*) __THROW;
+extern int _IO_fflush (_IO_FILE*);
+libc_hidden_proto (_IO_fflush)
+extern int _IO_fgetpos (_IO_FILE*, _IO_fpos_t*);
+extern int _IO_fgetpos64 (_IO_FILE*, _IO_fpos64_t*);
+extern char* _IO_fgets (char*, int, _IO_FILE*);
+extern _IO_FILE *_IO_fopen (const char*, const char*);
+extern _IO_FILE *_IO_old_fopen (const char*, const char*);
+extern _IO_FILE *_IO_new_fopen (const char*, const char*);
+extern _IO_FILE *_IO_fopen64 (const char*, const char*);
+extern _IO_FILE *__fopen_internal (const char*, const char*, int);
+extern _IO_FILE *__fopen_maybe_mmap (_IO_FILE *) __THROW;
+extern int _IO_fprintf (_IO_FILE*, const char*, ...);
+extern int _IO_fputs (const char*, _IO_FILE*);
 libc_hidden_proto (_IO_fputs)
-extern int _IO_fsetpos __P((_IO_FILE*, const _IO_fpos_t *));
-extern int _IO_fsetpos64 __P((_IO_FILE*, const _IO_fpos64_t *));
-extern long int _IO_ftell __P((_IO_FILE*));
-extern _IO_size_t _IO_fread __P((void*, _IO_size_t, _IO_size_t, _IO_FILE*));
-extern _IO_size_t _IO_fwrite __P((const void*,
-				      _IO_size_t, _IO_size_t, _IO_FILE*));
-extern char* _IO_gets __P((char*));
-extern void _IO_perror __P((const char*));
-extern int _IO_printf __P((const char*, ...));
-extern int _IO_puts __P((const char*));
-extern int _IO_scanf __P((const char*, ...));
-extern void _IO_setbuffer __P((_IO_FILE *, char*, _IO_size_t));
-extern int _IO_setvbuf __P((_IO_FILE*, char*, int, _IO_size_t));
-extern int _IO_sscanf __P((const char*, const char*, ...));
-extern int _IO_sprintf __P((char *, const char*, ...));
-extern int _IO_ungetc __P((int, _IO_FILE*));
-extern int _IO_vsscanf __P((const char *, const char *, _IO_va_list));
-extern int _IO_vsprintf __P((char*, const char*, _IO_va_list));
-extern int _IO_vswprintf __P((wchar_t*, _IO_size_t, const wchar_t*,
-			      _IO_va_list));
+extern int _IO_fsetpos (_IO_FILE*, const _IO_fpos_t *);
+extern int _IO_fsetpos64 (_IO_FILE*, const _IO_fpos64_t *);
+extern long int _IO_ftell (_IO_FILE*);
+libc_hidden_proto (_IO_ftell)
+extern _IO_size_t _IO_fread (void*, _IO_size_t, _IO_size_t, _IO_FILE*);
+libc_hidden_proto (_IO_fread)
+extern _IO_size_t _IO_fwrite (const void*, _IO_size_t, _IO_size_t, _IO_FILE*);
+libc_hidden_proto (_IO_fwrite)
+extern char* _IO_gets (char*);
+extern void _IO_perror (const char*) __THROW;
+extern int _IO_printf (const char*, ...);
+extern int _IO_puts (const char*);
+extern int _IO_scanf (const char*, ...);
+extern void _IO_setbuffer (_IO_FILE *, char*, _IO_size_t) __THROW;
+libc_hidden_proto (_IO_setbuffer)
+extern int _IO_setvbuf (_IO_FILE*, char*, int, _IO_size_t) __THROW;
+libc_hidden_proto (_IO_setvbuf)
+extern int _IO_sscanf (const char*, const char*, ...) __THROW;
+extern int _IO_sprintf (char *, const char*, ...) __THROW;
+extern int _IO_ungetc (int, _IO_FILE*) __THROW;
+extern int _IO_vsscanf (const char *, const char *, _IO_va_list) __THROW;
+extern int _IO_vsprintf (char*, const char*, _IO_va_list) __THROW;
+libc_hidden_proto (_IO_vsprintf)
+extern int _IO_vswprintf (wchar_t*, _IO_size_t, const wchar_t*, _IO_va_list)
+       __THROW;
 
 struct obstack;
-extern int _IO_obstack_vprintf __P ((struct obstack *, const char *,
-				     _IO_va_list));
-extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
+extern int _IO_obstack_vprintf (struct obstack *, const char *, _IO_va_list)
+       __THROW;
+extern int _IO_obstack_printf (struct obstack *, const char *, ...) __THROW;
 #ifndef _IO_pos_BAD
 #define _IO_pos_BAD ((_IO_off64_t)(-1))
 #endif
@@ -61,40 +68,27 @@ extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
 #define _IO_rewind(FILE) \
   (void) _IO_seekoff_unlocked (FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT)
 #define _IO_vprintf(FORMAT, ARGS) \
-  INTUSE(_IO_vfprintf) (_IO_stdout, FORMAT, ARGS)
+  _IO_vfprintf (_IO_stdout, FORMAT, ARGS)
 #define _IO_freopen(FILENAME, MODE, FP) \
-  (INTUSE(_IO_file_close_it)(FP), \
-   INTUSE(_IO_file_fopen)(FP, FILENAME, MODE, 1))
+  (_IO_file_close_it (FP), \
+   _IO_file_fopen (FP, FILENAME, MODE, 1))
 #define _IO_old_freopen(FILENAME, MODE, FP) \
   (_IO_old_file_close_it (FP), _IO_old_file_fopen(FP, FILENAME, MODE))
 #define _IO_freopen64(FILENAME, MODE, FP) \
-  (INTUSE(_IO_file_close_it)(FP), \
-   INTUSE(_IO_file_fopen)(FP, FILENAME, MODE, 0))
+  (_IO_file_close_it (FP), \
+   _IO_file_fopen (FP, FILENAME, MODE, 0))
 #define _IO_fileno(FP) ((FP)->_fileno)
-extern _IO_FILE* _IO_popen __P((const char*, const char*));
-extern _IO_FILE* _IO_new_popen __P((const char*, const char*));
-extern _IO_FILE* _IO_old_popen __P((const char*, const char*));
-extern int __new_pclose __P((_IO_FILE *));
-extern int __old_pclose __P((_IO_FILE *));
+extern _IO_FILE* _IO_popen (const char*, const char*) __THROW;
+extern _IO_FILE* _IO_new_popen (const char*, const char*) __THROW;
+extern _IO_FILE* _IO_old_popen (const char*, const char*) __THROW;
+extern int __new_pclose (_IO_FILE *) __THROW;
+extern int __old_pclose (_IO_FILE *) __THROW;
 #define _IO_pclose _IO_fclose
-#define _IO_setbuf(_FP, _BUF) INTUSE(_IO_setbuffer)(_FP, _BUF, _IO_BUFSIZ)
-#define _IO_setlinebuf(_FP) INTUSE(_IO_setvbuf)(_FP, NULL, 1, 0)
+#define _IO_setbuf(_FP, _BUF) _IO_setbuffer (_FP, _BUF, _IO_BUFSIZ)
+#define _IO_setlinebuf(_FP) _IO_setvbuf (_FP, NULL, 1, 0)
 
-_IO_FILE *__new_freopen __P ((const char *, const char *, _IO_FILE *));
-_IO_FILE *__old_freopen __P ((const char *, const char *, _IO_FILE *));
-
-/* Prototype for functions with alternative entry point.  */
-extern void _IO_setbuffer_internal __P((_IO_FILE *, char*, _IO_size_t));
-extern _IO_size_t _IO_fread_internal __P((void*, _IO_size_t, _IO_size_t,
-					  _IO_FILE*));
-extern _IO_FILE *_IO_fdopen_internal __P((int, const char*));
-extern int _IO_vsprintf_internal __P((char*, const char*, _IO_va_list));
-extern int _IO_fflush_internal __P((_IO_FILE*));
-extern _IO_size_t _IO_fwrite_internal __P((const void*, _IO_size_t,
-					   _IO_size_t, _IO_FILE*));
-extern long int _IO_ftell_internal __P((_IO_FILE*));
-extern int _IO_fputs_internal __P((const char*, _IO_FILE*));
-extern int _IO_setvbuf_internal __P((_IO_FILE*, char*, int, _IO_size_t));
+_IO_FILE *__new_freopen (const char *, const char *, _IO_FILE *) __THROW;
+_IO_FILE *__old_freopen (const char *, const char *, _IO_FILE *) __THROW;
 
 #ifdef __cplusplus
 }
diff --git a/src/system/libroot/posix/glibc/libio/iopadn.c b/src/system/libroot/posix/glibc/libio/iopadn.c
index b957394356..e1c5344634 100644
--- a/src/system/libroot/posix/glibc/libio/iopadn.c
+++ b/src/system/libroot/posix/glibc/libio/iopadn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -70,4 +69,4 @@ _IO_padn (fp, pad, count)
     }
   return written;
 }
-INTDEF(_IO_padn)
+libc_hidden_def (_IO_padn)
diff --git a/src/system/libroot/posix/glibc/libio/iopopen.c b/src/system/libroot/posix/glibc/libio/iopopen.c
index 7654de4f88..5d2ce4a571 100644
--- a/src/system/libroot/posix/glibc/libio/iopopen.c
+++ b/src/system/libroot/posix/glibc/libio/iopopen.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997-2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Per Bothner <bothner@cygnus.com>.
 
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -29,25 +28,55 @@
 #ifndef _POSIX_SOURCE
 # define _POSIX_SOURCE
 #endif
-
-#include <sys/types.h>
-#include <sys/wait.h>
 #include "libioP.h"
-#if _IO_HAVE_SYS_WAIT
 #include <signal.h>
 #include <unistd.h>
-#ifdef __STDC__
 #include <stdlib.h>
-#endif
 #ifdef _LIBC
 # include <unistd.h>
 # include <shlib-compat.h>
+# include <not-cancel.h>
+#endif
+#include <sys/types.h>
+#include <sys/wait.h>
+
+#ifndef __HAIKU__
+#include <kernel-features.h>
+#else
+#define __ASSUME_PIPE2
 #endif
 
-#endif /* _IO_HAVE_SYS_WAIT */
+#ifndef _IO_fork
+#define _IO_fork fork
+extern _IO_pid_t _IO_fork (void) __THROW;
+#endif
+
+#ifndef _IO_dup2
+#define _IO_dup2 dup2
+extern int _IO_dup2 (int fd, int fd2) __THROW;
+#endif
+
+#ifndef _IO_waitpid
+#ifdef _LIBC
+#define _IO_waitpid waitpid_not_cancel
+#else
+#define _IO_waitpid waitpid
+#endif
+#endif
+
+#ifndef _IO_execl
+#define _IO_execl execl
+#endif
+#ifndef _IO__exit
+#define _IO__exit _exit
+#endif
 
 #ifndef _IO_close
-#	define _IO_close close
+#ifdef _LIBC
+#define _IO_close close_not_cancel
+#else
+#define _IO_close close
+#endif
 #endif
 
 struct _IO_proc_file
@@ -59,22 +88,19 @@ struct _IO_proc_file
 };
 typedef struct _IO_proc_file _IO_proc_file;
 
-static struct _IO_jump_t _IO_proc_jumps;
-static struct _IO_jump_t _IO_wproc_jumps;
+static const struct _IO_jump_t _IO_proc_jumps;
 
 static struct _IO_proc_file *proc_file_chain;
 
 #ifdef _IO_MTSAFE_IO
 static _IO_lock_t proc_file_chain_lock = _IO_lock_initializer;
 
-#if 0
 static void
 unlock (void *not_used)
 {
   _IO_lock_unlock (proc_file_chain_lock);
 }
 #endif
-#endif
 
 _IO_FILE *
 _IO_new_proc_open (fp, command, mode)
@@ -82,54 +108,119 @@ _IO_new_proc_open (fp, command, mode)
      const char *command;
      const char *mode;
 {
-#if _IO_HAVE_SYS_WAIT
-  volatile int read_or_write;
-  volatile int parent_end, child_end;
+  int read_or_write;
+  int parent_end, child_end;
   int pipe_fds[2];
   _IO_pid_t child_pid;
+
+  int do_read = 0;
+  int do_write = 0;
+  int do_cloexec = 0;
+  while (*mode != '\0')
+    switch (*mode++)
+      {
+      case 'r':
+	do_read = 1;
+	break;
+      case 'w':
+	do_write = 1;
+	break;
+      case 'e':
+	do_cloexec = 1;
+	break;
+      default:
+      errout:
+	__set_errno (EINVAL);
+	return NULL;
+      }
+
+  if ((do_read ^ do_write) == 0)
+    goto errout;
+
   if (_IO_file_is_open (fp))
     return NULL;
-  if (pipe(pipe_fds) < 0)
-    return NULL;
-  if (mode[0] == 'r' && mode[1] == '\0')
+
+#ifdef O_CLOEXEC
+# ifndef __ASSUME_PIPE2
+  if (__have_pipe2 >= 0)
+# endif
+    {
+      int r = __pipe2 (pipe_fds, O_CLOEXEC);
+# ifndef __ASSUME_PIPE2
+      if (__have_pipe2 == 0)
+	__have_pipe2 = r != -1 || errno != ENOSYS ? 1 : -1;
+
+      if (__have_pipe2 > 0)
+# endif
+	if (r < 0)
+	  return NULL;
+    }
+#endif
+#ifndef __ASSUME_PIPE2
+# ifdef O_CLOEXEC
+  if (__have_pipe2 < 0)
+# endif
+    if (__pipe (pipe_fds) < 0)
+      return NULL;
+#endif
+
+  if (do_read)
     {
       parent_end = pipe_fds[0];
       child_end = pipe_fds[1];
       read_or_write = _IO_NO_WRITES;
     }
-  else if (mode[0] == 'w' && mode[1] == '\0')
+  else
     {
       parent_end = pipe_fds[1];
       child_end = pipe_fds[0];
       read_or_write = _IO_NO_READS;
     }
-  else
-    {
-      _IO_close (pipe_fds[0]);
-      _IO_close (pipe_fds[1]);
-      __set_errno (EINVAL);
-      return NULL;
-    }
-  ((_IO_proc_file *) fp)->pid = child_pid = fork();
+
+  ((_IO_proc_file *) fp)->pid = child_pid = _IO_fork ();
   if (child_pid == 0)
     {
-      int child_std_end = mode[0] == 'r' ? 1 : 0;
+      int child_std_end = do_read ? 1 : 0;
       struct _IO_proc_file *p;
 
+#ifndef __ASSUME_PIPE2
+      /* If we have pipe2 the descriptor is marked for close-on-exec.  */
       _IO_close (parent_end);
+#endif
       if (child_end != child_std_end)
 	{
-	  dup2(child_end, child_std_end);
+	  _IO_dup2 (child_end, child_std_end);
+#ifndef __ASSUME_PIPE2
 	  _IO_close (child_end);
+#endif
+	}
+#ifdef O_CLOEXEC
+      else
+	{
+	  /* The descriptor is already the one we will use.  But it must
+	     not be marked close-on-exec.  Undo the effects.  */
+# ifndef __ASSUME_PIPE2
+	  if (__have_pipe2 > 0)
+# endif
+	    __fcntl (child_end, F_SETFD, 0);
 	}
+#endif
       /* POSIX.2:  "popen() shall ensure that any streams from previous
          popen() calls that remain open in the parent process are closed
 	 in the new child process." */
       for (p = proc_file_chain; p; p = p->next)
-	_IO_close (_IO_fileno ((_IO_FILE *) p));
+	{
+	  int fd = _IO_fileno ((_IO_FILE *) p);
+
+	  /* If any stream from previous popen() calls has fileno
+	     child_std_end, it has been already closed by the dup2 syscall
+	     above.  */
+	  if (fd != child_std_end)
+	    _IO_close (fd);
+	}
 
-      execl("/bin/sh", "sh", "-c", command, (char *)0);
-      _exit(127);
+      _IO_execl ("/bin/sh", "sh", "-c", command, (char *) 0);
+      _IO__exit (127);
     }
   _IO_close (child_end);
   if (child_pid < 0)
@@ -137,6 +228,28 @@ _IO_new_proc_open (fp, command, mode)
       _IO_close (parent_end);
       return NULL;
     }
+
+  if (do_cloexec)
+    {
+#ifndef __ASSUME_PIPE2
+# ifdef O_CLOEXEC
+      if (__have_pipe2 < 0)
+# endif
+	__fcntl (parent_end, F_SETFD, FD_CLOEXEC);
+#endif
+    }
+  else
+    {
+#ifdef O_CLOEXEC
+      /* Undo the effects of the pipe2 call which set the
+	 close-on-exec flag.  */
+# ifndef __ASSUME_PIPE2
+      if (__have_pipe2 > 0)
+# endif
+	__fcntl (parent_end, F_SETFD, 0);
+#endif
+    }
+
   _IO_fileno (fp) = parent_end;
 
   /* Link into proc_file_chain. */
@@ -153,9 +266,6 @@ _IO_new_proc_open (fp, command, mode)
 
   _IO_mask_flags (fp, read_or_write, _IO_NO_READS|_IO_NO_WRITES);
   return fp;
-#else /* !_IO_HAVE_SYS_WAIT */
-  return NULL;
-#endif
 }
 
 _IO_FILE *
@@ -169,7 +279,6 @@ _IO_new_popen (command, mode)
 #ifdef _IO_MTSAFE_IO
     _IO_lock_t lock;
 #endif
-    struct _IO_wide_data wd;
   } *new_f;
   _IO_FILE *fp;
 
@@ -180,7 +289,7 @@ _IO_new_popen (command, mode)
   new_f->fpx.file.file._lock = &new_f->lock;
 #endif
   fp = &new_f->fpx.file.file;
-  _IO_no_init (fp, 0, 0, &new_f->wd, &_IO_wproc_jumps);
+  _IO_init (fp, 0);
   _IO_JUMPS (&new_f->fpx.file) = &_IO_proc_jumps;
   _IO_new_file_init (&new_f->fpx.file);
 #if  !_IO_UNIFIED_JUMPTABLES
@@ -188,7 +297,7 @@ _IO_new_popen (command, mode)
 #endif
   if (_IO_new_proc_open (fp, command, mode) != NULL)
     return (_IO_FILE *) &new_f->fpx.file;
-  INTUSE(_IO_un_link) (&new_f->fpx.file);
+  _IO_un_link (&new_f->fpx.file);
   free (new_f);
   return NULL;
 }
@@ -198,7 +307,6 @@ _IO_new_proc_close (fp)
      _IO_FILE *fp;
 {
   /* This is not name-space clean. FIXME! */
-#if _IO_HAVE_SYS_WAIT
   int wstatus;
   _IO_proc_file **ptr = &proc_file_chain;
   _IO_pid_t wait_pid;
@@ -231,59 +339,33 @@ _IO_new_proc_close (fp)
      described in POSIX.2, such implementations are not conforming." */
   do
     {
-      wait_pid = waitpid(((_IO_proc_file *) fp)->pid, &wstatus, 0);
+      wait_pid = _IO_waitpid (((_IO_proc_file *) fp)->pid, &wstatus, 0);
     }
   while (wait_pid == -1 && errno == EINTR);
   if (wait_pid == -1)
     return -1;
   return wstatus;
-#else /* !_IO_HAVE_SYS_WAIT */
-  return -1;
-#endif
 }
 
-static struct _IO_jump_t _IO_proc_jumps = {
-  JUMP_INIT_DUMMY,
-  JUMP_INIT(finish, _IO_new_file_finish),
-  JUMP_INIT(overflow, _IO_new_file_overflow),
-  JUMP_INIT(underflow, _IO_new_file_underflow),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
-  JUMP_INIT(xsputn, _IO_new_file_xsputn),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
-  JUMP_INIT(seekoff, _IO_new_file_seekoff),
-  JUMP_INIT(seekpos, _IO_default_seekpos),
-  JUMP_INIT(setbuf, _IO_new_file_setbuf),
-  JUMP_INIT(sync, _IO_new_file_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
-  JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
-  JUMP_INIT(close, _IO_new_proc_close),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
-  JUMP_INIT(showmanyc, _IO_default_showmanyc),
-  JUMP_INIT(imbue, _IO_default_imbue)
-};
-
-static struct _IO_jump_t _IO_wproc_jumps = {
+static const struct _IO_jump_t _IO_proc_jumps = {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_new_file_finish),
   JUMP_INIT(overflow, _IO_new_file_overflow),
   JUMP_INIT(underflow, _IO_new_file_underflow),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_default_pbackfail)),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_default_pbackfail),
   JUMP_INIT(xsputn, _IO_new_file_xsputn),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
   JUMP_INIT(seekoff, _IO_new_file_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_new_file_setbuf),
   JUMP_INIT(sync, _IO_new_file_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_file_doallocate)),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(doallocate, _IO_file_doallocate),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
+  JUMP_INIT(seek, _IO_file_seek),
   JUMP_INIT(close, _IO_new_proc_close),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
diff --git a/src/system/libroot/posix/glibc/libio/ioputs.c b/src/system/libroot/posix/glibc/libio/ioputs.c
index 047db0c0a0..e6d5c141f8 100644
--- a/src/system/libroot/posix/glibc/libio/ioputs.c
+++ b/src/system/libroot/posix/glibc/libio/ioputs.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -23,34 +22,31 @@
    however invalidate any other reasons why the executable file
    might be covered by the GNU Lesser General Public License.
    This exception applies to code released by its copyright holders
-   in files containing the exception.
-*/
-
+   in files containing the exception.  */
 
 #include "libioP.h"
 #include <string.h>
-
+#include <limits.h>
+#include <sys/param.h>
 
 int
-_IO_puts(const char *str)
+_IO_puts (str)
+     const char *str;
 {
-	int result = EOF;
-	_IO_size_t len = strlen(str);
-
-	_IO_cleanup_region_start((void (*) __P ((void *))) _IO_funlockfile, _IO_stdout);
-	_IO_flockfile(_IO_stdout);
-
-	if ((_IO_stdout->_vtable_offset != 0 || _IO_fwide(_IO_stdout, -1) == -1)
-		&& _IO_sputn(_IO_stdout, str, len) == len
-		&& _IO_putc_unlocked('\n', _IO_stdout) != EOF)
-		result = len + 1;
-
-	_IO_funlockfile(_IO_stdout);
-	_IO_cleanup_region_end(0);
-
-	return result;
+  int result = EOF;
+  _IO_size_t len = strlen (str);
+  _IO_acquire_lock (_IO_stdout);
+
+  if ((_IO_vtable_offset (_IO_stdout) != 0
+       || _IO_fwide (_IO_stdout, -1) == -1)
+      && _IO_sputn (_IO_stdout, str, len) == len
+      && _IO_putc_unlocked ('\n', _IO_stdout) != EOF)
+    result = MIN (INT_MAX, len + 1);
+
+  _IO_release_lock (_IO_stdout);
+  return result;
 }
 
 #ifdef weak_alias
-weak_alias(_IO_puts, puts)
+weak_alias (_IO_puts, puts)
 #endif
diff --git a/src/system/libroot/posix/glibc/libio/ioseekoff.c b/src/system/libroot/posix/glibc/libio/ioseekoff.c
index 154a343ced..fdb7968149 100644
--- a/src/system/libroot/posix/glibc/libio/ioseekoff.c
+++ b/src/system/libroot/posix/glibc/libio/ioseekoff.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1997,1998,1999,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,9 +24,15 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
-#include <libioP.h>
 #include <stdlib.h>
+#include <libioP.h>
 #include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+#ifndef __set_errno
+# define __set_errno(Val) errno = (Val)
+#endif
 
 _IO_off64_t
 _IO_seekoff_unlocked (fp, offset, dir, mode)
@@ -50,15 +55,15 @@ _IO_seekoff_unlocked (fp, offset, dir, mode)
     {
       if (dir == _IO_seek_cur && _IO_in_backup (fp))
 	{
-	  if (fp->_vtable_offset != 0 || fp->_mode <= 0)
+	  if (_IO_vtable_offset (fp) != 0 || fp->_mode <= 0)
 	    offset -= fp->_IO_read_end - fp->_IO_read_ptr;
 	  else
 	    abort ();
 	}
       if (_IO_fwide (fp, 0) < 0)
-	INTUSE(_IO_free_backup_area) (fp);
+	_IO_free_backup_area (fp);
       else
-	INTUSE(_IO_free_wbackup_area) (fp);
+	_IO_free_wbackup_area (fp);
     }
 
   return _IO_SEEKOFF (fp, offset, dir, mode);
@@ -74,12 +79,8 @@ _IO_seekoff (fp, offset, dir, mode)
 {
   _IO_off64_t retval;
 
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
-
+  _IO_acquire_lock (fp);
   retval = _IO_seekoff_unlocked (fp, offset, dir, mode);
-
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return retval;
 }
diff --git a/src/system/libroot/posix/glibc/libio/ioseekpos.c b/src/system/libroot/posix/glibc/libio/ioseekpos.c
index 1cb38dd28a..45b656751c 100644
--- a/src/system/libroot/posix/glibc/libio/ioseekpos.c
+++ b/src/system/libroot/posix/glibc/libio/ioseekpos.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1998, 1999, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -23,44 +22,44 @@
    however invalidate any other reasons why the executable file
    might be covered by the GNU Lesser General Public License.
    This exception applies to code released by its copyright holders
-   in files containing the exception.
-*/
-
+   in files containing the exception.  */
 
 #include <libioP.h>
 
-
 _IO_off64_t
-_IO_seekpos_unlocked(_IO_FILE *fp, _IO_off64_t pos, int mode)
+_IO_seekpos_unlocked (fp, pos, mode)
+     _IO_FILE *fp;
+     _IO_off64_t pos;
+     int mode;
 {
-	/* If we have a backup buffer, get rid of it, since the __seekoff
-	 * callback may not know to do the right thing about it.
-	 * This may be over-kill, but it'll do for now. TODO
-	 */
-
-	if (_IO_fwide(fp, 0) <= 0) {
-		if (_IO_have_backup(fp))
-			INTUSE(_IO_free_backup_area)(fp);
-	} else {
-		if (_IO_have_wbackup(fp))
-			INTUSE(_IO_free_wbackup_area)(fp);
-	}
+  /* If we have a backup buffer, get rid of it, since the __seekoff
+     callback may not know to do the right thing about it.
+     This may be over-kill, but it'll do for now. TODO */
+  if (_IO_fwide (fp, 0) <= 0)
+    {
+      if (_IO_have_backup (fp))
+	_IO_free_backup_area (fp);
+    }
+  else
+    {
+      if (_IO_have_wbackup (fp))
+	_IO_free_wbackup_area (fp);
+    }
 
-	return _IO_SEEKPOS(fp, pos, mode);
+  return _IO_SEEKOFF (fp, pos, 0, mode);
 }
 
 
 _IO_off64_t
-_IO_seekpos(_IO_FILE *fp, _IO_off64_t pos, int mode)
+_IO_seekpos (fp, pos, mode)
+     _IO_FILE *fp;
+     _IO_off64_t pos;
+     int mode;
 {
-	_IO_off64_t retval;
-
-	_IO_cleanup_region_start((void (*) __P ((void *)))_IO_funlockfile, fp);
-	_IO_flockfile(fp);
-
-	retval = _IO_seekpos_unlocked(fp, pos, mode);
+  _IO_off64_t retval;
 
-	_IO_funlockfile(fp);
-	_IO_cleanup_region_end(0);
-	return retval;
+  _IO_acquire_lock (fp);
+  retval = _IO_seekpos_unlocked (fp, pos, mode);
+  _IO_release_lock (fp);
+  return retval;
 }
diff --git a/src/system/libroot/posix/glibc/libio/iosetbuffer.c b/src/system/libroot/posix/glibc/libio/iosetbuffer.c
index 785fcab4bd..31b0bbca09 100644
--- a/src/system/libroot/posix/glibc/libio/iosetbuffer.c
+++ b/src/system/libroot/posix/glibc/libio/iosetbuffer.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,95,96,97,98,99,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -34,19 +33,17 @@ _IO_setbuffer (fp, buf, size)
      _IO_size_t size;
 {
   CHECK_FILE (fp, );
-  _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   fp->_flags &= ~_IO_LINE_BUF;
   if (!buf)
     size = 0;
   (void) _IO_SETBUF (fp, buf, size);
-  if (fp->_vtable_offset == 0 && fp->_mode == 0 && _IO_CHECK_WIDE (fp))
+  if (_IO_vtable_offset (fp) == 0 && fp->_mode == 0 && _IO_CHECK_WIDE (fp))
     /* We also have to set the buffer using the wide char function.  */
     (void) _IO_WSETBUF (fp, buf, size);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
 }
-INTDEF(_IO_setbuffer)
+libc_hidden_def (_IO_setbuffer)
 
 #ifdef weak_alias
 weak_alias (_IO_setbuffer, setbuffer)
diff --git a/src/system/libroot/posix/glibc/libio/iosetvbuf.c b/src/system/libroot/posix/glibc/libio/iosetvbuf.c
index 06d9f73fc4..d97e4820af 100644
--- a/src/system/libroot/posix/glibc/libio/iosetvbuf.c
+++ b/src/system/libroot/posix/glibc/libio/iosetvbuf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,96,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,12 +39,11 @@ _IO_setvbuf (fp, buf, mode, size)
 {
   int result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   switch (mode)
     {
     case _IOFBF:
-      fp->_IO_file_flags &= ~_IO_LINE_BUF|_IO_UNBUFFERED;
+      fp->_IO_file_flags &= ~(_IO_LINE_BUF|_IO_UNBUFFERED);
       if (buf == NULL)
 	{
 	  if (fp->_IO_buf_base == NULL)
@@ -96,11 +94,10 @@ _IO_setvbuf (fp, buf, mode, size)
   result = _IO_SETBUF (fp, buf, size) == NULL ? EOF : 0;
 
 unlock_return:
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
-INTDEF(_IO_setvbuf)
+libc_hidden_def (_IO_setvbuf)
 
 #ifdef weak_alias
 weak_alias (_IO_setvbuf, setvbuf)
diff --git a/src/system/libroot/posix/glibc/libio/ioungetc.c b/src/system/libroot/posix/glibc/libio/ioungetc.c
index d32359bd40..a3364ea773 100644
--- a/src/system/libroot/posix/glibc/libio/ioungetc.c
+++ b/src/system/libroot/posix/glibc/libio/ioungetc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1996,1997,1998,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,11 +35,9 @@ _IO_ungetc (c, fp)
   CHECK_FILE (fp, EOF);
   if (c == EOF)
     return EOF;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
-  result = INTUSE(_IO_sputbackc) (fp, (unsigned char) c);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_acquire_lock (fp);
+  result = _IO_sputbackc (fp, (unsigned char) c);
+  _IO_release_lock (fp);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/ioungetwc.c b/src/system/libroot/posix/glibc/libio/ioungetwc.c
index 1bff41256c..2c65d91b0d 100644
--- a/src/system/libroot/posix/glibc/libio/ioungetwc.c
+++ b/src/system/libroot/posix/glibc/libio/ioungetwc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1996-1999, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,16 +32,14 @@ ungetwc (c, fp)
      wint_t c;
      _IO_FILE *fp;
 {
-  int result;
+  wint_t result;
   CHECK_FILE (fp, WEOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   _IO_fwide (fp, 1);
   if (c == WEOF)
     result = WEOF;
   else
-    result = INTUSE(_IO_sputbackwc) (fp, c);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+    result = _IO_sputbackwc (fp, c);
+  _IO_release_lock (fp);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/iovdprintf.c b/src/system/libroot/posix/glibc/libio/iovdprintf.c
index 33fac6d8bd..21009eab6d 100644
--- a/src/system/libroot/posix/glibc/libio/iovdprintf.c
+++ b/src/system/libroot/posix/glibc/libio/iovdprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995, 1997-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,7 +24,7 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
-#include "libioP.h"
+#include <libioP.h>
 #include <stdio_ext.h>
 
 int
@@ -41,29 +40,29 @@ _IO_vdprintf (d, format, arg)
 #ifdef _IO_MTSAFE_IO
   tmpfil.file._lock = NULL;
 #endif
-  _IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &INTUSE(_IO_wfile_jumps));
-  _IO_JUMPS (&tmpfil) = &INTUSE(_IO_file_jumps);
-  INTUSE(_IO_file_init) (&tmpfil);
+  _IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps);
+  _IO_JUMPS (&tmpfil) = &_IO_file_jumps;
+  _IO_file_init (&tmpfil);
 #if  !_IO_UNIFIED_JUMPTABLES
   tmpfil.vtable = NULL;
 #endif
-  if (INTUSE(_IO_file_attach) (&tmpfil.file, d) == NULL)
+  if (_IO_file_attach (&tmpfil.file, d) == NULL)
     {
-      INTUSE(_IO_un_link) (&tmpfil);
+      _IO_un_link (&tmpfil);
       return EOF;
     }
-  tmpfil.file._IO_file_flags =
-    (_IO_mask_flags (&tmpfil.file, _IO_NO_READS,
-		     _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING)
-     | _IO_DELETE_DONT_CLOSE);
+  tmpfil.file._flags |= _IO_DELETE_DONT_CLOSE;
 
-  done = INTUSE(_IO_vfprintf) (&tmpfil.file, format, arg);
+  _IO_mask_flags (&tmpfil.file, _IO_NO_READS,
+		  _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING);
+
+  done = _IO_vfprintf (&tmpfil.file, format, arg);
+
+  if (done != EOF && _IO_do_flush (&tmpfil.file) == EOF)
+    done = EOF;
 
   _IO_FINISH (&tmpfil.file);
 
   return done;
 }
-
-#ifdef weak_alias
 weak_alias (_IO_vdprintf, vdprintf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/iovsprintf.c b/src/system/libroot/posix/glibc/libio/iovsprintf.c
index dbaa53f7c8..c4432ef0f2 100644
--- a/src/system/libroot/posix/glibc/libio/iovsprintf.c
+++ b/src/system/libroot/posix/glibc/libio/iovsprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -29,10 +28,7 @@
 #include "strfile.h"
 
 int
-_IO_vsprintf (string, format, args)
-     char *string;
-     const char *format;
-     _IO_va_list args;
+_IO_vsprintf (char *string, const char *format, _IO_va_list args)
 {
   _IO_strfile sf;
   int ret;
@@ -41,14 +37,11 @@ _IO_vsprintf (string, format, args)
   sf._sbf._f._lock = NULL;
 #endif
   _IO_no_init (&sf._sbf._f, _IO_USER_LOCK, -1, NULL, NULL);
-  _IO_JUMPS ((struct _IO_FILE_plus *) &sf._sbf) = &_IO_str_jumps;
-  INTUSE(_IO_str_init_static) (&sf, string, -1, string);
-  ret = INTUSE(_IO_vfprintf) ((_IO_FILE *) &sf._sbf, format, args);
-  _IO_putc_unlocked ('\0', (_IO_FILE *) &sf._sbf);
+  _IO_JUMPS (&sf._sbf) = &_IO_str_jumps;
+  _IO_str_init_static_internal (&sf, string, -1, string);
+  ret = _IO_vfprintf (&sf._sbf._f, format, args);
+  _IO_putc_unlocked ('\0', &sf._sbf._f);
   return ret;
 }
-INTDEF(_IO_vsprintf)
 
-#ifdef weak_alias
 weak_alias (_IO_vsprintf, vsprintf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/iovsscanf.c b/src/system/libroot/posix/glibc/libio/iovsscanf.c
index 1bb475549c..f179f35c07 100644
--- a/src/system/libroot/posix/glibc/libio/iovsscanf.c
+++ b/src/system/libroot/posix/glibc/libio/iovsscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,13 +39,10 @@ _IO_vsscanf (string, format, args)
   sf._sbf._f._lock = NULL;
 #endif
   _IO_no_init (&sf._sbf._f, _IO_USER_LOCK, -1, NULL, NULL);
-  _IO_JUMPS ((struct _IO_FILE_plus *) &sf._sbf) = &_IO_str_jumps;
-  INTUSE(_IO_str_init_static) (&sf, (char*)string, 0, NULL);
-  ret = INTUSE(_IO_vfscanf) ((_IO_FILE *) &sf._sbf, format, args, NULL);
+  _IO_JUMPS (&sf._sbf) = &_IO_str_jumps;
+  _IO_str_init_static_internal (&sf, (char*)string, 0, NULL);
+  ret = _IO_vfscanf (&sf._sbf._f, format, args, NULL);
   return ret;
 }
-
-#ifdef weak_alias
 weak_alias (_IO_vsscanf, __vsscanf)
 weak_alias (_IO_vsscanf, vsscanf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/iovswscanf.c b/src/system/libroot/posix/glibc/libio/iovswscanf.c
index 1bbddd442f..af0d9918c5 100644
--- a/src/system/libroot/posix/glibc/libio/iovswscanf.c
+++ b/src/system/libroot/posix/glibc/libio/iovswscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -30,10 +29,7 @@
 #include <wchar.h>
 
 int
-vswscanf (string, format, args)
-     const wchar_t *string;
-     const wchar_t *format;
-     _IO_va_list args;
+__vswscanf (const wchar_t *string, const wchar_t *format, _IO_va_list args)
 {
   int ret;
   _IO_strfile sf;
@@ -47,4 +43,4 @@ vswscanf (string, format, args)
   ret = _IO_vfwscanf ((_IO_FILE *) &sf._sbf, format, args, NULL);
   return ret;
 }
-libc_hidden_def (vswscanf)
+weak_alias (__vswscanf, vswscanf)
diff --git a/src/system/libroot/posix/glibc/libio/iowpadn.c b/src/system/libroot/posix/glibc/libio/iowpadn.c
index 7bbb06192b..a3581994a7 100644
--- a/src/system/libroot/posix/glibc/libio/iowpadn.c
+++ b/src/system/libroot/posix/glibc/libio/iowpadn.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/libio.h b/src/system/libroot/posix/glibc/libio/libio.h
index 45eff3d258..5c7330683e 100644
--- a/src/system/libroot/posix/glibc/libio/libio.h
+++ b/src/system/libroot/posix/glibc/libio/libio.h
@@ -31,61 +31,34 @@
 
 #include <_G_config.h>
 /* ALL of these should be defined in _G_config.h */
-#define _IO_pos_t _G_fpos_t /* obsolete */
 #define _IO_fpos_t _G_fpos_t
 #define _IO_fpos64_t _G_fpos64_t
-#define _IO_size_t _G_size_t
-#define _IO_ssize_t _G_ssize_t
-#define _IO_off_t _G_off_t
-#define _IO_off64_t _G_off64_t
-#define _IO_pid_t _G_pid_t
-#define _IO_uid_t _G_uid_t
+#define _IO_size_t size_t
+#define _IO_ssize_t __ssize_t
+#define _IO_off_t __off_t
+#define _IO_off64_t __off64_t
+#define _IO_pid_t pid_t
+#define _IO_uid_t __uid_t
 #define _IO_iconv_t _G_iconv_t
-#define _IO_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
 #define _IO_HAVE_ST_BLKSIZE _G_HAVE_ST_BLKSIZE
 #define _IO_BUFSIZ _G_BUFSIZ
 #define _IO_va_list _G_va_list
-#define _IO_wint_t _G_wint_t
+#define _IO_wint_t wint_t
 #define __mbstate_t __c_mbstate_t
 
-#ifdef _G_NEED_STDARG_H
 /* This define avoids name pollution if we're using GNU stdarg.h */
-# define __need___va_list
-# include <stdarg.h>
-# ifdef __GNUC_VA_LIST
-#  undef _IO_va_list
-#  define _IO_va_list __gnuc_va_list
-# endif /* __GNUC_VA_LIST */
-#endif
+#define __need___va_list
+#include <stdarg.h>
+#ifdef __GNUC_VA_LIST
+# undef _IO_va_list
+# define _IO_va_list __gnuc_va_list
+#endif /* __GNUC_VA_LIST */
 
 #ifndef __P
-# if _G_HAVE_SYS_CDEFS
-#  include <sys/cdefs.h>
-# else
-#  ifdef __STDC__
-#   define __P(p) p
-#   define __PMT(p) p
-#  else
-#   define __P(p) ()
-#   define __PMT(p) ()
-#  endif
-# endif
+# include <sys/cdefs.h>
 #endif /*!__P*/
 
-/* For backward compatibility */
-#ifndef _PARAMS
-# define _PARAMS(protos) __P(protos)
-#endif /*!_PARAMS*/
-
-#ifndef __STDC__
-# ifndef const
-#  define const
-# endif
-#endif
 #define _IO_UNIFIED_JUMPTABLES 1
-#ifndef _G_HAVE_PRINTF_FP
-# define _IO_USE_DTOA 1
-#endif
 
 #ifndef EOF
 # define EOF (-1)
@@ -139,7 +112,16 @@
 #define _IO_USER_LOCK 0x8000
 
 #define _IO_FLAGS2_MMAP 1
+#define _IO_FLAGS2_NOTCANCEL 2
+#ifdef _LIBC
+# define _IO_FLAGS2_FORTIFY 4
+#endif
 #define _IO_FLAGS2_USER_WBUF 8
+#ifdef _LIBC
+# define _IO_FLAGS2_SCANF_STD 16
+# define _IO_FLAGS2_NOCLOSE 32
+# define _IO_FLAGS2_CLOEXEC 64
+#endif
 
 /* These are "formatting flags" matching the iostream fmtflags enum values. */
 #define _IO_SKIPWS 01
@@ -258,7 +240,7 @@ struct _IO_wide_data
 
   wchar_t _shortbuf[1];
 
-  struct _IO_jump_t *_wide_vtable;
+  const struct _IO_jump_t *_wide_vtable;
 };
 #endif
 
@@ -406,42 +388,56 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
 extern "C" {
 #endif
 
-extern int __underflow (_IO_FILE *) __THROW;
-extern int __uflow (_IO_FILE *) __THROW;
-extern int __overflow (_IO_FILE *, int) __THROW;
-extern _IO_wint_t __wunderflow (_IO_FILE *) __THROW;
-extern _IO_wint_t __wuflow (_IO_FILE *) __THROW;
-extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t) __THROW;
+extern int __underflow (_IO_FILE *);
+extern int __uflow (_IO_FILE *);
+extern int __overflow (_IO_FILE *, int);
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+extern _IO_wint_t __wunderflow (_IO_FILE *);
+extern _IO_wint_t __wuflow (_IO_FILE *);
+extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
+#endif
+
+#if  __GNUC__ >= 3
+# define _IO_BE(expr, res) __builtin_expect ((expr), res)
+#else
+# define _IO_BE(expr, res) (expr)
+#endif
 
 #define _IO_getc_unlocked(_fp) \
-       ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end ? __uflow (_fp) \
-	: *(unsigned char *) (_fp)->_IO_read_ptr++)
+       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
+	? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++)
 #define _IO_peekc_unlocked(_fp) \
-       ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end \
+       (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
 	  && __underflow (_fp) == EOF ? EOF \
 	: *(unsigned char *) (_fp)->_IO_read_ptr)
 #define _IO_putc_unlocked(_ch, _fp) \
-   (((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \
+   (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \
     ? __overflow (_fp, (unsigned char) (_ch)) \
     : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
 
-#define _IO_getwc_unlocked(_fp) \
-  ((_fp)->_wide_data->_IO_read_ptr >= (_fp)->_wide_data->_IO_read_end \
+#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
+# define _IO_getwc_unlocked(_fp) \
+  (_IO_BE ((_fp)->_wide_data == NULL					\
+	   || ((_fp)->_wide_data->_IO_read_ptr				\
+	       >= (_fp)->_wide_data->_IO_read_end), 0)			\
    ? __wuflow (_fp) : (_IO_wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
-#define _IO_putwc_unlocked(_wch, _fp) \
-  ((_fp)->_wide_data->_IO_write_ptr >= (_fp)->_wide_data->_IO_write_end \
-   ? __woverflow (_fp, _wch) \
+# define _IO_putwc_unlocked(_wch, _fp) \
+  (_IO_BE ((_fp)->_wide_data == NULL					\
+	   || ((_fp)->_wide_data->_IO_write_ptr				\
+	       >= (_fp)->_wide_data->_IO_write_end), 0)			\
+   ? __woverflow (_fp, _wch)						\
    : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
+#endif
 
 #define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0)
 #define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0)
 
-extern int _IO_getc (_IO_FILE *__fp) __THROW;
-extern int _IO_putc (int __c, _IO_FILE *__fp) __THROW;
+extern int _IO_getc (_IO_FILE *__fp);
+extern int _IO_putc (int __c, _IO_FILE *__fp);
 extern int _IO_feof (_IO_FILE *__fp) __THROW;
 extern int _IO_ferror (_IO_FILE *__fp) __THROW;
 
-extern int _IO_peekc_locked (_IO_FILE *__fp) __THROW;
+extern int _IO_peekc_locked (_IO_FILE *__fp);
 
 /* This one is for Emacs. */
 #define _IO_PENDING_OUTPUT_COUNT(_fp)	\
@@ -467,20 +463,20 @@ extern int _IO_ftrylockfile (_IO_FILE *) __THROW;
 #endif /* !_IO_MTSAFE_IO */
 
 extern int _IO_vfscanf (_IO_FILE * __restrict, const char * __restrict,
-			_IO_va_list, int *__restrict) __THROW;
+			_IO_va_list, int *__restrict);
 extern int _IO_vfprintf (_IO_FILE *__restrict, const char *__restrict,
-			 _IO_va_list) __THROW;
-extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t) __THROW;
-extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t) __THROW;
+			 _IO_va_list);
+extern _IO_ssize_t _IO_padn (_IO_FILE *, int, _IO_ssize_t);
+extern _IO_size_t _IO_sgetn (_IO_FILE *, void *, _IO_size_t);
 
-extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW;
-extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int) __THROW;
+extern _IO_off64_t _IO_seekoff (_IO_FILE *, _IO_off64_t, int, int);
+extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int);
 
 extern void _IO_free_backup_area (_IO_FILE *) __THROW;
 
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
-extern _IO_wint_t _IO_getwc (_IO_FILE *__fp) __THROW;
-extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp) __THROW;
+extern _IO_wint_t _IO_getwc (_IO_FILE *__fp);
+extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp);
 extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW;
 # if __GNUC__ >= 2
 /* While compiling glibc we have to handle compatibility with very old
@@ -509,17 +505,17 @@ weak_extern (_IO_stdin_used);
 	 __result = (__fp)->_mode;					      \
        }								      \
      else if (__builtin_constant_p (__mode) && (__mode) == 0)		      \
-       __result = (__fp)->_mode;					      \
+       __result = _IO_fwide_maybe_incompatible ? -1 : (__fp)->_mode;	      \
      else								      \
        __result = _IO_fwide (__fp, __result);				      \
      __result; })
 # endif
 
 extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict,
-			 _IO_va_list, int *__restrict) __THROW;
+			 _IO_va_list, int *__restrict);
 extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict,
-			  _IO_va_list) __THROW;
-extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t) __THROW;
+			  _IO_va_list);
+extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t);
 extern void _IO_free_wbackup_area (_IO_FILE *) __THROW;
 #endif
 
diff --git a/src/system/libroot/posix/glibc/libio/libioP.h b/src/system/libroot/posix/glibc/libio/libioP.h
index cb1a48ac29..895d4fa566 100644
--- a/src/system/libroot/posix/glibc/libio/libioP.h
+++ b/src/system/libroot/posix/glibc/libio/libioP.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997-2002, 2003 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,10 +24,18 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
-#ifndef _LIBIO_P_H_
-#define _LIBIO_P_H_
+/* NOTE: libio is now exclusively used only by glibc since libstdc++ has its
+   own implementation.  As a result, functions that were implemented for C++
+   (like *sputn) may no longer have C++ semantics.  This is of course only
+   relevant for internal callers of these functions since these functions are
+   not intended for external use otherwise.
+
+   FIXME: All of the C++ cruft eventually needs to go away.  */
 
 #include <errno.h>
+#ifndef __set_errno
+# define __set_errno(Val) errno = (Val)
+#endif
 #if defined __GLIBC__ && __GLIBC__ >= 2
 # include <bits/libc-lock.h>
 #else
@@ -39,15 +46,6 @@
 
 /* Control of exported symbols.  Used in glibc.  By default we don't
    do anything.  */
-#ifndef INTUSE
-# define INTUSE(name) name
-#endif
-#ifndef INTDEF
-# define INTDEF(name)
-#endif
-#ifndef INTDEF2
-# define INTDEF2(name)
-#endif
 #ifndef libc_hidden_proto
 # define libc_hidden_proto(name)
 #endif
@@ -73,7 +71,7 @@ extern "C" {
  * These are all the same, just used differently.
  * An _IO_FILE (or FILE) object is allows followed by a pointer to
  * a jump table (of pointers to functions).  The pointer is accessed
- * with the _IO_JUMPS macro.  The jump table has a eccentric format,
+ * with the _IO_JUMPS macro.  The jump table has an eccentric format,
  * so as to be compatible with the layout of a C++ virtual function table.
  * (as implemented by g++).  When a pointer to a streambuf object is
  * coerced to an (_IO_FILE*), then _IO_JUMPS on the result just
@@ -100,6 +98,8 @@ extern "C" {
 #if (!defined _IO_USE_OLD_IO_FILE \
      && (!defined _G_IO_NO_BACKWARD_COMPAT || _G_IO_NO_BACKWARD_COMPAT == 0))
 # define _IO_JUMPS_OFFSET 1
+#else
+# define _IO_JUMPS_OFFSET 0
 #endif
 
 #define _IO_JUMPS(THIS) (THIS)->vtable
@@ -110,50 +110,36 @@ extern "C" {
 # define _IO_JUMPS_FUNC(THIS) \
  (*(struct _IO_jump_t **) ((void *) &_IO_JUMPS ((struct _IO_FILE_plus *) (THIS)) \
 			   + (THIS)->_vtable_offset))
+# define _IO_vtable_offset(THIS) (THIS)->_vtable_offset
 #else
 # define _IO_JUMPS_FUNC(THIS) _IO_JUMPS ((struct _IO_FILE_plus *) (THIS))
+# define _IO_vtable_offset(THIS) 0
 #endif
 #define _IO_WIDE_JUMPS_FUNC(THIS) _IO_WIDE_JUMPS(THIS)
-#ifdef _G_USING_THUNKS
-# define JUMP_FIELD(TYPE, NAME) TYPE NAME
-# define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
-# define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
-# define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
-# define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
-# define JUMP_INIT(NAME, VALUE) VALUE
-# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
-
-# define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
-# define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
-# define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
-# define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
-#else
-/* These macros will change when we re-implement vtables to use "thunks"! */
-# define JUMP_FIELD(TYPE, NAME) struct { short delta1, delta2; TYPE pfn; } NAME
-# define JUMP0(FUNC, THIS) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
-# define JUMP1(FUNC, THIS, X1) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
-# define JUMP2(FUNC, THIS, X1, X2) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
-# define JUMP3(FUNC, THIS, X1,X2,X3) _IO_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
-# define JUMP_INIT(NAME, VALUE) {0, 0, VALUE}
-# define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0)
-
-# define WJUMP0(FUNC, THIS) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS)
-# define WJUMP1(FUNC, THIS, X1) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1)
-# define WJUMP2(FUNC, THIS, X1, X2) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1, X2)
-# define WJUMP3(FUNC, THIS, X1,X2,X3) _IO_WIDE_JUMPS_FUNC(THIS)->FUNC.pfn (THIS, X1,X2,X3)
-#endif
+#define JUMP_FIELD(TYPE, NAME) TYPE NAME
+#define JUMP0(FUNC, THIS) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS)
+#define JUMP1(FUNC, THIS, X1) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
+#define JUMP2(FUNC, THIS, X1, X2) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
+#define JUMP3(FUNC, THIS, X1,X2,X3) (_IO_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
+#define JUMP_INIT(NAME, VALUE) VALUE
+#define JUMP_INIT_DUMMY JUMP_INIT(dummy, 0), JUMP_INIT (dummy2, 0)
+
+#define WJUMP0(FUNC, THIS) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS)
+#define WJUMP1(FUNC, THIS, X1) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1)
+#define WJUMP2(FUNC, THIS, X1, X2) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1, X2)
+#define WJUMP3(FUNC, THIS, X1,X2,X3) (_IO_WIDE_JUMPS_FUNC(THIS)->FUNC) (THIS, X1,X2, X3)
 
 /* The 'finish' function does any final cleaning up of an _IO_FILE object.
    It does not delete (free) it, but does everything else to finalize it.
    It matches the streambuf::~streambuf virtual destructor.  */
-typedef void (*_IO_finish_t) __PMT ((_IO_FILE *, int)); /* finalize */
+typedef void (*_IO_finish_t) (_IO_FILE *, int); /* finalize */
 #define _IO_FINISH(FP) JUMP1 (__finish, FP, 0)
 #define _IO_WFINISH(FP) WJUMP1 (__finish, FP, 0)
 
 /* The 'overflow' hook flushes the buffer.
    The second argument is a character, or EOF.
    It matches the streambuf::overflow virtual function. */
-typedef int (*_IO_overflow_t) __PMT ((_IO_FILE *, int));
+typedef int (*_IO_overflow_t) (_IO_FILE *, int);
 #define _IO_OVERFLOW(FP, CH) JUMP1 (__overflow, FP, CH)
 #define _IO_WOVERFLOW(FP, CH) WJUMP1 (__overflow, FP, CH)
 
@@ -161,7 +147,7 @@ typedef int (*_IO_overflow_t) __PMT ((_IO_FILE *, int));
    It returns the next character (as an unsigned char) or EOF.  The next
    character remains in the get buffer, and the get position is not changed.
    It matches the streambuf::underflow virtual function. */
-typedef int (*_IO_underflow_t) __PMT ((_IO_FILE *));
+typedef int (*_IO_underflow_t) (_IO_FILE *);
 #define _IO_UNDERFLOW(FP) JUMP0 (__underflow, FP)
 #define _IO_WUNDERFLOW(FP) WJUMP0 (__underflow, FP)
 
@@ -175,23 +161,22 @@ typedef int (*_IO_underflow_t) __PMT ((_IO_FILE *));
 
 /* The 'pbackfail' hook handles backing up.
    It matches the streambuf::pbackfail virtual function. */
-typedef int (*_IO_pbackfail_t) __PMT ((_IO_FILE *, int));
+typedef int (*_IO_pbackfail_t) (_IO_FILE *, int);
 #define _IO_PBACKFAIL(FP, CH) JUMP1 (__pbackfail, FP, CH)
 #define _IO_WPBACKFAIL(FP, CH) WJUMP1 (__pbackfail, FP, CH)
 
 /* The 'xsputn' hook writes upto N characters from buffer DATA.
-   Returns the number of character actually written.
+   Returns EOF or the number of character actually written.
    It matches the streambuf::xsputn virtual function. */
-typedef _IO_size_t (*_IO_xsputn_t) __PMT ((_IO_FILE *FP, const void *DATA,
-					   _IO_size_t N));
+typedef _IO_size_t (*_IO_xsputn_t) (_IO_FILE *FP, const void *DATA,
+				    _IO_size_t N);
 #define _IO_XSPUTN(FP, DATA, N) JUMP2 (__xsputn, FP, DATA, N)
 #define _IO_WXSPUTN(FP, DATA, N) WJUMP2 (__xsputn, FP, DATA, N)
 
 /* The 'xsgetn' hook reads upto N characters into buffer DATA.
    Returns the number of character actually read.
    It matches the streambuf::xsgetn virtual function. */
-typedef _IO_size_t (*_IO_xsgetn_t) __PMT ((_IO_FILE *FP, void *DATA,
-					   _IO_size_t N));
+typedef _IO_size_t (*_IO_xsgetn_t) (_IO_FILE *FP, void *DATA, _IO_size_t N);
 #define _IO_XSGETN(FP, DATA, N) JUMP2 (__xsgetn, FP, DATA, N)
 #define _IO_WXSGETN(FP, DATA, N) WJUMP2 (__xsgetn, FP, DATA, N)
 
@@ -200,8 +185,8 @@ typedef _IO_size_t (*_IO_xsgetn_t) __PMT ((_IO_FILE *FP, void *DATA,
    (MODE==1), or the end of the file (MODE==2).
    It matches the streambuf::seekoff virtual function.
    It is also used for the ANSI fseek function. */
-typedef _IO_off64_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off64_t OFF,
-					     int DIR, int MODE));
+typedef _IO_off64_t (*_IO_seekoff_t) (_IO_FILE *FP, _IO_off64_t OFF, int DIR,
+				      int MODE);
 #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
 #define _IO_WSEEKOFF(FP, OFF, DIR, MODE) WJUMP3 (__seekoff, FP, OFF, DIR, MODE)
 
@@ -210,27 +195,27 @@ typedef _IO_off64_t (*_IO_seekoff_t) __PMT ((_IO_FILE *FP, _IO_off64_t OFF,
    It matches the streambuf::seekpos virtual function.
    It is also used for the ANSI fgetpos and fsetpos functions.  */
 /* The _IO_seek_cur and _IO_seek_end options are not allowed. */
-typedef _IO_off64_t (*_IO_seekpos_t) __PMT ((_IO_FILE *, _IO_off64_t, int));
+typedef _IO_off64_t (*_IO_seekpos_t) (_IO_FILE *, _IO_off64_t, int);
 #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
 #define _IO_WSEEKPOS(FP, POS, FLAGS) WJUMP2 (__seekpos, FP, POS, FLAGS)
 
 /* The 'setbuf' hook gives a buffer to the file.
    It matches the streambuf::setbuf virtual function. */
-typedef _IO_FILE* (*_IO_setbuf_t) __PMT ((_IO_FILE *, char *, _IO_ssize_t));
+typedef _IO_FILE* (*_IO_setbuf_t) (_IO_FILE *, char *, _IO_ssize_t);
 #define _IO_SETBUF(FP, BUFFER, LENGTH) JUMP2 (__setbuf, FP, BUFFER, LENGTH)
 #define _IO_WSETBUF(FP, BUFFER, LENGTH) WJUMP2 (__setbuf, FP, BUFFER, LENGTH)
 
 /* The 'sync' hook attempts to synchronize the internal data structures
    of the file with the external state.
    It matches the streambuf::sync virtual function. */
-typedef int (*_IO_sync_t) __PMT ((_IO_FILE *));
+typedef int (*_IO_sync_t) (_IO_FILE *);
 #define _IO_SYNC(FP) JUMP0 (__sync, FP)
 #define _IO_WSYNC(FP) WJUMP0 (__sync, FP)
 
 /* The 'doallocate' hook is used to tell the file to allocate a buffer.
    It matches the streambuf::doallocate virtual function, which is not
    in the ANSI/ISO C++ standard, but is part traditional implementations. */
-typedef int (*_IO_doallocate_t) __PMT ((_IO_FILE *));
+typedef int (*_IO_doallocate_t) (_IO_FILE *);
 #define _IO_DOALLOCATE(FP) JUMP0 (__doallocate, FP)
 #define _IO_WDOALLOCATE(FP) WJUMP0 (__doallocate, FP)
 
@@ -239,7 +224,7 @@ typedef int (*_IO_doallocate_t) __PMT ((_IO_FILE *));
    There is no correspondence in the ANSI/ISO C++ standard library.
    The hooks basically correspond to the Unix system functions
    (read, write, close, lseek, and stat) except that a _IO_FILE*
-   parameter is used instead of a integer file descriptor;  the default
+   parameter is used instead of an integer file descriptor;  the default
    implementation used for normal files just calls those functions.
    The advantage of overriding these functions instead of the higher-level
    ones (underflow, overflow etc) is that you can leave all the buffering
@@ -249,7 +234,7 @@ typedef int (*_IO_doallocate_t) __PMT ((_IO_FILE *));
    an existing buffer.  It generalizes the Unix read(2) function.
    It matches the streambuf::sys_read virtual function, which is
    specific to this implementation. */
-typedef _IO_ssize_t (*_IO_read_t) __PMT ((_IO_FILE *, void *, _IO_ssize_t));
+typedef _IO_ssize_t (*_IO_read_t) (_IO_FILE *, void *, _IO_ssize_t);
 #define _IO_SYSREAD(FP, DATA, LEN) JUMP2 (__read, FP, DATA, LEN)
 #define _IO_WSYSREAD(FP, DATA, LEN) WJUMP2 (__read, FP, DATA, LEN)
 
@@ -257,8 +242,7 @@ typedef _IO_ssize_t (*_IO_read_t) __PMT ((_IO_FILE *, void *, _IO_ssize_t));
    to an external file.  It generalizes the Unix write(2) function.
    It matches the streambuf::sys_write virtual function, which is
    specific to this implementation. */
-typedef _IO_ssize_t (*_IO_write_t) __PMT ((_IO_FILE *, const void *,
-					   _IO_ssize_t));
+typedef _IO_ssize_t (*_IO_write_t) (_IO_FILE *, const void *, _IO_ssize_t);
 #define _IO_SYSWRITE(FP, DATA, LEN) JUMP2 (__write, FP, DATA, LEN)
 #define _IO_WSYSWRITE(FP, DATA, LEN) WJUMP2 (__write, FP, DATA, LEN)
 
@@ -266,7 +250,7 @@ typedef _IO_ssize_t (*_IO_write_t) __PMT ((_IO_FILE *, const void *,
    It generalizes the Unix lseek(2) function.
    It matches the streambuf::sys_seek virtual function, which is
    specific to this implementation. */
-typedef _IO_off64_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off64_t, int));
+typedef _IO_off64_t (*_IO_seek_t) (_IO_FILE *, _IO_off64_t, int);
 #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
 #define _IO_WSYSSEEK(FP, OFFSET, MODE) WJUMP2 (__seek, FP, OFFSET, MODE)
 
@@ -274,7 +258,7 @@ typedef _IO_off64_t (*_IO_seek_t) __PMT ((_IO_FILE *, _IO_off64_t, int));
    external file.  It generalizes the Unix close(2) function.
    It matches the streambuf::sys_close virtual function, which is
    specific to this implementation. */
-typedef int (*_IO_close_t) __PMT ((_IO_FILE *)); /* finalize */
+typedef int (*_IO_close_t) (_IO_FILE *); /* finalize */
 #define _IO_SYSCLOSE(FP) JUMP0 (__close, FP)
 #define _IO_WSYSCLOSE(FP) WJUMP0 (__close, FP)
 
@@ -282,20 +266,20 @@ typedef int (*_IO_close_t) __PMT ((_IO_FILE *)); /* finalize */
    into a struct stat buffer.  It generalizes the Unix fstat(2) call.
    It matches the streambuf::sys_stat virtual function, which is
    specific to this implementation. */
-typedef int (*_IO_stat_t) __PMT ((_IO_FILE *, void *));
+typedef int (*_IO_stat_t) (_IO_FILE *, void *);
 #define _IO_SYSSTAT(FP, BUF) JUMP1 (__stat, FP, BUF)
 #define _IO_WSYSSTAT(FP, BUF) WJUMP1 (__stat, FP, BUF)
 
 /* The 'showmany' hook can be used to get an image how much input is
    available.  In many cases the answer will be 0 which means unknown
    but some cases one can provide real information.  */
-typedef int (*_IO_showmanyc_t) __PMT ((_IO_FILE *));
+typedef int (*_IO_showmanyc_t) (_IO_FILE *);
 #define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)
 #define _IO_WSHOWMANYC(FP) WJUMP0 (__showmanyc, FP)
 
 /* The 'imbue' hook is used to get information about the currently
    installed locales.  */
-typedef void (*_IO_imbue_t) __PMT ((_IO_FILE *, void *));
+typedef void (*_IO_imbue_t) (_IO_FILE *, void *);
 #define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)
 #define _IO_WIMBUE(FP, LOCALE) WJUMP1 (__imbue, FP, LOCALE)
 
@@ -305,10 +289,8 @@ typedef void (*_IO_imbue_t) __PMT ((_IO_FILE *, void *));
 
 struct _IO_jump_t
 {
-    JUMP_FIELD(_G_size_t, __dummy);
-#ifdef _G_USING_THUNKS
-    JUMP_FIELD(_G_size_t, __dummy2);
-#endif
+    JUMP_FIELD(size_t, __dummy);
+    JUMP_FIELD(size_t, __dummy2);
     JUMP_FIELD(_IO_finish_t, __finish);
     JUMP_FIELD(_IO_overflow_t, __overflow);
     JUMP_FIELD(_IO_underflow_t, __underflow);
@@ -346,6 +328,17 @@ struct _IO_FILE_plus
   const struct _IO_jump_t *vtable;
 };
 
+#ifdef _IO_USE_OLD_IO_FILE
+/* This structure is used by the compatibility code as if it were an
+   _IO_FILE_plus, but has enough space to initialize the _mode argument
+   of an _IO_FILE_complete.  */
+struct _IO_FILE_complete_plus
+{
+  struct _IO_FILE_complete file;
+  const struct _IO_jump_t *vtable;
+};
+#endif
+
 /* Special file type for fopencookie function.  */
 struct _IO_cookie_file
 {
@@ -364,135 +357,167 @@ typedef struct _IO_FILE *_IO_ITER;
 
 /* Generic functions */
 
-extern void _IO_switch_to_main_get_area __P ((_IO_FILE *));
-extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
-extern int _IO_switch_to_get_mode __P ((_IO_FILE *));
-extern void _IO_init __P ((_IO_FILE *, int));
-extern int _IO_sputbackc __P ((_IO_FILE *, int));
-extern int _IO_sungetc __P ((_IO_FILE *));
-extern void _IO_un_link __P ((struct _IO_FILE_plus *));
-extern void _IO_link_in __P ((struct _IO_FILE_plus *));
-extern void _IO_doallocbuf __P ((_IO_FILE *));
-extern void _IO_unsave_markers __P ((_IO_FILE *));
-extern void _IO_setb __P ((_IO_FILE *, char *, char *, int));
-extern unsigned _IO_adjust_column __P ((unsigned, const char *, int));
+extern void _IO_switch_to_main_get_area (_IO_FILE *) __THROW;
+extern void _IO_switch_to_backup_area (_IO_FILE *) __THROW;
+extern int _IO_switch_to_get_mode (_IO_FILE *);
+libc_hidden_proto (_IO_switch_to_get_mode)
+extern void _IO_init (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_init)
+extern int _IO_sputbackc (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_sputbackc)
+extern int _IO_sungetc (_IO_FILE *) __THROW;
+extern void _IO_un_link (struct _IO_FILE_plus *) __THROW;
+libc_hidden_proto (_IO_un_link)
+extern void _IO_link_in (struct _IO_FILE_plus *) __THROW;
+libc_hidden_proto (_IO_link_in)
+extern void _IO_doallocbuf (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_doallocbuf)
+extern void _IO_unsave_markers (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_unsave_markers)
+extern void _IO_setb (_IO_FILE *, char *, char *, int) __THROW;
+libc_hidden_proto (_IO_setb)
+extern unsigned _IO_adjust_column (unsigned, const char *, int) __THROW;
+libc_hidden_proto (_IO_adjust_column)
 #define _IO_sputn(__fp, __s, __n) _IO_XSPUTN (__fp, __s, __n)
 
-extern void _IO_switch_to_main_wget_area __P ((_IO_FILE *));
-extern void _IO_switch_to_wbackup_area __P ((_IO_FILE *));
-extern int _IO_switch_to_wget_mode __P ((_IO_FILE *));
-extern void _IO_wsetb __P ((_IO_FILE *, wchar_t *, wchar_t *, int));
-extern wint_t _IO_sputbackwc __P ((_IO_FILE *, wint_t));
-extern wint_t _IO_sungetwc __P ((_IO_FILE *));
-extern void _IO_wdoallocbuf __P ((_IO_FILE *));
-extern void _IO_unsave_wmarkers __P ((_IO_FILE *));
-extern unsigned _IO_adjust_wcolumn __P ((unsigned, const wchar_t *, int));
+_IO_ssize_t _IO_least_wmarker (_IO_FILE *, wchar_t *) __THROW;
+libc_hidden_proto (_IO_least_wmarker)
+extern void _IO_switch_to_main_wget_area (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_switch_to_main_wget_area)
+extern void _IO_switch_to_wbackup_area (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_switch_to_wbackup_area)
+extern int _IO_switch_to_wget_mode (_IO_FILE *);
+libc_hidden_proto (_IO_switch_to_wget_mode)
+extern void _IO_wsetb (_IO_FILE *, wchar_t *, wchar_t *, int) __THROW;
+libc_hidden_proto (_IO_wsetb)
+extern wint_t _IO_sputbackwc (_IO_FILE *, wint_t) __THROW;
+libc_hidden_proto (_IO_sputbackwc)
+extern wint_t _IO_sungetwc (_IO_FILE *) __THROW;
+extern void _IO_wdoallocbuf (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_wdoallocbuf)
+extern void _IO_unsave_wmarkers (_IO_FILE *) __THROW;
+extern unsigned _IO_adjust_wcolumn (unsigned, const wchar_t *, int) __THROW;
+extern _IO_off64_t get_file_offset (_IO_FILE *fp);
 
 /* Marker-related function. */
 
-extern void _IO_init_marker __P ((struct _IO_marker *, _IO_FILE *));
-extern void _IO_init_wmarker __P ((struct _IO_marker *, _IO_FILE *));
-extern void _IO_remove_marker __P ((struct _IO_marker *));
-extern int _IO_marker_difference __P ((struct _IO_marker *,
-				       struct _IO_marker *));
-extern int _IO_marker_delta __P ((struct _IO_marker *));
-extern int _IO_wmarker_delta __P ((struct _IO_marker *));
-extern int _IO_seekmark __P ((_IO_FILE *, struct _IO_marker *, int));
-extern int _IO_seekwmark __P ((_IO_FILE *, struct _IO_marker *, int));
+extern void _IO_init_marker (struct _IO_marker *, _IO_FILE *);
+extern void _IO_init_wmarker (struct _IO_marker *, _IO_FILE *);
+extern void _IO_remove_marker (struct _IO_marker *) __THROW;
+extern int _IO_marker_difference (struct _IO_marker *, struct _IO_marker *)
+     __THROW;
+extern int _IO_marker_delta (struct _IO_marker *) __THROW;
+extern int _IO_wmarker_delta (struct _IO_marker *) __THROW;
+extern int _IO_seekmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
+extern int _IO_seekwmark (_IO_FILE *, struct _IO_marker *, int) __THROW;
 
-/* Functions for iterating global list and dealing with
-   its lock */
+/* Functions for iterating global list and dealing with its lock */
 
-extern _IO_ITER _IO_iter_begin __P ((void));
+extern _IO_ITER _IO_iter_begin (void) __THROW;
 libc_hidden_proto (_IO_iter_begin)
-extern _IO_ITER _IO_iter_end __P ((void));
+extern _IO_ITER _IO_iter_end (void) __THROW;
 libc_hidden_proto (_IO_iter_end)
-extern _IO_ITER _IO_iter_next __P ((_IO_ITER));
+extern _IO_ITER _IO_iter_next (_IO_ITER) __THROW;
 libc_hidden_proto (_IO_iter_next)
-extern _IO_FILE *_IO_iter_file __P ((_IO_ITER));
+extern _IO_FILE *_IO_iter_file (_IO_ITER) __THROW;
 libc_hidden_proto (_IO_iter_file)
-extern void _IO_list_lock __P ((void));
+extern void _IO_list_lock (void) __THROW;
 libc_hidden_proto (_IO_list_lock)
-extern void _IO_list_unlock __P ((void));
+extern void _IO_list_unlock (void) __THROW;
 libc_hidden_proto (_IO_list_unlock)
-extern void _IO_list_resetlock __P ((void));
+extern void _IO_list_resetlock (void) __THROW;
 libc_hidden_proto (_IO_list_resetlock)
 
 /* Default jumptable functions. */
 
-extern int _IO_default_underflow __P ((_IO_FILE *));
-extern int _IO_default_uflow __P ((_IO_FILE *));
-extern wint_t _IO_wdefault_uflow __P ((_IO_FILE *));
-extern int _IO_default_doallocate __P ((_IO_FILE *));
-extern int _IO_wdefault_doallocate __P ((_IO_FILE *));
-extern void _IO_default_finish __P ((_IO_FILE *, int));
-extern void _IO_wdefault_finish __P ((_IO_FILE *, int));
-extern int _IO_default_pbackfail __P ((_IO_FILE *, int));
-extern wint_t _IO_wdefault_pbackfail __P ((_IO_FILE *, wint_t));
-extern _IO_FILE* _IO_default_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
-extern _IO_size_t _IO_default_xsputn __P ((_IO_FILE *, const void *,
-					   _IO_size_t));
-extern _IO_size_t _IO_wdefault_xsputn __P ((_IO_FILE *, const void *,
-					    _IO_size_t));
-extern _IO_size_t _IO_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
-extern _IO_size_t _IO_wdefault_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
-extern _IO_off64_t _IO_default_seekoff __P ((_IO_FILE *,
-					     _IO_off64_t, int, int));
-extern _IO_off64_t _IO_default_seekpos __P ((_IO_FILE *, _IO_off64_t, int));
-extern _IO_ssize_t _IO_default_write __P ((_IO_FILE *, const void *,
-					   _IO_ssize_t));
-extern _IO_ssize_t _IO_default_read __P ((_IO_FILE *, void *, _IO_ssize_t));
-extern int _IO_default_stat __P ((_IO_FILE *, void *));
-extern _IO_off64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int));
-extern int _IO_default_sync __P ((_IO_FILE *));
+extern int _IO_default_underflow (_IO_FILE *) __THROW;
+extern int _IO_default_uflow (_IO_FILE *);
+libc_hidden_proto (_IO_default_uflow)
+extern wint_t _IO_wdefault_uflow (_IO_FILE *);
+libc_hidden_proto (_IO_wdefault_uflow)
+extern int _IO_default_doallocate (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_default_doallocate)
+extern int _IO_wdefault_doallocate (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_wdefault_doallocate)
+extern void _IO_default_finish (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_default_finish)
+extern void _IO_wdefault_finish (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_wdefault_finish)
+extern int _IO_default_pbackfail (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_default_pbackfail)
+extern wint_t _IO_wdefault_pbackfail (_IO_FILE *, wint_t) __THROW;
+libc_hidden_proto (_IO_wdefault_pbackfail)
+extern _IO_FILE* _IO_default_setbuf (_IO_FILE *, char *, _IO_ssize_t);
+extern _IO_size_t _IO_default_xsputn (_IO_FILE *, const void *, _IO_size_t);
+libc_hidden_proto (_IO_default_xsputn)
+extern _IO_size_t _IO_wdefault_xsputn (_IO_FILE *, const void *, _IO_size_t);
+libc_hidden_proto (_IO_wdefault_xsputn)
+extern _IO_size_t _IO_default_xsgetn (_IO_FILE *, void *, _IO_size_t);
+libc_hidden_proto (_IO_default_xsgetn)
+extern _IO_size_t _IO_wdefault_xsgetn (_IO_FILE *, void *, _IO_size_t);
+libc_hidden_proto (_IO_wdefault_xsgetn)
+extern _IO_off64_t _IO_default_seekoff (_IO_FILE *, _IO_off64_t, int, int)
+     __THROW;
+extern _IO_off64_t _IO_default_seekpos (_IO_FILE *, _IO_off64_t, int);
+extern _IO_ssize_t _IO_default_write (_IO_FILE *, const void *, _IO_ssize_t);
+extern _IO_ssize_t _IO_default_read (_IO_FILE *, void *, _IO_ssize_t);
+extern int _IO_default_stat (_IO_FILE *, void *) __THROW;
+extern _IO_off64_t _IO_default_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
+extern int _IO_default_sync (_IO_FILE *) __THROW;
 #define _IO_default_close ((_IO_close_t) _IO_default_sync)
-extern int _IO_default_showmanyc __P ((_IO_FILE *));
-extern void _IO_default_imbue __P ((_IO_FILE *, void *));
-
-extern struct _IO_jump_t _IO_file_jumps;
-extern struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden;
-extern struct _IO_jump_t _IO_file_jumps_maybe_mmap attribute_hidden;
-extern struct _IO_jump_t _IO_wfile_jumps attribute_hidden;
-extern struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden;
-extern struct _IO_jump_t _IO_wfile_jumps_maybe_mmap attribute_hidden;
-extern struct _IO_jump_t _IO_old_file_jumps attribute_hidden;
-extern struct _IO_jump_t _IO_streambuf_jumps;
-extern struct _IO_jump_t _IO_old_proc_jumps attribute_hidden;
-extern struct _IO_jump_t _IO_str_jumps attribute_hidden;
-extern struct _IO_jump_t _IO_wstr_jumps attribute_hidden;
-extern struct _IO_codecvt __libio_codecvt attribute_hidden;
-extern int _IO_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
-extern int _IO_new_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
-extern int _IO_old_do_write __P ((_IO_FILE *, const char *, _IO_size_t));
-extern int _IO_wdo_write __P ((_IO_FILE *, const wchar_t *, _IO_size_t));
-extern int _IO_flush_all_lockp __P ((int));
-extern int _IO_flush_all __P ((void));
-extern int _IO_cleanup __P ((void));
-extern void _IO_flush_all_linebuffered __P ((void));
-extern int _IO_new_fgetpos __P ((_IO_FILE *, _IO_fpos_t *));
-extern int _IO_old_fgetpos __P ((_IO_FILE *, _IO_fpos_t *));
-extern int _IO_new_fsetpos __P ((_IO_FILE *, const _IO_fpos_t *));
-extern int _IO_old_fsetpos __P ((_IO_FILE *, const _IO_fpos_t *));
-extern int _IO_new_fgetpos64 __P ((_IO_FILE *, _IO_fpos64_t *));
-extern int _IO_old_fgetpos64 __P ((_IO_FILE *, _IO_fpos64_t *));
-extern int _IO_new_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *));
-extern int _IO_old_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *));
+extern int _IO_default_showmanyc (_IO_FILE *) __THROW;
+extern void _IO_default_imbue (_IO_FILE *, void *) __THROW;
+
+extern const struct _IO_jump_t _IO_file_jumps;
+libc_hidden_proto (_IO_file_jumps)
+extern const struct _IO_jump_t _IO_file_jumps_mmap attribute_hidden;
+extern const struct _IO_jump_t _IO_file_jumps_maybe_mmap attribute_hidden;
+extern const struct _IO_jump_t _IO_wfile_jumps;
+libc_hidden_proto (_IO_wfile_jumps)
+extern const struct _IO_jump_t _IO_wfile_jumps_mmap attribute_hidden;
+extern const struct _IO_jump_t _IO_wfile_jumps_maybe_mmap attribute_hidden;
+extern const struct _IO_jump_t _IO_old_file_jumps attribute_hidden;
+extern const struct _IO_jump_t _IO_streambuf_jumps;
+extern const struct _IO_jump_t _IO_old_proc_jumps attribute_hidden;
+extern const struct _IO_jump_t _IO_str_jumps attribute_hidden;
+extern const struct _IO_jump_t _IO_wstr_jumps attribute_hidden;
+extern const struct _IO_codecvt __libio_codecvt attribute_hidden;
+extern int _IO_do_write (_IO_FILE *, const char *, _IO_size_t);
+libc_hidden_proto (_IO_do_write)
+extern int _IO_new_do_write (_IO_FILE *, const char *, _IO_size_t);
+extern int _IO_old_do_write (_IO_FILE *, const char *, _IO_size_t);
+extern int _IO_wdo_write (_IO_FILE *, const wchar_t *, _IO_size_t);
+libc_hidden_proto (_IO_wdo_write)
+extern int _IO_flush_all_lockp (int);
+extern int _IO_flush_all (void);
+libc_hidden_proto (_IO_flush_all)
+extern int _IO_cleanup (void);
+extern void _IO_flush_all_linebuffered (void);
+libc_hidden_proto (_IO_flush_all_linebuffered)
+extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *);
+extern int _IO_old_fgetpos (_IO_FILE *, _IO_fpos_t *);
+extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *);
+extern int _IO_old_fsetpos (_IO_FILE *, const _IO_fpos_t *);
+extern int _IO_new_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
+extern int _IO_old_fgetpos64 (_IO_FILE *, _IO_fpos64_t *);
+extern int _IO_new_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
+extern int _IO_old_fsetpos64 (_IO_FILE *, const _IO_fpos64_t *);
+extern void _IO_old_init (_IO_FILE *fp, int flags) __THROW;
 
 
 #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 # define _IO_do_flush(_f) \
   ((_f)->_mode <= 0							      \
-   ? INTUSE(_IO_do_write)(_f, (_f)->_IO_write_base,			      \
-			  (_f)->_IO_write_ptr-(_f)->_IO_write_base)	      \
-   : INTUSE(_IO_wdo_write)(_f, (_f)->_wide_data->_IO_write_base,	      \
-			   ((_f)->_wide_data->_IO_write_ptr		      \
-			    - (_f)->_wide_data->_IO_write_base)))
+   ? _IO_do_write(_f, (_f)->_IO_write_base,				      \
+		  (_f)->_IO_write_ptr-(_f)->_IO_write_base)		      \
+   : _IO_wdo_write(_f, (_f)->_wide_data->_IO_write_base,		      \
+		   ((_f)->_wide_data->_IO_write_ptr			      \
+		    - (_f)->_wide_data->_IO_write_base)))
 #else
 # define _IO_do_flush(_f) \
-   INTUSE(_IO_do_write)(_f, (_f)->_IO_write_base,			      \
-			(_f)->_IO_write_ptr-(_f)->_IO_write_base)
+  _IO_do_write(_f, (_f)->_IO_write_base,				      \
+	       (_f)->_IO_write_ptr-(_f)->_IO_write_base)
 #endif
-
 #define _IO_old_do_flush(_f) \
   _IO_old_do_write(_f, (_f)->_IO_write_base, \
 		   (_f)->_IO_write_ptr-(_f)->_IO_write_base)
@@ -521,238 +546,160 @@ extern int _IO_old_fsetpos64 __P ((_IO_FILE *, const _IO_fpos64_t *));
 
 /* Jumptable functions for files. */
 
-extern int _IO_file_doallocate __P ((_IO_FILE *));
-extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
-extern _IO_off64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
-extern _IO_off64_t _IO_file_seekoff_mmap __P ((_IO_FILE *, _IO_off64_t, int,
-					       int));
-extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
-extern _IO_size_t _IO_file_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
-extern int _IO_file_stat __P ((_IO_FILE *, void *));
-extern int _IO_file_close __P ((_IO_FILE *));
-extern int _IO_file_close_mmap __P ((_IO_FILE *));
-extern int _IO_file_underflow __P ((_IO_FILE *));
-extern int _IO_file_underflow_mmap __P ((_IO_FILE *));
-extern int _IO_file_underflow_maybe_mmap __P ((_IO_FILE *));
-extern int _IO_file_overflow __P ((_IO_FILE *, int));
+extern int _IO_file_doallocate (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_file_doallocate)
+extern _IO_FILE* _IO_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
+libc_hidden_proto (_IO_file_setbuf)
+extern _IO_off64_t _IO_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
+libc_hidden_proto (_IO_file_seekoff)
+extern _IO_off64_t _IO_file_seekoff_mmap (_IO_FILE *, _IO_off64_t, int, int)
+     __THROW;
+extern _IO_size_t _IO_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
+libc_hidden_proto (_IO_file_xsputn)
+extern _IO_size_t _IO_file_xsgetn (_IO_FILE *, void *, _IO_size_t);
+libc_hidden_proto (_IO_file_xsgetn)
+extern int _IO_file_stat (_IO_FILE *, void *) __THROW;
+libc_hidden_proto (_IO_file_stat)
+extern int _IO_file_close (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_file_close)
+extern int _IO_file_close_mmap (_IO_FILE *) __THROW;
+extern int _IO_file_underflow (_IO_FILE *);
+libc_hidden_proto (_IO_file_underflow)
+extern int _IO_file_underflow_mmap (_IO_FILE *);
+extern int _IO_file_underflow_maybe_mmap (_IO_FILE *);
+extern int _IO_file_overflow (_IO_FILE *, int);
+libc_hidden_proto (_IO_file_overflow)
 #define _IO_file_is_open(__fp) ((__fp)->_fileno != -1)
-extern void _IO_file_init __P ((struct _IO_FILE_plus *));
-extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
-extern _IO_FILE* _IO_file_open __P ((_IO_FILE *, const char *, int, int,
-				     int, int));
+extern void _IO_file_init (struct _IO_FILE_plus *) __THROW;
+libc_hidden_proto (_IO_file_init)
+extern _IO_FILE* _IO_file_attach (_IO_FILE *, int);
+libc_hidden_proto (_IO_file_attach)
+extern _IO_FILE* _IO_file_open (_IO_FILE *, const char *, int, int, int, int);
 libc_hidden_proto (_IO_file_open)
-extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *,
-				      int));
-extern _IO_ssize_t _IO_file_write __P ((_IO_FILE *, const void *,
-					_IO_ssize_t));
-extern _IO_ssize_t _IO_file_read __P ((_IO_FILE *, void *, _IO_ssize_t));
-extern int _IO_file_sync __P ((_IO_FILE *));
-extern int _IO_file_close_it __P ((_IO_FILE *));
-extern _IO_off64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int));
-extern void _IO_file_finish __P ((_IO_FILE *, int));
-
-extern _IO_FILE* _IO_new_file_attach __P ((_IO_FILE *, int));
-extern int _IO_new_file_close_it __P ((_IO_FILE *));
-extern void _IO_new_file_finish __P ((_IO_FILE *, int));
-extern _IO_FILE* _IO_new_file_fopen __P ((_IO_FILE *, const char *, const char *,
-					  int));
-extern void _IO_no_init __P ((_IO_FILE *, int, int, struct _IO_wide_data *,
-			      struct _IO_jump_t *));
-extern void _IO_new_file_init __P ((struct _IO_FILE_plus *));
-extern _IO_FILE* _IO_new_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
-extern _IO_FILE* _IO_file_setbuf_mmap __P ((_IO_FILE *, char *, _IO_ssize_t));
-extern int _IO_new_file_sync __P ((_IO_FILE *));
-extern int _IO_new_file_underflow __P ((_IO_FILE *));
-extern int _IO_new_file_overflow __P ((_IO_FILE *, int));
-extern _IO_off64_t _IO_new_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
-extern _IO_ssize_t _IO_new_file_write __P ((_IO_FILE *, const void *,
-					    _IO_ssize_t));
-extern _IO_size_t _IO_new_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
-
-extern _IO_FILE* _IO_old_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
-extern _IO_off64_t _IO_old_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int,
-					      int));
-extern _IO_size_t _IO_old_file_xsputn __P ((_IO_FILE *, const void *,
-					    _IO_size_t));
-extern int _IO_old_file_underflow __P ((_IO_FILE *));
-extern int _IO_old_file_overflow __P ((_IO_FILE *, int));
-extern void _IO_old_file_init __P ((struct _IO_FILE_plus *));
-extern _IO_FILE* _IO_old_file_attach __P ((_IO_FILE *, int));
-extern _IO_FILE* _IO_old_file_fopen __P ((_IO_FILE *, const char *,
-					  const char *));
-extern _IO_ssize_t _IO_old_file_write __P ((_IO_FILE *, const void *,
-					    _IO_ssize_t));
-extern int _IO_old_file_sync __P ((_IO_FILE *));
-extern int _IO_old_file_close_it __P ((_IO_FILE *));
-extern void _IO_old_file_finish __P ((_IO_FILE *, int));
-
-extern int _IO_wfile_doallocate __P ((_IO_FILE *));
-extern _IO_size_t _IO_wfile_xsputn __P ((_IO_FILE *, const void *,
-					 _IO_size_t));
-extern _IO_FILE* _IO_wfile_setbuf __P ((_IO_FILE *, wchar_t *, _IO_ssize_t));
-extern wint_t _IO_wfile_sync __P ((_IO_FILE *));
-extern wint_t _IO_wfile_underflow __P ((_IO_FILE *));
-extern wint_t _IO_wfile_overflow __P ((_IO_FILE *, wint_t));
-extern _IO_off64_t _IO_wfile_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
+extern _IO_FILE* _IO_file_fopen (_IO_FILE *, const char *, const char *, int);
+libc_hidden_proto (_IO_file_fopen)
+extern _IO_ssize_t _IO_file_write (_IO_FILE *, const void *, _IO_ssize_t);
+extern _IO_ssize_t _IO_file_read (_IO_FILE *, void *, _IO_ssize_t);
+libc_hidden_proto (_IO_file_read)
+extern int _IO_file_sync (_IO_FILE *);
+libc_hidden_proto (_IO_file_sync)
+extern int _IO_file_close_it (_IO_FILE *);
+libc_hidden_proto (_IO_file_close_it)
+extern _IO_off64_t _IO_file_seek (_IO_FILE *, _IO_off64_t, int) __THROW;
+libc_hidden_proto (_IO_file_seek)
+extern void _IO_file_finish (_IO_FILE *, int);
+libc_hidden_proto (_IO_file_finish)
+
+extern _IO_FILE* _IO_new_file_attach (_IO_FILE *, int);
+extern int _IO_new_file_close_it (_IO_FILE *);
+extern void _IO_new_file_finish (_IO_FILE *, int);
+extern _IO_FILE* _IO_new_file_fopen (_IO_FILE *, const char *, const char *,
+				     int);
+extern void _IO_no_init (_IO_FILE *, int, int, struct _IO_wide_data *,
+			 const struct _IO_jump_t *) __THROW;
+extern void _IO_new_file_init (struct _IO_FILE_plus *) __THROW;
+extern _IO_FILE* _IO_new_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
+extern _IO_FILE* _IO_file_setbuf_mmap (_IO_FILE *, char *, _IO_ssize_t);
+extern int _IO_new_file_sync (_IO_FILE *);
+extern int _IO_new_file_underflow (_IO_FILE *);
+extern int _IO_new_file_overflow (_IO_FILE *, int);
+extern _IO_off64_t _IO_new_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
+extern _IO_ssize_t _IO_new_file_write (_IO_FILE *, const void *, _IO_ssize_t);
+extern _IO_size_t _IO_new_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
+
+extern _IO_FILE* _IO_old_file_setbuf (_IO_FILE *, char *, _IO_ssize_t);
+extern _IO_off64_t _IO_old_file_seekoff (_IO_FILE *, _IO_off64_t, int, int);
+extern _IO_size_t _IO_old_file_xsputn (_IO_FILE *, const void *, _IO_size_t);
+extern int _IO_old_file_underflow (_IO_FILE *);
+extern int _IO_old_file_overflow (_IO_FILE *, int);
+extern void _IO_old_file_init (struct _IO_FILE_plus *) __THROW;
+extern _IO_FILE* _IO_old_file_attach (_IO_FILE *, int);
+extern _IO_FILE* _IO_old_file_fopen (_IO_FILE *, const char *, const char *);
+extern _IO_ssize_t _IO_old_file_write (_IO_FILE *, const void *, _IO_ssize_t);
+extern int _IO_old_file_sync (_IO_FILE *);
+extern int _IO_old_file_close_it (_IO_FILE *);
+extern void _IO_old_file_finish (_IO_FILE *, int);
+
+extern int _IO_wfile_doallocate (_IO_FILE *) __THROW;
+extern _IO_size_t _IO_wfile_xsputn (_IO_FILE *, const void *, _IO_size_t);
+libc_hidden_proto (_IO_wfile_xsputn)
+extern _IO_FILE* _IO_wfile_setbuf (_IO_FILE *, wchar_t *, _IO_ssize_t);
+extern wint_t _IO_wfile_sync (_IO_FILE *);
+libc_hidden_proto (_IO_wfile_sync)
+extern wint_t _IO_wfile_underflow (_IO_FILE *);
+libc_hidden_proto (_IO_wfile_underflow)
+extern wint_t _IO_wfile_overflow (_IO_FILE *, wint_t);
+libc_hidden_proto (_IO_wfile_overflow)
+extern _IO_off64_t _IO_wfile_seekoff (_IO_FILE *, _IO_off64_t, int, int);
+libc_hidden_proto (_IO_wfile_seekoff)
 
 /* Jumptable functions for proc_files. */
-extern _IO_FILE* _IO_proc_open __P ((_IO_FILE *, const char *, const char *));
-extern _IO_FILE* _IO_new_proc_open __P ((_IO_FILE *, const char *, const char *));
-extern _IO_FILE* _IO_old_proc_open __P ((_IO_FILE *, const char *, const char *));
-extern int _IO_proc_close __P ((_IO_FILE *));
-extern int _IO_new_proc_close __P ((_IO_FILE *));
-extern int _IO_old_proc_close __P ((_IO_FILE *));
+extern _IO_FILE* _IO_proc_open (_IO_FILE *, const char *, const char *)
+     __THROW;
+extern _IO_FILE* _IO_new_proc_open (_IO_FILE *, const char *, const char *)
+     __THROW;
+extern _IO_FILE* _IO_old_proc_open (_IO_FILE *, const char *, const char *);
+extern int _IO_proc_close (_IO_FILE *) __THROW;
+extern int _IO_new_proc_close (_IO_FILE *) __THROW;
+extern int _IO_old_proc_close (_IO_FILE *);
 
 /* Jumptable functions for strfiles. */
-extern int _IO_str_underflow __P ((_IO_FILE *));
-extern int _IO_str_overflow __P ((_IO_FILE *, int));
-extern int _IO_str_pbackfail __P ((_IO_FILE *, int));
-extern _IO_off64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
-extern void _IO_str_finish __P ((_IO_FILE *, int));
+extern int _IO_str_underflow (_IO_FILE *) __THROW;
+libc_hidden_proto (_IO_str_underflow)
+extern int _IO_str_overflow (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_str_overflow)
+extern int _IO_str_pbackfail (_IO_FILE *, int) __THROW;
+libc_hidden_proto (_IO_str_pbackfail)
+extern _IO_off64_t _IO_str_seekoff (_IO_FILE *, _IO_off64_t, int, int) __THROW;
+libc_hidden_proto (_IO_str_seekoff)
+extern void _IO_str_finish (_IO_FILE *, int) __THROW;
 
 /* Other strfile functions */
 struct _IO_strfile_;
-extern void _IO_str_init_static __P ((struct _IO_strfile_ *, char *, int, char *));
-extern void _IO_str_init_readonly __P ((struct _IO_strfile_ *, const char *, int));
-extern _IO_ssize_t _IO_str_count __P ((_IO_FILE *));
+extern void _IO_str_init_static (struct _IO_strfile_ *, char *, int, char *)
+     __THROW;
+extern void _IO_str_init_readonly (struct _IO_strfile_ *, const char *, int)
+     __THROW;
+extern _IO_ssize_t _IO_str_count (_IO_FILE *) __THROW;
 
 /* And the wide character versions.  */
-extern void _IO_wstr_init_static __P ((_IO_FILE *, wchar_t *, int, wchar_t *));
-extern void _IO_wstr_init_readonly __P ((_IO_FILE *, const char *, int));
-extern _IO_ssize_t _IO_wstr_count __P ((_IO_FILE *));
-extern _IO_wint_t _IO_wstr_overflow __P ((_IO_FILE *, _IO_wint_t));
-extern _IO_wint_t _IO_wstr_underflow __P ((_IO_FILE *));
-extern _IO_off64_t _IO_wstr_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
-extern _IO_wint_t _IO_wstr_pbackfail __P ((_IO_FILE *, _IO_wint_t));
-extern void _IO_wstr_finish __P ((_IO_FILE *, int));
-
-extern int _IO_vasprintf __P ((char **result_ptr, __const char *format,
-			       _IO_va_list args));
-extern int _IO_vdprintf __P ((int d, __const char *format, _IO_va_list arg));
-extern int _IO_vsnprintf __P ((char *string, _IO_size_t maxlen,
-			       __const char *format, _IO_va_list args));
-
-
-extern _IO_size_t _IO_getline __P ((_IO_FILE *,char *, _IO_size_t, int, int));
-extern _IO_size_t _IO_getline_info __P ((_IO_FILE *,char *, _IO_size_t,
-					 int, int, int *));
-extern _IO_ssize_t _IO_getdelim __P ((char **, _IO_size_t *, int, _IO_FILE *));
-extern _IO_size_t _IO_getwline __P ((_IO_FILE *,wchar_t *, _IO_size_t, wint_t,
-				     int));
-extern _IO_size_t _IO_getwline_info __P ((_IO_FILE *,wchar_t *, _IO_size_t,
-					  wint_t, int, wint_t *));
-extern double _IO_strtod __P ((const char *, char **));
-extern char *_IO_dtoa __P ((double __d, int __mode, int __ndigits,
-			    int *__decpt, int *__sign, char **__rve));
-extern int _IO_outfloat __P ((double __value, _IO_FILE *__sb, int __type,
-			      int __width, int __precision, int __flags,
-			      int __sign_mode, int __fill));
+extern void _IO_wstr_init_static (_IO_FILE *, wchar_t *, _IO_size_t, wchar_t *)
+     __THROW;
+extern _IO_ssize_t _IO_wstr_count (_IO_FILE *) __THROW;
+extern _IO_wint_t _IO_wstr_overflow (_IO_FILE *, _IO_wint_t) __THROW;
+extern _IO_wint_t _IO_wstr_underflow (_IO_FILE *) __THROW;
+extern _IO_off64_t _IO_wstr_seekoff (_IO_FILE *, _IO_off64_t, int, int)
+     __THROW;
+extern _IO_wint_t _IO_wstr_pbackfail (_IO_FILE *, _IO_wint_t) __THROW;
+extern void _IO_wstr_finish (_IO_FILE *, int) __THROW;
+
+extern int _IO_vasprintf (char **result_ptr, const char *format,
+			  _IO_va_list args) __THROW;
+extern int _IO_vdprintf (int d, const char *format, _IO_va_list arg);
+extern int _IO_vsnprintf (char *string, _IO_size_t maxlen,
+			  const char *format, _IO_va_list args) __THROW;
+
+
+extern _IO_size_t _IO_getline (_IO_FILE *,char *, _IO_size_t, int, int);
+libc_hidden_proto (_IO_getline)
+extern _IO_size_t _IO_getline_info (_IO_FILE *,char *, _IO_size_t,
+				    int, int, int *);
+libc_hidden_proto (_IO_getline_info)
+extern _IO_ssize_t _IO_getdelim (char **, _IO_size_t *, int, _IO_FILE *);
+extern _IO_size_t _IO_getwline (_IO_FILE *,wchar_t *, _IO_size_t, wint_t, int);
+extern _IO_size_t _IO_getwline_info (_IO_FILE *,wchar_t *, _IO_size_t,
+				     wint_t, int, wint_t *);
 
 extern struct _IO_FILE_plus *_IO_list_all;
-extern void (*_IO_cleanup_registration_needed) __PMT ((void));
-
-/* Prototype for functions with alternative entry point.  */
-extern int _IO_flush_all_internal __P ((void));
-extern unsigned _IO_adjust_column_internal __P ((unsigned, const char *, int));
-
-extern int _IO_default_uflow_internal __P ((_IO_FILE *));
-extern void _IO_default_finish_internal __P ((_IO_FILE *, int));
-extern int _IO_default_pbackfail_internal __P ((_IO_FILE *, int));
-extern _IO_size_t _IO_default_xsputn_internal __P ((_IO_FILE *, const void *,
-						    _IO_size_t));
-extern _IO_size_t _IO_default_xsgetn_internal __P ((_IO_FILE *, void *,
-						    _IO_size_t));
-extern int _IO_default_doallocate_internal __P ((_IO_FILE *));
-extern void _IO_wdefault_finish_internal __P ((_IO_FILE *, int));
-extern wint_t _IO_wdefault_pbackfail_internal __P ((_IO_FILE *, wint_t));
-extern _IO_size_t _IO_wdefault_xsputn_internal __P ((_IO_FILE *, const void *,
-						     _IO_size_t));
-extern _IO_size_t _IO_wdefault_xsgetn_internal __P ((_IO_FILE *, void *,
-						     _IO_size_t));
-extern int _IO_wdefault_doallocate_internal __P ((_IO_FILE *));
-extern wint_t _IO_wdefault_uflow_internal __P ((_IO_FILE *));
-
-extern int _IO_file_doallocate_internal __P ((_IO_FILE *));
-extern _IO_FILE* _IO_file_setbuf_internal __P ((_IO_FILE *, char *,
-						_IO_ssize_t));
-extern _IO_off64_t _IO_file_seekoff_internal __P ((_IO_FILE *, _IO_off64_t,
-						   int, int));
-extern _IO_size_t _IO_file_xsputn_internal __P ((_IO_FILE *, const void *,
-						 _IO_size_t));
-extern _IO_size_t _IO_file_xsgetn_internal __P ((_IO_FILE *, void *,
-						 _IO_size_t));
-extern int _IO_file_stat_internal __P ((_IO_FILE *, void *));
-extern int _IO_file_close_internal __P ((_IO_FILE *));
-extern int _IO_file_close_it_internal __P ((_IO_FILE *));
-extern int _IO_file_underflow_internal __P ((_IO_FILE *));
-extern int _IO_file_overflow_internal __P ((_IO_FILE *, int));
-extern void _IO_file_init_internal __P ((struct _IO_FILE_plus *));
-extern _IO_FILE* _IO_file_attach_internal __P ((_IO_FILE *, int));
-extern _IO_FILE* _IO_file_fopen_internal __P ((_IO_FILE *, const char *,
-					       const char *, int));
-extern _IO_ssize_t _IO_file_read_internal __P ((_IO_FILE *, void *,
-						_IO_ssize_t));
-extern int _IO_file_sync_internal __P ((_IO_FILE *));
-extern _IO_off64_t _IO_file_seek_internal __P ((_IO_FILE *, _IO_off64_t, int));
-extern void _IO_file_finish_internal __P ((_IO_FILE *, int));
-
-extern _IO_size_t _IO_wfile_xsputn_internal __P ((_IO_FILE *, const void *,
-						  _IO_size_t));
-extern _IO_off64_t _IO_wfile_seekoff_internal __P ((_IO_FILE *, _IO_off64_t,
-						    int, int));
-extern wint_t _IO_wfile_sync_internal __P ((_IO_FILE *));
-
-extern int _IO_str_underflow_internal __P ((_IO_FILE *));
-extern int _IO_str_overflow_internal __P ((_IO_FILE *, int));
-extern int _IO_str_pbackfail_internal __P ((_IO_FILE *, int));
-extern _IO_off64_t _IO_str_seekoff_internal __P ((_IO_FILE *, _IO_off64_t,
-						  int, int));
-extern void _IO_str_init_static_internal __P ((struct _IO_strfile_ *, char *,
-					       int, char *));
-
-extern struct _IO_jump_t _IO_file_jumps_internal attribute_hidden;
-extern struct _IO_jump_t _IO_wfile_jumps_internal attribute_hidden;
-
-extern struct _IO_FILE_plus *_IO_list_all_internal attribute_hidden;
-
-extern void _IO_link_in_internal __P ((struct _IO_FILE_plus *));
-extern int _IO_sputbackc_internal __P ((_IO_FILE *, int));
-extern void _IO_wdoallocbuf_internal __P ((_IO_FILE *));
-
-extern _IO_size_t _IO_sgetn_internal (_IO_FILE *, void *, _IO_size_t);
-extern void _IO_flush_all_linebuffered_internal __P ((void));
-extern int _IO_switch_to_wget_mode_internal __P ((_IO_FILE *));
-extern void _IO_unsave_markers_internal __P ((_IO_FILE *));
-extern void _IO_switch_to_main_wget_area_internal __P ((_IO_FILE *));
-extern int _IO_wdo_write_internal __P ((_IO_FILE *, const wchar_t *,
-					_IO_size_t));
-extern int _IO_do_write_internal __P ((_IO_FILE *, const char *, _IO_size_t));
-extern _IO_ssize_t _IO_padn_internal (_IO_FILE *, int, _IO_ssize_t);
-extern _IO_size_t _IO_getline_info_internal __P ((_IO_FILE *,char *,
-						  _IO_size_t, int, int,
-						  int *));
-extern _IO_size_t _IO_getline_internal __P ((_IO_FILE *, char *, _IO_size_t,
-					     int, int));
-extern void _IO_free_wbackup_area_internal (_IO_FILE *);
-extern void _IO_free_backup_area_internal (_IO_FILE *);
-extern void _IO_switch_to_wbackup_area_internal __P ((_IO_FILE *));
-extern void _IO_setb_internal __P ((_IO_FILE *, char *, char *, int));
-extern wint_t _IO_sputbackwc_internal __P ((_IO_FILE *, wint_t));
-extern int _IO_switch_to_get_mode_internal __P ((_IO_FILE *));
-extern int _IO_vfscanf_internal (_IO_FILE * __restrict,
-				 const char * __restrict,
-				 _IO_va_list, int *__restrict);
-extern int _IO_vfprintf_internal (_IO_FILE *__restrict, const char *__restrict,
-				  _IO_va_list);
-extern void _IO_doallocbuf_internal __P ((_IO_FILE *));
-extern void _IO_wsetb_internal __P ((_IO_FILE *, wchar_t *, wchar_t *, int));
+libc_hidden_proto (_IO_list_all)
+extern void (*_IO_cleanup_registration_needed) (void);
+
+extern void _IO_str_init_static_internal (struct _IO_strfile_ *, char *,
+					  _IO_size_t, char *) __THROW;
 extern _IO_off64_t _IO_seekoff_unlocked (_IO_FILE *, _IO_off64_t, int, int)
      attribute_hidden;
 extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int)
      attribute_hidden;
-extern int _IO_putc_internal (int __c, _IO_FILE *__fp);
-extern void _IO_init_internal __P ((_IO_FILE *, int));
-extern void _IO_un_link_internal __P ((struct _IO_FILE_plus *));
 
 #ifndef EOF
 # define EOF (-1)
@@ -841,13 +788,7 @@ extern void _IO_un_link_internal __P ((struct _IO_FILE_plus *));
 #ifndef OS_FSTAT
 # define OS_FSTAT fstat
 #endif
-struct stat;
-extern _IO_ssize_t _IO_read __P ((int, void *, _IO_size_t));
-extern _IO_ssize_t _IO_write __P ((int, const void *, _IO_size_t));
-extern _IO_off64_t _IO_lseek __P ((int, _IO_off64_t, int));
-extern int _IO_close __P ((int));
-extern int _IO_fstat __P ((int, struct stat *));
-extern int _IO_vscanf __P ((const char *, _IO_va_list));
+extern int _IO_vscanf (const char *, _IO_va_list) __THROW;
 
 /* _IO_pos_BAD is an _IO_off64_t value indicating error, unknown, or EOF. */
 #ifndef _IO_pos_BAD
@@ -911,35 +852,7 @@ extern int _IO_vscanf __P ((const char *, _IO_va_list));
 # endif
 #endif
 
-/* VTABLE_LABEL defines NAME as of the CLASS class.
-   CNLENGTH is strlen(#CLASS).  */
-#ifdef __GNUC__
-# if _G_VTABLE_LABEL_HAS_LENGTH
-#  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
-  extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CNLENGTH #CLASS);
-# else
-#  define VTABLE_LABEL(NAME, CLASS, CNLENGTH) \
-  extern char NAME[] asm (_G_VTABLE_LABEL_PREFIX #CLASS);
-# endif
-#endif /* __GNUC__ */
-
-#if !defined(builtinbuf_vtable) && defined(__cplusplus)
-# ifdef __GNUC__
-VTABLE_LABEL(builtinbuf_vtable, builtinbuf, 10)
-# else
-#  if _G_VTABLE_LABEL_HAS_LENGTH
-#   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##10builtinbuf
-#  else
-#   define builtinbuf_vtable _G_VTABLE_LABEL_PREFIX_ID##builtinbuf
-#  endif
-# endif
-#endif /* !defined(builtinbuf_vtable) && defined(__cplusplus) */
-
-#if defined(__STDC__) || defined(__cplusplus)
-# define _IO_va_start(args, last) va_start(args, last)
-#else
-# define _IO_va_start(args, last) va_start(args)
-#endif
+#define _IO_va_start(args, last) va_start(args, last)
 
 extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
 
@@ -968,4 +881,35 @@ extern struct _IO_fake_stdiobuf _IO_stdin_buf, _IO_stdout_buf, _IO_stderr_buf;
 # define CHECK_FILE(FILE, RET) COERCE_FILE (FILE)
 #endif
 
-#endif	/* _LIBIO_P_H_ */
+static inline void
+__attribute__ ((__always_inline__))
+_IO_acquire_lock_fct (_IO_FILE **p)
+{
+  _IO_FILE *fp = *p;
+  if ((fp->_flags & _IO_USER_LOCK) == 0)
+    _IO_funlockfile (fp);
+}
+
+static inline void
+__attribute__ ((__always_inline__))
+_IO_acquire_lock_clear_flags2_fct (_IO_FILE **p)
+{
+  _IO_FILE *fp = *p;
+  fp->_flags2 &= ~(_IO_FLAGS2_FORTIFY | _IO_FLAGS2_SCANF_STD);
+  if ((fp->_flags & _IO_USER_LOCK) == 0)
+    _IO_funlockfile (fp);
+}
+
+#if !defined _IO_MTSAFE_IO && !defined NOT_IN_libc
+# define _IO_acquire_lock(_fp)						      \
+  do {									      \
+    _IO_FILE *_IO_acquire_lock_file = NULL
+# define _IO_acquire_lock_clear_flags2(_fp)				      \
+  do {									      \
+    _IO_FILE *_IO_acquire_lock_file = (_fp)
+# define _IO_release_lock(_fp)						      \
+    if (_IO_acquire_lock_file != NULL)					      \
+      _IO_acquire_lock_file->_flags2 &= ~(_IO_FLAGS2_FORTIFY		      \
+                                          | _IO_FLAGS2_SCANF_STD);	      \
+  } while (0)
+#endif
diff --git a/src/system/libroot/posix/glibc/libio/memstream.c b/src/system/libroot/posix/glibc/libio/memstream.c
index a3ec964237..ddb64a01b7 100644
--- a/src/system/libroot/posix/glibc/libio/memstream.c
+++ b/src/system/libroot/posix/glibc/libio/memstream.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1996,1997,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "strfile.h"
@@ -30,51 +29,25 @@ struct _IO_FILE_memstream
 };
 
 
-static int _IO_mem_sync __P ((_IO_FILE* fp));
-static void _IO_mem_finish __P ((_IO_FILE* fp, int));
-static int _IO_wmem_sync __P ((_IO_FILE* fp));
-static void _IO_wmem_finish __P ((_IO_FILE* fp, int));
+static int _IO_mem_sync (_IO_FILE* fp) __THROW;
+static void _IO_mem_finish (_IO_FILE* fp, int) __THROW;
 
 
-static struct _IO_jump_t _IO_mem_jumps =
+static const struct _IO_jump_t _IO_mem_jumps =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT (finish, _IO_mem_finish),
-  JUMP_INIT (overflow, INTUSE(_IO_str_overflow)),
-  JUMP_INIT (underflow, INTUSE(_IO_str_underflow)),
-  JUMP_INIT (uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT (pbackfail, INTUSE(_IO_str_pbackfail)),
-  JUMP_INIT (xsputn, INTUSE(_IO_default_xsputn)),
-  JUMP_INIT (xsgetn, INTUSE(_IO_default_xsgetn)),
-  JUMP_INIT (seekoff, INTUSE(_IO_str_seekoff)),
+  JUMP_INIT (overflow, _IO_str_overflow),
+  JUMP_INIT (underflow, _IO_str_underflow),
+  JUMP_INIT (uflow, _IO_default_uflow),
+  JUMP_INIT (pbackfail, _IO_str_pbackfail),
+  JUMP_INIT (xsputn, _IO_default_xsputn),
+  JUMP_INIT (xsgetn, _IO_default_xsgetn),
+  JUMP_INIT (seekoff, _IO_str_seekoff),
   JUMP_INIT (seekpos, _IO_default_seekpos),
   JUMP_INIT (setbuf, _IO_default_setbuf),
   JUMP_INIT (sync, _IO_mem_sync),
-  JUMP_INIT (doallocate, INTUSE(_IO_default_doallocate)),
-  JUMP_INIT (read, _IO_default_read),
-  JUMP_INIT (write, _IO_default_write),
-  JUMP_INIT (seek, _IO_default_seek),
-  JUMP_INIT (close, _IO_default_close),
-  JUMP_INIT (stat, _IO_default_stat),
-  JUMP_INIT(showmanyc, _IO_default_showmanyc),
-  JUMP_INIT(imbue, _IO_default_imbue)
-};
-
-static struct _IO_jump_t _IO_wmem_jumps =
-{
-  JUMP_INIT_DUMMY,
-  JUMP_INIT (finish, (_IO_finish_t) _IO_wmem_finish),
-  JUMP_INIT (overflow, (_IO_overflow_t) _IO_wstr_overflow),
-  JUMP_INIT (underflow, (_IO_underflow_t) _IO_wstr_underflow),
-  JUMP_INIT (uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
-  JUMP_INIT (pbackfail, (_IO_pbackfail_t) _IO_wstr_pbackfail),
-  JUMP_INIT (xsputn, (_IO_xsputn_t) INTUSE(_IO_wdefault_xsputn)),
-  JUMP_INIT (xsgetn, (_IO_xsgetn_t) INTUSE(_IO_wdefault_xsgetn)),
-  JUMP_INIT (seekoff, _IO_wstr_seekoff),
-  JUMP_INIT (seekpos, _IO_default_seekpos),
-  JUMP_INIT (setbuf, _IO_default_setbuf),
-  JUMP_INIT (sync, (_IO_sync_t) _IO_wmem_sync),
-  JUMP_INIT (doallocate, INTUSE(_IO_wdefault_doallocate)),
+  JUMP_INIT (doallocate, _IO_default_doallocate),
   JUMP_INIT (read, _IO_default_read),
   JUMP_INIT (write, _IO_default_write),
   JUMP_INIT (seek, _IO_default_seek),
@@ -109,12 +82,15 @@ open_memstream (bufloc, sizeloc)
   new_f->fp._sf._sbf._f._lock = &new_f->lock;
 #endif
 
-  buf = malloc (_IO_BUFSIZ);
+  buf = calloc (1, _IO_BUFSIZ);
   if (buf == NULL)
-    return NULL;
-  _IO_no_init (&new_f->fp._sf._sbf._f, 0, 0, &new_f->wd, &_IO_wmem_jumps);
+    {
+      free (new_f);
+      return NULL;
+    }
+  _IO_init (&new_f->fp._sf._sbf._f, 0);
   _IO_JUMPS ((struct _IO_FILE_plus *) &new_f->fp._sf._sbf) = &_IO_mem_jumps;
-  INTUSE(_IO_str_init_static) (&new_f->fp._sf, buf, _IO_BUFSIZ, buf);
+  _IO_str_init_static_internal (&new_f->fp._sf, buf, _IO_BUFSIZ, buf);
   new_f->fp._sf._sbf._f._flags &= ~_IO_USER_BUF;
   new_f->fp._sf._s._allocate_buffer = (_IO_alloc_type) malloc;
   new_f->fp._sf._s._free_buffer = (_IO_free_type) free;
@@ -132,15 +108,10 @@ _IO_mem_sync (fp)
      _IO_FILE* fp;
 {
   struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp;
-  int res;
-
-  res = _IO_default_sync (fp);
-  if (res < 0)
-    return res;
 
   if (fp->_IO_write_ptr == fp->_IO_write_end)
     {
-      INTUSE(_IO_str_overflow) (fp, '\0');
+      _IO_str_overflow (fp, '\0');
       --fp->_IO_write_ptr;
     }
   else
@@ -166,61 +137,9 @@ _IO_mem_finish (fp, dummy)
     {
       (*mp->bufloc)[fp->_IO_write_ptr - fp->_IO_write_base] = '\0';
       *mp->sizeloc = fp->_IO_write_ptr - fp->_IO_write_base;
-    }
-
-  fp->_IO_buf_base = NULL;
-
-  INTUSE(_IO_default_finish) (fp, 0);
-}
-
-
-static int
-_IO_wmem_sync (fp)
-     _IO_FILE* fp;
-{
-  struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp;
-  int res;
-
-  res = _IO_default_sync (fp);
-  if (res < 0)
-    return res;
 
-  if (fp->_wide_data->_IO_write_ptr == fp->_wide_data->_IO_write_end)
-    {
-      _IO_wstr_overflow (fp, L'\0');
-      --fp->_wide_data->_IO_write_ptr;
+      fp->_IO_buf_base = NULL;
     }
-  else
-    *fp->_wide_data->_IO_write_ptr = '\0';
-
-  *mp->bufloc = (char *) fp->_wide_data->_IO_write_base;
-  *mp->sizeloc = (fp->_wide_data->_IO_write_ptr
-		  - fp->_wide_data->_IO_write_base);
-
-  return 0;
-}
-
-
-static void
-_IO_wmem_finish (fp, dummy)
-     _IO_FILE* fp;
-     int dummy;
-{
-  struct _IO_FILE_memstream *mp = (struct _IO_FILE_memstream *) fp;
-
-  *mp->bufloc = (char *) realloc (fp->_wide_data->_IO_write_base,
-				  (fp->_wide_data->_IO_write_ptr
-				   - fp->_wide_data->_IO_write_base + 1)
-				  * sizeof (wchar_t));
-  if (*mp->bufloc != NULL)
-    {
-      ((wchar_t *) (*mp->bufloc))[fp->_wide_data->_IO_write_ptr
-				 - fp->_wide_data->_IO_write_base] = '\0';
-      *mp->sizeloc = (fp->_wide_data->_IO_write_ptr
-		      - fp->_wide_data->_IO_write_base);
-    }
-
-  fp->_wide_data->_IO_buf_base = NULL;
 
-  INTUSE(_IO_default_finish) (fp, 0);
+  _IO_str_finish (fp, 0);
 }
diff --git a/src/system/libroot/posix/glibc/libio/pclose.c b/src/system/libroot/posix/glibc/libio/pclose.c
index 848c5a5b00..29220f6ca9 100644
--- a/src/system/libroot/posix/glibc/libio/pclose.c
+++ b/src/system/libroot/posix/glibc/libio/pclose.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996-1998, 2000 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
diff --git a/src/system/libroot/posix/glibc/libio/peekc.c b/src/system/libroot/posix/glibc/libio/peekc.c
index 95ba8aea0e..38998c5355 100644
--- a/src/system/libroot/posix/glibc/libio/peekc.c
+++ b/src/system/libroot/posix/glibc/libio/peekc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -36,10 +35,8 @@ _IO_peekc_locked (fp)
 {
   int result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_peekc_unlocked (fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/putc.c b/src/system/libroot/posix/glibc/libio/putc.c
index 649574494f..897d818238 100644
--- a/src/system/libroot/posix/glibc/libio/putc.c
+++ b/src/system/libroot/posix/glibc/libio/putc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1995,1996,1997,1998,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "stdio.h"
@@ -28,14 +27,12 @@ _IO_putc (c, fp)
 {
   int result;
   CHECK_FILE (fp, EOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_putc_unlocked (c, fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
-INTDEF(_IO_putc)
+libc_hidden_def (_IO_putc)
 
 #undef putc
 
diff --git a/src/system/libroot/posix/glibc/libio/putc_u.c b/src/system/libroot/posix/glibc/libio/putc_u.c
index ad8ca4eb05..f42f5c7a34 100644
--- a/src/system/libroot/posix/glibc/libio/putc_u.c
+++ b/src/system/libroot/posix/glibc/libio/putc_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "stdio.h"
diff --git a/src/system/libroot/posix/glibc/libio/putchar.c b/src/system/libroot/posix/glibc/libio/putchar.c
index ac20727c58..a002f4a4c8 100644
--- a/src/system/libroot/posix/glibc/libio/putchar.c
+++ b/src/system/libroot/posix/glibc/libio/putchar.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "stdio.h"
@@ -26,12 +25,9 @@ putchar (c)
      int c;
 {
   int result;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-			       _IO_stdout);
-  _IO_flockfile (_IO_stdout);
+  _IO_acquire_lock (_IO_stdout);
   result = _IO_putc_unlocked (c, _IO_stdout);
-  _IO_funlockfile (_IO_stdout);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (_IO_stdout);
   return result;
 }
 
diff --git a/src/system/libroot/posix/glibc/libio/putchar_u.c b/src/system/libroot/posix/glibc/libio/putchar_u.c
index 248574b5d9..46409849ed 100644
--- a/src/system/libroot/posix/glibc/libio/putchar_u.c
+++ b/src/system/libroot/posix/glibc/libio/putchar_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include "stdio.h"
diff --git a/src/system/libroot/posix/glibc/libio/putwc.c b/src/system/libroot/posix/glibc/libio/putwc.c
index 33da712f7f..1b0f1814eb 100644
--- a/src/system/libroot/posix/glibc/libio/putwc.c
+++ b/src/system/libroot/posix/glibc/libio/putwc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,95,96,97,98,99,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include <wchar.h>
@@ -26,11 +25,9 @@ putwc (wc, fp)
 {
   wint_t result;
   CHECK_FILE (fp, WEOF);
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   result = _IO_putwc_unlocked (wc, fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
   return result;
 }
 libc_hidden_def (putwc)
diff --git a/src/system/libroot/posix/glibc/libio/putwc_u.c b/src/system/libroot/posix/glibc/libio/putwc_u.c
index f0914c5d1a..08bd8f621b 100644
--- a/src/system/libroot/posix/glibc/libio/putwc_u.c
+++ b/src/system/libroot/posix/glibc/libio/putwc_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1995-1997,1999,2002,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include <wchar.h>
diff --git a/src/system/libroot/posix/glibc/libio/putwchar.c b/src/system/libroot/posix/glibc/libio/putwchar.c
index 56fec58aab..dac5bbf524 100644
--- a/src/system/libroot/posix/glibc/libio/putwchar.c
+++ b/src/system/libroot/posix/glibc/libio/putwchar.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 95, 96, 97, 98, 99 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include <wchar.h>
@@ -24,11 +23,8 @@ putwchar (wc)
      wchar_t wc;
 {
   wint_t result;
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-			    _IO_stdout);
-  _IO_flockfile (_IO_stdout);
+  _IO_acquire_lock (_IO_stdout);
   result = _IO_putwc_unlocked (wc, _IO_stdout);
-  _IO_funlockfile (_IO_stdout);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (_IO_stdout);
   return result;
 }
diff --git a/src/system/libroot/posix/glibc/libio/putwchar_u.c b/src/system/libroot/posix/glibc/libio/putwchar_u.c
index 9db179fc1a..4f09c16d72 100644
--- a/src/system/libroot/posix/glibc/libio/putwchar_u.c
+++ b/src/system/libroot/posix/glibc/libio/putwchar_u.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 #include "libioP.h"
 #include <wchar.h>
diff --git a/src/system/libroot/posix/glibc/libio/rewind.c b/src/system/libroot/posix/glibc/libio/rewind.c
index e1bdc571e0..06b2c38817 100644
--- a/src/system/libroot/posix/glibc/libio/rewind.c
+++ b/src/system/libroot/posix/glibc/libio/rewind.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,96,97,98,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,11 +32,9 @@ rewind (fp)
      _IO_FILE *fp;
 {
   CHECK_FILE (fp, );
-  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
-  _IO_flockfile (fp);
+  _IO_acquire_lock (fp);
   _IO_rewind (fp);
   _IO_clearerr (fp);
-  _IO_funlockfile (fp);
-  _IO_cleanup_region_end (0);
+  _IO_release_lock (fp);
 }
 libc_hidden_def (rewind)
diff --git a/src/system/libroot/posix/glibc/libio/setbuf.c b/src/system/libroot/posix/glibc/libio/setbuf.c
index 229cccb2df..db72cc6109 100644
--- a/src/system/libroot/posix/glibc/libio/setbuf.c
+++ b/src/system/libroot/posix/glibc/libio/setbuf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,5 +32,5 @@ setbuf (fp, buf)
      _IO_FILE *fp;
      char *buf;
 {
-  INTUSE(_IO_setbuffer) (fp, buf, _IO_BUFSIZ);
+  _IO_setbuffer (fp, buf, _IO_BUFSIZ);
 }
diff --git a/src/system/libroot/posix/glibc/libio/setlinebuf.c b/src/system/libroot/posix/glibc/libio/setlinebuf.c
index ded3c8f58c..b758c228b6 100644
--- a/src/system/libroot/posix/glibc/libio/setlinebuf.c
+++ b/src/system/libroot/posix/glibc/libio/setlinebuf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -34,5 +33,5 @@ void
 setlinebuf (stream)
      _IO_FILE *stream;
 {
-  INTUSE(_IO_setvbuf) (stream, NULL, 1, 0);
+  _IO_setvbuf (stream, NULL, 1, 0);
 }
diff --git a/src/system/libroot/posix/glibc/libio/stdfiles.c b/src/system/libroot/posix/glibc/libio/stdfiles.c
index cbc1407900..e7b56dfd21 100644
--- a/src/system/libroot/posix/glibc/libio/stdfiles.c
+++ b/src/system/libroot/posix/glibc/libio/stdfiles.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993-1997,1999,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -39,30 +38,30 @@
 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
   static struct _IO_wide_data _IO_wide_data_##FD \
-    = { ._wide_vtable = &INTUSE(_IO_wfile_jumps) }; \
+    = { ._wide_vtable = &_IO_wfile_jumps }; \
   struct _IO_FILE_plus NAME \
     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
-       &INTUSE(_IO_file_jumps)};
+       &_IO_file_jumps};
 # else
 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   static _IO_lock_t _IO_stdfile_##FD##_lock = _IO_lock_initializer; \
   struct _IO_FILE_plus NAME \
     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
-       &INTUSE(_IO_file_jumps)};
+       &_IO_file_jumps};
 # endif
 #else
 # if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   static struct _IO_wide_data _IO_wide_data_##FD \
-    = { ._wide_vtable = &INTUSE(_IO_wfile_jumps) }; \
+    = { ._wide_vtable = &_IO_wfile_jumps }; \
   struct _IO_FILE_plus NAME \
     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, &_IO_wide_data_##FD), \
-       &INTUSE(_IO_file_jumps)};
+       &_IO_file_jumps};
 # else
 #  define DEF_STDFILE(NAME, FD, CHAIN, FLAGS) \
   struct _IO_FILE_plus NAME \
     = {FILEBUF_LITERAL(CHAIN, FLAGS, FD, NULL), \
-       &INTUSE(_IO_file_jumps)};
+       &_IO_file_jumps};
 # endif
 #endif
 
@@ -71,4 +70,4 @@ DEF_STDFILE(_IO_2_1_stdout_, 1, &_IO_2_1_stdin_, _IO_NO_READS);
 DEF_STDFILE(_IO_2_1_stderr_, 2, &_IO_2_1_stdout_, _IO_NO_READS+_IO_UNBUFFERED);
 
 struct _IO_FILE_plus *_IO_list_all = &_IO_2_1_stderr_;
-INTVARDEF(_IO_list_all)
+libc_hidden_data_def (_IO_list_all)
diff --git a/src/system/libroot/posix/glibc/libio/stdio.c b/src/system/libroot/posix/glibc/libio/stdio.c
index 8dc24ed98f..3dadfadf36 100644
--- a/src/system/libroot/posix/glibc/libio/stdio.c
+++ b/src/system/libroot/posix/glibc/libio/stdio.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1994,1996,1997,2000,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -40,14 +39,9 @@ _IO_FILE *stderr = (FILE *) &_IO_2_1_stderr_;
 #undef _IO_stderr
 #ifdef _LIBC
 # define AL(name) AL2 (name, _IO_##name)
-# if defined HAVE_VISIBILITY_ATTRIBUTE
-#  define AL2(name, al) \
+# define AL2(name, al) \
   extern __typeof (name) al __attribute__ ((alias (#name),                    \
                                             visibility ("hidden")))
-# else
-#  define AL2(name, al) \
-  extern __typeof (name) al __attribute__ ((alias (#name)))
-# endif
 AL(stdin);
 AL(stdout);
 AL(stderr);
diff --git a/src/system/libroot/posix/glibc/libio/stdio.h b/src/system/libroot/posix/glibc/libio/stdio.h
index b922305640..713a43bed8 100644
--- a/src/system/libroot/posix/glibc/libio/stdio.h
+++ b/src/system/libroot/posix/glibc/libio/stdio.h
@@ -1,5 +1,5 @@
 /* Define ISO C stdio on top of C++ iostreams.
-   Copyright (C) 1991,1994-1999,2000,01,02 Free Software Foundation, Inc.
+   Copyright (C) 1991-2014 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
@@ -13,9 +13,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
 /*
  *	ISO C99 Standard: 7.19 Input/output	<stdio.h>
@@ -23,8 +22,6 @@
 
 #ifndef _STDIO_H
 
-//#include <libioP.h>
-
 #if !defined __need_FILE && !defined __need___FILE
 # define _STDIO_H	1
 # include <features.h>
@@ -43,12 +40,15 @@ __BEGIN_DECLS
 
 #if !defined __FILE_defined && defined __need_FILE
 
+/* Define outside of namespace so the C++ is happy.  */
+struct _IO_FILE;
+
 __BEGIN_NAMESPACE_STD
 /* The opaque type of streams.  This is the definition used elsewhere.  */
 typedef struct _IO_FILE FILE;
 __END_NAMESPACE_STD
-#if defined __USE_LARGEFILE64 || defined __USE_SVID || defined __USE_POSIX \
-    || defined __USE_BSD || defined __USE_ISOC99 || defined __USE_XOPEN \
+#if defined __USE_LARGEFILE64 || defined __USE_POSIX \
+    || defined __USE_ISOC99 || defined __USE_XOPEN \
     || defined __USE_POSIX2
 __USING_NAMESPACE_STD(FILE)
 #endif
@@ -83,7 +83,7 @@ typedef struct _IO_FILE __FILE;
 
 #include <libio.h>
 
-#ifdef __USE_XOPEN
+#if defined __USE_XOPEN || defined __USE_XOPEN2K8
 # ifdef __GNUC__
 #  ifndef _VA_LIST_DEFINED
 typedef _G_va_list va_list;
@@ -94,6 +94,26 @@ typedef _G_va_list va_list;
 # endif
 #endif
 
+#ifdef __USE_XOPEN2K8
+# ifndef __off_t_defined
+# ifndef __USE_FILE_OFFSET64
+typedef __off_t off_t;
+# else
+typedef __off64_t off_t;
+# endif
+# define __off_t_defined
+# endif
+# if defined __USE_LARGEFILE64 && !defined __off64_t_defined
+typedef __off64_t off64_t;
+# define __off64_t_defined
+# endif
+
+# ifndef __ssize_t_defined
+typedef __ssize_t ssize_t;
+# define __ssize_t_defined
+# endif
+#endif
+
 /* The type of the second argument to `fgetpos' and `fsetpos'.  */
 __BEGIN_NAMESPACE_STD
 #ifndef __USE_FILE_OFFSET64
@@ -107,7 +127,7 @@ typedef _G_fpos64_t fpos64_t;
 #endif
 
 /* The possibilities for the third argument to `setvbuf'.  */
-#define _IOFBF 0 		/* Fully buffered.  */
+#define _IOFBF 0		/* Fully buffered.  */
 #define _IOLBF 1		/* Line buffered.  */
 #define _IONBF 2		/* No buffering.  */
 
@@ -130,9 +150,13 @@ typedef _G_fpos64_t fpos64_t;
 #define SEEK_SET	0	/* Seek from beginning of file.  */
 #define SEEK_CUR	1	/* Seek from current position.  */
 #define SEEK_END	2	/* Seek from end of file.  */
+#ifdef __USE_GNU
+# define SEEK_DATA	3	/* Seek to next data.  */
+# define SEEK_HOLE	4	/* Seek to next hole.  */
+#endif
 
 
-#if defined __USE_SVID || defined __USE_XOPEN
+#if defined __USE_MISC || defined __USE_XOPEN
 /* Default path prefix for `tempnam' and `tmpnam'.  */
 # define P_tmpdir	"/tmp"
 #endif
@@ -141,7 +165,7 @@ typedef _G_fpos64_t fpos64_t;
 /* Get the values:
    L_tmpnam	How long an array of chars must be to be passed to `tmpnam'.
    TMP_MAX	The minimum number of unique filenames generated by tmpnam
-   		(and tempnam when it uses tmpnam's name space),
+		(and tempnam when it uses tmpnam's name space),
 		or tempnam (the two are separate).
    L_ctermid	How long an array to pass to `ctermid'.
    L_cuserid	How long an array to pass to `cuserid'.
@@ -161,40 +185,48 @@ extern struct _IO_FILE *stderr;		/* Standard error output stream.  */
 
 __BEGIN_NAMESPACE_STD
 /* Remove file FILENAME.  */
-extern int remove (__const char *__filename) __THROW;
+extern int remove (const char *__filename) __THROW;
 /* Rename file OLD to NEW.  */
-extern int rename (__const char *__old, __const char *__new) __THROW;
+extern int rename (const char *__old, const char *__new) __THROW;
 __END_NAMESPACE_STD
 
+#ifdef __USE_ATFILE
+/* Rename file OLD relative to OLDFD to NEW relative to NEWFD.  */
+extern int renameat (int __oldfd, const char *__old, int __newfd,
+		     const char *__new) __THROW;
+#endif
 
 __BEGIN_NAMESPACE_STD
-/* Create a temporary file and open it read/write.  */
+/* Create a temporary file and open it read/write.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
 #ifndef __USE_FILE_OFFSET64
-extern FILE *tmpfile (void) __THROW;
+extern FILE *tmpfile (void) __wur;
 #else
 # ifdef __REDIRECT
-extern FILE *__REDIRECT (tmpfile, (void) __THROW, tmpfile64);
+extern FILE *__REDIRECT (tmpfile, (void), tmpfile64) __wur;
 # else
 #  define tmpfile tmpfile64
 # endif
 #endif
 
-/* Generate a temporary filename.  */
-extern char *tmpnam (char *__s) __THROW;
-__END_NAMESPACE_STD
-
 #ifdef __USE_LARGEFILE64
-extern FILE *tmpfile64 (void) __THROW;
+extern FILE *tmpfile64 (void) __wur;
 #endif
 
+/* Generate a temporary filename.  */
+extern char *tmpnam (char *__s) __THROW __wur;
+__END_NAMESPACE_STD
+
 #ifdef __USE_MISC
 /* This is the reentrant variant of `tmpnam'.  The only difference is
    that it does not allow S to be NULL.  */
-extern char *tmpnam_r (char *__s) __THROW;
+extern char *tmpnam_r (char *__s) __THROW __wur;
 #endif
 
 
-#if defined __USE_SVID || defined __USE_XOPEN
+#if defined __USE_MISC || defined __USE_XOPEN
 /* Generate a unique temporary filename using up to five characters of PFX
    if it is not NULL.  The directory to put this file in is searched for
    as follows: First the environment variable "TMPDIR" is checked.
@@ -202,47 +234,69 @@ extern char *tmpnam_r (char *__s) __THROW;
    If not and if DIR is not NULL, that value is checked.  If that fails,
    P_tmpdir is tried and finally "/tmp".  The storage for the filename
    is allocated by `malloc'.  */
-extern char *tempnam (__const char *__dir, __const char *__pfx)
-     __THROW __attribute_malloc__;
+extern char *tempnam (const char *__dir, const char *__pfx)
+     __THROW __attribute_malloc__ __wur;
 #endif
 
 
 __BEGIN_NAMESPACE_STD
-/* Close STREAM.  */
-extern int fclose (FILE *__stream) __THROW;
-/* Flush STREAM, or all streams if STREAM is NULL.  */
-extern int fflush (FILE *__stream) __THROW;
+/* Close STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fclose (FILE *__stream);
+/* Flush STREAM, or all streams if STREAM is NULL.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fflush (FILE *__stream);
 __END_NAMESPACE_STD
 
 #ifdef __USE_MISC
-/* Faster versions when locking is not required.  */
-extern int fflush_unlocked (FILE *__stream) __THROW;
+/* Faster versions when locking is not required.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern int fflush_unlocked (FILE *__stream);
 #endif
 
 #ifdef __USE_GNU
-/* Close all streams.  */
-extern int fcloseall (void) __THROW;
+/* Close all streams.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern int fcloseall (void);
 #endif
 
 
 __BEGIN_NAMESPACE_STD
 #ifndef __USE_FILE_OFFSET64
-/* Open a file and create a new stream for it.  */
-extern FILE *fopen (__const char *__restrict __filename,
-		    __const char *__restrict __modes) __THROW;
-/* Open a file, replacing an existing stream with it. */
-extern FILE *freopen (__const char *__restrict __filename,
-		      __const char *__restrict __modes,
-		      FILE *__restrict __stream) __THROW;
+/* Open a file and create a new stream for it.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern FILE *fopen (const char *__restrict __filename,
+		    const char *__restrict __modes) __wur;
+/* Open a file, replacing an existing stream with it.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern FILE *freopen (const char *__restrict __filename,
+		      const char *__restrict __modes,
+		      FILE *__restrict __stream) __wur;
 #else
 # ifdef __REDIRECT
-extern FILE *__REDIRECT (fopen, (__const char *__restrict __filename,
-				 __const char *__restrict __modes) __THROW,
-			 fopen64);
-extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
-				   __const char *__restrict __modes,
-				   FILE *__restrict __stream) __THROW,
-			 freopen64);
+extern FILE *__REDIRECT (fopen, (const char *__restrict __filename,
+				 const char *__restrict __modes), fopen64)
+  __wur;
+extern FILE *__REDIRECT (freopen, (const char *__restrict __filename,
+				   const char *__restrict __modes,
+				   FILE *__restrict __stream), freopen64)
+  __wur;
 # else
 #  define fopen fopen64
 #  define freopen freopen64
@@ -250,33 +304,35 @@ extern FILE *__REDIRECT (freopen, (__const char *__restrict __filename,
 #endif
 __END_NAMESPACE_STD
 #ifdef __USE_LARGEFILE64
-extern FILE *fopen64 (__const char *__restrict __filename,
-		      __const char *__restrict __modes) __THROW;
-extern FILE *freopen64 (__const char *__restrict __filename,
-			__const char *__restrict __modes,
-			FILE *__restrict __stream) __THROW;
+extern FILE *fopen64 (const char *__restrict __filename,
+		      const char *__restrict __modes) __wur;
+extern FILE *freopen64 (const char *__restrict __filename,
+			const char *__restrict __modes,
+			FILE *__restrict __stream) __wur;
 #endif
 
 #ifdef	__USE_POSIX
 /* Create a new stream that refers to an existing system file descriptor.  */
-extern FILE *fdopen (int __fd, __const char *__modes) __THROW;
+extern FILE *fdopen (int __fd, const char *__modes) __THROW __wur;
 #endif
 
 #ifdef	__USE_GNU
 /* Create a new stream that refers to the given magic cookie,
    and uses the given functions for input and output.  */
 extern FILE *fopencookie (void *__restrict __magic_cookie,
-			  __const char *__restrict __modes,
-			  _IO_cookie_io_functions_t __io_funcs) __THROW;
+			  const char *__restrict __modes,
+			  _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
+#endif
 
+#ifdef __USE_XOPEN2K8
 /* Create a new stream that refers to a memory buffer.  */
-extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes) __THROW;
+extern FILE *fmemopen (void *__s, size_t __len, const char *__modes)
+  __THROW __wur;
 
 /* Open a stream that writes into a malloc'd buffer that is expanded as
    necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location
    and the number of characters written on fflush or fclose.  */
-extern FILE *open_memstream (char **__restrict __bufloc,
-			     size_t *__restrict __sizeloc) __THROW;
+extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
 #endif
 
 
@@ -291,7 +347,7 @@ extern int setvbuf (FILE *__restrict __stream, char *__restrict __buf,
 		    int __modes, size_t __n) __THROW;
 __END_NAMESPACE_STD
 
-#ifdef	__USE_BSD
+#ifdef	__USE_MISC
 /* If BUF is NULL, make STREAM unbuffered.
    Else make it use SIZE bytes of BUF for buffering.  */
 extern void setbuffer (FILE *__restrict __stream, char *__restrict __buf,
@@ -303,123 +359,235 @@ extern void setlinebuf (FILE *__stream) __THROW;
 
 
 __BEGIN_NAMESPACE_STD
-/* Write formatted output to STREAM.  */
+/* Write formatted output to STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
 extern int fprintf (FILE *__restrict __stream,
-		    __const char *__restrict __format, ...) __THROW;
-/* Write formatted output to stdout.  */
-extern int printf (__const char *__restrict __format, ...) __THROW;
+		    const char *__restrict __format, ...);
+/* Write formatted output to stdout.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int printf (const char *__restrict __format, ...);
 /* Write formatted output to S.  */
 extern int sprintf (char *__restrict __s,
-		    __const char *__restrict __format, ...) __THROW;
+		    const char *__restrict __format, ...) __THROWNL;
 
+/* Write formatted output to S from argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vfprintf (FILE *__restrict __s, const char *__restrict __format,
+		     _G_va_list __arg);
+/* Write formatted output to stdout from argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vprintf (const char *__restrict __format, _G_va_list __arg);
 /* Write formatted output to S from argument list ARG.  */
-extern int vfprintf (FILE *__restrict __s, __const char *__restrict __format,
-		     _G_va_list __arg) __THROW;
-/* Write formatted output to stdout from argument list ARG.  */
-extern int vprintf (__const char *__restrict __format, _G_va_list __arg)
-     __THROW;
-/* Write formatted output to S from argument list ARG.  */
-extern int vsprintf (char *__restrict __s, __const char *__restrict __format,
-		     _G_va_list __arg) __THROW;
+extern int vsprintf (char *__restrict __s, const char *__restrict __format,
+		     _G_va_list __arg) __THROWNL;
 __END_NAMESPACE_STD
 
-#if defined __USE_BSD || defined __USE_ISOC99 || defined __USE_UNIX98
+#if defined __USE_ISOC99 || defined __USE_UNIX98
 __BEGIN_NAMESPACE_C99
 /* Maximum chars of output to write in MAXLEN.  */
 extern int snprintf (char *__restrict __s, size_t __maxlen,
-		     __const char *__restrict __format, ...)
-     __THROW __attribute__ ((__format__ (__printf__, 3, 4)));
+		     const char *__restrict __format, ...)
+     __THROWNL __attribute__ ((__format__ (__printf__, 3, 4)));
 
 extern int vsnprintf (char *__restrict __s, size_t __maxlen,
-		      __const char *__restrict __format, _G_va_list __arg)
-     __THROW __attribute__ ((__format__ (__printf__, 3, 0)));
+		      const char *__restrict __format, _G_va_list __arg)
+     __THROWNL __attribute__ ((__format__ (__printf__, 3, 0)));
 __END_NAMESPACE_C99
 #endif
 
 #ifdef __USE_GNU
 /* Write formatted output to a string dynamically allocated with `malloc'.
    Store the address of the string in *PTR.  */
-extern int vasprintf (char **__restrict __ptr, __const char *__restrict __f,
+extern int vasprintf (char **__restrict __ptr, const char *__restrict __f,
 		      _G_va_list __arg)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
+     __THROWNL __attribute__ ((__format__ (__printf__, 2, 0))) __wur;
 extern int __asprintf (char **__restrict __ptr,
-		       __const char *__restrict __fmt, ...)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
+		       const char *__restrict __fmt, ...)
+     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
 extern int asprintf (char **__restrict __ptr,
-		     __const char *__restrict __fmt, ...)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
+		     const char *__restrict __fmt, ...)
+     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
+#endif
 
+#ifdef __USE_XOPEN2K8
 /* Write formatted output to a file descriptor.  */
-extern int vdprintf (int __fd, __const char *__restrict __fmt,
+extern int vdprintf (int __fd, const char *__restrict __fmt,
 		     _G_va_list __arg)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
-extern int dprintf (int __fd, __const char *__restrict __fmt, ...)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
+     __attribute__ ((__format__ (__printf__, 2, 0)));
+extern int dprintf (int __fd, const char *__restrict __fmt, ...)
+     __attribute__ ((__format__ (__printf__, 2, 3)));
 #endif
 
 
 __BEGIN_NAMESPACE_STD
-/* Read formatted input from STREAM.  */
+/* Read formatted input from STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
 extern int fscanf (FILE *__restrict __stream,
-		   __const char *__restrict __format, ...) __THROW;
-/* Read formatted input from stdin.  */
-extern int scanf (__const char *__restrict __format, ...) __THROW;
+		   const char *__restrict __format, ...) __wur;
+/* Read formatted input from stdin.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int scanf (const char *__restrict __format, ...) __wur;
 /* Read formatted input from S.  */
-extern int sscanf (__const char *__restrict __s,
-		   __const char *__restrict __format, ...) __THROW;
+extern int sscanf (const char *__restrict __s,
+		   const char *__restrict __format, ...) __THROW;
+
+#if defined __USE_ISOC99 && !defined __USE_GNU \
+    && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
+    && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+# ifdef __REDIRECT
+/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
+   GNU extension which conflicts with valid %a followed by letter
+   s, S or [.  */
+extern int __REDIRECT (fscanf, (FILE *__restrict __stream,
+				const char *__restrict __format, ...),
+		       __isoc99_fscanf) __wur;
+extern int __REDIRECT (scanf, (const char *__restrict __format, ...),
+		       __isoc99_scanf) __wur;
+extern int __REDIRECT_NTH (sscanf, (const char *__restrict __s,
+				    const char *__restrict __format, ...),
+			   __isoc99_sscanf);
+# else
+extern int __isoc99_fscanf (FILE *__restrict __stream,
+			    const char *__restrict __format, ...) __wur;
+extern int __isoc99_scanf (const char *__restrict __format, ...) __wur;
+extern int __isoc99_sscanf (const char *__restrict __s,
+			    const char *__restrict __format, ...) __THROW;
+#  define fscanf __isoc99_fscanf
+#  define scanf __isoc99_scanf
+#  define sscanf __isoc99_sscanf
+# endif
+#endif
+
 __END_NAMESPACE_STD
 
 #ifdef	__USE_ISOC99
 __BEGIN_NAMESPACE_C99
-/* Read formatted input from S into argument list ARG.  */
-extern int vfscanf (FILE *__restrict __s, __const char *__restrict __format,
+/* Read formatted input from S into argument list ARG.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vfscanf (FILE *__restrict __s, const char *__restrict __format,
 		    _G_va_list __arg)
-     __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
+     __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
+
+/* Read formatted input from stdin into argument list ARG.
 
-/* Read formatted input from stdin into argument list ARG.  */
-extern int vscanf (__const char *__restrict __format, _G_va_list __arg)
-     __THROW __attribute__ ((__format__ (__scanf__, 1, 0)));
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int vscanf (const char *__restrict __format, _G_va_list __arg)
+     __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
 
 /* Read formatted input from S into argument list ARG.  */
-extern int vsscanf (__const char *__restrict __s,
-		    __const char *__restrict __format, _G_va_list __arg)
+extern int vsscanf (const char *__restrict __s,
+		    const char *__restrict __format, _G_va_list __arg)
      __THROW __attribute__ ((__format__ (__scanf__, 2, 0)));
+
+# if !defined __USE_GNU \
+     && (!defined __LDBL_COMPAT || !defined __REDIRECT) \
+     && (defined __STRICT_ANSI__ || defined __USE_XOPEN2K)
+#  ifdef __REDIRECT
+/* For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
+   GNU extension which conflicts with valid %a followed by letter
+   s, S or [.  */
+extern int __REDIRECT (vfscanf,
+		       (FILE *__restrict __s,
+			const char *__restrict __format, _G_va_list __arg),
+		       __isoc99_vfscanf)
+     __attribute__ ((__format__ (__scanf__, 2, 0))) __wur;
+extern int __REDIRECT (vscanf, (const char *__restrict __format,
+				_G_va_list __arg), __isoc99_vscanf)
+     __attribute__ ((__format__ (__scanf__, 1, 0))) __wur;
+extern int __REDIRECT_NTH (vsscanf,
+			   (const char *__restrict __s,
+			    const char *__restrict __format,
+			    _G_va_list __arg), __isoc99_vsscanf)
+     __attribute__ ((__format__ (__scanf__, 2, 0)));
+#  else
+extern int __isoc99_vfscanf (FILE *__restrict __s,
+			     const char *__restrict __format,
+			     _G_va_list __arg) __wur;
+extern int __isoc99_vscanf (const char *__restrict __format,
+			    _G_va_list __arg) __wur;
+extern int __isoc99_vsscanf (const char *__restrict __s,
+			     const char *__restrict __format,
+			     _G_va_list __arg) __THROW;
+#   define vfscanf __isoc99_vfscanf
+#   define vscanf __isoc99_vscanf
+#   define vsscanf __isoc99_vsscanf
+#  endif
+# endif
+
 __END_NAMESPACE_C99
 #endif /* Use ISO C9x.  */
 
 
 __BEGIN_NAMESPACE_STD
-/* Read a character from STREAM.  */
-extern int fgetc (FILE *__stream) __THROW;
-extern int getc (FILE *__stream) __THROW;
+/* Read a character from STREAM.
 
-/* Read a character from stdin.  */
-extern int getchar (void) __THROW;
+   These functions are possible cancellation points and therefore not
+   marked with __THROW.  */
+extern int fgetc (FILE *__stream);
+extern int getc (FILE *__stream);
+
+/* Read a character from stdin.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int getchar (void);
 __END_NAMESPACE_STD
 
 /* The C standard explicitly says this is a macro, so we always do the
    optimization for it.  */
 #define getc(_fp) _IO_getc (_fp)
 
-#if defined __USE_POSIX || defined __USE_MISC
-/* These are defined in POSIX.1:1996.  */
-extern int getc_unlocked (FILE *__stream) __THROW;
-extern int getchar_unlocked (void) __THROW;
-#endif /* Use POSIX or MISC.  */
+#ifdef __USE_POSIX
+/* These are defined in POSIX.1:1996.
+
+   These functions are possible cancellation points and therefore not
+   marked with __THROW.  */
+extern int getc_unlocked (FILE *__stream);
+extern int getchar_unlocked (void);
+#endif /* Use POSIX.  */
 
 #ifdef __USE_MISC
-/* Faster version when locking is not necessary.  */
-extern int fgetc_unlocked (FILE *__stream) __THROW;
+/* Faster version when locking is not necessary.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern int fgetc_unlocked (FILE *__stream);
 #endif /* Use MISC.  */
 
 
 __BEGIN_NAMESPACE_STD
-/* Write a character to STREAM.  */
-extern int fputc (int __c, FILE *__stream) __THROW;
-extern int putc (int __c, FILE *__stream) __THROW;
+/* Write a character to STREAM.
 
-/* Write a character to stdout.  */
-extern int putchar (int __c) __THROW;
+   These functions are possible cancellation points and therefore not
+   marked with __THROW.
+
+   These functions is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fputc (int __c, FILE *__stream);
+extern int putc (int __c, FILE *__stream);
+
+/* Write a character to stdout.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int putchar (int __c);
 __END_NAMESPACE_STD
 
 /* The C standard explicitly says this can be a macro,
@@ -427,106 +595,178 @@ __END_NAMESPACE_STD
 #define putc(_ch, _fp) _IO_putc (_ch, _fp)
 
 #ifdef __USE_MISC
-/* Faster version when locking is not necessary.  */
-extern int fputc_unlocked (int __c, FILE *__stream) __THROW;
+/* Faster version when locking is not necessary.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern int fputc_unlocked (int __c, FILE *__stream);
 #endif /* Use MISC.  */
 
-#if defined __USE_POSIX || defined __USE_MISC
-/* These are defined in POSIX.1:1996.  */
-extern int putc_unlocked (int __c, FILE *__stream) __THROW;
-extern int putchar_unlocked (int __c) __THROW;
-#endif /* Use POSIX or MISC.  */
+#ifdef __USE_POSIX
+/* These are defined in POSIX.1:1996.
 
+   These functions are possible cancellation points and therefore not
+   marked with __THROW.  */
+extern int putc_unlocked (int __c, FILE *__stream);
+extern int putchar_unlocked (int __c);
+#endif /* Use POSIX.  */
 
-#if defined __USE_SVID || defined __USE_MISC || defined __USE_XOPEN
+
+#if defined __USE_MISC \
+    || (defined __USE_XOPEN && !defined __USE_XOPEN2K)
 /* Get a word (int) from STREAM.  */
-extern int getw (FILE *__stream) __THROW;
+extern int getw (FILE *__stream);
 
 /* Write a word (int) to STREAM.  */
-extern int putw (int __w, FILE *__stream) __THROW;
+extern int putw (int __w, FILE *__stream);
 #endif
 
 
 __BEGIN_NAMESPACE_STD
-/* Get a newline-terminated string of finite length from STREAM.  */
+/* Get a newline-terminated string of finite length from STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
 extern char *fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
-     __THROW;
+     __wur;
 
+#if !defined __USE_ISOC11 \
+    || (defined __cplusplus && __cplusplus <= 201103L)
 /* Get a newline-terminated string from stdin, removing the newline.
-   DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.  */
-extern char *gets (char *__s) __THROW;
+   DO NOT USE THIS FUNCTION!!  There is no limit on how much it will read.
+
+   The function has been officially removed in ISO C11.  This opportunity
+   is used to also remove it from the GNU feature list.  It is now only
+   available when explicitly using an old ISO C, Unix, or POSIX standard.
+   GCC defines _GNU_SOURCE when building C++ code and the function is still
+   in C++11, so it is also available for C++.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern char *gets (char *__s) __wur __attribute_deprecated__;
+#endif
 __END_NAMESPACE_STD
 
 #ifdef __USE_GNU
-/* This function does the same as `fgets' but does not lock the stream.  */
+/* This function does the same as `fgets' but does not lock the stream.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
 extern char *fgets_unlocked (char *__restrict __s, int __n,
-			     FILE *__restrict __stream) __THROW;
+			     FILE *__restrict __stream) __wur;
 #endif
 
 
-#ifdef	__USE_GNU
+#ifdef	__USE_XOPEN2K8
 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
    (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
    NULL), pointing to *N characters of space.  It is realloc'd as
    necessary.  Returns the number of characters read (not including the
-   null terminator), or -1 on error or EOF.  */
+   null terminator), or -1 on error or EOF.
+
+   These functions are not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation they are cancellation points and
+   therefore not marked with __THROW.  */
 extern _IO_ssize_t __getdelim (char **__restrict __lineptr,
 			       size_t *__restrict __n, int __delimiter,
-			       FILE *__restrict __stream) __THROW;
+			       FILE *__restrict __stream) __wur;
 extern _IO_ssize_t getdelim (char **__restrict __lineptr,
 			     size_t *__restrict __n, int __delimiter,
-			     FILE *__restrict __stream) __THROW;
+			     FILE *__restrict __stream) __wur;
 
-/* Like `getdelim', but reads up to a newline.  */
+/* Like `getdelim', but reads up to a newline.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
 extern _IO_ssize_t getline (char **__restrict __lineptr,
 			    size_t *__restrict __n,
-			    FILE *__restrict __stream) __THROW;
+			    FILE *__restrict __stream) __wur;
 #endif
 
 
 __BEGIN_NAMESPACE_STD
-/* Write a string to STREAM.  */
-extern int fputs (__const char *__restrict __s, FILE *__restrict __stream)
-     __THROW;
+/* Write a string to STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fputs (const char *__restrict __s, FILE *__restrict __stream);
+
+/* Write a string, followed by a newline, to stdout.
 
-/* Write a string, followed by a newline, to stdout.  */
-extern int puts (__const char *__s) __THROW;
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int puts (const char *__s);
 
 
-/* Push a character back onto the input buffer of STREAM.  */
-extern int ungetc (int __c, FILE *__stream) __THROW;
+/* Push a character back onto the input buffer of STREAM.
 
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int ungetc (int __c, FILE *__stream);
 
-/* Read chunks of generic data from STREAM.  */
+
+/* Read chunks of generic data from STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
 extern size_t fread (void *__restrict __ptr, size_t __size,
-		     size_t __n, FILE *__restrict __stream) __THROW;
-/* Write chunks of generic data to STREAM.  */
-extern size_t fwrite (__const void *__restrict __ptr, size_t __size,
-		      size_t __n, FILE *__restrict __s) __THROW;
+		     size_t __n, FILE *__restrict __stream) __wur;
+/* Write chunks of generic data to STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern size_t fwrite (const void *__restrict __ptr, size_t __size,
+		      size_t __n, FILE *__restrict __s);
 __END_NAMESPACE_STD
 
 #ifdef __USE_GNU
-/* This function does the same as `fputs' but does not lock the stream.  */
-extern int fputs_unlocked (__const char *__restrict __s,
-			   FILE *__restrict __stream) __THROW;
+/* This function does the same as `fputs' but does not lock the stream.
+
+   This function is not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation it is a cancellation point and
+   therefore not marked with __THROW.  */
+extern int fputs_unlocked (const char *__restrict __s,
+			   FILE *__restrict __stream);
 #endif
 
 #ifdef __USE_MISC
-/* Faster versions when locking is not necessary.  */
+/* Faster versions when locking is not necessary.
+
+   These functions are not part of POSIX and therefore no official
+   cancellation point.  But due to similarity with an POSIX interface
+   or due to the implementation they are cancellation points and
+   therefore not marked with __THROW.  */
 extern size_t fread_unlocked (void *__restrict __ptr, size_t __size,
-			      size_t __n, FILE *__restrict __stream) __THROW;
-extern size_t fwrite_unlocked (__const void *__restrict __ptr, size_t __size,
-			       size_t __n, FILE *__restrict __stream) __THROW;
+			      size_t __n, FILE *__restrict __stream) __wur;
+extern size_t fwrite_unlocked (const void *__restrict __ptr, size_t __size,
+			       size_t __n, FILE *__restrict __stream);
 #endif
 
 
 __BEGIN_NAMESPACE_STD
-/* Seek to a certain position on STREAM.  */
-extern int fseek (FILE *__stream, long int __off, int __whence) __THROW;
-/* Return the current position of STREAM.  */
-extern long int ftell (FILE *__stream) __THROW;
-/* Rewind to the beginning of STREAM.  */
-extern void rewind (FILE *__stream) __THROW;
+/* Seek to a certain position on STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fseek (FILE *__stream, long int __off, int __whence);
+/* Return the current position of STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern long int ftell (FILE *__stream) __wur;
+/* Rewind to the beginning of STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern void rewind (FILE *__stream);
 __END_NAMESPACE_STD
 
 /* The Single Unix Specification, Version 2, specifies an alternative,
@@ -534,18 +774,24 @@ __END_NAMESPACE_STD
    file offset.  `long int' is not the right type.  These definitions
    are originally defined in the Large File Support API.  */
 
-#ifdef __USE_LARGEFILE
+#if defined __USE_LARGEFILE || defined __USE_XOPEN2K
 # ifndef __USE_FILE_OFFSET64
-/* Seek to a certain position on STREAM.  */
-extern int fseeko (FILE *__stream, off_t __off, int __whence) __THROW;
-/* Return the current position of STREAM.  */
-extern off_t ftello (FILE *__stream) __THROW;
+/* Seek to a certain position on STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fseeko (FILE *__stream, __off_t __off, int __whence);
+/* Return the current position of STREAM.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern __off_t ftello (FILE *__stream) __wur;
 # else
 #  ifdef __REDIRECT
 extern int __REDIRECT (fseeko,
-		       (FILE *__stream, __off64_t __off, int __whence) __THROW,
+		       (FILE *__stream, __off64_t __off, int __whence),
 		       fseeko64);
-extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
+extern __off64_t __REDIRECT (ftello, (FILE *__stream), ftello64);
 #  else
 #   define fseeko fseeko64
 #   define ftello ftello64
@@ -555,18 +801,22 @@ extern __off64_t __REDIRECT (ftello, (FILE *__stream) __THROW, ftello64);
 
 __BEGIN_NAMESPACE_STD
 #ifndef __USE_FILE_OFFSET64
-/* Get STREAM's position.  */
-extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos)
-     __THROW;
-/* Set STREAM's position.  */
-extern int fsetpos (FILE *__stream, __const fpos_t *__pos) __THROW;
+/* Get STREAM's position.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fgetpos (FILE *__restrict __stream, fpos_t *__restrict __pos);
+/* Set STREAM's position.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int fsetpos (FILE *__stream, const fpos_t *__pos);
 #else
 # ifdef __REDIRECT
 extern int __REDIRECT (fgetpos, (FILE *__restrict __stream,
-				 fpos_t *__restrict __pos) __THROW, fgetpos64);
+				 fpos_t *__restrict __pos), fgetpos64);
 extern int __REDIRECT (fsetpos,
-		       (FILE *__stream, __const fpos_t *__pos) __THROW,
-		       fsetpos64);
+		       (FILE *__stream, const fpos_t *__pos), fsetpos64);
 # else
 #  define fgetpos fgetpos64
 #  define fsetpos fsetpos64
@@ -575,33 +825,35 @@ extern int __REDIRECT (fsetpos,
 __END_NAMESPACE_STD
 
 #ifdef __USE_LARGEFILE64
-extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence) __THROW;
-extern __off64_t ftello64 (FILE *__stream) __THROW;
-extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos)
-     __THROW;
-extern int fsetpos64 (FILE *__stream, __const fpos64_t *__pos) __THROW;
+extern int fseeko64 (FILE *__stream, __off64_t __off, int __whence);
+extern __off64_t ftello64 (FILE *__stream) __wur;
+extern int fgetpos64 (FILE *__restrict __stream, fpos64_t *__restrict __pos);
+extern int fsetpos64 (FILE *__stream, const fpos64_t *__pos);
 #endif
 
 __BEGIN_NAMESPACE_STD
 /* Clear the error and EOF indicators for STREAM.  */
 extern void clearerr (FILE *__stream) __THROW;
 /* Return the EOF indicator for STREAM.  */
-extern int feof (FILE *__stream) __THROW;
+extern int feof (FILE *__stream) __THROW __wur;
 /* Return the error indicator for STREAM.  */
-extern int ferror (FILE *__stream) __THROW;
+extern int ferror (FILE *__stream) __THROW __wur;
 __END_NAMESPACE_STD
 
 #ifdef __USE_MISC
 /* Faster versions when locking is not required.  */
 extern void clearerr_unlocked (FILE *__stream) __THROW;
-extern int feof_unlocked (FILE *__stream) __THROW;
-extern int ferror_unlocked (FILE *__stream) __THROW;
+extern int feof_unlocked (FILE *__stream) __THROW __wur;
+extern int ferror_unlocked (FILE *__stream) __THROW __wur;
 #endif
 
 
 __BEGIN_NAMESPACE_STD
-/* Print a message describing the meaning of the value of errno.  */
-extern void perror (__const char *__s) __THROW;
+/* Print a message describing the meaning of the value of errno.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern void perror (const char *__s);
 __END_NAMESPACE_STD
 
 /* Provide the declarations for `sys_errlist' and `sys_nerr' if they
@@ -613,22 +865,27 @@ __END_NAMESPACE_STD
 
 #ifdef	__USE_POSIX
 /* Return the system file descriptor for STREAM.  */
-extern int fileno (FILE *__stream) __THROW;
+extern int fileno (FILE *__stream) __THROW __wur;
 #endif /* Use POSIX.  */
 
 #ifdef __USE_MISC
 /* Faster version when locking is not required.  */
-extern int fileno_unlocked (FILE *__stream) __THROW;
+extern int fileno_unlocked (FILE *__stream) __THROW __wur;
 #endif
 
 
-#if (defined __USE_POSIX2 || defined __USE_SVID  || defined __USE_BSD || \
-     defined __USE_MISC)
-/* Create a new stream connected to a pipe running the given command.  */
-extern FILE *popen (__const char *__command, __const char *__modes) __THROW;
+#ifdef __USE_POSIX2
+/* Create a new stream connected to a pipe running the given command.
+
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern FILE *popen (const char *__command, const char *__modes) __wur;
+
+/* Close a stream opened by popen and return the status of its child.
 
-/* Close a stream opened by popen and return the status of its child.  */
-extern int pclose (FILE *__stream) __THROW;
+   This function is a possible cancellation point and therefore not
+   marked with __THROW.  */
+extern int pclose (FILE *__stream);
 #endif
 
 
@@ -640,7 +897,7 @@ extern char *ctermid (char *__s) __THROW;
 
 #ifdef __USE_XOPEN
 /* Return the name of the current user.  */
-extern char *cuserid (char *__s) __THROW;
+extern char *cuserid (char *__s);
 #endif /* Use X/Open, but not issue 6.  */
 
 
@@ -649,16 +906,16 @@ struct obstack;			/* See <obstack.h>.  */
 
 /* Write formatted output to an obstack.  */
 extern int obstack_printf (struct obstack *__restrict __obstack,
-			   __const char *__restrict __format, ...)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 3)));
+			   const char *__restrict __format, ...)
+     __THROWNL __attribute__ ((__format__ (__printf__, 2, 3)));
 extern int obstack_vprintf (struct obstack *__restrict __obstack,
-			    __const char *__restrict __format,
+			    const char *__restrict __format,
 			    _G_va_list __args)
-     __THROW __attribute__ ((__format__ (__printf__, 2, 0)));
+     __THROWNL __attribute__ ((__format__ (__printf__, 2, 0)));
 #endif /* Use GNU.  */
 
 
-#if defined __USE_POSIX || defined __USE_MISC
+#ifdef __USE_POSIX
 /* These are defined in POSIX.1:1996.  */
 
 /* Acquire ownership of STREAM.  */
@@ -666,11 +923,11 @@ extern void flockfile (FILE *__stream) __THROW;
 
 /* Try to acquire ownership of STREAM but do not block if it is not
    possible.  */
-extern int ftrylockfile (FILE *__stream) __THROW;
+extern int ftrylockfile (FILE *__stream) __THROW __wur;
 
 /* Relinquish the ownership granted for STREAM.  */
 extern void funlockfile (FILE *__stream) __THROW;
-#endif /* POSIX || misc */
+#endif /* POSIX */
 
 #if defined __USE_XOPEN && !defined __USE_XOPEN2K && !defined __USE_GNU
 /* The X/Open standard requires some functions and variables to be
@@ -685,6 +942,12 @@ extern void funlockfile (FILE *__stream) __THROW;
 #ifdef __USE_EXTERN_INLINES
 # include <bits/stdio.h>
 #endif
+#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline
+# include <bits/stdio2.h>
+#endif
+#ifdef __LDBL_COMPAT
+# include <bits/stdio-ldbl.h>
+#endif
 
 __END_DECLS
 
diff --git a/src/system/libroot/posix/glibc/libio/strfile.h b/src/system/libroot/posix/glibc/libio/strfile.h
index bcac784717..1c73ed8169 100644
--- a/src/system/libroot/posix/glibc/libio/strfile.h
+++ b/src/system/libroot/posix/glibc/libio/strfile.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1998, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -47,7 +46,7 @@ struct _IO_str_fields
 struct _IO_streambuf
 {
   struct _IO_FILE _f;
-  const void *_vtable;
+  const struct _IO_jump_t *vtable;
 };
 
 typedef struct _IO_strfile_
@@ -63,3 +62,24 @@ typedef struct _IO_strfile_
 /* frozen: set when the program has requested that the array object not
    be altered, reallocated, or freed. */
 #define _IO_STR_FROZEN(FP) ((FP)->_f._IO_file_flags & _IO_USER_BUF)
+
+typedef struct
+{
+  _IO_strfile f;
+  /* This is used for the characters which do not fit in the buffer
+     provided by the user.  */
+  char overflow_buf[64];
+} _IO_strnfile;
+
+extern const struct _IO_jump_t _IO_strn_jumps attribute_hidden;
+
+
+typedef struct
+{
+  _IO_strfile f;
+  /* This is used for the characters which do not fit in the buffer
+     provided by the user.  */
+  wchar_t overflow_buf[64];
+} _IO_wstrnfile;
+
+extern const struct _IO_jump_t _IO_wstrn_jumps attribute_hidden;
diff --git a/src/system/libroot/posix/glibc/libio/strops.c b/src/system/libroot/posix/glibc/libio/strops.c
index 591546b71d..a480083b22 100644
--- a/src/system/libroot/posix/glibc/libio/strops.c
+++ b/src/system/libroot/posix/glibc/libio/strops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997-2000, 2001, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,71 +24,29 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
-#include "libioP.h"
+#include <assert.h>
 #include "strfile.h"
+#include "libioP.h"
 #include <string.h>
 #include <stdio_ext.h>
 
-#if 0
-/* The following definitions are for exposition only.
-   They map the terminology used in the ANSI/ISO C++ draft standard
-   to the implementation. */
-
-/* allocated:  set  when a dynamic array object has been allocated, and
-   hence should be freed by the destructor for the strstreambuf object. */
-#define ALLOCATED(FP) ((FP)->_f._IO_buf_base && DYNAMIC(FP))
-
-/* constant:  set when the array object has const elements,
-   so the output sequence cannot be written. */
-#define CONSTANT(FP) ((FP)->_f._IO_file_flags & _IO_NO_WRITES)
-
-/* alsize:  the suggested minimum size for a dynamic array object. */
-#define ALSIZE(FP) ??? /* not stored */
-
-/* palloc: points to the function to call to allocate a dynamic array object.*/
-#define PALLOC(FP) \
-  ((FP)->_s._allocate_buffer == default_alloc ? 0 : (FP)->_s._allocate_buffer)
-
-/* pfree: points  to  the  function  to call to free a dynamic array object. */
-#define PFREE(FP) \
-  ((FP)->_s._free_buffer == default_free ? 0 : (FP)->_s._free_buffer)
-
-#endif
-
-#ifdef TODO
-/* An "unbounded buffer" is when a buffer is supplied, but with no
-   specified length.  An example is the buffer argument to sprintf.
-   */
-#endif
-
 void
-_IO_str_init_static (sf, ptr, size, pstart)
+_IO_str_init_static_internal (sf, ptr, size, pstart)
      _IO_strfile *sf;
      char *ptr;
-     int size;
+     _IO_size_t size;
      char *pstart;
 {
   _IO_FILE *fp = &sf->_sbf._f;
+  char *end;
 
   if (size == 0)
-    size = strlen (ptr);
-  else if (size < 0)
-    {
-      /* If size is negative 'the characters are assumed to
-	 continue indefinitely.'  This is kind of messy ... */
-      int s;
-      size = 512;
-      /* Try increasing powers of 2, as long as we don't wrap around. */
-      for (; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
-	size = s;
-      /* Try increasing size as much as we can without wrapping around. */
-      for (s = size >> 1; s > 0; s >>= 1)
-	{
-	  if (ptr + size + s > ptr)
-	    size += s;
-	}
-    }
-  INTUSE(_IO_setb) (fp, ptr, ptr + size, 0);
+    end = ptr + strlen (ptr);
+  else if ((_IO_size_t) ptr + size > (_IO_size_t) ptr)
+    end = ptr + size;
+  else
+    end = (char *) -1;
+  _IO_setb (fp, ptr, end, 0);
 
   fp->_IO_write_base = ptr;
   fp->_IO_read_base = ptr;
@@ -97,19 +54,28 @@ _IO_str_init_static (sf, ptr, size, pstart)
   if (pstart)
     {
       fp->_IO_write_ptr = pstart;
-      fp->_IO_write_end = ptr + size;
+      fp->_IO_write_end = end;
       fp->_IO_read_end = pstart;
     }
   else
     {
       fp->_IO_write_ptr = ptr;
       fp->_IO_write_end = ptr;
-      fp->_IO_read_end = ptr+size;
+      fp->_IO_read_end = end;
     }
   /* A null _allocate_buffer function flags the strfile as being static. */
   sf->_s._allocate_buffer = (_IO_alloc_type) 0;
 }
-INTDEF(_IO_str_init_static)
+
+void
+_IO_str_init_static (sf, ptr, size, pstart)
+     _IO_strfile *sf;
+     char *ptr;
+     int size;
+     char *pstart;
+{
+  return _IO_str_init_static_internal (sf, ptr, size < 0 ? -1 : size, pstart);
+}
 
 void
 _IO_str_init_readonly (sf, ptr, size)
@@ -117,7 +83,7 @@ _IO_str_init_readonly (sf, ptr, size)
      const char *ptr;
      int size;
 {
-  INTUSE(_IO_str_init_static) (sf, (char *) ptr, size, NULL);
+  _IO_str_init_static_internal (sf, (char *) ptr, size < 0 ? -1 : size, NULL);
   sf->_sbf._f._IO_file_flags |= _IO_NO_WRITES;
 }
 
@@ -136,7 +102,7 @@ _IO_str_overflow (fp, c)
       fp->_IO_write_ptr = fp->_IO_read_ptr;
       fp->_IO_read_ptr = fp->_IO_read_end;
     }
-  pos =  fp->_IO_write_ptr - fp->_IO_write_base;
+  pos = fp->_IO_write_ptr - fp->_IO_write_base;
   if (pos >= (_IO_size_t) (_IO_blen (fp) + flush_only))
     {
       if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
@@ -145,7 +111,10 @@ _IO_str_overflow (fp, c)
 	{
 	  char *new_buf;
 	  char *old_buf = fp->_IO_buf_base;
-	  _IO_size_t new_size = 2 * _IO_blen (fp) + 100;
+	  size_t old_blen = _IO_blen (fp);
+	  _IO_size_t new_size = 2 * old_blen + 100;
+	  if (new_size < old_blen)
+	    return EOF;
 	  new_buf
 	    = (char *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (new_size);
 	  if (new_buf == NULL)
@@ -155,16 +124,14 @@ _IO_str_overflow (fp, c)
 	    }
 	  if (old_buf)
 	    {
-	      memcpy (new_buf, old_buf, _IO_blen (fp));
+	      memcpy (new_buf, old_buf, old_blen);
 	      (*((_IO_strfile *) fp)->_s._free_buffer) (old_buf);
 	      /* Make sure _IO_setb won't try to delete _IO_buf_base. */
 	      fp->_IO_buf_base = NULL;
 	    }
-#if 0
-	  if (lenp == &LEN(fp)) /* use '\0'-filling */
-	      memset (new_buf + pos, 0, blen() - pos);
-#endif
-	  INTUSE(_IO_setb) (fp, new_buf, new_buf + new_size, 1);
+	  memset (new_buf + old_blen, '\0', new_size - old_blen);
+
+	  _IO_setb (fp, new_buf, new_buf + new_size, 1);
 	  fp->_IO_read_base = new_buf + (fp->_IO_read_base - old_buf);
 	  fp->_IO_read_ptr = new_buf + (fp->_IO_read_ptr - old_buf);
 	  fp->_IO_read_end = new_buf + (fp->_IO_read_end - old_buf);
@@ -181,7 +148,7 @@ _IO_str_overflow (fp, c)
     fp->_IO_read_end = fp->_IO_write_ptr;
   return c;
 }
-INTDEF(_IO_str_overflow)
+libc_hidden_def (_IO_str_overflow)
 
 int
 _IO_str_underflow (fp)
@@ -200,7 +167,7 @@ _IO_str_underflow (fp)
   else
     return EOF;
 }
-INTDEF(_IO_str_underflow)
+libc_hidden_def (_IO_str_underflow)
 
 /* The size of the valid part of the buffer.  */
 
@@ -213,6 +180,73 @@ _IO_str_count (fp)
 	  - fp->_IO_read_base);
 }
 
+
+static int
+enlarge_userbuf (_IO_FILE *fp, _IO_off64_t offset, int reading)
+{
+  _IO_ssize_t oldend, newsize;
+  char *oldbuf, *newbuf;
+  if ((_IO_ssize_t) offset <= _IO_blen (fp))
+    return 0;
+
+  oldend = fp->_IO_write_end - fp->_IO_write_base;
+
+  /* Try to enlarge the buffer.  */
+  if (fp->_flags & _IO_USER_BUF)
+    /* User-provided buffer.  */
+    return 1;
+
+  newsize = offset + 100;
+  oldbuf = fp->_IO_buf_base;
+  newbuf
+    = (char *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (newsize);
+  if (newbuf == NULL)
+    return 1;
+
+  if (oldbuf != NULL)
+    {
+      memcpy (newbuf, oldbuf, _IO_blen (fp));
+      (*((_IO_strfile *) fp)->_s._free_buffer) (oldbuf);
+      /* Make sure _IO_setb won't try to delete
+	 _IO_buf_base. */
+      fp->_IO_buf_base = NULL;
+    }
+
+  _IO_setb (fp, newbuf, newbuf + newsize, 1);
+
+  if (reading)
+    {
+      fp->_IO_write_base = newbuf + (fp->_IO_write_base - oldbuf);
+      fp->_IO_write_ptr = newbuf + (fp->_IO_write_ptr - oldbuf);
+      fp->_IO_write_end = newbuf + (fp->_IO_write_end - oldbuf);
+      fp->_IO_read_ptr = newbuf + (fp->_IO_read_ptr - oldbuf);
+
+      fp->_IO_read_base = newbuf;
+      fp->_IO_read_end = fp->_IO_buf_end;
+    }
+  else
+    {
+      fp->_IO_read_base = newbuf + (fp->_IO_read_base - oldbuf);
+      fp->_IO_read_ptr = newbuf + (fp->_IO_read_ptr - oldbuf);
+      fp->_IO_read_end = newbuf + (fp->_IO_read_end - oldbuf);
+      fp->_IO_write_ptr = newbuf + (fp->_IO_write_ptr - oldbuf);
+
+      fp->_IO_write_base = newbuf;
+      fp->_IO_write_end = fp->_IO_buf_end;
+    }
+
+  /* Clear the area between the last write position and th
+     new position.  */
+  assert (offset >= oldend);
+  if (reading)
+    memset (fp->_IO_read_base + oldend, '\0', offset - oldend);
+  else
+    memset (fp->_IO_write_base + oldend, '\0', offset - oldend);
+
+  return 0;
+}
+
+
 _IO_off64_t
 _IO_str_seekoff (fp, offset, dir, mode)
      _IO_FILE *fp;
@@ -253,7 +287,10 @@ _IO_str_seekoff (fp, offset, dir, mode)
 	    default: /* case _IO_seek_set: */
 	      break;
 	    }
-	  if (offset < 0 || (_IO_ssize_t) offset > cur_size)
+	  if (offset < 0)
+	    return EOF;
+	  if ((_IO_ssize_t) offset > cur_size
+	      && enlarge_userbuf (fp, offset, 1) != 0)
 	    return EOF;
 	  fp->_IO_read_ptr = fp->_IO_read_base + offset;
 	  fp->_IO_read_end = fp->_IO_read_base + cur_size;
@@ -274,7 +311,10 @@ _IO_str_seekoff (fp, offset, dir, mode)
 	    default: /* case _IO_seek_set: */
 	      break;
 	    }
-	  if (offset < 0 || (_IO_ssize_t) offset > cur_size)
+	  if (offset < 0)
+	    return EOF;
+	  if ((_IO_ssize_t) offset > cur_size
+	      && enlarge_userbuf (fp, offset, 0) != 0)
 	    return EOF;
 	  fp->_IO_write_ptr = fp->_IO_write_base + offset;
 	  new_pos = offset;
@@ -282,7 +322,7 @@ _IO_str_seekoff (fp, offset, dir, mode)
     }
   return new_pos;
 }
-INTDEF(_IO_str_seekoff)
+libc_hidden_def (_IO_str_seekoff)
 
 int
 _IO_str_pbackfail (fp, c)
@@ -291,9 +331,9 @@ _IO_str_pbackfail (fp, c)
 {
   if ((fp->_flags & _IO_NO_WRITES) && c != EOF)
     return EOF;
-  return INTUSE(_IO_default_pbackfail) (fp, c);
+  return _IO_default_pbackfail (fp, c);
 }
-INTDEF(_IO_str_pbackfail)
+libc_hidden_def (_IO_str_pbackfail)
 
 void
 _IO_str_finish (fp, dummy)
@@ -304,24 +344,24 @@ _IO_str_finish (fp, dummy)
     (((_IO_strfile *) fp)->_s._free_buffer) (fp->_IO_buf_base);
   fp->_IO_buf_base = NULL;
 
-  INTUSE(_IO_default_finish) (fp, 0);
+  _IO_default_finish (fp, 0);
 }
 
-struct _IO_jump_t _IO_str_jumps =
+const struct _IO_jump_t _IO_str_jumps =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_str_finish),
-  JUMP_INIT(overflow, INTUSE(_IO_str_overflow)),
-  JUMP_INIT(underflow, INTUSE(_IO_str_underflow)),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_str_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_default_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_str_seekoff)),
+  JUMP_INIT(overflow, _IO_str_overflow),
+  JUMP_INIT(underflow, _IO_str_underflow),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_str_pbackfail),
+  JUMP_INIT(xsputn, _IO_default_xsputn),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
+  JUMP_INIT(seekoff, _IO_str_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_default_setbuf),
   JUMP_INIT(sync, _IO_default_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_default_doallocate)),
+  JUMP_INIT(doallocate, _IO_default_doallocate),
   JUMP_INIT(read, _IO_default_read),
   JUMP_INIT(write, _IO_default_write),
   JUMP_INIT(seek, _IO_default_seek),
diff --git a/src/system/libroot/posix/glibc/libio/swprintf.c b/src/system/libroot/posix/glibc/libio/swprintf.c
index 298c1e7537..90f3c49f9f 100644
--- a/src/system/libroot/posix/glibc/libio/swprintf.c
+++ b/src/system/libroot/posix/glibc/libio/swprintf.c
@@ -1,5 +1,4 @@
-/* Copyright (C) 1991,1995,1997,1998,1999,2000,2003
-	Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -13,17 +12,17 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <wchar.h>
 
 /* Write formatted output into S, according to the format string FORMAT.  */
 /* VARARGS3 */
 int
-swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
+__swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
 {
   va_list arg;
   int done;
@@ -34,3 +33,4 @@ swprintf (wchar_t *s, size_t n, const wchar_t *format, ...)
 
   return done;
 }
+weak_alias (__swprintf, swprintf)
diff --git a/src/system/libroot/posix/glibc/libio/swscanf.c b/src/system/libroot/posix/glibc/libio/swscanf.c
index c837ad14f6..0e7d8a773c 100644
--- a/src/system/libroot/posix/glibc/libio/swscanf.c
+++ b/src/system/libroot/posix/glibc/libio/swscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1995,1996,1998,1999,2003 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,17 +12,17 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <wchar.h>
 
 /* Read formatted input from S, according to the format string FORMAT.  */
 /* VARARGS2 */
 int
-swscanf (const wchar_t *s, const wchar_t *format, ...)
+__swscanf (const wchar_t *s, const wchar_t *format, ...)
 {
   va_list arg;
   int done;
@@ -33,3 +33,4 @@ swscanf (const wchar_t *s, const wchar_t *format, ...)
 
   return done;
 }
+weak_alias (__swscanf, swscanf)
diff --git a/src/system/libroot/posix/glibc/libio/vasprintf.c b/src/system/libroot/posix/glibc/libio/vasprintf.c
index fb7e00675a..7fe98f871d 100644
--- a/src/system/libroot/posix/glibc/libio/vasprintf.c
+++ b/src/system/libroot/posix/glibc/libio/vasprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1995,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1995-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -46,29 +45,31 @@ _IO_vasprintf (result_ptr, format, args)
   int ret;
   _IO_size_t needed;
   _IO_size_t allocated;
+  /* No need to clear the memory here (unlike for open_memstream) since
+     we know we will never seek on the stream.  */
   string = (char *) malloc (init_string_size);
   if (string == NULL)
     return -1;
 #ifdef _IO_MTSAFE_IO
   sf._sbf._f._lock = NULL;
 #endif
-  _IO_no_init ((_IO_FILE *) &sf._sbf, _IO_USER_LOCK, -1, NULL, NULL);
-  _IO_JUMPS ((struct _IO_FILE_plus *) &sf._sbf) = &_IO_str_jumps;
-  INTUSE(_IO_str_init_static) (&sf, string, init_string_size, string);
+  _IO_no_init (&sf._sbf._f, _IO_USER_LOCK, -1, NULL, NULL);
+  _IO_JUMPS (&sf._sbf) = &_IO_str_jumps;
+  _IO_str_init_static_internal (&sf, string, init_string_size, string);
   sf._sbf._f._flags &= ~_IO_USER_BUF;
   sf._s._allocate_buffer = (_IO_alloc_type) malloc;
   sf._s._free_buffer = (_IO_free_type) free;
-  ret = INTUSE(_IO_vfprintf) (&sf._sbf._f, format, args);
+  ret = _IO_vfprintf (&sf._sbf._f, format, args);
   if (ret < 0)
     {
       free (sf._sbf._f._IO_buf_base);
       return ret;
     }
-  /* Only use realloc if the size we need is of the same order of
-     magnitude then the memory we allocated.  */
+  /* Only use realloc if the size we need is of the same (binary)
+     order of magnitude then the memory we allocated.  */
   needed = sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base + 1;
   allocated = sf._sbf._f._IO_write_end - sf._sbf._f._IO_write_base;
-  if ((allocated << 1) <= needed)
+  if ((allocated >> 1) <= needed)
     *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base, needed);
   else
     {
@@ -87,7 +88,4 @@ _IO_vasprintf (result_ptr, format, args)
   (*result_ptr)[needed - 1] = '\0';
   return ret;
 }
-
-#ifdef weak_alias
 weak_alias (_IO_vasprintf, vasprintf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/vscanf.c b/src/system/libroot/posix/glibc/libio/vscanf.c
index 477cbaee84..bf30c95820 100644
--- a/src/system/libroot/posix/glibc/libio/vscanf.c
+++ b/src/system/libroot/posix/glibc/libio/vscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -35,9 +34,6 @@ _IO_vscanf (format, args)
      const char *format;
      _IO_va_list args;
 {
-  return INTUSE(_IO_vfscanf) (_IO_stdin, format, args, NULL);
+  return _IO_vfscanf (_IO_stdin, format, args, NULL);
 }
-
-#ifdef weak_alias
 weak_alias (_IO_vscanf, vscanf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/vsnprintf.c b/src/system/libroot/posix/glibc/libio/vsnprintf.c
index 8a3afc46bd..9b6514660a 100644
--- a/src/system/libroot/posix/glibc/libio/vsnprintf.c
+++ b/src/system/libroot/posix/glibc/libio/vsnprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -28,17 +27,7 @@
 #include "libioP.h"
 #include "strfile.h"
 
-
-typedef struct
-{
-  _IO_strfile f;
-  /* This is used for the characters which do not fit in the buffer
-     provided by the user.  */
-  char overflow_buf[64];
-} _IO_strnfile;
-
-
-static int _IO_strn_overflow __P ((_IO_FILE *fp, int c));
+static int _IO_strn_overflow (_IO_FILE *fp, int c) __THROW;
 
 static int
 _IO_strn_overflow (fp, c)
@@ -59,8 +48,8 @@ _IO_strn_overflow (fp, c)
 	 a size to make this possible.  */
       *fp->_IO_write_ptr = '\0';
 
-      INTUSE(_IO_setb) (fp, snf->overflow_buf,
-			snf->overflow_buf + sizeof (snf->overflow_buf), 0);
+      _IO_setb (fp, snf->overflow_buf,
+		snf->overflow_buf + sizeof (snf->overflow_buf), 0);
 
       fp->_IO_write_base = snf->overflow_buf;
       fp->_IO_read_base = snf->overflow_buf;
@@ -77,21 +66,21 @@ _IO_strn_overflow (fp, c)
 }
 
 
-static struct _IO_jump_t _IO_strn_jumps =
+const struct _IO_jump_t _IO_strn_jumps attribute_hidden =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_str_finish),
   JUMP_INIT(overflow, _IO_strn_overflow),
-  JUMP_INIT(underflow, INTUSE(_IO_str_underflow)),
-  JUMP_INIT(uflow, INTUSE(_IO_default_uflow)),
-  JUMP_INIT(pbackfail, INTUSE(_IO_str_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_default_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_default_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_str_seekoff)),
+  JUMP_INIT(underflow, _IO_str_underflow),
+  JUMP_INIT(uflow, _IO_default_uflow),
+  JUMP_INIT(pbackfail, _IO_str_pbackfail),
+  JUMP_INIT(xsputn, _IO_default_xsputn),
+  JUMP_INIT(xsgetn, _IO_default_xsgetn),
+  JUMP_INIT(seekoff, _IO_str_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_default_setbuf),
   JUMP_INIT(sync, _IO_default_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_default_doallocate)),
+  JUMP_INIT(doallocate, _IO_default_doallocate),
   JUMP_INIT(read, _IO_default_read),
   JUMP_INIT(write, _IO_default_write),
   JUMP_INIT(seek, _IO_default_seek),
@@ -124,17 +113,14 @@ _IO_vsnprintf (string, maxlen, format, args)
     }
 
   _IO_no_init (&sf.f._sbf._f, _IO_USER_LOCK, -1, NULL, NULL);
-  _IO_JUMPS ((struct _IO_FILE_plus *) &sf.f._sbf) = &_IO_strn_jumps;
+  _IO_JUMPS (&sf.f._sbf) = &_IO_strn_jumps;
   string[0] = '\0';
-  INTUSE(_IO_str_init_static) (&sf.f, string, maxlen - 1, string);
-  ret = INTUSE(_IO_vfprintf) ((_IO_FILE *) &sf.f._sbf, format, args);
+  _IO_str_init_static_internal (&sf.f, string, maxlen - 1, string);
+  ret = _IO_vfprintf (&sf.f._sbf._f, format, args);
 
   if (sf.f._sbf._f._IO_buf_base != sf.overflow_buf)
     *sf.f._sbf._f._IO_write_ptr = '\0';
   return ret;
 }
-
-#ifdef weak_alias
 weak_alias (_IO_vsnprintf, __vsnprintf)
 weak_alias (_IO_vsnprintf, vsnprintf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/vswprintf.c b/src/system/libroot/posix/glibc/libio/vswprintf.c
index 3ec44d1463..35ec43790d 100644
--- a/src/system/libroot/posix/glibc/libio/vswprintf.c
+++ b/src/system/libroot/posix/glibc/libio/vswprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1994,1997,1999,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1994-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -29,16 +28,7 @@
 #include "strfile.h"
 
 
-typedef struct
-{
-  _IO_strfile f;
-  /* This is used for the characters which do not fit in the buffer
-     provided by the user.  */
-  wchar_t overflow_buf[64];
-} _IO_strnfile;
-
-
-static wint_t _IO_wstrn_overflow __P ((_IO_FILE *fp, wint_t c));
+static wint_t _IO_wstrn_overflow (_IO_FILE *fp, wint_t c) __THROW;
 
 static wint_t
 _IO_wstrn_overflow (fp, c)
@@ -49,14 +39,14 @@ _IO_wstrn_overflow (fp, c)
      filled.  But since we must return the number of characters which
      would have been written in total we must provide a buffer for
      further use.  We can do this by writing on and on in the overflow
-     buffer in the _IO_strnfile structure.  */
-  _IO_strnfile *snf = (_IO_strnfile *) fp;
+     buffer in the _IO_wstrnfile structure.  */
+  _IO_wstrnfile *snf = (_IO_wstrnfile *) fp;
 
   if (fp->_wide_data->_IO_buf_base != snf->overflow_buf)
     {
-      INTUSE(_IO_wsetb) (fp, snf->overflow_buf,
-			 snf->overflow_buf + (sizeof (snf->overflow_buf)
-					      / sizeof (wchar_t)), 0);
+      _IO_wsetb (fp, snf->overflow_buf,
+		 snf->overflow_buf + (sizeof (snf->overflow_buf)
+				      / sizeof (wchar_t)), 0);
 
       fp->_wide_data->_IO_write_base = snf->overflow_buf;
       fp->_wide_data->_IO_read_base = snf->overflow_buf;
@@ -75,21 +65,21 @@ _IO_wstrn_overflow (fp, c)
 }
 
 
-static struct _IO_jump_t _IO_wstrn_jumps =
+const struct _IO_jump_t _IO_wstrn_jumps attribute_hidden =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_wstr_finish),
   JUMP_INIT(overflow, (_IO_overflow_t) _IO_wstrn_overflow),
   JUMP_INIT(underflow, (_IO_underflow_t) _IO_wstr_underflow),
-  JUMP_INIT(uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
+  JUMP_INIT(uflow, (_IO_underflow_t) _IO_wdefault_uflow),
   JUMP_INIT(pbackfail, (_IO_pbackfail_t) _IO_wstr_pbackfail),
-  JUMP_INIT(xsputn, INTUSE(_IO_wdefault_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_wdefault_xsgetn)),
+  JUMP_INIT(xsputn, _IO_wdefault_xsputn),
+  JUMP_INIT(xsgetn, _IO_wdefault_xsgetn),
   JUMP_INIT(seekoff, _IO_wstr_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_default_setbuf),
   JUMP_INIT(sync, _IO_default_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_wdefault_doallocate)),
+  JUMP_INIT(doallocate, _IO_wdefault_doallocate),
   JUMP_INIT(read, _IO_default_read),
   JUMP_INIT(write, _IO_default_write),
   JUMP_INIT(seek, _IO_default_seek),
@@ -107,7 +97,7 @@ _IO_vswprintf (string, maxlen, format, args)
      const wchar_t *format;
      _IO_va_list args;
 {
-  _IO_strnfile sf;
+  _IO_wstrnfile sf;
   int ret;
   struct _IO_wide_data wd;
 #ifdef _IO_MTSAFE_IO
@@ -127,7 +117,7 @@ _IO_vswprintf (string, maxlen, format, args)
 
   if (sf.f._sbf._f._wide_data->_IO_buf_base == sf.overflow_buf)
     /* ISO C99 requires swprintf/vswprintf to return an error if the
-       output does not fit int he provided buffer.  */
+       output does not fit in the provided buffer.  */
     return -1;
 
   /* Terminate the string.  */
@@ -135,8 +125,5 @@ _IO_vswprintf (string, maxlen, format, args)
 
   return ret;
 }
-
-#ifdef weak_alias
 weak_alias (_IO_vswprintf, __vswprintf)
 weak_alias (_IO_vswprintf, vswprintf)
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/vwprintf.c b/src/system/libroot/posix/glibc/libio/vwprintf.c
index 814fdf32bf..b93f035421 100644
--- a/src/system/libroot/posix/glibc/libio/vwprintf.c
+++ b/src/system/libroot/posix/glibc/libio/vwprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1993,1995,1997,1999,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,10 +12,10 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
@@ -23,9 +23,8 @@
 /* Write formatted output to stdout according to the
    format string FORMAT, using the argument list in ARG.  */
 int
-vwprintf (format, arg)
-     const wchar_t *format;
-     __gnuc_va_list arg;
+__vwprintf (const wchar_t *format, __gnuc_va_list arg)
 {
   return __vfwprintf (stdout, format, arg);
 }
+weak_alias (__vwprintf, vwprintf)
diff --git a/src/system/libroot/posix/glibc/libio/vwscanf.c b/src/system/libroot/posix/glibc/libio/vwscanf.c
index cd7af9ce5b..2c10572b02 100644
--- a/src/system/libroot/posix/glibc/libio/vwscanf.c
+++ b/src/system/libroot/posix/glibc/libio/vwscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -29,9 +28,8 @@
 #include <wchar.h>
 
 int
-vwscanf (format, args)
-     const wchar_t *format;
-     _IO_va_list args;
+__vwscanf (const wchar_t *format, _IO_va_list args)
 {
   return _IO_vfwscanf (_IO_stdin, format, args, NULL);
 }
+weak_alias (__vwscanf, vwscanf)
diff --git a/src/system/libroot/posix/glibc/libio/wfiledoalloc.c b/src/system/libroot/posix/glibc/libio/wfiledoalloc.c
index 2f8140b0ac..f8e554e9f0 100644
--- a/src/system/libroot/posix/glibc/libio/wfiledoalloc.c
+++ b/src/system/libroot/posix/glibc/libio/wfiledoalloc.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993, 1997, 1999, 2000, 2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -28,7 +27,7 @@
 /*
    Copyright (C) 1990 The Regents of the University of California.
    All rights reserved.
- 
+
    Redistribution and use in source and binary forms, with or without
    modification, are permitted provided that the following conditions
    are met:
@@ -41,7 +40,7 @@
    4. Neither the name of the University nor the names of its contributors
       may be used to endorse or promote products derived from this software
       without specific prior written permission.
-   
+
    THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
    ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
    IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -62,10 +61,8 @@
 #include "libioP.h"
 #include <sys/types.h>
 #include <sys/stat.h>
-#ifdef __STDC__
 #include <stdlib.h>
 #include <unistd.h>
-#endif
 
 #ifdef _LIBC
 # undef isatty
@@ -85,35 +82,20 @@ _IO_wfile_doallocate (fp)
      _IO_FILE *fp;
 {
   _IO_size_t size;
-  int couldbetty;
   wchar_t *p;
-  struct _G_stat64 st;
 
   /* Allocate room for the external buffer.  */
   if (fp->_IO_buf_base == NULL)
-    INTUSE(_IO_file_doallocate) (fp);
+    _IO_file_doallocate (fp);
 
-  if (fp->_fileno < 0 || _IO_SYSSTAT (fp, &st) < 0)
-    {
-      couldbetty = 0;
-      size = _IO_BUFSIZ;
-#if 0
-      /* do not try to optimise fseek() */
-      fp->_flags |= __SNPT;
-#endif
-    }
-  else
-    {
-      couldbetty = S_ISCHR (st.st_mode);
-#if _IO_HAVE_ST_BLKSIZE
-      size = st.st_blksize <= 0 ? _IO_BUFSIZ : st.st_blksize;
-#else
-      size = _IO_BUFSIZ;
-#endif
-    }
+  /* If narrow buffer is user allocated (set by setvbuf etc.),
+     use that size as the size of the wide buffer, when it is
+     allocated by _IO_file_doallocate, multiply that by size
+     of the wide character.  */
+  size = fp->_IO_buf_end - fp->_IO_buf_base;
+  if ((fp->_flags & _IO_USER_BUF))
+    size = (size + sizeof (wchar_t) - 1) / sizeof (wchar_t);
   ALLOC_WBUF (p, size * sizeof (wchar_t), EOF);
-  INTUSE(_IO_wsetb) (fp, p, p + size, 1);
-  if (couldbetty && isatty (fp->_fileno))
-    fp->_flags |= _IO_LINE_BUF;
+  _IO_wsetb (fp, p, p + size, 1);
   return 1;
 }
diff --git a/src/system/libroot/posix/glibc/libio/wfileops.c b/src/system/libroot/posix/glibc/libio/wfileops.c
index 382220c6f3..4d9653848a 100644
--- a/src/system/libroot/posix/glibc/libio/wfileops.c
+++ b/src/system/libroot/posix/glibc/libio/wfileops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,95,97,98,99,2000,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@cygnus.com>.
    Based on the single byte version by Per Bothner <bothner@cygnus.com>.
@@ -14,9 +14,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -33,7 +32,10 @@
 #include <gconv.h>
 #include <stdlib.h>
 #include <string.h>
+
+#include <stdbool.h>
 #include <sys/stat.h>
+#include <sys/param.h>
 
 
 #ifndef _LIBC
@@ -70,7 +72,7 @@ _IO_wdo_write (fp, data, to_do)
 	{
 	  if (_IO_new_do_write (fp, fp->_IO_write_base,
 				fp->_IO_write_ptr - fp->_IO_write_base) == EOF)
-	    return EOF;
+	    return WEOF;
 	}
 
       do
@@ -114,7 +116,7 @@ _IO_wdo_write (fp, data, to_do)
 
   return to_do == 0 ? 0 : WEOF;
 }
-INTDEF(_IO_wdo_write)
+libc_hidden_def (_IO_wdo_write)
 
 
 wint_t
@@ -124,10 +126,11 @@ _IO_wfile_underflow (fp)
   struct _IO_codecvt *cd;
   enum __codecvt_result status;
   _IO_ssize_t count;
-  int tries;
   const char *read_ptr_copy;
+  char accbuf[MB_LEN_MAX];
+  size_t naccbuf = 0;
 
-  if (__builtin_expect (fp->_flags & _IO_NO_READS, 0))
+  if (__glibc_unlikely (fp->_flags & _IO_NO_READS))
     {
       fp->_flags |= _IO_ERR_SEEN;
       __set_errno (EBADF);
@@ -154,6 +157,7 @@ _IO_wfile_underflow (fp)
 				       fp->_wide_data->_IO_buf_end,
 				       &fp->_wide_data->_IO_read_end);
 
+      fp->_IO_read_base = fp->_IO_read_ptr;
       fp->_IO_read_ptr = (char *) read_stop;
 
       /* If we managed to generate some text return the next character.  */
@@ -186,7 +190,7 @@ _IO_wfile_underflow (fp)
 	  free (fp->_IO_save_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
 
       fp->_IO_read_base = fp->_IO_read_ptr = fp->_IO_read_end =
 	fp->_IO_buf_base;
@@ -203,7 +207,7 @@ _IO_wfile_underflow (fp)
 	  free (fp->_wide_data->_IO_save_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_wdoallocbuf) (fp);
+      _IO_wdoallocbuf (fp);
     }
 
   /* Flush all line buffered files before reading. */
@@ -211,27 +215,24 @@ _IO_wfile_underflow (fp)
   if (fp->_flags & (_IO_LINE_BUF|_IO_UNBUFFERED))
     {
 #if 0
-      INTUSE(_IO_flush_all_linebuffered) ();
+      _IO_flush_all_linebuffered ();
 #else
       /* We used to flush all line-buffered stream.  This really isn't
 	 required by any standard.  My recollection is that
 	 traditional Unix systems did this for stdout.  stderr better
 	 not be line buffered.  So we do just that here
 	 explicitly.  --drepper */
-      _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile,
-				_IO_stdout);
-      _IO_flockfile (_IO_stdout);
+      _IO_acquire_lock (_IO_stdout);
 
       if ((_IO_stdout->_flags & (_IO_LINKED | _IO_NO_WRITES | _IO_LINE_BUF))
 	  == (_IO_LINKED | _IO_LINE_BUF))
 	_IO_OVERFLOW (_IO_stdout, EOF);
 
-      _IO_funlockfile (_IO_stdout);
-      _IO_cleanup_region_end (0);
+      _IO_release_lock (_IO_stdout);
 #endif
     }
 
-  INTUSE(_IO_switch_to_get_mode) (fp);
+  _IO_switch_to_get_mode (fp);
 
   fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr =
     fp->_wide_data->_IO_buf_base;
@@ -239,13 +240,12 @@ _IO_wfile_underflow (fp)
   fp->_wide_data->_IO_write_base = fp->_wide_data->_IO_write_ptr =
     fp->_wide_data->_IO_write_end = fp->_wide_data->_IO_buf_base;
 
-  tries = 0;
  again:
   count = _IO_SYSREAD (fp, fp->_IO_read_end,
 		       fp->_IO_buf_end - fp->_IO_read_end);
   if (count <= 0)
     {
-      if (count == 0 && tries == 0)
+      if (count == 0 && naccbuf == 0)
 	fp->_flags |= _IO_EOF_SEEN;
       else
 	fp->_flags |= _IO_ERR_SEEN, count = 0;
@@ -253,9 +253,9 @@ _IO_wfile_underflow (fp)
   fp->_IO_read_end += count;
   if (count == 0)
     {
-      if (tries != 0)
+      if (naccbuf != 0)
 	/* There are some bytes in the external buffer but they don't
-           convert to anything.  */
+	   convert to anything.  */
 	__set_errno (EILSEQ);
       return WEOF;
     }
@@ -265,18 +265,32 @@ _IO_wfile_underflow (fp)
   /* Now convert the read input.  */
   fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state;
   fp->_IO_read_base = fp->_IO_read_ptr;
+  {
+  const char *from = fp->_IO_read_ptr;
+  const char *to = fp->_IO_read_end;
+  size_t to_copy = count;
+  if (__glibc_unlikely (naccbuf != 0))
+    {
+      to_copy = MIN (sizeof (accbuf) - naccbuf, count);
+      to = __mempcpy (&accbuf[naccbuf], from, to_copy);
+      naccbuf += to_copy;
+      from = accbuf;
+    }
   status = (*cd->__codecvt_do_in) (cd, &fp->_wide_data->_IO_state,
-				   fp->_IO_read_ptr, fp->_IO_read_end,
-				   &read_ptr_copy,
+				   from, to, &read_ptr_copy,
 				   fp->_wide_data->_IO_read_end,
 				   fp->_wide_data->_IO_buf_end,
 				   &fp->_wide_data->_IO_read_end);
 
-  fp->_IO_read_ptr = (char *) read_ptr_copy;
+  if (__glibc_unlikely (naccbuf != 0))
+    fp->_IO_read_ptr += MAX (0, read_ptr_copy - &accbuf[naccbuf - to_copy]);
+  else
+    fp->_IO_read_ptr = (char *) read_ptr_copy;
   if (fp->_wide_data->_IO_read_end == fp->_wide_data->_IO_buf_base)
     {
-      if (status == __codecvt_error || fp->_IO_read_end == fp->_IO_buf_end)
+      if (status == __codecvt_error)
 	{
+	out_eilseq:
 	  __set_errno (EILSEQ);
 	  fp->_flags |= _IO_ERR_SEEN;
 	  return WEOF;
@@ -284,24 +298,56 @@ _IO_wfile_underflow (fp)
 
       /* The read bytes make no complete character.  Try reading again.  */
       assert (status == __codecvt_partial);
-      ++tries;
+
+      if (naccbuf == 0)
+	{
+	  if (fp->_IO_read_base < fp->_IO_read_ptr)
+	    {
+	      /* Partially used the buffer for some input data that
+		 produces no output.  */
+	      size_t avail = fp->_IO_read_end - fp->_IO_read_ptr;
+	      memmove (fp->_IO_read_base, fp->_IO_read_ptr, avail);
+	      fp->_IO_read_ptr = fp->_IO_read_base;
+	      fp->_IO_read_end -= avail;
+	      goto again;
+	    }
+	  naccbuf = fp->_IO_read_end - fp->_IO_read_ptr;
+	  if (naccbuf >= sizeof (accbuf))
+	    goto out_eilseq;
+
+	  memcpy (accbuf, fp->_IO_read_ptr, naccbuf);
+	}
+      else
+	{
+	  size_t used = read_ptr_copy - accbuf;
+	  if (used > 0)
+	    {
+	      memmove (accbuf, read_ptr_copy, naccbuf - used);
+	      naccbuf -= used;
+	    }
+
+	  if (naccbuf == sizeof (accbuf))
+	    goto out_eilseq;
+	}
+
+      fp->_IO_read_ptr = fp->_IO_read_end = fp->_IO_read_base;
+
       goto again;
     }
+  }
 
   return *fp->_wide_data->_IO_read_ptr;
 }
-INTDEF(_IO_wfile_underflow)
+libc_hidden_def (_IO_wfile_underflow)
 
 
-#ifdef HAVE_MMAP
 static wint_t
 _IO_wfile_underflow_mmap (_IO_FILE *fp)
 {
   struct _IO_codecvt *cd;
-  enum __codecvt_result status;
   const char *read_stop;
 
-  if (__builtin_expect (fp->_flags & _IO_NO_READS, 0))
+  if (__glibc_unlikely (fp->_flags & _IO_NO_READS))
     {
       fp->_flags |= _IO_ERR_SEEN;
       __set_errno (EBADF);
@@ -331,18 +377,18 @@ _IO_wfile_underflow_mmap (_IO_FILE *fp)
 	  free (fp->_wide_data->_IO_save_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_wdoallocbuf) (fp);
+      _IO_wdoallocbuf (fp);
     }
 
   fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state;
   fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr =
     fp->_wide_data->_IO_buf_base;
-  status = (*cd->__codecvt_do_in) (cd, &fp->_wide_data->_IO_state,
-				   fp->_IO_read_ptr, fp->_IO_read_end,
-				   &read_stop,
-				   fp->_wide_data->_IO_read_ptr,
-				   fp->_wide_data->_IO_buf_end,
-				   &fp->_wide_data->_IO_read_end);
+  (*cd->__codecvt_do_in) (cd, &fp->_wide_data->_IO_state,
+			  fp->_IO_read_ptr, fp->_IO_read_end,
+			  &read_stop,
+			  fp->_wide_data->_IO_read_ptr,
+			  fp->_wide_data->_IO_buf_end,
+			  &fp->_wide_data->_IO_read_end);
 
   fp->_IO_read_ptr = (char *) read_stop;
 
@@ -367,7 +413,6 @@ _IO_wfile_underflow_maybe_mmap (_IO_FILE *fp)
 
   return _IO_WUNDERFLOW (fp);
 }
-#endif
 
 
 wint_t
@@ -387,13 +432,13 @@ _IO_wfile_overflow (f, wch)
       /* Allocate a buffer if needed. */
       if (f->_wide_data->_IO_write_base == 0)
 	{
-	  INTUSE(_IO_wdoallocbuf) (f);
+	  _IO_wdoallocbuf (f);
 	  _IO_wsetg (f, f->_wide_data->_IO_buf_base,
 		     f->_wide_data->_IO_buf_base, f->_wide_data->_IO_buf_base);
 
 	  if (f->_IO_write_base == NULL)
 	    {
-	      INTUSE(_IO_doallocbuf) (f);
+	      _IO_doallocbuf (f);
 	      _IO_setg (f, f->_IO_buf_base, f->_IO_buf_base, f->_IO_buf_base);
 	    }
 	}
@@ -442,7 +487,7 @@ _IO_wfile_overflow (f, wch)
       return WEOF;
   return wch;
 }
-INTDEF(_IO_wfile_overflow)
+libc_hidden_def (_IO_wfile_overflow)
 
 wint_t
 _IO_wfile_sync (fp)
@@ -472,9 +517,9 @@ _IO_wfile_sync (fp)
       else
 	{
 	  /* We have to find out the hard way how much to back off.
-             To do this we determine how much input we needed to
-             generate the wide characters up to the current reading
-             position.  */
+	     To do this we determine how much input we needed to
+	     generate the wide characters up to the current reading
+	     position.  */
 	  int nread;
 
 	  fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
@@ -504,27 +549,94 @@ _IO_wfile_sync (fp)
   /*    setg(base(), ptr, ptr); */
   return retval;
 }
-INTDEF(_IO_wfile_sync)
+libc_hidden_def (_IO_wfile_sync)
 
-_IO_off64_t
-_IO_wfile_seekoff (fp, offset, dir, mode)
-     _IO_FILE *fp;
-     _IO_off64_t offset;
-     int dir;
-     int mode;
+/* Adjust the internal buffer pointers to reflect the state in the external
+   buffer.  The content between fp->_IO_read_base and fp->_IO_read_ptr is
+   assumed to be converted and available in the range
+   fp->_wide_data->_IO_read_base and fp->_wide_data->_IO_read_end.
+
+   Returns 0 on success and -1 on error with the _IO_ERR_SEEN flag set.  */
+static int
+adjust_wide_data (_IO_FILE *fp, bool do_convert)
 {
-  _IO_off64_t result;
-  _IO_off64_t delta, new_offset;
-  long int count;
-  /* POSIX.1 8.2.3.7 says that after a call the fflush() the file
-     offset of the underlying file must be exact.  */
-  int must_be_exact = ((fp->_wide_data->_IO_read_base
-			== fp->_wide_data->_IO_read_end)
-		       && (fp->_wide_data->_IO_write_base
-			   == fp->_wide_data->_IO_write_ptr));
+  struct _IO_codecvt *cv = fp->_codecvt;
 
-  if (mode == 0)
+  int clen = (*cv->__codecvt_do_encoding) (cv);
+
+  /* Take the easy way out for constant length encodings if we don't need to
+     convert.  */
+  if (!do_convert && clen > 0)
+    {
+      fp->_wide_data->_IO_read_end += ((fp->_IO_read_ptr - fp->_IO_read_base)
+				       / clen);
+      goto done;
+    }
+
+  {
+  enum __codecvt_result status;
+  const char *read_stop = (const char *) fp->_IO_read_base;
+  do
     {
+
+      fp->_wide_data->_IO_last_state = fp->_wide_data->_IO_state;
+      status = (*cv->__codecvt_do_in) (cv, &fp->_wide_data->_IO_state,
+				       fp->_IO_read_base, fp->_IO_read_ptr,
+				       &read_stop,
+				       fp->_wide_data->_IO_read_base,
+				       fp->_wide_data->_IO_buf_end,
+				       &fp->_wide_data->_IO_read_end);
+
+      /* Should we return EILSEQ?  */
+      if (__glibc_unlikely (status == __codecvt_error))
+	{
+	  fp->_flags |= _IO_ERR_SEEN;
+	  return -1;
+	}
+    }
+  while (__builtin_expect (status == __codecvt_partial, 0));
+  }
+
+done:
+  /* Now seek to _IO_read_end to behave as if we have read it all in.  */
+  fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
+
+  return 0;
+}
+
+/* ftell{,o} implementation for wide mode.  Don't modify any state of the file
+   pointer while we try to get the current state of the stream except in one
+   case, which is when we have unflushed writes in append mode.  */
+static _IO_off64_t
+do_ftell_wide (_IO_FILE *fp)
+{
+  _IO_off64_t result, offset = 0;
+
+  /* No point looking for offsets in the buffer if it hasn't even been
+     allocated.  */
+  if (fp->_wide_data->_IO_buf_base != NULL)
+    {
+      const wchar_t *wide_read_base;
+      const wchar_t *wide_read_ptr;
+      const wchar_t *wide_read_end;
+      bool was_writing = ((fp->_wide_data->_IO_write_ptr
+			   > fp->_wide_data->_IO_write_base)
+			  || _IO_in_put_mode (fp));
+
+      bool append_mode = (fp->_flags & _IO_IS_APPENDING) == _IO_IS_APPENDING;
+
+      /* When we have unflushed writes in append mode, seek to the end of the
+	 file and record that offset.  This is the only time we change the file
+	 stream state and it is safe since the file handle is active.  */
+      if (was_writing && append_mode)
+	{
+	  result = _IO_SYSSEEK (fp, 0, _IO_seek_end);
+	  if (result == _IO_pos_BAD)
+	    return EOF;
+	  else
+	    fp->_offset = result;
+	}
+
       /* XXX For wide stream with backup store it is not very
 	 reasonable to determine the offset.  The pushed-back
 	 character might require a state change and we need not be
@@ -539,26 +651,149 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
 	      return -1;
 	    }
 
-	  /* There is no more data in the backup buffer.  We can
-	     switch back.  */
-	  INTUSE(_IO_switch_to_main_wget_area) (fp);
+	  /* Nothing in the backup store, so note the backed up pointers
+	     without changing the state.  */
+	  wide_read_base = fp->_wide_data->_IO_save_base;
+	  wide_read_ptr = wide_read_base;
+	  wide_read_end = fp->_wide_data->_IO_save_end;
 	}
+      else
+	{
+	  wide_read_base = fp->_wide_data->_IO_read_base;
+	  wide_read_ptr = fp->_wide_data->_IO_read_ptr;
+	  wide_read_end = fp->_wide_data->_IO_read_end;
+	}
+
+   {
+      struct _IO_codecvt *cv = fp->_codecvt;
+      int clen = (*cv->__codecvt_do_encoding) (cv);
 
-      dir = _IO_seek_cur, offset = 0; /* Don't move any pointers. */
+      if (!was_writing)
+	{
+	  if (clen > 0)
+	    {
+	      offset -= (wide_read_end - wide_read_ptr) * clen;
+	      offset -= fp->_IO_read_end - fp->_IO_read_ptr;
+	    }
+	  else
+	    {
+	      int nread;
+
+	      size_t delta = wide_read_ptr - wide_read_base;
+	      __mbstate_t state = fp->_wide_data->_IO_last_state;
+	      nread = (*cv->__codecvt_do_length) (cv, &state,
+						  fp->_IO_read_base,
+						  fp->_IO_read_end, delta);
+	      offset -= fp->_IO_read_end - fp->_IO_read_base - nread;
+	    }
+	}
+      else
+	{
+	  if (clen > 0)
+	    offset += (fp->_wide_data->_IO_write_ptr
+		       - fp->_wide_data->_IO_write_base) * clen;
+	  else
+	    {
+	      size_t delta = (fp->_wide_data->_IO_write_ptr
+			      - fp->_wide_data->_IO_write_base);
+
+	      /* Allocate enough space for the conversion.  */
+	      size_t outsize = delta * sizeof (wchar_t);
+	      char *out = malloc (outsize);
+	      char *outstop = out;
+	      const wchar_t *in = fp->_wide_data->_IO_write_base;
+
+	      enum __codecvt_result status;
+
+	      __mbstate_t state = fp->_wide_data->_IO_last_state;
+	      status = (*cv->__codecvt_do_out) (cv, &state,
+						in, in + delta, &in,
+						out, out + outsize, &outstop);
+
+	      /* We don't check for __codecvt_partial because it can be
+		 returned on one of two conditions: either the output
+		 buffer is full or the input sequence is incomplete.  We
+		 take care to allocate enough buffer and our input
+		 sequences must be complete since they are accepted as
+		 wchar_t; if not, then that is an error.  */
+	      if (__glibc_unlikely (status != __codecvt_ok))
+		return WEOF;
+
+	      offset += outstop - out;
+	    }
+
+	  /* We don't trust _IO_read_end to represent the current file offset
+	     when writing in append mode because the value would have to be
+	     shifted to the end of the file during a flush.  Use the write base
+	     instead, along with the new offset we got above when we did a seek
+	     to the end of the file.  */
+	  if (append_mode)
+	    offset += fp->_IO_write_ptr - fp->_IO_write_base;
+	  /* For all other modes, _IO_read_end represents the file offset.  */
+	  else
+	    offset += fp->_IO_write_ptr - fp->_IO_read_end;
+	}
     }
+  }
+
+  if (fp->_offset != _IO_pos_BAD)
+    result = fp->_offset;
+  else
+    result = _IO_SYSSEEK (fp, 0, _IO_seek_cur);
+
+  if (result == EOF)
+    return result;
+
+  result += offset;
+
+  if (result < 0)
+    {
+      __set_errno (EINVAL);
+      return EOF;
+    }
+
+  return result;
+}
+
+_IO_off64_t
+_IO_wfile_seekoff (fp, offset, dir, mode)
+     _IO_FILE *fp;
+     _IO_off64_t offset;
+     int dir;
+     int mode;
+{
+  _IO_off64_t result;
+  _IO_off64_t delta, new_offset;
+  long int count;
+  int must_be_exact;
+  bool was_writing;
+
+  /* Short-circuit into a separate function.  We don't want to mix any
+     functionality and we don't want to touch anything inside the FILE
+     object. */
+  if (mode == 0)
+    return do_ftell_wide (fp);
+
+  /* POSIX.1 8.2.3.7 says that after a call the fflush() the file
+     offset of the underlying file must be exact.  */
+  must_be_exact = ((fp->_wide_data->_IO_read_base
+			== fp->_wide_data->_IO_read_end)
+		       && (fp->_wide_data->_IO_write_base
+			   == fp->_wide_data->_IO_write_ptr));
+
+  was_writing = ((fp->_wide_data->_IO_write_ptr
+		       > fp->_wide_data->_IO_write_base)
+		      || _IO_in_put_mode (fp));
 
   /* Flush unwritten characters.
      (This may do an unneeded write if we seek within the buffer.
      But to be able to switch to reading, we would need to set
-     egptr to ptr.  That can't be done in the current design,
+     egptr to pptr.  That can't be done in the current design,
      which assumes file_ptr() is eGptr.  Anyway, since we probably
      end up flushing when we close(), it doesn't make much difference.)
      FIXME: simulate mem-mapped files. */
-
-  if (fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_write_base
-      || _IO_in_put_mode (fp))
-    if (INTUSE(_IO_switch_to_wget_mode) (fp))
-      return WEOF;
+  if (was_writing && _IO_switch_to_wget_mode (fp))
+    return WEOF;
 
   if (fp->_wide_data->_IO_buf_base == NULL)
     {
@@ -568,7 +803,7 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
 	  free (fp->_wide_data->_IO_read_base);
 	  fp->_flags &= ~_IO_IN_BACKUP;
 	}
-      INTUSE(_IO_doallocbuf) (fp);
+      _IO_doallocbuf (fp);
       _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
       _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
       _IO_wsetp (fp, fp->_wide_data->_IO_buf_base,
@@ -584,30 +819,40 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
 
     case _IO_seek_cur:
       /* Adjust for read-ahead (bytes is buffer).  To do this we must
-         find out which position in the external buffer corresponds to
-         the current position in the internal buffer.  */
+	 find out which position in the external buffer corresponds to
+	 the current position in the internal buffer.  */
       cv = fp->_codecvt;
       clen = (*cv->__codecvt_do_encoding) (cv);
 
-      if (clen > 0)
-	offset -= (fp->_wide_data->_IO_read_end
-		   - fp->_wide_data->_IO_read_ptr) * clen;
-      else
+      if (mode != 0 || !was_writing)
 	{
-	  int nread;
+	  if (clen > 0)
+	    {
+	      offset -= (fp->_wide_data->_IO_read_end
+			 - fp->_wide_data->_IO_read_ptr) * clen;
+	      /* Adjust by readahead in external buffer.  */
+	      offset -= fp->_IO_read_end - fp->_IO_read_ptr;
+	    }
+	  else
+	    {
+	      int nread;
 
-	  delta = fp->_wide_data->_IO_read_ptr - fp->_wide_data->_IO_read_base;
-	  fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
-	  nread = (*cv->__codecvt_do_length) (cv, &fp->_wide_data->_IO_state,
-					      fp->_IO_read_base,
-					      fp->_IO_read_end, delta);
-	  fp->_IO_read_ptr = fp->_IO_read_base + nread;
-	  fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
-	  offset -= fp->_IO_read_end - fp->_IO_read_base - nread;
+	      delta = (fp->_wide_data->_IO_read_ptr
+		       - fp->_wide_data->_IO_read_base);
+	      fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
+	      nread = (*cv->__codecvt_do_length) (cv,
+						  &fp->_wide_data->_IO_state,
+						  fp->_IO_read_base,
+						  fp->_IO_read_end, delta);
+	      fp->_IO_read_ptr = fp->_IO_read_base + nread;
+	      fp->_wide_data->_IO_read_end = fp->_wide_data->_IO_read_ptr;
+	      offset -= fp->_IO_read_end - fp->_IO_read_base - nread;
+	    }
 	}
 
       if (fp->_offset == _IO_pos_BAD)
 	goto dumb;
+
       /* Make offset absolute, assuming current pointer is file_ptr(). */
       offset += fp->_offset;
 
@@ -617,7 +862,7 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
       break;
     case _IO_seek_end:
       {
-	struct _G_stat64 st;
+	struct stat st;
 	if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
 	  {
 	    offset += st.st_size;
@@ -629,96 +874,32 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
     }
   /* At this point, dir==_IO_seek_set. */
 
-  /* If we are only interested in the current position we've found it now.  */
-  if (mode == 0)
-    return offset;
-
   /* If destination is within current buffer, optimize: */
   if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
       && !_IO_in_backup (fp))
     {
-      /* Offset relative to start of main get area. */
-      _IO_off64_t rel_offset = (offset - fp->_offset
-				+ (fp->_IO_read_end - fp->_IO_buf_base));
-      if (rel_offset >= 0)
+      _IO_off64_t start_offset = (fp->_offset
+				  - (fp->_IO_read_end - fp->_IO_buf_base));
+      if (offset >= start_offset && offset < fp->_offset)
 	{
-#if 0
-	  if (_IO_in_backup (fp))
-	    _IO_switch_to_main_get_area (fp);
-#endif
-	  if (rel_offset <= fp->_IO_read_end - fp->_IO_buf_base)
-	    {
-	      enum __codecvt_result status;
-	      struct _IO_codecvt *cd = fp->_codecvt;
-	      const char *read_ptr_copy;
-
-	      fp->_IO_read_ptr = fp->_IO_read_base + rel_offset;
-	      _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
-
-	      /* Now set the pointer for the internal buffer.  This
-                 might be an iterative process.  Though the read
-                 pointer is somewhere in the current external buffer
-                 this does not mean we can convert this whole buffer
-                 at once fitting in the internal buffer.  */
-	      fp->_wide_data->_IO_state = fp->_wide_data->_IO_last_state;
-	      read_ptr_copy = fp->_IO_read_base;
-	      fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
-	      do
-		{
-		  wchar_t buffer[1024];
-		  wchar_t *ignore;
-		  status = (*cd->__codecvt_do_in) (cd,
-						   &fp->_wide_data->_IO_state,
-						   read_ptr_copy,
-						   fp->_IO_read_ptr,
-						   &read_ptr_copy,
-						   buffer,
-						   buffer
-						   + (sizeof (buffer)
-						      / sizeof (buffer[0])),
-						   &ignore);
-		  if (status != __codecvt_ok && status != __codecvt_partial)
-		    {
-		      fp->_flags |= _IO_ERR_SEEN;
-		      goto dumb;
-		    }
-		}
-	      while (read_ptr_copy != fp->_IO_read_ptr);
+	  _IO_setg (fp, fp->_IO_buf_base,
+		    fp->_IO_buf_base + (offset - start_offset),
+		    fp->_IO_read_end);
+	  _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+	  _IO_wsetg (fp, fp->_wide_data->_IO_buf_base,
+		     fp->_wide_data->_IO_buf_base,
+		     fp->_wide_data->_IO_buf_base);
+	  _IO_wsetp (fp, fp->_wide_data->_IO_buf_base,
+		     fp->_wide_data->_IO_buf_base);
+
+	  if (adjust_wide_data (fp, false))
+	    goto dumb;
 
-	      fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
-
-	      _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
-	      goto resync;
-	    }
-#ifdef TODO
-	    /* If we have streammarkers, seek forward by reading ahead. */
-	    if (_IO_have_markers (fp))
-	      {
-		int to_skip = rel_offset
-		  - (fp->_IO_read_ptr - fp->_IO_read_base);
-		if (ignore (to_skip) != to_skip)
-		  goto dumb;
-		_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
-		goto resync;
-	      }
-#endif
-	}
-#ifdef TODO
-      if (rel_offset < 0 && rel_offset >= Bbase () - Bptr ())
-	{
-	  if (!_IO_in_backup (fp))
-	    _IO_switch_to_backup_area (fp);
-	  gbump (fp->_IO_read_end + rel_offset - fp->_IO_read_ptr);
 	  _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
 	  goto resync;
 	}
-#endif
     }
 
-#ifdef TODO
-  INTUSE(_IO_unsave_markers) (fp);
-#endif
-
   if (fp->_flags & _IO_NO_READS)
     goto dumb;
 
@@ -751,12 +932,19 @@ _IO_wfile_seekoff (fp, offset, dir, mode)
   _IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base + delta,
 	    fp->_IO_buf_base + count);
   _IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
+  _IO_wsetg (fp, fp->_wide_data->_IO_buf_base,
+	     fp->_wide_data->_IO_buf_base, fp->_wide_data->_IO_buf_base);
+  _IO_wsetp (fp, fp->_wide_data->_IO_buf_base, fp->_wide_data->_IO_buf_base);
+
+  if (adjust_wide_data (fp, true))
+    goto dumb;
+
   fp->_offset = result + count;
   _IO_mask_flags (fp, 0, _IO_EOF_SEEN);
   return offset;
  dumb:
 
-  INTUSE(_IO_unsave_markers) (fp);
+  _IO_unsave_markers (fp);
   result = _IO_SYSSEEK (fp, offset, dir);
   if (result != EOF)
     {
@@ -775,13 +963,13 @@ resync:
   /* We need to do it since it is possible that the file offset in
      the kernel may be changed behind our back. It may happen when
      we fopen a file and then do a fork. One process may access the
-     the file and the kernel file offset will be changed. */
+     file and the kernel file offset will be changed. */
   if (fp->_offset >= 0)
     _IO_SYSSEEK (fp, fp->_offset, 0);
 
   return offset;
 }
-INTDEF(_IO_wfile_seekoff)
+libc_hidden_def (_IO_wfile_seekoff)
 
 
 _IO_size_t
@@ -790,7 +978,7 @@ _IO_wfile_xsputn (f, data, n)
      const void *data;
      _IO_size_t n;
 {
-  register const wchar_t *s = (const wchar_t *) data;
+  const wchar_t *s = (const wchar_t *) data;
   _IO_size_t to_do = n;
   int must_flush = 0;
   _IO_size_t count;
@@ -808,7 +996,7 @@ _IO_wfile_xsputn (f, data, n)
       count = f->_wide_data->_IO_buf_end - f->_wide_data->_IO_write_ptr;
       if (count >= n)
 	{
-	  register const wchar_t *p;
+	  const wchar_t *p;
 	  for (p = s + n; p > s; )
 	    {
 	      if (*--p == L'\n')
@@ -838,8 +1026,8 @@ _IO_wfile_xsputn (f, data, n)
 	}
       else
 	{
-	  register wchar_t *p = f->_wide_data->_IO_write_ptr;
-	  register int i = (int) count;
+	  wchar_t *p = f->_wide_data->_IO_write_ptr;
+	  int i = (int) count;
 	  while (--i >= 0)
 	    *p++ = *s++;
 	  f->_wide_data->_IO_write_ptr = p;
@@ -847,90 +1035,88 @@ _IO_wfile_xsputn (f, data, n)
       to_do -= count;
     }
   if (to_do > 0)
-    to_do -= INTUSE(_IO_wdefault_xsputn) (f, s, to_do);
+    to_do -= _IO_wdefault_xsputn (f, s, to_do);
   if (must_flush
       && f->_wide_data->_IO_write_ptr != f->_wide_data->_IO_write_base)
-    INTUSE(_IO_wdo_write) (f, f->_wide_data->_IO_write_base,
-			   f->_wide_data->_IO_write_ptr
-			   - f->_wide_data->_IO_write_base);
+    _IO_wdo_write (f, f->_wide_data->_IO_write_base,
+		   f->_wide_data->_IO_write_ptr
+		   - f->_wide_data->_IO_write_base);
 
   return n - to_do;
 }
-INTDEF(_IO_wfile_xsputn)
+libc_hidden_def (_IO_wfile_xsputn)
 
 
-struct _IO_jump_t _IO_wfile_jumps =
+const struct _IO_jump_t _IO_wfile_jumps =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_new_file_finish),
-  JUMP_INIT(overflow, (_IO_overflow_t) INTUSE(_IO_wfile_overflow)),
-  JUMP_INIT(underflow, (_IO_underflow_t) INTUSE(_IO_wfile_underflow)),
-  JUMP_INIT(uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
-  JUMP_INIT(pbackfail, (_IO_pbackfail_t) INTUSE(_IO_wdefault_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_wfile_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_file_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_wfile_seekoff)),
+  JUMP_INIT(overflow, (_IO_overflow_t) _IO_wfile_overflow),
+  JUMP_INIT(underflow, (_IO_underflow_t) _IO_wfile_underflow),
+  JUMP_INIT(uflow, (_IO_underflow_t) _IO_wdefault_uflow),
+  JUMP_INIT(pbackfail, (_IO_pbackfail_t) _IO_wdefault_pbackfail),
+  JUMP_INIT(xsputn, _IO_wfile_xsputn),
+  JUMP_INIT(xsgetn, _IO_file_xsgetn),
+  JUMP_INIT(seekoff, _IO_wfile_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_new_file_setbuf),
-  JUMP_INIT(sync, (_IO_sync_t) INTUSE(_IO_wfile_sync)),
+  JUMP_INIT(sync, (_IO_sync_t) _IO_wfile_sync),
   JUMP_INIT(doallocate, _IO_wfile_doallocate),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
-  JUMP_INIT(close, INTUSE(_IO_file_close)),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(seek, _IO_file_seek),
+  JUMP_INIT(close, _IO_file_close),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
-INTVARDEF(_IO_wfile_jumps)
+libc_hidden_data_def (_IO_wfile_jumps)
 
 
-#ifdef HAVE_MMAP
-struct _IO_jump_t _IO_wfile_jumps_mmap =
+const struct _IO_jump_t _IO_wfile_jumps_mmap =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_new_file_finish),
-  JUMP_INIT(overflow, (_IO_overflow_t) INTUSE(_IO_wfile_overflow)),
+  JUMP_INIT(overflow, (_IO_overflow_t) _IO_wfile_overflow),
   JUMP_INIT(underflow, (_IO_underflow_t) _IO_wfile_underflow_mmap),
-  JUMP_INIT(uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
-  JUMP_INIT(pbackfail, (_IO_pbackfail_t) INTUSE(_IO_wdefault_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_wfile_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_file_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_wfile_seekoff)),
+  JUMP_INIT(uflow, (_IO_underflow_t) _IO_wdefault_uflow),
+  JUMP_INIT(pbackfail, (_IO_pbackfail_t) _IO_wdefault_pbackfail),
+  JUMP_INIT(xsputn, _IO_wfile_xsputn),
+  JUMP_INIT(xsgetn, _IO_file_xsgetn),
+  JUMP_INIT(seekoff, _IO_wfile_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_file_setbuf_mmap),
-  JUMP_INIT(sync, (_IO_sync_t) INTUSE(_IO_wfile_sync)),
+  JUMP_INIT(sync, (_IO_sync_t) _IO_wfile_sync),
   JUMP_INIT(doallocate, _IO_wfile_doallocate),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
+  JUMP_INIT(seek, _IO_file_seek),
   JUMP_INIT(close, _IO_file_close_mmap),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
 
-struct _IO_jump_t _IO_wfile_jumps_maybe_mmap =
+const struct _IO_jump_t _IO_wfile_jumps_maybe_mmap =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_new_file_finish),
-  JUMP_INIT(overflow, (_IO_overflow_t) INTUSE(_IO_wfile_overflow)),
+  JUMP_INIT(overflow, (_IO_overflow_t) _IO_wfile_overflow),
   JUMP_INIT(underflow, (_IO_underflow_t) _IO_wfile_underflow_maybe_mmap),
-  JUMP_INIT(uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
-  JUMP_INIT(pbackfail, (_IO_pbackfail_t) INTUSE(_IO_wdefault_pbackfail)),
-  JUMP_INIT(xsputn, INTUSE(_IO_wfile_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_file_xsgetn)),
-  JUMP_INIT(seekoff, INTUSE(_IO_wfile_seekoff)),
+  JUMP_INIT(uflow, (_IO_underflow_t) _IO_wdefault_uflow),
+  JUMP_INIT(pbackfail, (_IO_pbackfail_t) _IO_wdefault_pbackfail),
+  JUMP_INIT(xsputn, _IO_wfile_xsputn),
+  JUMP_INIT(xsgetn, _IO_file_xsgetn),
+  JUMP_INIT(seekoff, _IO_wfile_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_file_setbuf_mmap),
-  JUMP_INIT(sync, (_IO_sync_t) INTUSE(_IO_wfile_sync)),
+  JUMP_INIT(sync, (_IO_sync_t) _IO_wfile_sync),
   JUMP_INIT(doallocate, _IO_wfile_doallocate),
-  JUMP_INIT(read, INTUSE(_IO_file_read)),
+  JUMP_INIT(read, _IO_file_read),
   JUMP_INIT(write, _IO_new_file_write),
-  JUMP_INIT(seek, INTUSE(_IO_file_seek)),
-  JUMP_INIT(close, INTUSE(_IO_file_close)),
-  JUMP_INIT(stat, INTUSE(_IO_file_stat)),
+  JUMP_INIT(seek, _IO_file_seek),
+  JUMP_INIT(close, _IO_file_close),
+  JUMP_INIT(stat, _IO_file_stat),
   JUMP_INIT(showmanyc, _IO_default_showmanyc),
   JUMP_INIT(imbue, _IO_default_imbue)
 };
-#endif
diff --git a/src/system/libroot/posix/glibc/libio/wgenops.c b/src/system/libroot/posix/glibc/libio/wgenops.c
index 8a3eb96680..a1f86c9d42 100644
--- a/src/system/libroot/posix/glibc/libio/wgenops.c
+++ b/src/system/libroot/posix/glibc/libio/wgenops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1995,1997-2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Written by Ulrich Drepper <drepper@cygnus.com>.
    Based on the single byte version by Per Bothner <bothner@cygnus.com>.
@@ -14,9 +14,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -30,9 +29,7 @@
 /* Generic or default I/O operations. */
 
 #include "libioP.h"
-#ifdef __STDC__
 #include <stdlib.h>
-#endif
 #include <string.h>
 #include <wchar.h>
 
@@ -42,7 +39,7 @@
 #endif
 
 
-static int save_for_wbackup __P ((_IO_FILE *fp, wchar_t *end_p))
+static int save_for_wbackup (_IO_FILE *fp, wchar_t *end_p) __THROW
 #ifdef _LIBC
      internal_function
 #endif
@@ -50,8 +47,6 @@ static int save_for_wbackup __P ((_IO_FILE *fp, wchar_t *end_p))
 
 /* Return minimum _pos markers
    Assumes the current get area is the main get area. */
-_IO_ssize_t _IO_least_wmarker __P ((_IO_FILE *fp, wchar_t *end_p));
-
 _IO_ssize_t
 _IO_least_wmarker (fp, end_p)
      _IO_FILE *fp;
@@ -64,7 +59,7 @@ _IO_least_wmarker (fp, end_p)
       least_so_far = mark->_pos;
   return least_so_far;
 }
-INTDEF(_IO_least_wmarker)
+libc_hidden_def (_IO_least_wmarker)
 
 /* Switch current get area from backup buffer to (start of) main get area. */
 void
@@ -84,7 +79,7 @@ _IO_switch_to_main_wget_area (fp)
   /* Set _IO_read_ptr. */
   fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_base;
 }
-INTDEF(_IO_switch_to_main_wget_area)
+libc_hidden_def (_IO_switch_to_main_wget_area)
 
 
 /* Switch current get area from main get area to (end of) backup area. */
@@ -105,7 +100,7 @@ _IO_switch_to_wbackup_area (fp)
   /* Set _IO_read_ptr.  */
   fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
 }
-INTDEF(_IO_switch_to_wbackup_area)
+libc_hidden_def (_IO_switch_to_wbackup_area)
 
 
 void
@@ -116,7 +111,7 @@ _IO_wsetb (f, b, eb, a)
      int a;
 {
   if (f->_wide_data->_IO_buf_base && !(f->_flags2 & _IO_FLAGS2_USER_WBUF))
-	FREE_BUF (f->_wide_data->_IO_buf_base, _IO_wblen (f));
+    FREE_BUF (f->_wide_data->_IO_buf_base, _IO_wblen (f) * sizeof (wchar_t));
   f->_wide_data->_IO_buf_base = b;
   f->_wide_data->_IO_buf_end = eb;
   if (a)
@@ -124,7 +119,7 @@ _IO_wsetb (f, b, eb, a)
   else
     f->_flags2 |= _IO_FLAGS2_USER_WBUF;
 }
-INTDEF(_IO_wsetb)
+libc_hidden_def (_IO_wsetb)
 
 
 wint_t
@@ -164,7 +159,7 @@ _IO_wdefault_pbackfail (fp, c)
 	      fp->_wide_data->_IO_backup_base = fp->_wide_data->_IO_save_end;
 	    }
 	  fp->_wide_data->_IO_read_base = fp->_wide_data->_IO_read_ptr;
-	  INTUSE(_IO_switch_to_wbackup_area) (fp);
+	  _IO_switch_to_wbackup_area (fp);
 	}
       else if (fp->_wide_data->_IO_read_ptr <= fp->_wide_data->_IO_read_base)
 	{
@@ -189,7 +184,7 @@ _IO_wdefault_pbackfail (fp, c)
     }
   return c;
 }
-INTDEF(_IO_wdefault_pbackfail)
+libc_hidden_def (_IO_wdefault_pbackfail)
 
 
 void
@@ -219,9 +214,9 @@ _IO_wdefault_finish (fp, dummy)
     _IO_lock_fini (*fp->_lock);
 #endif
 
-  INTUSE(_IO_un_link) ((struct _IO_FILE_plus *) fp);
+  _IO_un_link ((struct _IO_FILE_plus *) fp);
 }
-INTDEF(_IO_wdefault_finish)
+libc_hidden_def (_IO_wdefault_finish)
 
 
 wint_t
@@ -234,7 +229,7 @@ _IO_wdefault_uflow (fp)
     return WEOF;
   return *fp->_wide_data->_IO_read_ptr++;
 }
-INTDEF(_IO_wdefault_uflow)
+libc_hidden_def (_IO_wdefault_uflow)
 
 
 wint_t
@@ -259,13 +254,13 @@ __wuflow (fp)
   if (fp->_mode == 0)
     _IO_fwide (fp, 1);
   if (_IO_in_put_mode (fp))
-    if (INTUSE(_IO_switch_to_wget_mode) (fp) == EOF)
+    if (_IO_switch_to_wget_mode (fp) == EOF)
       return WEOF;
   if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
     return *fp->_wide_data->_IO_read_ptr++;
   if (_IO_in_backup (fp))
     {
-      INTUSE(_IO_switch_to_main_wget_area) (fp);
+      _IO_switch_to_main_wget_area (fp);
       if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
 	return *fp->_wide_data->_IO_read_ptr++;
     }
@@ -275,7 +270,7 @@ __wuflow (fp)
 	return WEOF;
     }
   else if (_IO_have_wbackup (fp))
-    INTUSE(_IO_free_wbackup_area) (fp);
+    _IO_free_wbackup_area (fp);
   return _IO_UFLOW (fp);
 }
 libc_hidden_def (__wuflow)
@@ -290,13 +285,13 @@ __wunderflow (fp)
   if (fp->_mode == 0)
     _IO_fwide (fp, 1);
   if (_IO_in_put_mode (fp))
-    if (INTUSE(_IO_switch_to_wget_mode) (fp) == EOF)
+    if (_IO_switch_to_wget_mode (fp) == EOF)
       return WEOF;
   if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
     return *fp->_wide_data->_IO_read_ptr;
   if (_IO_in_backup (fp))
     {
-      INTUSE(_IO_switch_to_main_wget_area) (fp);
+      _IO_switch_to_main_wget_area (fp);
       if (fp->_wide_data->_IO_read_ptr < fp->_wide_data->_IO_read_end)
 	return *fp->_wide_data->_IO_read_ptr;
     }
@@ -306,7 +301,7 @@ __wunderflow (fp)
 	return WEOF;
     }
   else if (_IO_have_backup (fp))
-    INTUSE(_IO_free_wbackup_area) (fp);
+    _IO_free_wbackup_area (fp);
   return _IO_UNDERFLOW (fp);
 }
 libc_hidden_def (__wunderflow)
@@ -360,7 +355,7 @@ _IO_wdefault_xsputn (f, data, n)
     }
   return n - more;
 }
-INTDEF(_IO_wdefault_xsputn)
+libc_hidden_def (_IO_wdefault_xsputn)
 
 
 _IO_size_t
@@ -407,7 +402,7 @@ _IO_wdefault_xsgetn (fp, data, n)
     }
   return n - more;
 }
-INTDEF(_IO_wdefault_xsgetn)
+libc_hidden_def (_IO_wdefault_xsgetn)
 
 
 void
@@ -419,10 +414,10 @@ _IO_wdoallocbuf (fp)
   if (!(fp->_flags & _IO_UNBUFFERED))
     if ((wint_t)_IO_WDOALLOCATE (fp) != WEOF)
       return;
-  INTUSE(_IO_wsetb) (fp, fp->_wide_data->_shortbuf,
+  _IO_wsetb (fp, fp->_wide_data->_shortbuf,
 		     fp->_wide_data->_shortbuf + 1, 0);
 }
-INTDEF(_IO_wdoallocbuf)
+libc_hidden_def (_IO_wdoallocbuf)
 
 
 int
@@ -432,10 +427,10 @@ _IO_wdefault_doallocate (fp)
   wchar_t *buf;
 
   ALLOC_WBUF (buf, _IO_BUFSIZ, EOF);
-  INTUSE(_IO_wsetb) (fp, buf, buf + _IO_BUFSIZ, 1);
+  _IO_wsetb (fp, buf, buf + _IO_BUFSIZ, 1);
   return 1;
 }
-INTDEF(_IO_wdefault_doallocate)
+libc_hidden_def (_IO_wdefault_doallocate)
 
 
 int
@@ -461,20 +456,20 @@ _IO_switch_to_wget_mode (fp)
   fp->_flags &= ~_IO_CURRENTLY_PUTTING;
   return 0;
 }
-INTDEF(_IO_switch_to_wget_mode)
+libc_hidden_def (_IO_switch_to_wget_mode)
 
 void
 _IO_free_wbackup_area (fp)
      _IO_FILE *fp;
 {
   if (_IO_in_backup (fp))
-    INTUSE(_IO_switch_to_main_wget_area) (fp);  /* Just in case. */
+    _IO_switch_to_main_wget_area (fp);  /* Just in case. */
   free (fp->_wide_data->_IO_save_base);
   fp->_wide_data->_IO_save_base = NULL;
   fp->_wide_data->_IO_save_end = NULL;
   fp->_wide_data->_IO_backup_base = NULL;
 }
-INTDEF(_IO_free_wbackup_area)
+libc_hidden_def (_IO_free_wbackup_area)
 
 #if 0
 int
@@ -506,7 +501,7 @@ save_for_wbackup (fp, end_p)
      wchar_t *end_p;
 {
   /* Append [_IO_read_base..end_p] to backup area. */
-  _IO_ssize_t least_mark = INTUSE(_IO_least_wmarker) (fp, end_p);
+  _IO_ssize_t least_mark = _IO_least_wmarker (fp, end_p);
   /* needed_size is how much space we need in the backup area. */
   _IO_size_t needed_size = ((end_p - fp->_wide_data->_IO_read_base)
 			    - least_mark);
@@ -553,8 +548,7 @@ save_for_wbackup (fp, end_p)
 		  needed_size * sizeof (wchar_t));
 #endif
 	}
-      if (fp->_wide_data->_IO_save_base)
-	free (fp->_wide_data->_IO_save_base);
+      free (fp->_wide_data->_IO_save_base);
       fp->_wide_data->_IO_save_base = new_buffer;
       fp->_wide_data->_IO_save_end = new_buffer + avail + needed_size;
     }
@@ -619,7 +613,7 @@ _IO_sputbackwc (fp, c)
 
   return result;
 }
-INTDEF(_IO_sputbackwc)
+libc_hidden_def (_IO_sputbackwc)
 
 wint_t
 _IO_sungetwc (fp)
@@ -662,7 +656,7 @@ _IO_init_wmarker (marker, fp)
 {
   marker->_sbuf = fp;
   if (_IO_in_put_mode (fp))
-    INTUSE(_IO_switch_to_wget_mode) (fp);
+    _IO_switch_to_wget_mode (fp);
   if (_IO_in_backup (fp))
     marker->_pos = fp->_wide_data->_IO_read_ptr - fp->_wide_data->_IO_read_end;
   else
@@ -704,14 +698,14 @@ _IO_seekwmark (fp, mark, delta)
  if (mark->_pos >= 0)
     {
       if (_IO_in_backup (fp))
-	INTUSE(_IO_switch_to_main_wget_area) (fp);
+	_IO_switch_to_main_wget_area (fp);
       fp->_wide_data->_IO_read_ptr = (fp->_wide_data->_IO_read_base
 				      + mark->_pos);
     }
   else
     {
       if (!_IO_in_backup (fp))
-	INTUSE(_IO_switch_to_wbackup_area) (fp);
+	_IO_switch_to_wbackup_area (fp);
       fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end + mark->_pos;
     }
   return 0;
@@ -742,5 +736,5 @@ _IO_unsave_wmarkers (fp)
     }
 
   if (_IO_have_backup (fp))
-    INTUSE(_IO_free_wbackup_area) (fp);
+    _IO_free_wbackup_area (fp);
 }
diff --git a/src/system/libroot/posix/glibc/libio/wprintf.c b/src/system/libroot/posix/glibc/libio/wprintf.c
index f418cf515d..b004ce806d 100644
--- a/src/system/libroot/posix/glibc/libio/wprintf.c
+++ b/src/system/libroot/posix/glibc/libio/wprintf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991,1995,1996,1997,1999,2001 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,10 +12,10 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
@@ -23,7 +23,7 @@
 /* Write formatted output to stdout from the format string FORMAT.  */
 /* VARARGS1 */
 int
-wprintf (const wchar_t *format, ...)
+__wprintf (const wchar_t *format, ...)
 {
   va_list arg;
   int done;
@@ -34,3 +34,4 @@ wprintf (const wchar_t *format, ...)
 
   return done;
 }
+weak_alias (__wprintf, wprintf)
diff --git a/src/system/libroot/posix/glibc/libio/wscanf.c b/src/system/libroot/posix/glibc/libio/wscanf.c
index f4b8cd1b83..499a0eb7df 100644
--- a/src/system/libroot/posix/glibc/libio/wscanf.c
+++ b/src/system/libroot/posix/glibc/libio/wscanf.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991, 1995, 1996, 1997, 1999 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2014 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
@@ -12,10 +12,10 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.  */
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
 
+#include <libioP.h>
 #include <stdarg.h>
 #include <stdio.h>
 #include <wchar.h>
@@ -24,7 +24,7 @@
 /* Read formatted input from stdin according to the format string FORMAT.  */
 /* VARARGS1 */
 int
-wscanf (const wchar_t *format, ...)
+__wscanf (const wchar_t *format, ...)
 {
   va_list arg;
   int done;
@@ -35,3 +35,4 @@ wscanf (const wchar_t *format, ...)
 
   return done;
 }
+weak_alias (__wscanf, wscanf)
diff --git a/src/system/libroot/posix/glibc/libio/wstrops.c b/src/system/libroot/posix/glibc/libio/wstrops.c
index 3c9c4971e8..b78138033b 100644
--- a/src/system/libroot/posix/glibc/libio/wstrops.c
+++ b/src/system/libroot/posix/glibc/libio/wstrops.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1993,1997,1998,1999,2001,2002 Free Software Foundation, Inc.
+/* Copyright (C) 1993-2014 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
@@ -12,9 +12,8 @@
    Lesser General Public License for more details.
 
    You should have received a copy of the GNU Lesser General Public
-   License along with the GNU C Library; if not, write to the Free
-   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
-   02111-1307 USA.
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.
 
    As a special exception, if you link the code in this file with
    files compiled with a GNU compiler to produce an executable,
@@ -25,70 +24,31 @@
    This exception applies to code released by its copyright holders
    in files containing the exception.  */
 
+#include <assert.h>
 #include "strfile.h"
 #include "libioP.h"
 #include <string.h>
 #include <wchar.h>
 #include <stdio_ext.h>
 
-#if 0
-/* The following definitions are for exposition only.
-   They map the terminology used in the ANSI/ISO C++ draft standard
-   to the implementation. */
-
-/* allocated:  set  when a dynamic array object has been allocated, and
-   hence should be freed by the destructor for the strstreambuf object. */
-#define ALLOCATED(FP) ((FP)->_f._IO_buf_base && DYNAMIC(FP))
-
-/* constant:  set when the array object has const elements,
-   so the output sequence cannot be written. */
-#define CONSTANT(FP) ((FP)->_f._IO_file_flags & _IO_NO_WRITES)
-
-/* alsize:  the suggested minimum size for a dynamic array object. */
-#define ALSIZE(FP) ??? /* not stored */
-
-/* palloc: points to the function to call to allocate a dynamic array object.*/
-#define PALLOC(FP) \
-  ((FP)->_s._allocate_buffer == default_alloc ? 0 : (FP)->_s._allocate_buffer)
-
-/* pfree: points  to  the  function  to call to free a dynamic array object. */
-#define PFREE(FP) \
-  ((FP)->_s._free_buffer == default_free ? 0 : (FP)->_s._free_buffer)
-
-#endif
-
-#ifdef TODO
-/* An "unbounded buffer" is when a buffer is supplied, but with no
-   specified length.  An example is the buffer argument to sprintf.
-   */
-#endif
-
 void
 _IO_wstr_init_static (fp, ptr, size, pstart)
      _IO_FILE *fp;
      wchar_t *ptr;
-     int size;
+     _IO_size_t size;
      wchar_t *pstart;
 {
+  wchar_t *end;
+
   if (size == 0)
-    size = __wcslen (ptr);
-  else if (size < 0)
-    {
-      /* If size is negative 'the characters are assumed to
-	 continue indefinitely.'  This is kind of messy ... */
-      int s;
-      size = 512;
-      /* Try increasing powers of 2, as long as we don't wrap around. */
-      for (; s = 2*size, s > 0 && ptr + s > ptr && s < 0x4000000L; )
-	size = s;
-      /* Try increasing size as much as we can without wrapping around. */
-      for (s = size >> 1; s > 0; s >>= 1)
-	{
-	  if (ptr + size + s > ptr)
-	    size += s;
-	}
-    }
-  INTUSE(_IO_wsetb) (fp, ptr, ptr + size, 0);
+    end = ptr + __wcslen (ptr);
+  else if ((_IO_size_t) ptr + size * sizeof (wchar_t) > (_IO_size_t) ptr)
+    end = ptr + size;
+  else
+    /* Even for misaligned ptr make sure there is integral number of wide
+       characters.  */
+    end = ptr + (-1 - (_IO_size_t) ptr) / sizeof (wchar_t);
+  _IO_wsetb (fp, ptr, end, 0);
 
   fp->_wide_data->_IO_write_base = ptr;
   fp->_wide_data->_IO_read_base = ptr;
@@ -96,27 +56,17 @@ _IO_wstr_init_static (fp, ptr, size, pstart)
   if (pstart)
     {
       fp->_wide_data->_IO_write_ptr = pstart;
-      fp->_wide_data->_IO_write_end = ptr + size;
+      fp->_wide_data->_IO_write_end = end;
       fp->_wide_data->_IO_read_end = pstart;
     }
   else
     {
       fp->_wide_data->_IO_write_ptr = ptr;
       fp->_wide_data->_IO_write_end = ptr;
-      fp->_wide_data->_IO_read_end = ptr + size;
+      fp->_wide_data->_IO_read_end = end;
     }
   /* A null _allocate_buffer function flags the strfile as being static. */
-  (((_IO_strfile *) fp)->_s._allocate_buffer) =  (_IO_alloc_type)0;
-}
-
-void
-_IO_wstr_init_readonly (fp, ptr, size)
-     _IO_FILE *fp;
-     const char *ptr;
-     int size;
-{
-  _IO_wstr_init_static (fp, (wchar_t *) ptr, size, NULL);
-  fp->_IO_file_flags |= _IO_NO_WRITES;
+  (((_IO_strfile *) fp)->_s._allocate_buffer) = (_IO_alloc_type)0;
 }
 
 _IO_wint_t
@@ -134,16 +84,19 @@ _IO_wstr_overflow (fp, c)
       fp->_wide_data->_IO_write_ptr = fp->_wide_data->_IO_read_ptr;
       fp->_wide_data->_IO_read_ptr = fp->_wide_data->_IO_read_end;
     }
-  pos =  fp->_wide_data->_IO_write_ptr - fp->_wide_data->_IO_write_base;
+  pos = fp->_wide_data->_IO_write_ptr - fp->_wide_data->_IO_write_base;
   if (pos >= (_IO_size_t) (_IO_wblen (fp) + flush_only))
     {
-      if (fp->_flags & _IO_USER_BUF) /* not allowed to enlarge */
+      if (fp->_flags2 & _IO_FLAGS2_USER_WBUF) /* not allowed to enlarge */
 	return WEOF;
       else
 	{
 	  wchar_t *new_buf;
 	  wchar_t *old_buf = fp->_wide_data->_IO_buf_base;
-	  _IO_size_t new_size = 2 * _IO_wblen (fp) + 100;
+	  size_t old_wblen = _IO_wblen (fp);
+	  _IO_size_t new_size = 2 * old_wblen + 100;
+	  if (new_size < old_wblen)
+	    return EOF;
 	  new_buf
 	    = (wchar_t *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (new_size
 									* sizeof (wchar_t));
@@ -154,12 +107,15 @@ _IO_wstr_overflow (fp, c)
 	    }
 	  if (old_buf)
 	    {
-	      __wmemcpy (new_buf, old_buf, _IO_wblen (fp));
+	      __wmemcpy (new_buf, old_buf, old_wblen);
 	      (*((_IO_strfile *) fp)->_s._free_buffer) (old_buf);
 	      /* Make sure _IO_setb won't try to delete _IO_buf_base. */
 	      fp->_wide_data->_IO_buf_base = NULL;
 	    }
-	  INTUSE(_IO_wsetb) (fp, new_buf, new_buf + new_size, 1);
+
+	  wmemset (new_buf + old_wblen, L'\0', new_size - old_wblen);
+
+	  _IO_wsetb (fp, new_buf, new_buf + new_size, 1);
 	  fp->_wide_data->_IO_read_base =
 	    new_buf + (fp->_wide_data->_IO_read_base - old_buf);
 	  fp->_wide_data->_IO_read_ptr =
@@ -181,6 +137,7 @@ _IO_wstr_overflow (fp, c)
   return c;
 }
 
+
 _IO_wint_t
 _IO_wstr_underflow (fp)
      _IO_FILE *fp;
@@ -199,17 +156,92 @@ _IO_wstr_underflow (fp)
     return WEOF;
 }
 
-/* The size of the valid part of the buffer.  */
 
+/* The size of the valid part of the buffer.  */
 _IO_ssize_t
 _IO_wstr_count (fp)
      _IO_FILE *fp;
 {
-  return ((fp->_wide_data->_IO_write_ptr > fp->_wide_data->_IO_read_end
-	   ? fp->_wide_data->_IO_write_ptr : fp->_wide_data->_IO_read_end)
-	  - fp->_wide_data->_IO_read_base);
+  struct _IO_wide_data *wd = fp->_wide_data;
+
+  return ((wd->_IO_write_ptr > wd->_IO_read_end
+	   ? wd->_IO_write_ptr : wd->_IO_read_end)
+	  - wd->_IO_read_base);
 }
 
+
+static int
+enlarge_userbuf (_IO_FILE *fp, _IO_off64_t offset, int reading)
+{
+  struct _IO_wide_data *wd;
+  _IO_ssize_t oldend;
+  _IO_size_t newsize;
+  wchar_t *oldbuf, *newbuf;
+
+  if ((_IO_ssize_t) offset <= _IO_blen (fp))
+    return 0;
+
+  wd = fp->_wide_data;
+
+  oldend = wd->_IO_write_end - wd->_IO_write_base;
+
+  /* Try to enlarge the buffer.  */
+  if (fp->_flags2 & _IO_FLAGS2_USER_WBUF)
+    /* User-provided buffer.  */
+    return 1;
+
+  newsize = offset + 100;
+  oldbuf = wd->_IO_buf_base;
+  newbuf
+    = (wchar_t *) (*((_IO_strfile *) fp)->_s._allocate_buffer) (newsize
+								* sizeof (wchar_t));
+  if (newbuf == NULL)
+    return 1;
+
+  if (oldbuf != NULL)
+    {
+      __wmemcpy (newbuf, oldbuf, _IO_wblen (fp));
+      (*((_IO_strfile *) fp)->_s._free_buffer) (oldbuf);
+      /* Make sure _IO_setb won't try to delete
+	 _IO_buf_base. */
+      wd->_IO_buf_base = NULL;
+    }
+
+  _IO_wsetb (fp, newbuf, newbuf + newsize, 1);
+
+  if (reading)
+    {
+      wd->_IO_write_base = newbuf + (wd->_IO_write_base - oldbuf);
+      wd->_IO_write_ptr = newbuf + (wd->_IO_write_ptr - oldbuf);
+      wd->_IO_write_end = newbuf + (wd->_IO_write_end - oldbuf);
+      wd->_IO_read_ptr = newbuf + (wd->_IO_read_ptr - oldbuf);
+
+      wd->_IO_read_base = newbuf;
+      wd->_IO_read_end = wd->_IO_buf_end;
+    }
+  else
+    {
+      wd->_IO_read_base = newbuf + (wd->_IO_read_base - oldbuf);
+      wd->_IO_read_ptr = newbuf + (wd->_IO_read_ptr - oldbuf);
+      wd->_IO_read_end = newbuf + (wd->_IO_read_end - oldbuf);
+      wd->_IO_write_ptr = newbuf + (wd->_IO_write_ptr - oldbuf);
+
+      wd->_IO_write_base = newbuf;
+      wd->_IO_write_end = wd->_IO_buf_end;
+    }
+
+  /* Clear the area between the last write position and th
+     new position.  */
+  assert (offset >= oldend);
+  if (reading)
+    wmemset (wd->_IO_read_base + oldend, L'\0', offset - oldend);
+  else
+    wmemset (wd->_IO_write_base + oldend, L'\0', offset - oldend);
+
+  return 0;
+}
+
+
 _IO_off64_t
 _IO_wstr_seekoff (fp, offset, dir, mode)
      _IO_FILE *fp;
@@ -252,7 +284,10 @@ _IO_wstr_seekoff (fp, offset, dir, mode)
 	    default: /* case _IO_seek_set: */
 	      break;
 	    }
-	  if (offset < 0 || (_IO_ssize_t) offset > cur_size)
+	  if (offset < 0)
+	    return EOF;
+	  if ((_IO_ssize_t) offset > cur_size
+	      && enlarge_userbuf (fp, offset, 1) != 0)
 	    return EOF;
 	  fp->_wide_data->_IO_read_ptr = (fp->_wide_data->_IO_read_base
 					  + offset);
@@ -276,7 +311,10 @@ _IO_wstr_seekoff (fp, offset, dir, mode)
 	    default: /* case _IO_seek_set: */
 	      break;
 	    }
-	  if (offset < 0 || (_IO_ssize_t) offset > cur_size)
+	  if (offset < 0)
+	    return EOF;
+	  if ((_IO_ssize_t) offset > cur_size
+	      && enlarge_userbuf (fp, offset, 0) != 0)
 	    return EOF;
 	  fp->_wide_data->_IO_write_ptr = (fp->_wide_data->_IO_write_base
 					   + offset);
@@ -293,7 +331,7 @@ _IO_wstr_pbackfail (fp, c)
 {
   if ((fp->_flags & _IO_NO_WRITES) && c != WEOF)
     return WEOF;
-  return INTUSE(_IO_wdefault_pbackfail) (fp, c);
+  return _IO_wdefault_pbackfail (fp, c);
 }
 
 void
@@ -301,28 +339,28 @@ _IO_wstr_finish (fp, dummy)
      _IO_FILE *fp;
      int dummy;
 {
-  if (fp->_wide_data->_IO_buf_base && !(fp->_flags & _IO_USER_BUF))
+  if (fp->_wide_data->_IO_buf_base && !(fp->_flags2 & _IO_FLAGS2_USER_WBUF))
     (((_IO_strfile *) fp)->_s._free_buffer) (fp->_wide_data->_IO_buf_base);
   fp->_wide_data->_IO_buf_base = NULL;
 
-  INTUSE(_IO_wdefault_finish) (fp, 0);
+  _IO_wdefault_finish (fp, 0);
 }
 
-struct _IO_jump_t _IO_wstr_jumps =
+const struct _IO_jump_t _IO_wstr_jumps =
 {
   JUMP_INIT_DUMMY,
   JUMP_INIT(finish, _IO_wstr_finish),
   JUMP_INIT(overflow, (_IO_overflow_t) _IO_wstr_overflow),
   JUMP_INIT(underflow, (_IO_underflow_t) _IO_wstr_underflow),
-  JUMP_INIT(uflow, (_IO_underflow_t) INTUSE(_IO_wdefault_uflow)),
+  JUMP_INIT(uflow, (_IO_underflow_t) _IO_wdefault_uflow),
   JUMP_INIT(pbackfail, (_IO_pbackfail_t) _IO_wstr_pbackfail),
-  JUMP_INIT(xsputn, INTUSE(_IO_wdefault_xsputn)),
-  JUMP_INIT(xsgetn, INTUSE(_IO_wdefault_xsgetn)),
+  JUMP_INIT(xsputn, _IO_wdefault_xsputn),
+  JUMP_INIT(xsgetn, _IO_wdefault_xsgetn),
   JUMP_INIT(seekoff, _IO_wstr_seekoff),
   JUMP_INIT(seekpos, _IO_default_seekpos),
   JUMP_INIT(setbuf, _IO_default_setbuf),
   JUMP_INIT(sync, _IO_default_sync),
-  JUMP_INIT(doallocate, INTUSE(_IO_wdefault_doallocate)),
+  JUMP_INIT(doallocate, _IO_wdefault_doallocate),
   JUMP_INIT(read, _IO_default_read),
   JUMP_INIT(write, _IO_default_write),
   JUMP_INIT(seek, _IO_default_seek),
diff --git a/src/system/libroot/posix/glibc/wcsmbs/wchar.h b/src/system/libroot/posix/glibc/wcsmbs/wchar.h
index 3541b46fbf..b4d8f2883f 100644
--- a/src/system/libroot/posix/glibc/wcsmbs/wchar.h
+++ b/src/system/libroot/posix/glibc/wcsmbs/wchar.h
@@ -287,7 +287,7 @@ extern unsigned long long int __wcstoull_internal (__const wchar_t *
 #endif
 
 
-#if defined __OPTIMIZE__ && __GNUC__ >= 2
+#if defined(__USE_EXTERN_INLINES) && !defined(__HAIKU__)
 /* Define inline functions which call the internal entry points.  */
 
 __extern_inline double wcstod (__const wchar_t *__restrict __nptr,
-- 
2.39.5

