about summary refs log tree commit diff
path: root/libio
diff options
context:
space:
mode:
Diffstat (limited to 'libio')
-rw-r--r--libio/Makefile4
-rw-r--r--libio/filedoalloc.c2
-rw-r--r--libio/fileops.c51
-rw-r--r--libio/freopen64.c49
-rw-r--r--libio/fseeko64.c48
-rw-r--r--libio/ftello64.c55
-rw-r--r--libio/genops.c35
-rw-r--r--libio/iofgetpos.c2
-rw-r--r--libio/iofgetpos64.c61
-rw-r--r--libio/iofopen.c2
-rw-r--r--libio/iofopen64.c69
-rw-r--r--libio/iofopncook.c14
-rw-r--r--libio/iofsetpos64.c61
-rw-r--r--libio/iolibio.h7
-rw-r--r--libio/iopopen.c4
-rw-r--r--libio/ioseekoff.c6
-rw-r--r--libio/ioseekpos.c6
-rw-r--r--libio/libio.h10
-rw-r--r--libio/libioP.h67
-rw-r--r--libio/memstream.c4
-rw-r--r--libio/obprintf.c4
-rw-r--r--libio/stdio.h133
-rw-r--r--libio/strops.c10
-rw-r--r--libio/vsnprintf.c4
24 files changed, 607 insertions, 101 deletions
diff --git a/libio/Makefile b/libio/Makefile
index aea60f5226..4df874d722 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -25,14 +25,16 @@ headers	:= stdio.h libio.h _G_config.h
 
 routines	:=							      \
 	filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen      \
-	iofopncook iofprintf iofputs iofread iofsetpos ioftell		      \
+	iofopncook iofputs iofread iofsetpos ioftell			      \
 	iofwrite iogetdelim iogetline iogets iopadn iopopen ioputs	      \
 	ioseekoff ioseekpos iosetbuffer iosetvbuf iosprintf ioungetc	      \
 	iovsprintf iovsscanf						      \
+	iofgetpos64 iofopen64 iofsetpos64				      \
 									      \
 	clearerr feof ferror fgetc fileno fputc freopen fseek getc getchar    \
 	memstream pclose putc putchar rewind setbuf setlinebuf vasprintf      \
 	iovdprintf vscanf vsnprintf obprintf fcloseall fseeko ftello	      \
+	freopen64 fseeko64 ftello64					      \
 									      \
 	libc_fatal
 
diff --git a/libio/filedoalloc.c b/libio/filedoalloc.c
index f1b781e8a0..6abab602d1 100644
--- a/libio/filedoalloc.c
+++ b/libio/filedoalloc.c
@@ -73,7 +73,7 @@ _IO_file_doallocate (fp)
   _IO_size_t size;
   int couldbetty;
   char *p;
-  struct stat st;
+  struct _G_stat64 st;
 
 #ifndef _LIBC
   /* If _IO_cleanup_registration_needed is non-zero, we should call the
diff --git a/libio/fileops.c b/libio/fileops.c
index 22feb74fdd..ccfce3c776 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -161,10 +161,11 @@ _IO_file_finish (fp, dummy)
 }
 
 _IO_FILE *
-_IO_file_fopen (fp, filename, mode)
+_IO_file_fopen (fp, filename, mode, is32not64)
      _IO_FILE *fp;
      const char *filename;
      const char *mode;
+     int is32not64;
 {
   int oflags = 0, omode;
   int read_write, fdesc;
@@ -196,13 +197,19 @@ _IO_file_fopen (fp, filename, mode)
       omode = O_RDWR;
       read_write &= _IO_IS_APPENDING;
     }
+#ifdef _G_OPEN64
+  fdesc = (is32not64
+	   ? open (filename, omode|oflags, oprot)
+	   : _G_OPEN64 (filename, omode|oflags, oprot));
+#else
   fdesc = open (filename, omode|oflags, oprot);
+#endif
   if (fdesc < 0)
     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)
-    if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT)
+    if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_end, _IOS_INPUT|_IOS_OUTPUT)
 	== _IO_pos_BAD && errno != ESPIPE)
       return NULL;
   _IO_link_in (fp);
@@ -222,7 +229,7 @@ _IO_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;
-  if (_IO_SEEKOFF (fp, (_IO_off_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT)
+  if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT)
       == _IO_pos_BAD && errno != ESPIPE)
     return NULL;
   return fp;
@@ -265,7 +272,7 @@ _IO_do_write (fp, data, to_do)
     fp->_offset = _IO_pos_BAD;
   else if (fp->_IO_read_end != fp->_IO_write_base)
     {
-      _IO_pos_t new_pos
+      _IO_fpos64_t new_pos
 	= _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1);
       if (new_pos == _IO_pos_BAD)
 	return EOF;
@@ -406,8 +413,8 @@ _IO_file_sync (fp)
       if (_IO_in_backup (fp))
 	delta -= eGptr () - Gbase ();
 #endif
-      _IO_off_t new_pos = _IO_SYSSEEK (fp, delta, 1);
-      if (new_pos != (_IO_off_t) EOF)
+      _IO_off64_t new_pos = _IO_SYSSEEK (fp, delta, 1);
+      if (new_pos != (_IO_off64_t) EOF)
 	fp->_IO_read_end = fp->_IO_read_ptr;
 #ifdef ESPIPE
       else if (errno == ESPIPE)
@@ -424,15 +431,15 @@ _IO_file_sync (fp)
   return retval;
 }
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_file_seekoff (fp, offset, dir, mode)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
      int mode;
 {
-  _IO_pos_t result;
-  _IO_off_t delta, new_offset;
+  _IO_fpos64_t result;
+  _IO_off64_t delta, new_offset;
   long count;
   /* POSIX.1 8.2.3.7 says that after a call the fflush() the file
      offset of the underlying file must be exact.  */
