diff options
Diffstat (limited to 'libio')
| -rw-r--r-- | libio/Makefile | 4 | ||||
| -rw-r--r-- | libio/filedoalloc.c | 2 | ||||
| -rw-r--r-- | libio/fileops.c | 51 | ||||
| -rw-r--r-- | libio/freopen64.c | 49 | ||||
| -rw-r--r-- | libio/fseeko64.c | 48 | ||||
| -rw-r--r-- | libio/ftello64.c | 55 | ||||
| -rw-r--r-- | libio/genops.c | 35 | ||||
| -rw-r--r-- | libio/iofgetpos.c | 2 | ||||
| -rw-r--r-- | libio/iofgetpos64.c | 61 | ||||
| -rw-r--r-- | libio/iofopen.c | 2 | ||||
| -rw-r--r-- | libio/iofopen64.c | 69 | ||||
| -rw-r--r-- | libio/iofopncook.c | 14 | ||||
| -rw-r--r-- | libio/iofsetpos64.c | 61 | ||||
| -rw-r--r-- | libio/iolibio.h | 7 | ||||
| -rw-r--r-- | libio/iopopen.c | 4 | ||||
| -rw-r--r-- | libio/ioseekoff.c | 6 | ||||
| -rw-r--r-- | libio/ioseekpos.c | 6 | ||||
| -rw-r--r-- | libio/libio.h | 10 | ||||
| -rw-r--r-- | libio/libioP.h | 67 | ||||
| -rw-r--r-- | libio/memstream.c | 4 | ||||
| -rw-r--r-- | libio/obprintf.c | 4 | ||||
| -rw-r--r-- | libio/stdio.h | 133 | ||||
| -rw-r--r-- | libio/strops.c | 10 | ||||
| -rw-r--r-- | libio/vsnprintf.c | 4 |
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; + |
