[3/6] Remove legacy configuration knobs from libio.
Commit Message
This patch eliminates the "compatibility defines"
_IO_UNIFIED_JUMPTABLES (always defined to 1, used in a number of #ifs
which are therefore always false), _STDIO_USES_IOSTREAM (unused),
__HAVE_COLUMN (unused), _IO_BE (replaced with __glibc_unlikely), and
yet another redundant definition of EOF.
* libio/libio.h (_IO_UNIFIED_JUMPTABLES, _STDIO_USES_IOSTREAM)
(__HAVE_COLUMN, _IO_BE): Don't define.
(_IO_peekc_unlocked, _IO_getwc_unlocked, _IO_putwc_unlocked)
(_IO_fwide_maybe_incompatible): Use __glibc_unlikely.
* libio/libioP.h (EOF): Don't define.
* libio/iofdopen.c, libio/iofopen.c, libio/iopopen.c
* libio/iovdprintf.c, libio/oldiofdopen.c, libio/oldiofopen.c
* libio/oldiopopen.c, debug/vdprintf_chk.c: Remove #if block
testing _IO_UNIFIED_JUMPTABLES.
---
debug/vdprintf_chk.c | 3 ---
libio/iofdopen.c | 3 ---
libio/iofopen.c | 3 ---
libio/iopopen.c | 3 ---
libio/iovdprintf.c | 3 ---
libio/libio.h | 36 ++++++++++++++----------------------
libio/libioP.h | 4 ----
libio/oldiofdopen.c | 3 ---
libio/oldiofopen.c | 3 ---
libio/oldiopopen.c | 3 ---
10 files changed, 14 insertions(+), 50 deletions(-)
Comments
On Feb 11 2018, Zack Weinberg <zackw@panix.com> wrote:
> * libio/libio.h (_IO_UNIFIED_JUMPTABLES, _STDIO_USES_IOSTREAM)
> (__HAVE_COLUMN, _IO_BE): Don't define.
> (_IO_peekc_unlocked, _IO_getwc_unlocked, _IO_putwc_unlocked)
> (_IO_fwide_maybe_incompatible): Use __glibc_unlikely.
> * libio/libioP.h (EOF): Don't define.
> * libio/iofdopen.c, libio/iofopen.c, libio/iopopen.c
> * libio/iovdprintf.c, libio/oldiofdopen.c, libio/oldiofopen.c
> * libio/oldiopopen.c, debug/vdprintf_chk.c: Remove #if block
> testing _IO_UNIFIED_JUMPTABLES.
^^^^^^^^^ tab
Ok.
Andreas.
On 11/02/2018 14:35, Zack Weinberg wrote:
> This patch eliminates the "compatibility defines"
> _IO_UNIFIED_JUMPTABLES (always defined to 1, used in a number of #ifs
> which are therefore always false), _STDIO_USES_IOSTREAM (unused),
> __HAVE_COLUMN (unused), _IO_BE (replaced with __glibc_unlikely), and
> yet another redundant definition of EOF.
>
> * libio/libio.h (_IO_UNIFIED_JUMPTABLES, _STDIO_USES_IOSTREAM)
> (__HAVE_COLUMN, _IO_BE): Don't define.
> (_IO_peekc_unlocked, _IO_getwc_unlocked, _IO_putwc_unlocked)
> (_IO_fwide_maybe_incompatible): Use __glibc_unlikely.
> * libio/libioP.h (EOF): Don't define.
> * libio/iofdopen.c, libio/iofopen.c, libio/iopopen.c
> * libio/iovdprintf.c, libio/oldiofdopen.c, libio/oldiofopen.c
> * libio/oldiopopen.c, debug/vdprintf_chk.c: Remove #if block
> testing _IO_UNIFIED_JUMPTABLES.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> debug/vdprintf_chk.c | 3 ---
> libio/iofdopen.c | 3 ---
> libio/iofopen.c | 3 ---
> libio/iopopen.c | 3 ---
> libio/iovdprintf.c | 3 ---
> libio/libio.h | 36 ++++++++++++++----------------------
> libio/libioP.h | 4 ----
> libio/oldiofdopen.c | 3 ---
> libio/oldiofopen.c | 3 ---
> libio/oldiopopen.c | 3 ---
> 10 files changed, 14 insertions(+), 50 deletions(-)
>
> diff --git a/debug/vdprintf_chk.c b/debug/vdprintf_chk.c
> index c195a7951e0..bc713b49628 100644
> --- a/debug/vdprintf_chk.c
> +++ b/debug/vdprintf_chk.c
> @@ -40,9 +40,6 @@ __vdprintf_chk (int d, int flags, const char *format, va_list arg)
> _IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps);
> _IO_JUMPS (&tmpfil) = &_IO_file_jumps;
> _IO_new_file_init_internal (&tmpfil);
> -#if !_IO_UNIFIED_JUMPTABLES
> - tmpfil.vtable = NULL;
> -#endif
> if (_IO_file_attach (&tmpfil.file, d) == NULL)
> {
> _IO_un_link (&tmpfil);
Ok.
> diff --git a/libio/iofdopen.c b/libio/iofdopen.c
> index 39617365f53..21a53e30f6c 100644
> --- a/libio/iofdopen.c
> +++ b/libio/iofdopen.c
> @@ -137,9 +137,6 @@ _IO_new_fdopen (int fd, const char *mode)
> #endif
> &_IO_file_jumps;
> _IO_new_file_init_internal (&new_f->fp);
> -#if !_IO_UNIFIED_JUMPTABLES
> - new_f->fp.vtable = NULL;
> -#endif
> /* We only need to record the fd because _IO_file_init_internal will
> have unset the offset. It is important to unset the cached
> offset because the real offset in the file could change between
Ok.
> diff --git a/libio/iofopen.c b/libio/iofopen.c
> index f17ec914579..ed3e8b853c6 100644
> --- a/libio/iofopen.c
> +++ b/libio/iofopen.c
> @@ -72,9 +72,6 @@ __fopen_internal (const char *filename, const char *mode, int is32)
> _IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps);
> _IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
> _IO_new_file_init_internal (&new_f->fp);
> -#if !_IO_UNIFIED_JUMPTABLES
> - new_f->fp.vtable = NULL;
> -#endif
> if (_IO_file_fopen ((FILE *) new_f, filename, mode, is32) != NULL)
> return __fopen_maybe_mmap (&new_f->fp.file);
>
Ok.
> diff --git a/libio/iopopen.c b/libio/iopopen.c
> index efdd0a6f586..2eff45b4c80 100644
> --- a/libio/iopopen.c
> +++ b/libio/iopopen.c
> @@ -200,9 +200,6 @@ _IO_new_popen (const char *command, const char *mode)
> _IO_init_internal (fp, 0);
> _IO_JUMPS (&new_f->fpx.file) = &_IO_proc_jumps;
> _IO_new_file_init_internal (&new_f->fpx.file);
> -#if !_IO_UNIFIED_JUMPTABLES
> - new_f->fpx.file.vtable = NULL;
> -#endif
> if (_IO_new_proc_open (fp, command, mode) != NULL)
> return (FILE *) &new_f->fpx.file;
> _IO_un_link (&new_f->fpx.file);
Ok.
> diff --git a/libio/iovdprintf.c b/libio/iovdprintf.c
> index 78df2fe559b..78a3a2bd159 100644
> --- a/libio/iovdprintf.c
> +++ b/libio/iovdprintf.c
> @@ -40,9 +40,6 @@ _IO_vdprintf (int d, const char *format, va_list arg)
> _IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps);
> _IO_JUMPS (&tmpfil) = &_IO_file_jumps;
> _IO_new_file_init_internal (&tmpfil);
> -#if !_IO_UNIFIED_JUMPTABLES
> - tmpfil.vtable = NULL;
> -#endif
> if (_IO_file_attach (&tmpfil.file, d) == NULL)
> {
> _IO_un_link (&tmpfil);
Ok.
> diff --git a/libio/libio.h b/libio/libio.h
> index 890b825ed86..a3c679ca666 100644
> --- a/libio/libio.h
> +++ b/libio/libio.h
> @@ -61,9 +61,6 @@ typedef union
> #include <shlib-compat.h>
>
> /* compatibility defines */
> -#define _STDIO_USES_IOSTREAM
> -#define _IO_UNIFIED_JUMPTABLES 1
> -#define __HAVE_COLUMN
> #define _IO_file_flags _flags
>
Ok.
> /* open modes */
> @@ -228,28 +225,23 @@ extern wint_t __wunderflow (FILE *);
> extern wint_t __wuflow (FILE *);
> extern wint_t __woverflow (FILE *, wint_t);
>
> -#if __GNUC__ >= 3
> -# define _IO_BE(expr, res) __builtin_expect ((expr), res)
> -#else
> -# define _IO_BE(expr, res) (expr)
> -#endif
> -
> #define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
> -#define _IO_peekc_unlocked(_fp) \
> - (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
> - && __underflow (_fp) == EOF ? EOF \
> - : *(unsigned char *) (_fp)->_IO_read_ptr)
> +#define _IO_peekc_unlocked(_fp) \
> + (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \
> + && __underflow (_fp) == EOF \
> + ? EOF \
> + : *(unsigned char *) (_fp)->_IO_read_ptr)
> #define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
>
> -# define _IO_getwc_unlocked(_fp) \
> - (_IO_BE ((_fp)->_wide_data == NULL \
> - || ((_fp)->_wide_data->_IO_read_ptr \
> - >= (_fp)->_wide_data->_IO_read_end), 0) \
> +# define _IO_getwc_unlocked(_fp) \
> + (__glibc_unlikely ((_fp)->_wide_data == NULL \
> + || ((_fp)->_wide_data->_IO_read_ptr \
> + >= (_fp)->_wide_data->_IO_read_end)) \
> ? __wuflow (_fp) : (wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
> -# define _IO_putwc_unlocked(_wch, _fp) \
> - (_IO_BE ((_fp)->_wide_data == NULL \
> - || ((_fp)->_wide_data->_IO_write_ptr \
> - >= (_fp)->_wide_data->_IO_write_end), 0) \
> +# define _IO_putwc_unlocked(_wch, _fp) \
> + (__glibc_unlikely ((_fp)->_wide_data == NULL \
> + || ((_fp)->_wide_data->_IO_write_ptr \
> + >= (_fp)->_wide_data->_IO_write_end)) \
> ? __woverflow (_fp, _wch) \
> : (wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
>
Ok.
> @@ -304,7 +296,7 @@ extern int _IO_fwide (FILE *__fp, int __mode) __THROW;
>
> #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
> # define _IO_fwide_maybe_incompatible \
> - (__builtin_expect (&_IO_stdin_used == NULL, 0))
> + (__glibc_unlikely (&_IO_stdin_used == NULL))
> extern const int _IO_stdin_used;
> weak_extern (_IO_stdin_used);
> #else
Ok.
> diff --git a/libio/libioP.h b/libio/libioP.h
> index 57fd60567c7..5064bdf69d4 100644
> --- a/libio/libioP.h
> +++ b/libio/libioP.h
> @@ -690,10 +690,6 @@ extern off64_t _IO_seekoff_unlocked (FILE *, off64_t, int, int)
> extern off64_t _IO_seekpos_unlocked (FILE *, off64_t, int)
> attribute_hidden;
>
> -#ifndef EOF
> -# define EOF (-1)
> -#endif
> -
> #if _G_HAVE_MMAP
>
> # include <unistd.h>
Ok.
> diff --git a/libio/oldiofdopen.c b/libio/oldiofdopen.c
> index be670e8da4d..17930c2786f 100644
> --- a/libio/oldiofdopen.c
> +++ b/libio/oldiofdopen.c
> @@ -102,9 +102,6 @@ _IO_old_fdopen (int fd, const char *mode)
> _IO_old_init (&new_f->fp.file._file, 0);
> _IO_JUMPS_FILE_plus (&new_f->fp) = &_IO_old_file_jumps;
> _IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fp);
> -#if !_IO_UNIFIED_JUMPTABLES
> - new_f->fp.vtable = NULL;
> -#endif
> if (_IO_old_file_attach (&new_f->fp.file._file, fd) == NULL)
> {
> _IO_un_link ((struct _IO_FILE_plus *) &new_f->fp);
Ok.
> diff --git a/libio/oldiofopen.c b/libio/oldiofopen.c
> index f4ead0c1299..f0a67104fb0 100644
> --- a/libio/oldiofopen.c
> +++ b/libio/oldiofopen.c
> @@ -52,9 +52,6 @@ _IO_old_fopen (const char *filename, const char *mode)
> _IO_old_init (&new_f->fp.file._file, 0);
> _IO_JUMPS_FILE_plus (&new_f->fp) = &_IO_old_file_jumps;
> _IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fp);
> -#if !_IO_UNIFIED_JUMPTABLES
> - new_f->fp.vtable = NULL;
> -#endif
> if (_IO_old_file_fopen ((FILE *) &new_f->fp, filename, mode) != NULL)
> return (FILE *) &new_f->fp;
> _IO_un_link ((struct _IO_FILE_plus *) &new_f->fp);
Ok.
> diff --git a/libio/oldiopopen.c b/libio/oldiopopen.c
> index 42cab4e8f77..e47965db0ac 100644
> --- a/libio/oldiopopen.c
> +++ b/libio/oldiopopen.c
> @@ -157,9 +157,6 @@ _IO_old_popen (const char *command, const char *mode)
> _IO_old_init (fp, 0);
> _IO_JUMPS_FILE_plus (&new_f->fpx.file) = &_IO_old_proc_jumps;
> _IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fpx.file);
> -#if !_IO_UNIFIED_JUMPTABLES
> - new_f->fpx.file.vtable = NULL;
> -#endif
> if (_IO_old_proc_open (fp, command, mode) != NULL)
> return fp;
> _IO_un_link ((struct _IO_FILE_plus *) &new_f->fpx.file);
>
Ok.
@@ -40,9 +40,6 @@ __vdprintf_chk (int d, int flags, const char *format, va_list arg)
_IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps);
_IO_JUMPS (&tmpfil) = &_IO_file_jumps;
_IO_new_file_init_internal (&tmpfil);
-#if !_IO_UNIFIED_JUMPTABLES
- tmpfil.vtable = NULL;
-#endif
if (_IO_file_attach (&tmpfil.file, d) == NULL)
{
_IO_un_link (&tmpfil);
@@ -137,9 +137,6 @@ _IO_new_fdopen (int fd, const char *mode)
#endif
&_IO_file_jumps;
_IO_new_file_init_internal (&new_f->fp);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
-#endif
/* We only need to record the fd because _IO_file_init_internal will
have unset the offset. It is important to unset the cached
offset because the real offset in the file could change between
@@ -72,9 +72,6 @@ __fopen_internal (const char *filename, const char *mode, int is32)
_IO_no_init (&new_f->fp.file, 0, 0, &new_f->wd, &_IO_wfile_jumps);
_IO_JUMPS (&new_f->fp) = &_IO_file_jumps;
_IO_new_file_init_internal (&new_f->fp);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
-#endif
if (_IO_file_fopen ((FILE *) new_f, filename, mode, is32) != NULL)
return __fopen_maybe_mmap (&new_f->fp.file);
@@ -200,9 +200,6 @@ _IO_new_popen (const char *command, const char *mode)
_IO_init_internal (fp, 0);
_IO_JUMPS (&new_f->fpx.file) = &_IO_proc_jumps;
_IO_new_file_init_internal (&new_f->fpx.file);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fpx.file.vtable = NULL;
-#endif
if (_IO_new_proc_open (fp, command, mode) != NULL)
return (FILE *) &new_f->fpx.file;
_IO_un_link (&new_f->fpx.file);
@@ -40,9 +40,6 @@ _IO_vdprintf (int d, const char *format, va_list arg)
_IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps);
_IO_JUMPS (&tmpfil) = &_IO_file_jumps;
_IO_new_file_init_internal (&tmpfil);
-#if !_IO_UNIFIED_JUMPTABLES
- tmpfil.vtable = NULL;
-#endif
if (_IO_file_attach (&tmpfil.file, d) == NULL)
{
_IO_un_link (&tmpfil);
@@ -61,9 +61,6 @@ typedef union
#include <shlib-compat.h>
/* compatibility defines */
-#define _STDIO_USES_IOSTREAM
-#define _IO_UNIFIED_JUMPTABLES 1
-#define __HAVE_COLUMN
#define _IO_file_flags _flags
/* open modes */
@@ -228,28 +225,23 @@ extern wint_t __wunderflow (FILE *);
extern wint_t __wuflow (FILE *);
extern wint_t __woverflow (FILE *, wint_t);
-#if __GNUC__ >= 3
-# define _IO_BE(expr, res) __builtin_expect ((expr), res)
-#else
-# define _IO_BE(expr, res) (expr)
-#endif
-
#define _IO_getc_unlocked(_fp) __getc_unlocked_body (_fp)
-#define _IO_peekc_unlocked(_fp) \
- (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \
- && __underflow (_fp) == EOF ? EOF \
- : *(unsigned char *) (_fp)->_IO_read_ptr)
+#define _IO_peekc_unlocked(_fp) \
+ (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \
+ && __underflow (_fp) == EOF \
+ ? EOF \
+ : *(unsigned char *) (_fp)->_IO_read_ptr)
#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
-# define _IO_getwc_unlocked(_fp) \
- (_IO_BE ((_fp)->_wide_data == NULL \
- || ((_fp)->_wide_data->_IO_read_ptr \
- >= (_fp)->_wide_data->_IO_read_end), 0) \
+# define _IO_getwc_unlocked(_fp) \
+ (__glibc_unlikely ((_fp)->_wide_data == NULL \
+ || ((_fp)->_wide_data->_IO_read_ptr \
+ >= (_fp)->_wide_data->_IO_read_end)) \
? __wuflow (_fp) : (wint_t) *(_fp)->_wide_data->_IO_read_ptr++)
-# define _IO_putwc_unlocked(_wch, _fp) \
- (_IO_BE ((_fp)->_wide_data == NULL \
- || ((_fp)->_wide_data->_IO_write_ptr \
- >= (_fp)->_wide_data->_IO_write_end), 0) \
+# define _IO_putwc_unlocked(_wch, _fp) \
+ (__glibc_unlikely ((_fp)->_wide_data == NULL \
+ || ((_fp)->_wide_data->_IO_write_ptr \
+ >= (_fp)->_wide_data->_IO_write_end)) \
? __woverflow (_fp, _wch) \
: (wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
@@ -304,7 +296,7 @@ extern int _IO_fwide (FILE *__fp, int __mode) __THROW;
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
# define _IO_fwide_maybe_incompatible \
- (__builtin_expect (&_IO_stdin_used == NULL, 0))
+ (__glibc_unlikely (&_IO_stdin_used == NULL))
extern const int _IO_stdin_used;
weak_extern (_IO_stdin_used);
#else
@@ -690,10 +690,6 @@ extern off64_t _IO_seekoff_unlocked (FILE *, off64_t, int, int)
extern off64_t _IO_seekpos_unlocked (FILE *, off64_t, int)
attribute_hidden;
-#ifndef EOF
-# define EOF (-1)
-#endif
-
#if _G_HAVE_MMAP
# include <unistd.h>
@@ -102,9 +102,6 @@ _IO_old_fdopen (int fd, const char *mode)
_IO_old_init (&new_f->fp.file._file, 0);
_IO_JUMPS_FILE_plus (&new_f->fp) = &_IO_old_file_jumps;
_IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fp);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
-#endif
if (_IO_old_file_attach (&new_f->fp.file._file, fd) == NULL)
{
_IO_un_link ((struct _IO_FILE_plus *) &new_f->fp);
@@ -52,9 +52,6 @@ _IO_old_fopen (const char *filename, const char *mode)
_IO_old_init (&new_f->fp.file._file, 0);
_IO_JUMPS_FILE_plus (&new_f->fp) = &_IO_old_file_jumps;
_IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fp);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fp.vtable = NULL;
-#endif
if (_IO_old_file_fopen ((FILE *) &new_f->fp, filename, mode) != NULL)
return (FILE *) &new_f->fp;
_IO_un_link ((struct _IO_FILE_plus *) &new_f->fp);
@@ -157,9 +157,6 @@ _IO_old_popen (const char *command, const char *mode)
_IO_old_init (fp, 0);
_IO_JUMPS_FILE_plus (&new_f->fpx.file) = &_IO_old_proc_jumps;
_IO_old_file_init_internal ((struct _IO_FILE_plus *) &new_f->fpx.file);
-#if !_IO_UNIFIED_JUMPTABLES
- new_f->fpx.file.vtable = NULL;
-#endif
if (_IO_old_proc_open (fp, command, mode) != NULL)
return fp;
_IO_un_link ((struct _IO_FILE_plus *) &new_f->fpx.file);