@@ -477,7 +484,7 @@ _IO_file_seekoff (fp, offset, dir, mode)
       break;
     case _IO_seek_end:
       {
-	struct stat st;
+	struct _G_stat64 st;
 	if (_IO_SYSSTAT (fp, &st) == 0 && S_ISREG (st.st_mode))
 	  {
 	    offset += st.st_size;
@@ -494,8 +501,8 @@ _IO_file_seekoff (fp, offset, dir, mode)
       && !_IO_in_backup (fp))
     {
       /* Offset relative to start of main get area. */
-      _IO_pos_t rel_offset = (offset - fp->_offset
-			      + (fp->_IO_read_end - fp->_IO_read_base));
+      _IO_fpos64_t rel_offset = (offset - fp->_offset
+				 + (fp->_IO_read_end - fp->_IO_read_base));
       if (rel_offset >= 0)
 	{
 #if 0
@@ -592,13 +599,17 @@ _IO_file_read (fp, buf, size)
   return read (fp->_fileno, buf, size);
 }
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_file_seek (fp, offset, dir)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
 {
+#ifdef _G_LSEEK64
+  return _G_LSEEK64 (fp->_fileno, offset, dir);
+#else
   return lseek (fp->_fileno, offset, dir);
+#endif
 }
 
 int
@@ -606,7 +617,11 @@ _IO_file_stat (fp, st)
      _IO_FILE *fp;
      void *st;
 {
-  return fstat (fp->_fileno, (struct stat *) st);
+#ifdef _G_STAT64
+  return _G_FSTAT64 (fp->_fileno, (struct _G_stat64 *) st);
+#else
+  return fstat (fp->_fileno, (struct _G_stat64 *) st);
+#endif
 }
 
 int
@@ -812,5 +827,7 @@ struct _IO_jump_t _IO_file_jumps =
   JUMP_INIT(write, _IO_file_write),
   JUMP_INIT(seek, _IO_file_seek),
   JUMP_INIT(close, _IO_file_close),
-  JUMP_INIT(stat, _IO_file_stat)
+  JUMP_INIT(stat, _IO_file_stat),
+  JUMP_INIT(showmanyc, _IO_default_showmanyc),
+  JUMP_INIT(imbue, _IO_default_imbue)
 };
diff --git a/libio/freopen64.c b/libio/freopen64.c
new file mode 100644
index 0000000000..78e994df46
--- /dev/null
+++ b/libio/freopen64.c
@@ -0,0 +1,49 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include "libioP.h"
+#include "stdio.h"
+
+FILE *
+freopen64 (filename, mode, fp)
+     const char* filename;
+     const char* mode;
+     FILE *fp;
+{
+#ifdef _G_OPEN64
+  FILE *result;
+  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);
+  result = _IO_freopen64 (filename, mode, fp);
+  _IO_cleanup_region_end (1);
+  return result;
+#else
+  __set_errno (ENOSYS);
+  return NULL;
+#endif
+}
diff --git a/libio/fseeko64.c b/libio/fseeko64.c
new file mode 100644
index 0000000000..81c17b398c
--- /dev/null
+++ b/libio/fseeko64.c
@@ -0,0 +1,48 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include <errno.h>
+#include "libioP.h"
+#include "stdio.h"
+
+int
+fseeko64 (fp, offset, whence)
+     _IO_FILE* fp;
+     __off64_t offset;
+     int whence;
+{
+#ifdef _G_LSEEK64
+  int result;
+  CHECK_FILE (fp, -1);
+  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+  _IO_flockfile (fp);
+  result = _IO_fseek (fp, offset, whence);
+  _IO_cleanup_region_end (1);
+  return result;
+#else
+  __set_errno (ENOSYS);
+  return -1;
+#endif
+}
diff --git a/libio/ftello64.c b/libio/ftello64.c
new file mode 100644
index 0000000000..886591dca9
--- /dev/null
+++ b/libio/ftello64.c
@@ -0,0 +1,55 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include <stdio.h>
+#include <libioP.h>
+#include <errno.h>
+
+
+off64_t
+ftello64 (fp)
+     _IO_FILE *fp;
+{
+#ifdef _G_LSEEK64
+  _IO_pos_t pos;
+  CHECK_FILE (fp, -1L);
+  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+  _IO_flockfile (fp);
+  pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
+  _IO_cleanup_region_end (1);
+  if (pos == _IO_pos_BAD)
+    {
+#ifdef EIO
+      if (errno == 0)
+	__set_errno (EIO);
+#endif
+      return -1L;
+    }
+  return _IO_pos_as_off (pos);
+#else
+  __set_errno (ENOSYS);
+  return -1;
+#endif
+}
diff --git a/libio/genops.c b/libio/genops.c
index de9c826b9f..71275da28c 100644
--- a/libio/genops.c
+++ b/libio/genops.c
@@ -180,9 +180,16 @@ __overflow (f, ch)
   return _IO_OVERFLOW (f, ch);
 }
 
-static int save_for_backup __P ((_IO_FILE *fp));
+static int save_for_backup __P ((_IO_FILE *fp))
+#ifdef _LIBC
+     internal_function
+#endif
+     ;
 
      static int
+#ifdef _LIBC
+     internal_function
+#endif
 save_for_backup (fp)
      _IO_FILE *fp;
 {
@@ -467,10 +474,10 @@ _IO_default_setbuf (fp, p, len)
     return fp;
 }
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_default_seekpos (fp, pos, mode)
      _IO_FILE *fp;
-     _IO_pos_t pos;
+     _IO_fpos64_t pos;
      int mode;
 {
   return _IO_SEEKOFF (fp, _IO_pos_as_off (pos), 0, mode);
@@ -551,10 +558,10 @@ _IO_default_finish (fp, dummy)
   _IO_un_link (fp);
 }
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_default_seekoff (fp, offset, dir, mode)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
      int mode;
 {
@@ -882,10 +889,10 @@ _IO_default_pbackfail (fp, c)
   return (unsigned char) *fp->_IO_read_ptr;
 }
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_default_seek (fp, offset, dir)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
 {
   return _IO_pos_BAD;
@@ -917,6 +924,20 @@ _IO_default_write (fp, data, n)
   return 0;
 }
 
