aboutsummaryrefslogtreecommitdiff
path: root/libio/fileops.c
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/fileops.c
parentdfd2257ad98eb0f6eab167e5fe5ff68ca87172e3 (diff)
downloadglibc-1ea89a402d892b68b193e2e4390d8eb33ed686e7.tar
glibc-1ea89a402d892b68b193e2e4390d8eb33ed686e7.tar.gz
glibc-1ea89a402d892b68b193e2e4390d8eb33ed686e7.tar.bz2
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/fileops.c')
-rw-r--r--libio/fileops.c40
1 files changed, 24 insertions, 16 deletions
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;
}