aboutsummaryrefslogtreecommitdiff
path: root/libio
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>1997-10-13 01:27:24 +0000
committerUlrich Drepper <drepper@redhat.com>1997-10-13 01:27:24 +0000
commit1ea89a402d892b68b193e2e4390d8eb33ed686e7 (patch)
tree5e14832655316159895c8ee546fd73e4c1a72914 /libio
parentdfd2257ad98eb0f6eab167e5fe5ff68ca87172e3 (diff)
downloadglibc-1ea89a402d892b68b193e2e4390d8eb33ed686e7.tar.xz
glibc-1ea89a402d892b68b193e2e4390d8eb33ed686e7.zip
1997-10-13 03:14 Ulrich Drepper <drepper@cygnus.com> * libc.map: Move _IO_fopen, fopen, _IO_stdin_, _IO_stdout_, _IO_stderr_, _IO_list_all, and freopen to GLIBC_2.1 version. * include/libc-symbol.h: Define define_symbol. * libio/Makefile [$(versioning)=yes] (routines): Add oldiofopen and oldfreopen. [$(versioning)=yes] (aux): Add oldfileops and oldstdfiles. * libio/fileops.c: Use _IO_FILE_complete when accessing _offset field. * libio/freopen.c: Use versioning. * libio/iofopen.c: Likewise. Generate object of type _IO_FILE_complete. * libio/iofopen64.c: Generate object of type _IO_FILE_complete. * libio/iolibio.h: Declare _IO_{old,new}_fopen and __{old,new}_freopen. Define _IO_old_freopen. * libio/libio.h: Remove _offset field from _IO_FILE. Rename _unused2 field to _old_offset. Declare _IO_std*_ streams as of type _IO_FILE_complete. * libio/libioP.h: Define _IO_FILE_complete. Declare callbacks for old fileops implementation. * libio/stdfile.c: Define standard stream of type _IO_FILE_complete. * libio/stdio.c: Correctly address FILE part of standard streams. * libio/oldfileops.c: New file. * libio/oldfreopen.c: New file. * libio/oldiofopen.c: New file. * libio/oldstdfiles.c: New file. * sysdeps/i386/fpu/bits/mathinline.h: Define fma optimization. * sysdeps/libm-i387/e_scalb.S: Make sure code gets into .text section. * sysdeps/libm-i387/e_scalbl.S: Likewise. * sysdeps/libm-i387/s_fma.S: Fix typo. * sysdeps/libm-i387/s_fmaf.S: Likewise. * sysdeps/libm-i387/s_fmal.S: Likewise. 1997-10-12 20:14 Zack Weinberg <zack@rabi.phys.columbia.edu> * sysdeps/stub/getsid.c: Add a stub_warning. * sysdeps/stub/mmap.c: Likewise. * sysdeps/stub/munmap.c: Likewise. * sysdeps/libm-ieee754/s_fma.c: New file. * sysdeps/libm-ieee754/s_fmaf.c: New file. * sysdeps/libm-ieee754/s_fmal.c: New file. * sysdeps/libm-ieee754/s_llrintf.c: New file. * sysdeps/libm-ieee754/s_llrintl.c: New file. * sysdeps/libm-ieee754/s_lrintf.c: New file. * sysdeps/libm-ieee754/s_lrintl.c: New file.
Diffstat (limited to 'libio')
-rw-r--r--libio/Makefile8
-rw-r--r--libio/fileops.c40
-rw-r--r--libio/freopen.c4
-rw-r--r--libio/iofopen.c31
-rw-r--r--libio/iofopen64.c18
-rw-r--r--libio/iolibio.h7
-rw-r--r--libio/libio.h8
-rw-r--r--libio/libioP.h31
-rw-r--r--libio/oldfileops.c720
-rw-r--r--libio/oldfreopen.c46
-rw-r--r--libio/oldiofopen.c65
-rw-r--r--libio/oldstdfiles.c55
-rw-r--r--libio/stdfiles.c31
-rw-r--r--libio/stdio.c6
14 files changed, 1007 insertions, 63 deletions
diff --git a/libio/Makefile b/libio/Makefile
index 4df874d722..3e9f6eae39 100644
--- a/libio/Makefile
+++ b/libio/Makefile
@@ -42,6 +42,10 @@ all: # Make this the default target; it will be defined in Rules.
include ../Makeconfig
+ifeq ($(versioning),yes)
+routines += oldiofopen oldfreopen
+endif
+
CPPFLAGS-.o += -DIO_DEBUG
ifneq (,$(filter %REENTRANT, $(defines)))
@@ -54,6 +58,10 @@ endif
aux := \
fileops genops stdfiles stdio strops
+ifeq ($(versioning),yes)
+aux += oldfileops oldstdfiles
+endif
+
distribute := iolibio.h libioP.h strfile.h Banner
include ../Rules
diff --git a/libio/fileops.c b/libio/fileops.c
index ccfce3c776..e82e2b36bd 100644
--- a/libio/fileops.c
+++ b/libio/fileops.c
@@ -109,10 +109,11 @@ void
_IO_file_init (fp)
_IO_FILE *fp;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
/* POSIX.1 allows another file handle to be used to change the position
of our file descriptor. Hence we actually don't know the actual
position before we do the first fseek (and until a following fflush). */
- fp->_offset = _IO_pos_BAD;
+ fc->_offset = _IO_pos_BAD;
fp->_IO_file_flags |= CLOSED_FILEBUF_FLAGS;
_IO_link_in(fp);
@@ -123,6 +124,7 @@ int
_IO_file_close_it (fp)
_IO_FILE *fp;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
int write_status, close_status;
if (!_IO_file_is_open (fp))
return EOF;
@@ -141,7 +143,7 @@ _IO_file_close_it (fp)
_IO_un_link (fp);
fp->_flags = _IO_MAGIC|CLOSED_FILEBUF_FLAGS;
fp->_fileno = EOF;
- fp->_offset = _IO_pos_BAD;
+ fc->_offset = _IO_pos_BAD;
return close_status ? close_status : write_status;
}
@@ -221,6 +223,7 @@ _IO_file_attach (fp, fd)
_IO_FILE *fp;
int fd;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
if (_IO_file_is_open (fp))
return NULL;
fp->_fileno = fd;
@@ -228,7 +231,7 @@ _IO_file_attach (fp, fd)
fp->_flags |= _IO_DELETE_DONT_CLOSE;
/* Get the current position of the file. */
/* We have to do that since that may be junk. */
- fp->_offset = _IO_pos_BAD;
+ fc->_offset = _IO_pos_BAD;
if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT)
== _IO_pos_BAD && errno != ESPIPE)
return NULL;
@@ -260,6 +263,7 @@ _IO_do_write (fp, data, to_do)
const char *data;
_IO_size_t to_do;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
_IO_size_t count;
if (to_do == 0)
return 0;
@@ -269,14 +273,14 @@ _IO_do_write (fp, data, to_do)
is 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;
+ fc->_offset = _IO_pos_BAD;
else if (fp->_IO_read_end != fp->_IO_write_base)
{
_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;
- fp->_offset = new_pos;
+ fc->_offset = new_pos;
}
count = _IO_SYSWRITE (fp, data, to_do);
if (fp->_cur_column)
@@ -292,6 +296,7 @@ int
_IO_file_underflow (fp)
_IO_FILE *fp;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
_IO_ssize_t count;
#if 0
/* SysV does not make this test; take it out for compatibility */
@@ -338,8 +343,8 @@ _IO_file_underflow (fp)
fp->_IO_read_end += count;
if (count == 0)
return EOF;
- if (fp->_offset != _IO_pos_BAD)
- _IO_pos_adjust (fp->_offset, count);
+ if (fc->_offset != _IO_pos_BAD)
+ _IO_pos_adjust (fc->_offset, count);
return *(unsigned char *) fp->_IO_read_ptr;
}
@@ -398,6 +403,7 @@ int
_IO_file_sync (fp)
_IO_FILE *fp;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
_IO_size_t delta;
int retval = 0;
@@ -424,7 +430,7 @@ _IO_file_sync (fp)
retval = EOF;
}
if (retval != EOF)
- fp->_offset = _IO_pos_BAD;
+ fc->_offset = _IO_pos_BAD;
/* FIXME: Cleanup - can this be shared? */
/* setg(base(), ptr, ptr); */
_IO_cleanup_region_end (1);
@@ -438,6 +444,7 @@ _IO_file_seekoff (fp, offset, dir, mode)
int dir;
int mode;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) fp;
_IO_fpos64_t result;
_IO_off64_t delta, new_offset;
long count;
@@ -473,10 +480,10 @@ _IO_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)
+ if (fc->_offset == _IO_pos_BAD)
goto dumb;
/* Make offset absolute, assuming current pointer is file_ptr(). */
- offset += _IO_pos_as_off (fp->_offset);
+ offset += _IO_pos_as_off (fc->_offset);
dir = _IO_seek_set;
break;
@@ -497,11 +504,11 @@ _IO_file_seekoff (fp, offset, dir, mode)
/* At this point, dir==_IO_seek_set. */
/* If destination is within current buffer, optimize: */
- if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
+ if (fc->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL
&& !_IO_in_backup (fp))
{
/* Offset relative to start of main get area. */
- _IO_fpos64_t rel_offset = (offset - fp->_offset
+ _IO_fpos64_t rel_offset = (offset - fc->_offset
+ (fp->_IO_read_end - fp->_IO_read_base));
if (rel_offset >= 0)
{
@@ -575,7 +582,7 @@ _IO_file_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);
- fp->_offset = result + count;
+ fc->_offset = result + count;
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
return offset;
dumb:
@@ -584,7 +591,7 @@ _IO_file_seekoff (fp, offset, dir, mode)
result = _IO_SYSSEEK (fp, offset, dir);
if (result != EOF)
_IO_mask_flags (fp, 0, _IO_EOF_SEEN);
- fp->_offset = result;
+ fc->_offset = result;
_IO_setg (fp, fp->_IO_buf_base, fp->_IO_buf_base, fp->_IO_buf_base);
_IO_setp (fp, fp->_IO_buf_base, fp->_IO_buf_base);
return result;
@@ -637,6 +644,7 @@ _IO_file_write (f, data, n)
const void *data;
_IO_ssize_t n;
{
+ struct _IO_FILE_complete *fc = (struct _IO_FILE_complete *) f;
_IO_ssize_t to_do = n;
while (to_do > 0)
{
@@ -650,8 +658,8 @@ _IO_file_write (f, data, n)
data = (void *) ((char *) data + count);
}
n -= to_do;
- if (f->_offset >= 0)
- f->_offset += n;
+ if (fc->_offset >= 0)
+ fc->_offset += n;
return n;
}
diff --git a/libio/freopen.c b/libio/freopen.c
index ff57d6033d..c443bbc2eb 100644
--- a/libio/freopen.c
+++ b/libio/freopen.c
@@ -27,7 +27,7 @@
#include "stdio.h"
FILE*
-freopen (filename, mode, fp)
+__new_freopen (filename, mode, fp)
const char* filename;
const char* mode;
FILE* fp;
@@ -42,3 +42,5 @@ freopen (filename, mode, fp)
_IO_cleanup_region_end (1);
return result;
}
+
+symbol_version (__new_freopen, freopen, GLIBC_2.1);
diff --git a/libio/iofopen.c b/libio/iofopen.c
index 5019e9a798..c27b69bc1b 100644
--- a/libio/iofopen.c
+++ b/libio/iofopen.c
@@ -29,13 +29,13 @@
#endif
_IO_FILE *
-_IO_fopen (filename, mode)
+_IO_new_fopen (filename, mode)
const char *filename;
const char *mode;
{
struct locked_FILE
{
- struct _IO_FILE_plus fp;
+ struct _IO_FILE_complete fp;
#ifdef _IO_MTSAFE_IO
_IO_lock_t lock;
#endif
@@ -44,21 +44,28 @@ _IO_fopen (filename, mode)
if (new_f == NULL)
return NULL;
#ifdef _IO_MTSAFE_IO
- new_f->fp.file._lock = &new_f->lock;
+ new_f->fp.plus.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);
+ _IO_init (&new_f->fp.plus.file, 0);
+ _IO_JUMPS (&new_f->fp.plus.file) = &_IO_file_jumps;
+ _IO_file_init (&new_f->fp.plus.file);
#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
+ new_f->fp.plus.vtable = NULL;
#endif
- 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);
+ if (_IO_file_fopen (&new_f->fp.plus.file, filename, mode, 0) != NULL)
+ return (_IO_FILE *) &new_f->fp.plus;
+ _IO_un_link (&new_f->fp.plus.file);
free (new_f);
return NULL;
}
-#ifdef weak_alias
-weak_alias (_IO_fopen, fopen)
+#ifdef DO_VERSIONING
+strong_alias (_IO_new_fopen, __new_fopen)
+symbol_version (_IO_new_fopen, _IO_fopen, GLIBC_2.1);
+symbol_version (__new_fopen, fopen, GLIBC_2.1);
+#else
+# ifdef weak_alias
+weak_symbol (_IO_new_fopen, _IO_fopen)
+weak_symbol (_IO_new_fopen, fopen)
+# endif
#endif
diff --git a/libio/iofopen64.c b/libio/iofopen64.c
index cdd508d08a..fc6ccc0b92 100644
--- a/libio/iofopen64.c
+++ b/libio/iofopen64.c
@@ -36,7 +36,7 @@ _IO_fopen64 (filename, mode)
#ifdef _G_OPEN64
struct locked_FILE
{
- struct _IO_FILE_plus fp;
+ struct _IO_FILE_complete fp;
#ifdef _IO_MTSAFE_IO
_IO_lock_t lock;
#endif
@@ -45,17 +45,17 @@ _IO_fopen64 (filename, mode)
if (new_f == NULL)
return NULL;
#ifdef _IO_MTSAFE_IO
- new_f->fp.file._lock = &new_f->lock;
+ new_f->fp.plus.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);
+ _IO_init (&new_f->fp.plus.file, 0);
+ _IO_JUMPS (&new_f->fp.plus.file) = &_IO_file_jumps;
+ _IO_file_init (&new_f->fp.plus.file);
#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
+ new_f->fp.plus.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);
+ if (_IO_file_fopen (&new_f->fp.plus.file, filename, mode, 1) != NULL)
+ return (_IO_FILE *) &new_f->fp.plus;
+ _IO_un_link (&new_f->fp.plus.file);
free (new_f);
return NULL;
#else
diff --git a/libio/iolibio.h b/libio/iolibio.h
index bcf8bbd775..bb5506444f 100644
--- a/libio/iolibio.h
+++ b/libio/iolibio.h
@@ -14,6 +14,8 @@ 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 int _IO_fprintf __P((_IO_FILE*, const char*, ...));
extern int _IO_fputs __P((const char*, _IO_FILE*));
@@ -50,6 +52,8 @@ extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...));
#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, 0))
+#define _IO_old_freopen(FILENAME, MODE, FP) \
+ (_IO_file_close_it(FP), _IO_old_file_fopen(FP, FILENAME, MODE))
#define _IO_freopen64(FILENAME, MODE, FP) \
(_IO_file_close_it(FP), _IO_file_fopen(FP, FILENAME, MODE, 1))
#define _IO_fileno(FP) ((FP)->_fileno)
@@ -58,6 +62,9 @@ extern _IO_FILE* _IO_popen __P((const char*, const char*));
#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 *));
+
#ifdef __cplusplus
}
#endif
diff --git a/libio/libio.h b/libio/libio.h
index ad5583f486..2e9e62ad61 100644
--- a/libio/libio.h
+++ b/libio/libio.h
@@ -207,7 +207,7 @@ struct _IO_FILE {
int _fileno;
int _blksize;
- _IO_off_t _unused2; /* This used to be _offset but it's too small. */
+ _IO_off_t _old_offset; /* This used to be _offset but it's too small. */
#define __HAVE_COLUMN /* temporary */
/* 1+column number of pbase(); 0 is unknown. */
@@ -218,16 +218,14 @@ struct _IO_FILE {
/* char* _save_gptr; char* _save_egptr; */
_IO_lock_t *_lock;
-
- _IO_off64_t _offset;
};
#ifndef __cplusplus
typedef struct _IO_FILE _IO_FILE;
#endif
-struct _IO_FILE_plus;
-extern struct _IO_FILE_plus _IO_stdin_, _IO_stdout_, _IO_stderr_;
+struct _IO_FILE_complete;
+extern struct _IO_FILE_complete _IO_stdin_, _IO_stdout_, _IO_stderr_;
#define _IO_stdin ((_IO_FILE*)(&_IO_stdin_))
#define _IO_stdout ((_IO_FILE*)(&_IO_stdout_))
#define _IO_stderr ((_IO_FILE*)(&_IO_stderr_))
diff --git a/libio/libioP.h b/libio/libioP.h
index 5fe9598c0d..97c3206c4d 100644
--- a/libio/libioP.h
+++ b/libio/libioP.h
@@ -267,6 +267,17 @@ struct _IO_FILE_plus
const struct _IO_jump_t *vtable;
};
+/* We had to extend _IO_FILE but this isn't easily possible without
+ compatibility problems. So we mimic the C++ way to do this which
+ especially takes care that the position of the vtable stays the
+ same. */
+struct _IO_FILE_complete
+{
+ struct _IO_FILE_plus plus;;
+ _IO_off64_t _offset;
+ int _unused2[16]; /* Make sure we don't get into trouble again. */
+};
+
/* Generic functions */
extern _IO_fpos64_t _IO_seekoff __P ((_IO_FILE *, _IO_off64_t, int, int));
@@ -321,10 +332,13 @@ 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_new_file_jumps;
+extern struct _IO_jump_t _IO_old_file_jumps;
extern struct _IO_jump_t _IO_streambuf_jumps;
extern struct _IO_jump_t _IO_proc_jumps;
extern struct _IO_jump_t _IO_str_jumps;
extern int _IO_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_flush_all __P ((void));
extern void _IO_cleanup __P ((void));
extern void _IO_flush_all_linebuffered __P ((void));
@@ -367,6 +381,23 @@ extern int _IO_file_close_it __P ((_IO_FILE *));
extern _IO_fpos64_t _IO_file_seek __P ((_IO_FILE *, _IO_off64_t, int));
extern void _IO_file_finish __P ((_IO_FILE *, int));
+extern _IO_FILE* _IO_old_file_setbuf __P ((_IO_FILE *, char *, _IO_ssize_t));
+extern _IO_fpos64_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 ((_IO_FILE *));
+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));
+
/* Jumptable functions for proc_files. */
extern _IO_FILE* _IO_proc_open __P ((_IO_FILE *, const char *, const char *));
extern int _IO_proc_close __P ((_IO_FILE *));
diff --git a/libio/oldfileops.c b/libio/oldfileops.c
new file mode 100644
index 0000000000..ab4445c594
--- /dev/null
+++ b/libio/oldfileops.c
@@ -0,0 +1,720 @@
+/* Copyright (C) 1993, 1995, 1997 Free Software Foundation, Inc.
+ This file is part of the GNU IO Library.
+ Written by Per Bothner <bothner@cygnus.com>.
+
+ 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. */
+
+/* This is a compatibility file. If we don't build the libc with
+ versioning don't compile this file. */
+#if DO_VERSIONING
+
+
+#ifndef _POSIX_SOURCE
+# define _POSIX_SOURCE
+#endif
+#include "libioP.h"
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <errno.h>
+#ifndef errno
+extern int errno;
+#endif
+#ifndef __set_errno
+# define __set_errno(Val) errno = (Val)
+#endif
+
+
+#ifdef _LIBC
+# define open(Name, Flags, Prot) __open (Name, Flags, Prot)
+# define close(FD) __close (FD)
+# define fstat(FD, Statbuf) __fstat (FD, Statbuf)
+# define lseek(FD, Offset, Whence) __lseek (FD, Offset, Whence)
+# define read(FD, Buf, NBytes) __read (FD, Buf, NBytes)
+# define write(FD, Buf, NBytes) __write (FD, Buf, NBytes)
+#endif
+
+/* An fstream can be in at most one of put mode, get mode, or putback mode.
+ Putback mode is a variant of get mode.
+
+ In a filebuf, there is only one current position, instead of two
+ separate get and put pointers. In get mode, the current position
+ is that of gptr(); in put mode that of pptr().
+
+ 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.
+ If the field _fb._offset is >= 0, it gives the offset in
+ the file as a whole corresponding to eGptr(). (?)
+
+ PUT MODE:
+ If a filebuf is in put mode, then all of _IO_read_ptr, _IO_read_end,
+ and _IO_read_base are equal to each other. These are usually equal
+ 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.
+ 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.
+
+ GET MODE:
+ If a fil