+int
+_IO_default_showmanyc (fp)
+     _IO_FILE *fp;
+{
+  return -1;
+}
+
+void
+_IO_default_imbue (fp, locale)
+     _IO_FILE *fp;
+     void *locale;
+{
+}
+
 
 #ifdef TODO
 #if defined(linux)
diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c
index 08a3c20e86..6afc323136 100644
--- a/libio/iofgetpos.c
+++ b/libio/iofgetpos.c
@@ -28,7 +28,7 @@
 
 int
 _IO_fgetpos (fp, posp)
-     _IO_FILE* fp;
+     _IO_FILE *fp;
      _IO_fpos_t *posp;
 {
   _IO_fpos_t pos;
diff --git a/libio/iofgetpos64.c b/libio/iofgetpos64.c
new file mode 100644
index 0000000000..0cb79d6619
--- /dev/null
+++ b/libio/iofgetpos64.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1993, 1995, 1996, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include "libioP.h"
+#include <errno.h>
+
+int
+_IO_fgetpos64 (fp, posp)
+     _IO_FILE *fp;
+     _IO_fpos64_t *posp;
+{
+#ifdef _G_LSEEK64
+  _IO_fpos64_t pos;
+  CHECK_FILE (fp, EOF);
+  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+  _IO_flockfile (fp);
+  pos = _IO_seekoff (fp, 0, _IO_seek_cur, 0);
+  _IO_cleanup_region_end (1);
+  if (pos == _IO_pos_BAD)
+    {
+      /* ANSI explicitly requires setting errno to a positive value on
+	 failure.  */
+#ifdef EIO
+      if (errno == 0)
+	__set_errno (EIO);
+#endif
+      return EOF;
+    }
+  *posp = pos;
+  return 0;
+#else
+  __set_errno (ENOSYS);
+  return EOF;
+#endif
+}
+
+#ifdef weak_alias
+weak_alias (_IO_fgetpos64, fgetpos64)
+#endif
diff --git a/libio/iofopen.c b/libio/iofopen.c
index 1dbeccb81a..5019e9a798 100644
--- a/libio/iofopen.c
+++ b/libio/iofopen.c
@@ -52,7 +52,7 @@ _IO_fopen (filename, mode)
 #if  !_IO_UNIFIED_JUMPTABLES
   new_f->fp.vtable = NULL;
 #endif
-  if (_IO_file_fopen (&new_f->fp.file, filename, mode) != NULL)
+  if (_IO_file_fopen (&new_f->fp.file, filename, mode, 0) != NULL)
         return (_IO_FILE *) &new_f->fp;
   _IO_un_link (&new_f->fp.file);
   free (new_f);
diff --git a/libio/iofopen64.c b/libio/iofopen64.c
new file mode 100644
index 0000000000..cdd508d08a
--- /dev/null
+++ b/libio/iofopen64.c
@@ -0,0 +1,69 @@
+/* Copyright (C) 1993, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include "libioP.h"
+#ifdef __STDC__
+#include <stdlib.h>
+#endif
+
+_IO_FILE *
+_IO_fopen64 (filename, mode)
+     const char *filename;
+     const char *mode;
+{
+#ifdef _G_OPEN64
+  struct locked_FILE
+  {
+    struct _IO_FILE_plus fp;
+#ifdef _IO_MTSAFE_IO
+    _IO_lock_t lock;
+#endif
+  } *new_f = (struct locked_FILE *) malloc (sizeof (struct locked_FILE));
+
+  if (new_f == NULL)
+    return NULL;
+#ifdef _IO_MTSAFE_IO
+  new_f->fp.file._lock = &new_f->lock;
+#endif
+  _IO_init (&new_f->fp.file, 0);
+  _IO_JUMPS (&new_f->fp.file) = &_IO_file_jumps;
+  _IO_file_init (&new_f->fp.file);
+#if  !_IO_UNIFIED_JUMPTABLES
+  new_f->fp.vtable = NULL;
+#endif
+  if (_IO_file_fopen (&new_f->fp.file, filename, mode, 1) != NULL)
+        return (_IO_FILE *) &new_f->fp;
+  _IO_un_link (&new_f->fp.file);
+  free (new_f);
+  return NULL;
+#else
+  __set_errno (ENOSYS);
+  return NULL;
+#endif
+}
+
+#ifdef weak_alias
+weak_alias (_IO_fopen64, fopen64)
+#endif
diff --git a/libio/iofopncook.c b/libio/iofopncook.c
index 9bf29e71ae..4f28ec20a8 100644
--- a/libio/iofopncook.c
+++ b/libio/iofopncook.c
@@ -33,8 +33,8 @@ static _IO_ssize_t _IO_cookie_read __P ((register _IO_FILE* fp, void* buf,
 					 _IO_ssize_t size));
 static _IO_ssize_t _IO_cookie_write __P ((register _IO_FILE* fp,
 					  const void* buf, _IO_ssize_t size));
-static _IO_fpos_t _IO_cookie_seek __P ((_IO_FILE *fp, _IO_off_t offset,
-					int dir));
+static _IO_fpos64_t _IO_cookie_seek __P ((_IO_FILE *fp, _IO_off64_t offset,
+					  int dir));
 static int _IO_cookie_close __P ((_IO_FILE* fp));
 
 
@@ -66,14 +66,14 @@ _IO_cookie_write (fp, buf, size)
   return cfile->io_functions.write (cfile->cookie, buf, size);
 }
 
-static _IO_fpos_t
+static _IO_fpos64_t
 _IO_cookie_seek (fp, offset, dir)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
 {
   struct _IO_cookie_file *cfile = (struct _IO_cookie_file *) fp;
-  _IO_fpos_t pos;
+  _IO_fpos64_t pos;
 
   if (cfile->io_functions.seek == NULL)
     return _IO_pos_BAD;
@@ -118,7 +118,9 @@ static struct _IO_jump_t _IO_cookie_jumps = {
   JUMP_INIT(write, _IO_cookie_write),
   JUMP_INIT(seek, _IO_cookie_seek),
   JUMP_INIT(close, _IO_cookie_close),
-  JUMP_INIT(stat, _IO_default_stat)
+  JUMP_INIT(stat, _IO_default_stat),
+  JUMP_INIT(showmanyc, _IO_default_showmanyc),
+  JUMP_INIT(imbue, _IO_default_imbue),
 };
 
 
diff --git a/libio/iofsetpos64.c b/libio/iofsetpos64.c
new file mode 100644
index 0000000000..534e0cf3ca
--- /dev/null
+++ b/libio/iofsetpos64.c
@@ -0,0 +1,61 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+   This file is part of the GNU IO Library.
+
+   This library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License as
+   published by the Free Software Foundation; either version 2, or (at
+   your option) any later version.
+
+   This library is distributed in the hope that it will be useful, but
+   WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this library; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330, Boston,
+   MA 02111-1307, USA.
+
+   As a special exception, if you link this library with files
+   compiled with a GNU compiler to produce an executable, this does
+   not cause the resulting executable to be covered by the GNU General
+   Public License.  This exception does not however invalidate any
+   other reasons why the executable file might be covered by the GNU
+   General Public License.  */
+
+#include <libioP.h>
+#include <errno.h>
+
+int
+_IO_fsetpos64 (fp, posp)
+     _IO_FILE *fp;
+     const _IO_fpos64_t *posp;
+{
+#ifdef _G_LSEEK64
+  int result;
+  CHECK_FILE (fp, EOF);
+  _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp);
+  _IO_flockfile (fp);
+  if (_IO_seekpos (fp, *posp, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD)
+    {
+      /* ANSI explicitly requires setting errno to a positive value on
+	 failure.  */
+#ifdef EIO
+      if (errno == 0)
+	__set_errno (EIO);
+#endif
+      result = EOF;
+    }
+  else
+    result = 0;
+  _IO_cleanup_region_end (1);
+  return result;
+#else
+  __set_errno (ENOSYS);
+  return EOF;
+#endif
+}
+
+#ifdef weak_alias
+weak_alias (_IO_fsetpos64, fsetpos64)
+#endif
diff --git a/libio/iolibio.h b/libio/iolibio.h
index 92df6a6fd2..bcf8bbd775 100644
--- a/libio/iolibio.h
+++ b/libio/iolibio.h
@@ -11,11 +11,14 @@ extern int _IO_fclose __P((_IO_FILE*));
 extern _IO_FILE *_IO_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_fopen64 __P((const char*, const char*));
 extern int _IO_fprintf __P((_IO_FILE*, const char*, ...));
 extern int _IO_fputs __P((const char*, _IO_FILE*));
 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*,
@@ -46,7 +49,9 @@ extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
 #define _IO_rewind(FILE) (void)_IO_seekoff(FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT)
 #define _IO_vprintf(FORMAT, ARGS) _IO_vfprintf(_IO_stdout, FORMAT, ARGS)
 #define _IO_freopen(FILENAME, MODE, FP) \
-  (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE))
+  (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE, 0))
+#define _IO_freopen64(FILENAME, MODE, FP) \
+  (_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE, 1))
 #define _IO_fileno(FP) ((FP)->_fileno)
 extern _IO_FILE* _IO_popen __P((const char*, const char*));
 #define _IO_pclose _IO_fclose
