diff options
author | Zack Weinberg <zackw@panix.com> | 2018-02-07 18:42:04 -0500 |
---|---|---|
committer | Zack Weinberg <zackw@panix.com> | 2018-02-21 14:11:05 -0500 |
commit | 9964a14579e5eef925aaa82facc4980f627802fe (patch) | |
tree | 10bab616fb792754708552ee49a3cd914f9c167e /libio/fileops.c | |
parent | 349579047db0fb55a2835ca20dfd646a45b6ac27 (diff) | |
download | glibc-9964a14579e5eef925aaa82facc4980f627802fe.zip glibc-9964a14579e5eef925aaa82facc4980f627802fe.tar.gz glibc-9964a14579e5eef925aaa82facc4980f627802fe.tar.bz2 |
Mechanically remove _IO_ name aliases for types and constants.
This patch mechanically removes all remaining uses, and the
definitions, of the following libio name aliases:
name replaced with
---- -------------
_IO_FILE FILE
_IO_fpos_t __fpos_t
_IO_fpos64_t __fpos64_t
_IO_size_t size_t
_IO_ssize_t ssize_t or __ssize_t
_IO_off_t off_t
_IO_off64_t off64_t
_IO_pid_t pid_t
_IO_uid_t uid_t
_IO_wint_t wint_t
_IO_va_list va_list or __gnuc_va_list
_IO_BUFSIZ BUFSIZ
_IO_cookie_io_functions_t cookie_io_functions_t
__io_read_fn cookie_read_function_t
__io_write_fn cookie_write_function_t
__io_seek_fn cookie_seek_function_t
__io_close_fn cookie_close_function_t
I used __fpos_t and __fpos64_t instead of fpos_t and fpos64_t because
the definitions of fpos_t and fpos64_t depend on the largefile mode.
I used __ssize_t and __gnuc_va_list in a handful of headers where
namespace cleanliness might be relevant even though they're
internal-use-only. In all other cases, I used the public-namespace
name.
There are a tiny handful of places where I left a use of 'struct _IO_FILE'
alone, because it was being used together with 'struct _IO_FILE_plus'
or 'struct _IO_FILE_complete' in the same arithmetic expression.
Because this patch was almost entirely done with search and replace, I
may have introduced indentation botches. I did proofread the diff,
but I may have missed something.
The ChangeLog below calls out all of the places where this was not a
pure search-and-replace change.
Installed stripped libraries and executables are unchanged by this patch,
except that some assertions in vfscanf.c change line numbers.
* libio/libio.h (_IO_FILE): Delete; all uses changed to FILE.
(_IO_fpos_t): Delete; all uses changed to __fpos_t.
(_IO_fpos64_t): Delete; all uses changed to __fpos64_t.
(_IO_size_t): Delete; all uses changed to size_t.
(_IO_ssize_t): Delete; all uses changed to ssize_t or __ssize_t.
(_IO_off_t): Delete; all uses changed to off_t.
(_IO_off64_t): Delete; all uses changed to off64_t.
(_IO_pid_t): Delete; all uses changed to pid_t.
(_IO_uid_t): Delete; all uses changed to uid_t.
(_IO_wint_t): Delete; all uses changed to wint_t.
(_IO_va_list): Delete; all uses changed to va_list or __gnuc_va_list.
(_IO_BUFSIZ): Delete; all uses changed to BUFSIZ.
(_IO_cookie_io_functions_t): Delete; all uses changed to
cookie_io_functions_t.
(__io_read_fn): Delete; all uses changed to cookie_read_function_t.
(__io_write_fn): Delete; all uses changed to cookie_write_function_t.
(__io_seek_fn): Delete; all uses changed to cookie_seek_function_t.
(__io_close_fn): Delete: all uses changed to cookie_close_function_t.
* libio/iofopncook.c: Remove unnecessary forward declarations.
* libio/iolibio.h: Correct outdated commentary.
* malloc/malloc.c (__malloc_stats): Remove unnecessary casts.
* stdio-common/fxprintf.c (__fxprintf_nocancel):
Remove unnecessary casts.
* stdio-common/getline.c: Use _IO_getdelim directly.
Don't redefine ssize_t.
* stdio-common/printf_fp.c, stdio_common/printf_fphex.c
* stdio-common/printf_size.c: Don't redefine size_t or FILE.
Remove outdated comments.
* stdio-common/vfscanf.c: Don't redefine va_list.
Diffstat (limited to 'libio/fileops.c')
-rw-r--r-- | libio/fileops.c | 155 |
1 files changed, 77 insertions, 78 deletions
diff --git a/libio/fileops.c b/libio/fileops.c index 5fd8a96..4b8e443 100644 --- a/libio/fileops.c +++ b/libio/fileops.c @@ -125,7 +125,7 @@ _IO_new_file_init (struct _IO_FILE_plus *fp) } int -_IO_new_file_close_it (_IO_FILE *fp) +_IO_new_file_close_it (FILE *fp) { int write_status; if (!_IO_file_is_open (fp)) @@ -165,7 +165,7 @@ _IO_new_file_close_it (_IO_FILE *fp) libc_hidden_ver (_IO_new_file_close_it, _IO_file_close_it) void -_IO_new_file_finish (_IO_FILE *fp, int dummy) +_IO_new_file_finish (FILE *fp, int dummy) { if (_IO_file_is_open (fp)) { @@ -177,8 +177,8 @@ _IO_new_file_finish (_IO_FILE *fp, int dummy) } libc_hidden_ver (_IO_new_file_finish, _IO_file_finish) -_IO_FILE * -_IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot, +FILE * +_IO_file_open (FILE *fp, const char *filename, int posix_mode, int prot, int read_write, int is32not64) { int fdesc; @@ -196,7 +196,7 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot, if ((read_write & (_IO_IS_APPENDING | _IO_NO_READS)) == (_IO_IS_APPENDING | _IO_NO_READS)) { - _IO_off64_t new_pos = _IO_SYSSEEK (fp, 0, _IO_seek_end); + off64_t new_pos = _IO_SYSSEEK (fp, 0, _IO_seek_end); if (new_pos == _IO_pos_BAD && errno != ESPIPE) { __close_nocancel (fdesc); @@ -208,15 +208,15 @@ _IO_file_open (_IO_FILE *fp, const char *filename, int posix_mode, int prot, } libc_hidden_def (_IO_file_open) -_IO_FILE * -_IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode, +FILE * +_IO_new_file_fopen (FILE *fp, const char *filename, const char *mode, int is32not64) { int oflags = 0, omode; int read_write; int oprot = 0666; int i; - _IO_FILE *result; + FILE *result; const char *cs; const char *last_recognized; @@ -364,8 +364,8 @@ _IO_new_file_fopen (_IO_FILE *fp, const char *filename, const char *mode, } libc_hidden_ver (_IO_new_file_fopen, _IO_file_fopen) -_IO_FILE * -_IO_new_file_attach (_IO_FILE *fp, int fd) +FILE * +_IO_new_file_attach (FILE *fp, int fd) { if (_IO_file_is_open (fp)) return NULL; @@ -376,7 +376,7 @@ _IO_new_file_attach (_IO_FILE *fp, int fd) /* We have to do that since that may be junk. */ fp->_offset = _IO_pos_BAD; int save_errno = errno; - if (_IO_SEEKOFF (fp, (_IO_off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT) + if (_IO_SEEKOFF (fp, (off64_t)0, _IO_seek_cur, _IOS_INPUT|_IOS_OUTPUT) == _IO_pos_BAD && errno != ESPIPE) return NULL; __set_errno (save_errno); @@ -384,8 +384,8 @@ _IO_new_file_attach (_IO_FILE *fp, int fd) } libc_hidden_ver (_IO_new_file_attach, _IO_file_attach) -_IO_FILE * -_IO_new_file_setbuf (_IO_FILE *fp, char *p, _IO_ssize_t len) +FILE * +_IO_new_file_setbuf (FILE *fp, char *p, ssize_t len) { if (_IO_default_setbuf (fp, p, len) == NULL) return NULL; @@ -399,10 +399,10 @@ _IO_new_file_setbuf (_IO_FILE *fp, char *p, _IO_ssize_t len) libc_hidden_ver (_IO_new_file_setbuf, _IO_file_setbuf) -_IO_FILE * -_IO_file_setbuf_mmap (_IO_FILE *fp, char *p, _IO_ssize_t len) +FILE * +_IO_file_setbuf_mmap (FILE *fp, char *p, ssize_t len) { - _IO_FILE *result; + FILE *result; /* Change the function table. */ _IO_JUMPS_FILE_plus (fp) = &_IO_file_jumps; @@ -421,24 +421,23 @@ _IO_file_setbuf_mmap (_IO_FILE *fp, char *p, _IO_ssize_t len) return result; } -static _IO_size_t new_do_write (_IO_FILE *, const char *, _IO_size_t); +static size_t new_do_write (FILE *, const char *, size_t); /* Write TO_DO bytes from DATA to FP. Then mark FP as having empty buffers. */ int -_IO_new_do_write (_IO_FILE *fp, const char *data, _IO_size_t to_do) +_IO_new_do_write (FILE *fp, const char *data, size_t to_do) { return (to_do == 0 - || (_IO_size_t) new_do_write (fp, data, to_do) == to_do) ? 0 : EOF; + || (size_t) new_do_write (fp, data, to_do) == to_do) ? 0 : EOF; } libc_hidden_ver (_IO_new_do_write, _IO_do_write) -static -_IO_size_t -new_do_write (_IO_FILE *fp, const char *data, _IO_size_t to_do) +static size_t +new_do_write (FILE *fp, const char *data, size_t to_do) { - _IO_size_t count; + size_t count; if (fp->_flags & _IO_IS_APPENDING) /* On a system without a proper O_APPEND implementation, you would need to sys_seek(0, SEEK_END) here, but is @@ -448,7 +447,7 @@ new_do_write (_IO_FILE *fp, const char *data, _IO_size_t to_do) fp->_offset = _IO_pos_BAD; else if (fp->_IO_read_end != fp->_IO_write_base) { - _IO_off64_t new_pos + off64_t new_pos = _IO_SYSSEEK (fp, fp->_IO_write_base - fp->_IO_read_end, 1); if (new_pos == _IO_pos_BAD) return 0; @@ -466,9 +465,9 @@ new_do_write (_IO_FILE *fp, const char *data, _IO_size_t to_do) } int -_IO_new_file_underflow (_IO_FILE *fp) +_IO_new_file_underflow (FILE *fp) { - _IO_ssize_t count; + ssize_t count; #if 0 /* SysV does not make this test; take it out for compatibility */ if (fp->_flags & _IO_EOF_SEEN) @@ -557,7 +556,7 @@ libc_hidden_ver (_IO_new_file_underflow, _IO_file_underflow) If the file is no longer eligible for mmap, its jump tables are reset to the vanilla ones and we return nonzero. */ static int -mmap_remap_check (_IO_FILE *fp) +mmap_remap_check (FILE *fp) { struct stat64 st; @@ -653,7 +652,7 @@ mmap_remap_check (_IO_FILE *fp) /* Special callback replacing the underflow callbacks if we mmap the file. */ int -_IO_file_underflow_mmap (_IO_FILE *fp) +_IO_file_underflow_mmap (FILE *fp) { if (fp->_IO_read_ptr < fp->_IO_read_end) return *(unsigned char *) fp->_IO_read_ptr; @@ -670,7 +669,7 @@ _IO_file_underflow_mmap (_IO_FILE *fp) } static void -decide_maybe_mmap (_IO_FILE *fp) +decide_maybe_mmap (FILE *fp) { /* We use the file in read-only mode. This could mean we can mmap the file and use it without any copying. But not all @@ -732,7 +731,7 @@ decide_maybe_mmap (_IO_FILE *fp) } int -_IO_file_underflow_maybe_mmap (_IO_FILE *fp) +_IO_file_underflow_maybe_mmap (FILE *fp) { /* This is the first read attempt. Choose mmap or vanilla operations and then punt to the chosen underflow routine. */ @@ -742,7 +741,7 @@ _IO_file_underflow_maybe_mmap (_IO_FILE *fp) int -_IO_new_file_overflow (_IO_FILE *f, int ch) +_IO_new_file_overflow (FILE *f, int ch) { if (f->_flags & _IO_NO_WRITES) /* SET ERROR */ { @@ -803,9 +802,9 @@ _IO_new_file_overflow (_IO_FILE *f, int ch) libc_hidden_ver (_IO_new_file_overflow, _IO_file_overflow) int -_IO_new_file_sync (_IO_FILE *fp) +_IO_new_file_sync (FILE *fp) { - _IO_ssize_t delta; + ssize_t delta; int retval = 0; /* char* ptr = cur_ptr(); */ @@ -818,8 +817,8 @@ _IO_new_file_sync (_IO_FILE *fp) if (_IO_in_backup (fp)) delta -= eGptr () - Gbase (); #endif - _IO_off64_t new_pos = _IO_SYSSEEK (fp, delta, 1); - if (new_pos != (_IO_off64_t) EOF) + off64_t new_pos = _IO_SYSSEEK (fp, delta, 1); + if (new_pos != (off64_t) EOF) fp->_IO_read_end = fp->_IO_read_ptr; else if (errno == ESPIPE) ; /* Ignore error from unseekable devices. */ @@ -835,7 +834,7 @@ _IO_new_file_sync (_IO_FILE *fp) libc_hidden_ver (_IO_new_file_sync, _IO_file_sync) static int -_IO_file_sync_mmap (_IO_FILE *fp) +_IO_file_sync_mmap (FILE *fp) { if (fp->_IO_read_ptr != fp->_IO_read_end) { @@ -859,10 +858,10 @@ _IO_file_sync_mmap (_IO_FILE *fp) /* ftell{,o} implementation. The only time we modify the state of the stream is when we have unflushed writes. In that case we seek to the end and record that offset in the stream object. */ -static _IO_off64_t -do_ftell (_IO_FILE *fp) +static off64_t +do_ftell (FILE *fp) { - _IO_off64_t result, offset = 0; + off64_t result, offset = 0; /* No point looking at unflushed data if we haven't allocated buffers yet. */ @@ -918,11 +917,11 @@ do_ftell (_IO_FILE *fp) return result; } -_IO_off64_t -_IO_new_file_seekoff (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode) +off64_t +_IO_new_file_seekoff (FILE *fp, off64_t offset, int dir, int mode) { - _IO_off64_t result; - _IO_off64_t delta, new_offset; + off64_t result; + off64_t delta, new_offset; long count; /* Short-circuit into a separate function. We don't want to mix any @@ -1003,8 +1002,8 @@ _IO_new_file_seekoff (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode) if (fp->_offset != _IO_pos_BAD && fp->_IO_read_base != NULL && !_IO_in_backup (fp)) { - _IO_off64_t start_offset = (fp->_offset - - (fp->_IO_read_end - fp->_IO_buf_base)); + off64_t start_offset = (fp->_offset + - (fp->_IO_read_end - fp->_IO_buf_base)); if (offset >= start_offset && offset < fp->_offset) { _IO_setg (fp, fp->_IO_buf_base, @@ -1077,10 +1076,10 @@ resync: } libc_hidden_ver (_IO_new_file_seekoff, _IO_file_seekoff) -_IO_off64_t -_IO_file_seekoff_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode) +off64_t +_IO_file_seekoff_mmap (FILE *fp, off64_t offset, int dir, int mode) { - _IO_off64_t result; + off64_t result; /* If we are only interested in the current position, calculate it and return right now. This calculation does the right thing when we are @@ -1132,15 +1131,15 @@ _IO_file_seekoff_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir, int mode) return offset; } -static _IO_off64_t -_IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir, +static off64_t +_IO_file_seekoff_maybe_mmap (FILE *fp, off64_t offset, int dir, int mode) { /* We only get here when we haven't tried to read anything yet. So there is nothing more useful for us to do here than just the underlying lseek call. */ - _IO_off64_t result = _IO_SYSSEEK (fp, offset, dir); + off64_t result = _IO_SYSSEEK (fp, offset, dir); if (result < 0) return EOF; @@ -1148,8 +1147,8 @@ _IO_file_seekoff_maybe_mmap (_IO_FILE *fp, _IO_off64_t offset, int dir, return result; } -_IO_ssize_t -_IO_file_read (_IO_FILE *fp, void *buf, _IO_ssize_t size) +ssize_t +_IO_file_read (FILE *fp, void *buf, ssize_t size) { return (__builtin_expect (fp->_flags2 & _IO_FLAGS2_NOTCANCEL, 0) ? __read_nocancel (fp->_fileno, buf, size) @@ -1157,22 +1156,22 @@ _IO_file_read (_IO_FILE *fp, void *buf, _IO_ssize_t size) } libc_hidden_def (_IO_file_read) -_IO_off64_t -_IO_file_seek (_IO_FILE *fp, _IO_off64_t offset, int dir) +off64_t +_IO_file_seek (FILE *fp, off64_t offset, int dir) { return __lseek64 (fp->_fileno, offset, dir); } libc_hidden_def (_IO_file_seek) int -_IO_file_stat (_IO_FILE *fp, void *st) +_IO_file_stat (FILE *fp, void *st) { return __fxstat64 (_STAT_VER, fp->_fileno, (struct stat64 *) st); } libc_hidden_def (_IO_file_stat) int -_IO_file_close_mmap (_IO_FILE *fp) +_IO_file_close_mmap (FILE *fp) { /* In addition to closing the file descriptor we have to unmap the file. */ (void) __munmap (fp->_IO_buf_base, fp->_IO_buf_end - fp->_IO_buf_base); @@ -1183,7 +1182,7 @@ _IO_file_close_mmap (_IO_FILE *fp) } int -_IO_file_close (_IO_FILE *fp) +_IO_file_close (FILE *fp) { /* Cancelling close should be avoided if possible since it leaves an unrecoverable state behind. */ @@ -1191,14 +1190,14 @@ _IO_file_close (_IO_FILE *fp) } libc_hidden_def (_IO_file_close) -_IO_ssize_t -_IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n) +ssize_t +_IO_new_file_write (FILE *f, const void *data, ssize_t n) { - _IO_ssize_t to_do = n; + ssize_t to_do = n; while (to_do > 0) { - _IO_ssize_t count = (__builtin_expect (f->_flags2 - & _IO_FLAGS2_NOTCANCEL, 0) + ssize_t count = (__builtin_expect (f->_flags2 + & _IO_FLAGS2_NOTCANCEL, 0) ? __write_nocancel (f->_fileno, data, to_do) : __write (f->_fileno, data, to_do)); if (count < 0) @@ -1215,13 +1214,13 @@ _IO_new_file_write (_IO_FILE *f, const void *data, _IO_ssize_t n) return n; } -_IO_size_t -_IO_new_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n) +size_t +_IO_new_file_xsputn (FILE *f, const void *data, size_t n) { const char *s = (const char *) data; - _IO_size_t to_do = n; + size_t to_do = n; int must_flush = 0; - _IO_size_t count = 0; + size_t count = 0; if (n <= 0) return 0; @@ -1261,7 +1260,7 @@ _IO_new_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n) } if (to_do + must_flush > 0) { - _IO_size_t block_size, do_write; + size_t block_size, do_write; /* Next flush the (full) buffer. */ if (_IO_OVERFLOW (f, EOF) == EOF) /* If nothing else has to be written we must not signal the @@ -1290,11 +1289,11 @@ _IO_new_file_xsputn (_IO_FILE *f, const void *data, _IO_size_t n) } libc_hidden_ver (_IO_new_file_xsputn, _IO_file_xsputn) -_IO_size_t -_IO_file_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n) +size_t +_IO_file_xsgetn (FILE *fp, void *data, size_t n) { - _IO_size_t want, have; - _IO_ssize_t count; + size_t want, have; + ssize_t count; char *s = data; want = n; @@ -1356,7 +1355,7 @@ _IO_file_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n) count = want; if (fp->_IO_buf_base) { - _IO_size_t block_size = fp->_IO_buf_end - fp->_IO_buf_base; + size_t block_size = fp->_IO_buf_end - fp->_IO_buf_base; if (block_size >= 128) count -= want % block_size; } @@ -1383,10 +1382,10 @@ _IO_file_xsgetn (_IO_FILE *fp, void *data, _IO_size_t n) } libc_hidden_def (_IO_file_xsgetn) -static _IO_size_t -_IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n) +static size_t +_IO_file_xsgetn_mmap (FILE *fp, void *data, size_t n) { - _IO_size_t have; + size_t have; char *read_ptr = fp->_IO_read_ptr; char *s = (char *) data; @@ -1428,8 +1427,8 @@ _IO_file_xsgetn_mmap (_IO_FILE *fp, void *data, _IO_size_t n) return s - (char *) data; } -static _IO_size_t -_IO_file_xsgetn_maybe_mmap (_IO_FILE *fp, void *data, _IO_size_t n) +static size_t +_IO_file_xsgetn_maybe_mmap (FILE *fp, void *data, size_t n) { /* We only get here if this is the first attempt to read something. Decide which operations to use and then punt to the chosen one. */ |