From 52a16e580103729ad0cc228b564a811a7a19cc8d Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 5 Nov 2002 08:43:05 +0000 Subject: [PATCH] Update. 2002-11-05 Ulrich Drepper * libio/ioseekoff.c: Remove INTDEF. Define _IO_seekoff_unlocked. Same as old code without locking. _IO_seekoff calls this function after locking the stream. * libio/ioseekpos.c: Likewise for _IO_seekpos. * libio/libioP.h: Replace _IO_seekoff_internal and _IO_seekpos_internal prototypes with _IO_seekoff_unlocked and _IO_seekpos_unlocked prototypes. * libio/iolibio.h (_IO_fseek): Call _IO_seekoff_unlocked instead of _IO_seekoff_internal. (_IO_rewind): Likewise. * libio/ioftell.c: Likewise. * libio/ftello.c: Likewise. * libio/ftello64.c: Likewise. * libio/iofgetpos.c: Likewise. * libio/iofgetpos64.c: Likewise. * libio/oldiofgetpos.c: Likewise. * libio/oldiofgetpos64.c: Likewise. * libio/iofsetpos.c: Call _IO_seekpos_unlocked instead of _IO_seekpos_internal. * libio/iofsetpos64.c: Likewise. * libio/oldiofsetpos.c: Likewise. * libio/oldiofsetpos64.c: Likewise. * libio/wfileops.c (_IO_wfile_seekoff): Don't modify _offset and _wide_data->_IO_read_end if adjustment can be made in the current buffer. --- ChangeLog | 29 +++++++++++++++++++++++++++++ NEWS | 4 +++- libio/ftello.c | 2 +- libio/ftello64.c | 2 +- libio/iofgetpos.c | 2 +- libio/iofgetpos64.c | 2 +- libio/iofsetpos.c | 2 +- libio/iofsetpos64.c | 2 +- libio/ioftell.c | 2 +- libio/iolibio.h | 4 ++-- libio/ioseekoff.c | 26 ++++++++++++++++++-------- libio/ioseekpos.c | 25 +++++++++++++++++-------- libio/libioP.h | 6 ++++-- libio/oldiofgetpos.c | 2 +- libio/oldiofgetpos64.c | 2 +- libio/oldiofsetpos.c | 2 +- libio/oldiofsetpos64.c | 2 +- 17 files changed, 84 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3da0f0f..2714b51 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,28 @@ +2002-11-05 Ulrich Drepper + + * libio/ioseekoff.c: Remove INTDEF. Define _IO_seekoff_unlocked. Same + as old code without locking. _IO_seekoff calls this function after + locking the stream. + * libio/ioseekpos.c: Likewise for _IO_seekpos. + * libio/libioP.h: Replace _IO_seekoff_internal and _IO_seekpos_internal + prototypes with _IO_seekoff_unlocked and _IO_seekpos_unlocked + prototypes. + * libio/iolibio.h (_IO_fseek): Call _IO_seekoff_unlocked instead + of _IO_seekoff_internal. + (_IO_rewind): Likewise. + * libio/ioftell.c: Likewise. + * libio/ftello.c: Likewise. + * libio/ftello64.c: Likewise. + * libio/iofgetpos.c: Likewise. + * libio/iofgetpos64.c: Likewise. + * libio/oldiofgetpos.c: Likewise. + * libio/oldiofgetpos64.c: Likewise. + * libio/iofsetpos.c: Call _IO_seekpos_unlocked instead of + _IO_seekpos_internal. + * libio/iofsetpos64.c: Likewise. + * libio/oldiofsetpos.c: Likewise. + * libio/oldiofsetpos64.c: Likewise. + 2002-11-04 Roland McGrath * sysdeps/unix/sysv/linux/powerpc/chown.c: Use INLINE_SYSCALL macro. @@ -55,6 +80,10 @@ 2002-11-04 Ulrich Drepper + * libio/wfileops.c (_IO_wfile_seekoff): Don't modify _offset and + _wide_data->_IO_read_end if adjustment can be made in the current + buffer. + * sysdeps/unix/sysv/linux/fexecve.c: New file. * libio/bug-wfflush.c (do_test): Using fseek is not allowed when diff --git a/NEWS b/NEWS index f8550a1..249b69f 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,4 @@ -GNU C Library NEWS -- history of user-visible changes. 2002-10-13 +GNU C Library NEWS -- history of user-visible changes. 2002-11-5 Copyright (C) 1992-2001, 2002 Free Software Foundation, Inc. See the end for copying conditions. @@ -15,6 +15,8 @@ Version 2.3.2 * The new dynamic string token $LIB is expanded in shared library names. This normally expands to lib, but on some 64-bit platforms to lib64 instead. + +* fexecve is implemented on Linux. Version 2.3 diff --git a/libio/ftello.c b/libio/ftello.c index 94a2541..e148664 100644 --- a/libio/ftello.c +++ b/libio/ftello.c @@ -39,7 +39,7 @@ ftello (fp) CHECK_FILE (fp, -1L); _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) { if (fp->_mode <= 0) diff --git a/libio/ftello64.c b/libio/ftello64.c index bbf7767..b2da11d 100644 --- a/libio/ftello64.c +++ b/libio/ftello64.c @@ -40,7 +40,7 @@ ftello64 (fp) CHECK_FILE (fp, -1L); _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) { if (fp->_mode <= 0) diff --git a/libio/iofgetpos.c b/libio/iofgetpos.c index 4b50898..0c80b2f 100644 --- a/libio/iofgetpos.c +++ b/libio/iofgetpos.c @@ -40,7 +40,7 @@ _IO_new_fgetpos (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) { if (fp->_mode <= 0) diff --git a/libio/iofgetpos64.c b/libio/iofgetpos64.c index 525a75c..3ad7e11 100644 --- a/libio/iofgetpos64.c +++ b/libio/iofgetpos64.c @@ -40,7 +40,7 @@ _IO_new_fgetpos64 (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) (void *)) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) { if (fp->_mode <= 0) diff --git a/libio/iofsetpos.c b/libio/iofsetpos.c index 3c3e61d..f3821e2 100644 --- a/libio/iofsetpos.c +++ b/libio/iofsetpos.c @@ -38,7 +38,7 @@ _IO_new_fsetpos (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - if (INTUSE(_IO_seekpos) (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) + if (_IO_seekpos_unlocked (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD) { /* ANSI explicitly requires setting errno to a positive value on diff --git a/libio/iofsetpos64.c b/libio/iofsetpos64.c index f8c5374..4746d72 100644 --- a/libio/iofsetpos64.c +++ b/libio/iofsetpos64.c @@ -39,7 +39,7 @@ _IO_new_fsetpos64 (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - if (INTUSE(_IO_seekpos) (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) + if (_IO_seekpos_unlocked (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD) { /* ANSI explicitly requires setting errno to a positive value on diff --git a/libio/ioftell.c b/libio/ioftell.c index 2a389c3..fd5da6b 100644 --- a/libio/ioftell.c +++ b/libio/ioftell.c @@ -38,7 +38,7 @@ _IO_ftell (fp) CHECK_FILE (fp, -1L); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) { if (fp->_vtable_offset != 0 || fp->_mode <= 0) diff --git a/libio/iolibio.h b/libio/iolibio.h index 80fb527..db71be2 100644 --- a/libio/iolibio.h +++ b/libio/iolibio.h @@ -56,10 +56,10 @@ extern int _IO_obstack_printf __P ((struct obstack *, const char *, ...)); #endif #define _IO_clearerr(FP) ((FP)->_flags &= ~(_IO_ERR_SEEN|_IO_EOF_SEEN)) #define _IO_fseek(__fp, __offset, __whence) \ - (INTUSE(_IO_seekoff)(__fp, __offset, __whence, _IOS_INPUT|_IOS_OUTPUT) \ + (_IO_seekoff_unlocked (__fp, __offset, __whence, _IOS_INPUT|_IOS_OUTPUT) \ == _IO_pos_BAD ? EOF : 0) #define _IO_rewind(FILE) \ - (void)INTUSE(_IO_seekoff)(FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT) + (void) _IO_seekoff_unlocked (FILE, 0, 0, _IOS_INPUT|_IOS_OUTPUT) #define _IO_vprintf(FORMAT, ARGS) \ INTUSE(_IO_vfprintf) (_IO_stdout, FORMAT, ARGS) #define _IO_freopen(FILENAME, MODE, FP) \ diff --git a/libio/ioseekoff.c b/libio/ioseekoff.c index eff6d38..09c1388 100644 --- a/libio/ioseekoff.c +++ b/libio/ioseekoff.c @@ -36,14 +36,12 @@ extern int errno; #endif _IO_off64_t -_IO_seekoff (fp, offset, dir, mode) +_IO_seekoff_unlocked (fp, offset, dir, mode) _IO_FILE *fp; _IO_off64_t offset; int dir; int mode; { - _IO_off64_t retval; - if (dir != _IO_seek_cur && dir != _IO_seek_set && dir != _IO_seek_end) { __set_errno (EINVAL); @@ -53,9 +51,6 @@ _IO_seekoff (fp, offset, dir, mode) /* If we have a backup buffer, get rid of it, since the __seekoff callback may not know to do the right thing about it. This may be over-kill, but it'll do for now. TODO */ - _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); - _IO_flockfile (fp); - if (mode != 0 && ((_IO_fwide (fp, 0) < 0 && _IO_have_backup (fp)) || (_IO_fwide (fp, 0) > 0 && _IO_have_wbackup (fp)))) { @@ -72,10 +67,25 @@ _IO_seekoff (fp, offset, dir, mode) INTUSE(_IO_free_wbackup_area) (fp); } - retval = _IO_SEEKOFF (fp, offset, dir, mode); + return _IO_SEEKOFF (fp, offset, dir, mode); +} + + +_IO_off64_t +_IO_seekoff (fp, offset, dir, mode) + _IO_FILE *fp; + _IO_off64_t offset; + int dir; + int mode; +{ + _IO_off64_t retval; + + _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); + _IO_flockfile (fp); + + retval = _IO_seekoff_unlocked (fp, offset, dir, mode); _IO_funlockfile (fp); _IO_cleanup_region_end (0); return retval; } -INTDEF(_IO_seekoff) diff --git a/libio/ioseekpos.c b/libio/ioseekpos.c index 8aa151a..37d32af 100644 --- a/libio/ioseekpos.c +++ b/libio/ioseekpos.c @@ -28,19 +28,14 @@ #include _IO_off64_t -_IO_seekpos (fp, pos, mode) +_IO_seekpos_unlocked (fp, pos, mode) _IO_FILE *fp; _IO_off64_t pos; int mode; { - _IO_off64_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. This may be over-kill, but it'll do for now. TODO */ - _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); - _IO_flockfile (fp); - if (_IO_fwide (fp, 0) <= 0) { if (_IO_have_backup (fp)) @@ -52,10 +47,24 @@ _IO_seekpos (fp, pos, mode) INTUSE(_IO_free_wbackup_area) (fp); } - retval = _IO_SEEKPOS (fp, pos, mode); + return _IO_SEEKPOS (fp, pos, mode); +} + + +_IO_off64_t +_IO_seekpos (fp, pos, mode) + _IO_FILE *fp; + _IO_off64_t pos; + int mode; +{ + _IO_off64_t retval; + + _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); + _IO_flockfile (fp); + + retval = _IO_seekpos_unlocked (fp, pos, mode); _IO_funlockfile (fp); _IO_cleanup_region_end (0); return retval; } -INTDEF(_IO_seekpos) diff --git a/libio/libioP.h b/libio/libioP.h index 9cdfebc..105ffcce 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -730,8 +730,10 @@ extern int _IO_vfprintf_internal (_IO_FILE *__restrict, const char *__restrict, _IO_va_list); extern void _IO_doallocbuf_internal __P ((_IO_FILE *)); extern void _IO_wsetb_internal __P ((_IO_FILE *, wchar_t *, wchar_t *, int)); -extern _IO_off64_t _IO_seekoff_internal (_IO_FILE *, _IO_off64_t, int, int); -extern _IO_off64_t _IO_seekpos_internal (_IO_FILE *, _IO_off64_t, int); +extern _IO_off64_t _IO_seekoff_unlocked (_IO_FILE *, _IO_off64_t, int, int) + attribute_hidden; +extern _IO_off64_t _IO_seekpos_unlocked (_IO_FILE *, _IO_off64_t, int) + attribute_hidden; extern int _IO_putc_internal (int __c, _IO_FILE *__fp); extern void _IO_init_internal __P ((_IO_FILE *, int)); extern void _IO_un_link_internal __P ((struct _IO_FILE_plus *)); diff --git a/libio/oldiofgetpos.c b/libio/oldiofgetpos.c index 0d6d187..596c405 100644 --- a/libio/oldiofgetpos.c +++ b/libio/oldiofgetpos.c @@ -40,7 +40,7 @@ _IO_old_fgetpos (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) pos -= fp->_IO_save_end - fp->_IO_save_base; _IO_funlockfile (fp); diff --git a/libio/oldiofgetpos64.c b/libio/oldiofgetpos64.c index b7fecbd..4a38c38 100644 --- a/libio/oldiofgetpos64.c +++ b/libio/oldiofgetpos64.c @@ -41,7 +41,7 @@ _IO_old_fgetpos64 (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - pos = INTUSE(_IO_seekoff) (fp, 0, _IO_seek_cur, 0); + pos = _IO_seekoff_unlocked (fp, 0, _IO_seek_cur, 0); if (_IO_in_backup (fp)) pos -= fp->_IO_save_end - fp->_IO_save_base; _IO_funlockfile (fp); diff --git a/libio/oldiofsetpos.c b/libio/oldiofsetpos.c index 39adc5f..ce3bb12 100644 --- a/libio/oldiofsetpos.c +++ b/libio/oldiofsetpos.c @@ -39,7 +39,7 @@ _IO_old_fsetpos (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - if (INTUSE(_IO_seekpos) (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) + if (_IO_seekpos_unlocked (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD) { /* ANSI explicitly requires setting errno to a positive value on diff --git a/libio/oldiofsetpos64.c b/libio/oldiofsetpos64.c index 8807133..834f154 100644 --- a/libio/oldiofsetpos64.c +++ b/libio/oldiofsetpos64.c @@ -41,7 +41,7 @@ _IO_old_fsetpos64 (fp, posp) CHECK_FILE (fp, EOF); _IO_cleanup_region_start ((void (*) __P ((void *))) _IO_funlockfile, fp); _IO_flockfile (fp); - if (INTUSE(_IO_seekpos) (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) + if (_IO_seekpos_unlocked (fp, posp->__pos, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD) { /* ANSI explicitly requires setting errno to a positive value on -- 2.7.4