diff --git a/libio/iopopen.c b/libio/iopopen.c
index 59d4fc3f0e..f0589bf184 100644
--- a/libio/iopopen.c
+++ b/libio/iopopen.c
@@ -247,5 +247,7 @@ struct _IO_jump_t _IO_proc_jumps = {
   JUMP_INIT(write, _IO_file_write),
   JUMP_INIT(seek, _IO_file_seek),
   JUMP_INIT(close, _IO_proc_close),
-  JUMP_INIT(stat, _IO_file_stat)
+  JUMP_INIT(stat, _IO_file_stat),
+  JUMP_INIT(showmanyc, _IO_default_showmanyc),
+  JUMP_INIT(imbue, _IO_default_imbue)
 };
diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c
index b1c4729b3d..13086ee912 100644
--- a/libio/ioseekoff.c
+++ b/libio/ioseekoff.c
@@ -25,14 +25,14 @@
 
 #include <libioP.h>
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_seekoff (fp, offset, dir, mode)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
      int mode;
 {
-  _IO_pos_t retval;
+  _IO_fpos64_t retval;
 
   /* If we have a backup buffer, get rid of it, since the __seekoff
      callback may not know to do the right thing about it.
diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c
index 2ce0c2224e..5b59ed7d99 100644
--- a/libio/ioseekpos.c
+++ b/libio/ioseekpos.c
@@ -25,13 +25,13 @@
 
 #include <libioP.h>
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_seekpos (fp, pos, mode)
      _IO_FILE *fp;
-     _IO_pos_t pos;
+     _IO_fpos64_t pos;
      int mode;
 {
-  _IO_pos_t retval;
+  _IO_fpos64_t retval;
 
   /* If we have a backup buffer, get rid of it, since the __seekoff
      callback may not know to do the right thing about it.
diff --git a/libio/libio.h b/libio/libio.h
index 1dddaf27b7..ad5583f486 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -30,9 +30,11 @@
 #include <_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_HAVE_SYS_WAIT _G_HAVE_SYS_WAIT
@@ -205,7 +207,7 @@ struct _IO_FILE {
 
   int _fileno;
   int _blksize;
-  _IO_off_t _offset;
+  _IO_off_t _unused2;	/* This used to be _offset but it's too small.  */
 
 #define __HAVE_COLUMN /* temporary */
   /* 1+column number of pbase(); 0 is unknown. */
@@ -216,6 +218,8 @@ struct _IO_FILE {
   /*  char* _save_gptr;  char* _save_egptr; */
 
   _IO_lock_t *_lock;
+
+  _IO_off64_t _offset;
 };
 
 #ifndef __cplusplus
@@ -303,8 +307,8 @@ extern int _IO_vfprintf __P ((_IO_FILE *, const char *, _IO_va_list));
 extern _IO_ssize_t _IO_padn __P ((_IO_FILE *, int, _IO_ssize_t));
 extern _IO_size_t _IO_sgetn __P ((_IO_FILE *, void *, _IO_size_t));
 
-extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
-extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
+extern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int));
 
 extern void _IO_free_backup_area __P ((_IO_FILE *));
 
