From b1a0fec7927585225a9f9b73d9d0dbee62b8002b Mon Sep 17 00:00:00 2001 From: drepper Date: Mon, 6 Oct 1997 00:25:32 +0000 Subject: [PATCH] Implement LFS interface. --- libio/fseeko64.c | 48 +++++++++++++++++++++++++++++++++++++ libio/ftello64.c | 55 ++++++++++++++++++++++++++++++++++++++++++ libio/iofgetpos64.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ libio/iofopen64.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++++++++ libio/iofsetpos64.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 294 insertions(+) create mode 100644 libio/fseeko64.c create mode 100644 libio/ftello64.c create mode 100644 libio/iofgetpos64.c create mode 100644 libio/iofopen64.c create mode 100644 libio/iofsetpos64.c 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 +#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 +#include +#include + + +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/iofgetpos64.c b/libio/iofgetpos64.c new file mode 100644 index 0000000000..23507a0e40 --- /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 + +int +_IO_fgetpos64 (fp, posp) + _IO_FILE *fp; + _IO_fpos64_t *posp; +{ +#ifdef _G_LSEEK64 + _IO_fpos_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/iofopen64.c b/libio/iofopen64.c new file mode 100644 index 0000000000..8fb6934f08 --- /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 +#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_fopen64 (&new_f->fp.file, filename, mode) != 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/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 +#include + +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 -- 2.11.0