diff --git a/libio/libioP.h b/libio/libioP.h
index 2337071d39..5fe9598c0d 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -134,16 +134,16 @@ typedef _IO_size_t (*_IO_xsgetn_t) __P ((_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_fpos_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off_t OFF,
+typedef _IO_fpos64_t (*_IO_seekoff_t) __P ((_IO_FILE *FP, _IO_off64_t OFF,
 					  int DIR, int MODE));
 #define _IO_SEEKOFF(FP, OFF, DIR, MODE) JUMP3 (__seekoff, FP, OFF, DIR, MODE)
 
 /* The 'seekpos' hook also moves the stream position,
-   but to an absolute position given by a fpos_t (seekpos).
+   but to an absolute position given by a fpos64_t (seekpos).
    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_fpos_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos_t, int));
+typedef _IO_fpos64_t (*_IO_seekpos_t) __P ((_IO_FILE *, _IO_fpos64_t, int));
 #define _IO_SEEKPOS(FP, POS, FLAGS) JUMP2 (__seekpos, FP, POS, FLAGS)
 
 /* The 'setbuf' hook gives a buffer to the file.
@@ -192,7 +192,7 @@ typedef _IO_ssize_t (*_IO_write_t) __P ((_IO_FILE *,const void *,_IO_ssize_t));
    It generalizes the Unix lseek(2) function.
    It matches the streambuf::sys_seek virtual function, which is
    specific to this implementation. */
-typedef _IO_fpos_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off_t, int));
+typedef _IO_fpos64_t (*_IO_seek_t) __P ((_IO_FILE *, _IO_off64_t, int));
 #define _IO_SYSSEEK(FP, OFFSET, MODE) JUMP2 (__seek, FP, OFFSET, MODE)
 
 /* The 'sysclose' hook is used to finalize (close, finish up) an
@@ -209,6 +209,17 @@ typedef int (*_IO_close_t) __P ((_IO_FILE *)); /* finalize */
 typedef int (*_IO_stat_t) __P ((_IO_FILE *, void *));
 #define _IO_SYSSTAT(FP, BUF) JUMP1 (__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) __P ((_IO_FILE *));
+#define _IO_SHOWMANYC(FP) JUMP0 (__showmanyc, FP)
+
+/* The 'imbue' hook is used to get information about the currently
+   installed locales.  */
+typedef void (*_IO_imbue_t) __P ((_IO_FILE *, void *));
+#define _IO_IMBUE(FP, LOCALE) JUMP1 (__imbue, FP, LOCALE)
+
 
 #define _IO_CHAR_TYPE char /* unsigned char ? */
 #define _IO_INT_TYPE int
@@ -237,6 +248,8 @@ struct _IO_jump_t
     JUMP_FIELD(_IO_seek_t, __seek);
     JUMP_FIELD(_IO_close_t, __close);
     JUMP_FIELD(_IO_stat_t, __stat);
+    JUMP_FIELD(_IO_showmanyc_t, __showmanyc);
+    JUMP_FIELD(_IO_imbue_t, __imbue);
 #if 0
     get_column;
     set_column;
@@ -256,8 +269,8 @@ struct _IO_FILE_plus
 
 /* Generic functions */
 
-extern _IO_fpos_t _IO_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
-extern _IO_fpos_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
+extern _IO_fpos64_t _IO_seekpos __P ((_IO_FILE *, _IO_fpos64_t, int));
 
 extern void _IO_switch_to_main_get_area __P ((_IO_FILE *));
 extern void _IO_switch_to_backup_area __P ((_IO_FILE *));
@@ -293,15 +306,19 @@ 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_default_xsgetn __P ((_IO_FILE *, void *, _IO_size_t));
-extern _IO_fpos_t _IO_default_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
-extern _IO_fpos_t _IO_default_seekpos __P ((_IO_FILE *, _IO_fpos_t, int));
+extern _IO_fpos64_t _IO_default_seekoff __P ((_IO_FILE *,
+					      _IO_off64_t, int, int));
+extern _IO_fpos64_t _IO_default_seekpos __P ((_IO_FILE *,
+					      _IO_fpos64_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_fpos_t _IO_default_seek __P ((_IO_FILE *, _IO_off_t, int));
+extern _IO_fpos64_t _IO_default_seek __P ((_IO_FILE *, _IO_off64_t, int));
 extern int _IO_default_sync __P ((_IO_FILE *));
 #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_streambuf_jumps;
@@ -331,7 +348,7 @@ extern void _IO_flush_all_linebuffered __P ((void));
 
 extern int _IO_file_doallocate __P ((_IO_FILE *));
 extern _IO_FILE* _IO_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
-extern _IO_fpos_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_fpos64_t _IO_file_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
 extern _IO_size_t _IO_file_xsputn __P ((_IO_FILE *, const void *, _IO_size_t));
 extern int _IO_file_stat __P ((_IO_FILE *, void *));
 extern int _IO_file_close __P ((_IO_FILE *));
@@ -340,13 +357,14 @@ extern int _IO_file_overflow __P ((_IO_FILE *, int));
 #define _IO_file_is_open(__fp) ((__fp)->_fileno >= 0)
 extern void _IO_file_init __P ((_IO_FILE *));
 extern _IO_FILE* _IO_file_attach __P ((_IO_FILE *, int));
-extern _IO_FILE* _IO_file_fopen __P ((_IO_FILE *, const char *, const char *));
+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_fpos_t _IO_file_seek __P ((_IO_FILE *, _IO_off_t, int));
+extern _IO_fpos64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int));
 extern void _IO_file_finish __P ((_IO_FILE *, int));
 
 /* Jumptable functions for proc_files. */
@@ -357,7 +375,7 @@ extern int _IO_proc_close __P ((_IO_FILE *));
 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_fpos_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off_t, int, int));
+extern _IO_fpos64_t _IO_str_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
 extern void _IO_str_finish __P ((_IO_FILE *, int));
 
 /* Other strfile functions */
@@ -424,6 +442,7 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
 /* When using this code in the GNU libc we must not pollute the name space.  */
 #  define mmap __mmap
 #  define munmap __munmap
+#  define ftruncate __ftruncate
 # endif
 
 # define ROUND_TO_PAGE(_S) \
@@ -459,31 +478,31 @@ extern void (*_IO_cleanup_registration_needed) __P ((void));
 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_off_t _IO_lseek __P ((int, _IO_off_t, int));
+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));
 
-/* Operations on _IO_fpos_t.
+/* Operations on _IO_fpos64_t.
    Normally, these are trivial, but we provide hooks for configurations
-   where an _IO_fpos_t is a struct.
-   Note that _IO_off_t must be an integral type. */
+   where an _IO_fpos64_t is a struct.
+   Note that _IO_off64_t must be an integral type. */
 
-/* _IO_pos_BAD is an _IO_fpos_t value indicating error, unknown, or EOF. */
+/* _IO_pos_BAD is an _IO_fpos64_t value indicating error, unknown, or EOF. */
 #ifndef _IO_pos_BAD
-# define _IO_pos_BAD ((_IO_fpos_t) -1)
+# define _IO_pos_BAD ((_IO_fpos64_t) -1)
 #endif
-/* _IO_pos_as_off converts an _IO_fpos_t value to an _IO_off_t value. */
+/* _IO_pos_as_off converts an _IO_fpos64_t value to an _IO_off64_t value. */
 #ifndef _IO_pos_as_off
-# define _IO_pos_as_off(__pos) ((_IO_off_t) (__pos))
+# define _IO_pos_as_off(__pos) ((_IO_off64_t) (__pos))
 #endif
-/* _IO_pos_adjust adjust an _IO_fpos_t by some number of bytes. */
+/* _IO_pos_adjust adjust an _IO_fpos64_t by some number of bytes. */
 #ifndef _IO_pos_adjust
 # define _IO_pos_adjust(__pos, __delta) ((__pos) += (__delta))
 #endif
-/* _IO_pos_0 is an _IO_fpos_t value indicating beginning of file. */
+/* _IO_pos_0 is an _IO_fpos64_t value indicating beginning of file. */
 #ifndef _IO_pos_0
-# define _IO_pos_0 ((_IO_fpos_t) 0)
+# define _IO_pos_0 ((_IO_fpos64_t) 0)
 #endif
 
 #ifdef __cplusplus
diff --git a/libio/memstream.c b/libio/memstream.c
index 7b9ccd3d37..71aab2f6ea 100644
--- a/libio/memstream.c
+++ b/libio/memstream.c
@@ -53,7 +53,9 @@ static const struct _IO_jump_t _IO_mem_jumps =
   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 (stat, _IO_default_stat),
+  JUMP_INIT(showmanyc, _IO_default_showmanyc),
+  JUMP_INIT(imbue, _IO_default_imbue)
 };
 
 /* Open a stream that writes into a malloc'd buffer that is expanded as
diff --git a/libio/obprintf.c b/libio/obprintf.c
index 6b959e455a..a0c4df6293 100644
--- a/libio/obprintf.c
+++ b/libio/obprintf.c
@@ -109,7 +109,9 @@ static struct _IO_jump_t _IO_obstack_jumps =
   JUMP_INIT(write, NULL),
   JUMP_INIT(seek, NULL),
   JUMP_INIT(close, NULL),
-  JUMP_INIT(stat, NULL)
+  JUMP_INIT(stat, NULL),
+  JUMP_INIT(showmanyc, NULL),
+  JUMP_INIT(imbue, NULL)
 };
 
 
diff --git a/libio/stdio.h b/libio/stdio.h
index bbed294056..a835fed6cc 100644
--- a/libio/stdio.h
+++ b/libio/stdio.h
@@ -23,16 +23,16 @@
 #ifndef _STDIO_H
 
 #if !defined __need_FILE
-#define _STDIO_H	1
-#include <features.h>
+# define _STDIO_H	1
+# include <features.h>
 
 __BEGIN_DECLS
 
-#define __need_size_t
-#define	__need_NULL
-#include <stddef.h>
+# define __need_size_t
+# define __need_NULL
+# include <stddef.h>
 
-#include <bits/types.h>
+# include <bits/types.h>
 #endif /* Don't need FILE.  */
 #undef	__need_FILE
 
@@ -42,7 +42,7 @@ __BEGIN_DECLS
 /* The opaque type of streams.  */
 typedef struct _IO_FILE FILE;
 
-#define	__FILE_defined	1
+# define __FILE_defined	1
 #endif /* FILE not defined.  */
 
 
@@ -58,8 +58,14 @@ typedef struct _IO_FILE FILE;
 #endif
 
 /* The type of the second argument to `fgetpos' and `fsetpos'.  */
+#ifndef __USE_FILE_OFFSET64
 typedef _G_fpos_t fpos_t;
-
+#else
+typedef _G_fpos64_t fpos_t;
+#endif
+#ifdef __USE_LARGEFILE64
+typedef _G_fpos64_t fpos64_t;
+#endif
 
 /* Generate a unique file name (and possibly open it with mode "w+b").  */
 extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
@@ -67,7 +73,8 @@ extern char *__stdio_gen_tempname __P ((char *__buf, size_t __bufsize,
 					__const char *__pfx,
 					int __dir_search,
 					size_t *__lenptr,
-					FILE **__streamptr));
+					FILE **__streamptr,
+					int __large_file));
 
 
 /* Print out MESSAGE on the error output and abort.  */
@@ -83,14 +90,14 @@ extern void __libc_fatal __P ((__const char *__message))
 
 /* Default buffer size.  */
 #ifndef BUFSIZ
-#define BUFSIZ _IO_BUFSIZ
+# define BUFSIZ _IO_BUFSIZ
 #endif
 
 
 /* End of file character.
    Some things throughout the library rely on this being -1.  */
 #ifndef EOF
-#define EOF (-1)
+# define EOF (-1)
 #endif
 
 
@@ -103,7 +110,7 @@ extern void __libc_fatal __P ((__const char *__message))
 
 #ifdef	__USE_SVID
 /* Default path prefix for `tempnam' and `tmpnam'.  */
-#define P_tmpdir      "/tmp"
+# define P_tmpdir	"/tmp"
 #endif
 
 
@@ -134,7 +141,14 @@ extern int rename __P ((__const char *__old, __const char *__new));
 
 
 /* Create a temporary file and open it read/write.  */
+#ifndef __USE_FILE_OFFSET64
 extern FILE *tmpfile __P ((void));
+#else
+extern FILE *tmpfile __P ((void)) __asm__ ("tmpfile64");
+#endif
+#ifdef __USE_LARGEFILE64
+extern FILE *tmpfile64 __P ((void));
+#endif
 /* Generate a temporary filename.  */
 extern char *tmpnam __P ((char *__s));
 
@@ -176,11 +190,30 @@ extern int fcloseall __P ((void));
 
 
 /* Open a file and create a new stream for it.  */
+#ifndef __USE_FILE_OFFSET64
 extern FILE *fopen __P ((__const char *__filename, __const char *__modes));
+#else
+extern FILE *fopen __P ((__const char *__filename, __const char *__modes))
+     __asm__ ("fopen64");
+#endif
+#ifdef __USE_LARGEFILE64
+extern FILE *fopen64 __P ((__const char *__filename, __const char *__modes));
+#endif
 /* Open a file, replacing an existing stream with it. */
+#ifndef __USE_FILE_OFFSET64
 extern FILE *freopen __P ((__const char *__restrict __filename,
 			   __const char *__restrict __modes,
 			   FILE *__restrict __stream));
+#else
+extern FILE *freopen __P ((__const char *__restrict __filename,
+			   __const char *__restrict __modes,
+			   FILE *__restrict __stream)) __asm__ ("freopen64");
+#endif
+#ifdef __USE_LARGEFILE64
+extern FILE *freopen64 __P ((__const char *__restrict __filename,
+			     __const char *__restrict __modes,
+			     FILE *__restrict __stream));
+#endif
 
 #ifdef	__USE_POSIX
 /* Create a new stream that refers to an existing system file descriptor.  */
@@ -242,7 +275,7 @@ extern int vsprintf __P ((char *__restrict __s,
 
 #ifdef	__OPTIMIZE__
 __STDIO_INLINE int
-vprintf (const char *__restrict __fmt, _G_va_list __arg)
+vprintf (__const char *__restrict __fmt, _G_va_list __arg)
 {
   return vfprintf (stdout, __fmt, __arg);
 }
@@ -349,7 +382,7 @@ getchar (void)
 extern int getc_unlocked __P ((FILE *__stream));
 extern int getchar_unlocked __P ((void));
 
-#ifdef __OPTIMIZE__
+# ifdef __OPTIMIZE__
 __STDIO_INLINE int
 getc_unlocked (FILE *__fp)
 {
@@ -361,7 +394,7 @@ getchar_unlocked (void)
 {
   return _IO_getc_unlocked (stdin);
 }
-#endif /* Optimizing.  */
+# endif /* Optimizing.  */
 #endif /* Use POSIX or MISC.  */
 
 
@@ -388,13 +421,13 @@ putchar (int __c)
 /* Faster version when locking is not necessary.  */
 extern int fputc_unlocked __P ((int __c, FILE *__stream));
 
-#ifdef __OPTIMIZE__
+# ifdef __OPTIMIZE__
 __STDIO_INLINE int
 fputc_unlocked (int __c, FILE *__stream)
 {
   return _IO_putc_unlocked (__c, __stream);
 }
-#endif /* Optimizing.  */
+# endif /* Optimizing.  */
 #endif /* Use MISC.  */
 
 #if defined __USE_POSIX || defined __USE_MISC
@@ -402,7 +435,7 @@ fputc_unlocked (int __c, FILE *__stream)
 extern int putc_unlocked __P ((int __c, FILE *__stream));
 extern int putchar_unlocked __P ((int __c));
 
-#ifdef __OPTIMIZE__
+# ifdef __OPTIMIZE__
 __STDIO_INLINE int
 putc_unlocked (int __c, FILE *__stream)
 {
@@ -414,7 +447,7 @@ putchar_unlocked (int __c)
 {
   return _IO_putc_unlocked (__c, stdout);
 }
-#endif /* Optimizing.  */
+# endif /* Optimizing.  */
 #endif /* Use POSIX or MISc.  */
 
 
@@ -451,13 +484,13 @@ _IO_ssize_t getdelim __P ((char **__lineptr, size_t *__n,
 _IO_ssize_t __getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
 _IO_ssize_t getline __P ((char **__lineptr, size_t *__n, FILE *__stream));
 
-#ifdef	__OPTIMIZE__
+# ifdef	__OPTIMIZE__
 __STDIO_INLINE _IO_ssize_t
 getline (char **__lineptr, size_t *__n, FILE *__stream)
 {
   return __getdelim (__lineptr, __n, '\n', __stream);
 }
-#endif /* Optimizing.  */
+# endif /* Optimizing.  */
 #endif
 
 
@@ -496,22 +529,72 @@ extern long int ftell __P ((FILE *__stream));
 /* Rewind to the beginning of STREAM.  */
 extern void rewind __P ((FILE *__stream));
 
-#ifdef __USE_UNIX98
+#if (defined __USE_LARGEFILE || defined __USE_LARGEFILE64 \
+     || defined __USE_FILE_OFFSET64)
 /* The Single Unix Specification, Version 2, specifies an alternative,
    more adequate interface for the two functions above which deal with
-   file offset.  `long int' is not the right type.  */
+   file offset.  `long int' is not the right type.  These definitions
+   are originally defined in the Large File Support API.  */
+
+/* Types needed in these functions.  */
+# ifndef off_t
+#  ifndef __USE_FILE_OFFSET64
+typedef __off_t off_t;
+#  else
+typedef __off64_t off_t;
+#  endif
+#  define off_t off_t
+# endif
+
+# if defined __USE_LARGEFILE64 && !defined off64_t
+typedef __off64_t off64_t;
+#  define off64_t off64_t
+# endif
 
 /* Seek to a certain position on STREAM.  */
+# ifndef __USE_FILE_OFFSET64
 extern int fseeko __P ((FILE *__stream, __off_t __off, int __whence));
+# else
+extern int fseeko __P ((FILE *__stream, __off_t __off, int __whence))
+     __asm__ ("fseeko64");
+# endif
+# ifdef __USE_LARGEFILE64
+extern int fseeko64 __P ((FILE *__stream, __off64_t __off, int __whence));
+# endif
+
 /* Return the current position of STREAM.  */
+# ifndef __USE_FILE_OFFSET64
 extern __off_t ftello __P ((FILE *__stream));
+# else
+extern __off_t ftello __P ((FILE *__stream)) __asm__ ("ftello");
+# endif
+# ifdef __USE_LARGEFILE64
+extern __off64_t ftello64 __P ((FILE *__stream));
+# endif
 #endif
 
 /* Get STREAM's position.  */
+#ifndef __USE_FILE_OFFSET64
 extern int fgetpos __P ((FILE *__restrict __stream,
 			 fpos_t *__restrict __pos));
+#else
+extern int fgetpos __P ((FILE *__restrict __stream,
+			 fpos_t *__restrict __pos)) __asm__ ("fgetpos64");
+#endif
+#ifdef __USE_LARGEFILE64
+extern int fgetpos64 __P ((FILE *__restrict __stream,
+			   fpos64_t *__restrict __pos));
+#endif
 /* Set STREAM's position.  */
+#ifndef __USE_FILE_OFFSET64
 extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos));
+#else
+extern int fsetpos __P ((FILE *__stream, __const fpos_t *__pos))
+     __asm__ ("fsetpos64");
+#endif
+#ifdef __USE_LARGEFILE64
+extern int fsetpos64 __P ((FILE *__stream, __const fpos64_t *__pos));
+#endif
 
 
 /* Clear the error and EOF indicators for STREAM.  */
@@ -527,7 +610,7 @@ extern void clearerr_unlocked __P ((FILE *__stream));
 extern int feof_unlocked __P ((FILE *__stream));
 extern int ferror_unlocked __P ((FILE *__stream));
 
-#ifdef __OPTIMIZE__
+# ifdef __OPTIMIZE__
 __STDIO_INLINE int
 feof_unlocked (FILE *__stream)
 {
@@ -539,7 +622,7 @@ ferror_unlocked (FILE *__stream)
 {
   return _IO_ferror_unlocked (__stream);
 }
-#endif /* Optimizing.  */
+# endif /* Optimizing.  */
 #endif
 
 
diff --git a/libio/strops.c b/libio/strops.c
index a9f812e045..c596315b60 100644
--- a/libio/strops.c
+++ b/libio/strops.c
@@ -205,15 +205,15 @@ _IO_str_count (fp)
 	  - fp->_IO_read_base);
 }
 
-_IO_pos_t
+_IO_fpos64_t
 _IO_str_seekoff (fp, offset, dir, mode)
      _IO_FILE *fp;
-     _IO_off_t offset;
+     _IO_off64_t offset;
      int dir;
      int mode;
 {
   _IO_ssize_t cur_size = _IO_str_count (fp);
-  _IO_pos_t new_pos = EOF;
+  _IO_fpos64_t new_pos = EOF;
 
   /* Move the get pointer, if requested. */
   if (mode & _IOS_INPUT)
@@ -299,5 +299,7 @@ struct _IO_jump_t _IO_str_jumps =
   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(stat, _IO_default_stat),
+  JUMP_INIT(showmanyc, _IO_default_showmanyc),
+  JUMP_INIT(imbue, _IO_default_imbue)
 };
diff --git a/libio/vsnprintf.c b/libio/vsnprintf.c
index 3f35af299a..5ac2317579 100644
--- a/libio/vsnprintf.c
+++ b/libio/vsnprintf.c
@@ -94,7 +94,9 @@ static struct _IO_jump_t _IO_strn_jumps =
   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(stat, _IO_default_stat),
+  JUMP_INIT(showmanyc, _IO_default_showmanyc),
+  JUMP_INIT(imbue, _IO_default_imbue)
 };