This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: [PATCH 6/6] Remove completely unused libio flag bits.
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: Zack Weinberg <zackw at panix dot com>, libc-alpha at sourceware dot org
- Cc: fweimer at redhat dot com
- Date: Mon, 12 Feb 2018 09:40:50 -0200
- Subject: Re: [PATCH 6/6] Remove completely unused libio flag bits.
- Authentication-results: sourceware.org; auth=none
- References: <20180211163558.14124-1-zackw@panix.com> <20180211163558.14124-7-zackw@panix.com>
On 11/02/2018 14:35, Zack Weinberg wrote:
> These macros are used literally nowhere in the source tree, and all
> of them appear to relate to the C++ functionality of the original
> libio that never got taken into glibc in the first place. I also
> reformatted the first set of flags to make it really obvious which
> bits are not used (there's one bit that never gets set by current
> code but might get set by old code).
>
> This is as far as I propose to go in this patchset. The next most
> pressing changes are to eliminate _IO_MTSAFE_IO and to start removing
> support for deprecated-but-exported _IO_ symbols, and both of those I
> believe Florian has already been working on, so I'll leave them to
> him.
>
> * libio/libio.h (_IOS_ATEND, _IOS_APPEND, _IOS_TRUNC)
> (_IOS_NOCREATE, _IOS_NOREPLACE, _IOS_BIN, _OLD_STDIO_MAGIC)
> (_IO_SKIPWS, _IO_LEFT, _IO_RIGHT, _IO_INTERNAL, _IO_DEC)
> (_IO_OCT, _IO_HEX, _IO_SHOWBASE, _IO_SHOWPOINT, _IO_UPPERCASE)
> (_IO_SHOWPOS, _IO_SCIENTIFIC, _IO_FIXED, _IO_UNITBUF, _IO_STDIO)
> (_IO_DONT_CLOSE, _IO_BOOLALPHA): Remove, unused.
> (_IO_BAD_SEEN): Comment out but leave as documentation.
> Reformat bit flags for _flags field to make occupancy clearer.
> Update commentary.
> * libio/bits/types/struct_FILE.h (_IO_EOF_SEEN, _IO_ERR_SEEN):
> Keep definitions consistent with those in libio/libio.h.
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
> ---
> libio/bits/types/struct_FILE.h | 4 +--
> libio/libio.h | 77 ++++++++++++++----------------------------
> 2 files changed, 27 insertions(+), 54 deletions(-)
>
> diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h
> index a120c762685..359f9494534 100644
> --- a/libio/bits/types/struct_FILE.h
> +++ b/libio/bits/types/struct_FILE.h
> @@ -108,10 +108,10 @@ struct _IO_FILE_complete
> ? __overflow (_fp, (unsigned char) (_ch)) \
> : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch)))
>
> -#define _IO_EOF_SEEN 0x10
> +#define _IO_EOF_SEEN 0x0010
> #define __feof_unlocked_body(_fp) (((_fp)->_flags & _IO_EOF_SEEN) != 0)
>
> -#define _IO_ERR_SEEN 0x20
> +#define _IO_ERR_SEEN 0x0020
> #define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0)
>
> #define _IO_USER_LOCK 0x8000
Ok.
> diff --git a/libio/libio.h b/libio/libio.h
> index 1371161e025..b25e583a794 100644
> --- a/libio/libio.h
> +++ b/libio/libio.h
> @@ -60,42 +60,34 @@ typedef union
>
> #include <shlib-compat.h>
>
> -/* open modes */
> +/* _IO_seekoff modes */
> #define _IOS_INPUT 1
> #define _IOS_OUTPUT 2
> -#define _IOS_ATEND 4
> -#define _IOS_APPEND 8
> -#define _IOS_TRUNC 16
> -#define _IOS_NOCREATE 32
> -#define _IOS_NOREPLACE 64
> -#define _IOS_BIN 128
> -
> -/* Magic numbers and bits for the _flags field.
> - The magic numbers use the high-order bits of _flags;
> - the remaining bits are available for variable flags.
> - Note: The magic numbers must all be negative if stdio
> - emulation is desired. */
> -
> -#define _IO_MAGIC 0xFBAD0000 /* Magic number */
> -#define _OLD_STDIO_MAGIC 0xFABC0000 /* Emulate old stdio. */
> -#define _IO_MAGIC_MASK 0xFFFF0000
> -#define _IO_USER_BUF 1 /* User owns buffer; don't delete it on close. */
> -#define _IO_UNBUFFERED 2
> -#define _IO_NO_READS 4 /* Reading not allowed */
> -#define _IO_NO_WRITES 8 /* Writing not allowd */
> -#define _IO_EOF_SEEN 0x10
> -#define _IO_ERR_SEEN 0x20
> -#define _IO_DELETE_DONT_CLOSE 0x40 /* Don't call close(_fileno) on cleanup. */
> -#define _IO_LINKED 0x80 /* Set if linked (using _chain) to streambuf::_list_all.*/
> -#define _IO_IN_BACKUP 0x100
> -#define _IO_LINE_BUF 0x200
> -#define _IO_TIED_PUT_GET 0x400 /* Set if put and get pointer logicly tied. */
> -#define _IO_CURRENTLY_PUTTING 0x800
> -#define _IO_IS_APPENDING 0x1000
> -#define _IO_IS_FILEBUF 0x2000
> -#define _IO_BAD_SEEN 0x4000
> -#define _IO_USER_LOCK 0x8000
>
> +/* Magic number and bits for the _flags field. The magic number is
> + mostly vestigial, but preserved for compatibility. It occupies the
> + high 16 bits of _flags; the low 16 bits are actual flag bits. */
> +
> +#define _IO_MAGIC 0xFBAD0000 /* Magic number */
> +#define _IO_MAGIC_MASK 0xFFFF0000
> +#define _IO_USER_BUF 0x0001 /* Don't deallocate buffer on close. */
> +#define _IO_UNBUFFERED 0x0002
> +#define _IO_NO_READS 0x0004 /* Reading not allowed. */
> +#define _IO_NO_WRITES 0x0008 /* Writing not allowed. */
> +#define _IO_EOF_SEEN 0x0010
> +#define _IO_ERR_SEEN 0x0020
> +#define _IO_DELETE_DONT_CLOSE 0x0040 /* Don't call close(_fileno) on close. */
> +#define _IO_LINKED 0x0080 /* In the list of all open files. */
> +#define _IO_IN_BACKUP 0x0100
> +#define _IO_LINE_BUF 0x0200
> +#define _IO_TIED_PUT_GET 0x0400 /* Put and get pointer move in unison. */
> +#define _IO_CURRENTLY_PUTTING 0x0800
> +#define _IO_IS_APPENDING 0x1000
> +#define _IO_IS_FILEBUF 0x2000
> +/*#define _IO_BAD_SEEN 0x4000 No longer used, reserved for compat. */
There is no need to comment _IO_BAD_SEEN (and it add some confusion why it is
commented).
> +#define _IO_USER_LOCK 0x8000
> +
> +/* Bits for the _flags2 field. */
> #define _IO_FLAGS2_MMAP 1
> #define _IO_FLAGS2_NOTCANCEL 2
> #define _IO_FLAGS2_FORTIFY 4
> @@ -105,25 +97,6 @@ typedef union
> #define _IO_FLAGS2_CLOEXEC 64
> #define _IO_FLAGS2_NEED_LOCK 128
>
> -/* These are "formatting flags" matching the iostream fmtflags enum values. */
> -#define _IO_SKIPWS 01
> -#define _IO_LEFT 02
> -#define _IO_RIGHT 04
> -#define _IO_INTERNAL 010
> -#define _IO_DEC 020
> -#define _IO_OCT 040
> -#define _IO_HEX 0100
> -#define _IO_SHOWBASE 0200
> -#define _IO_SHOWPOINT 0400
> -#define _IO_UPPERCASE 01000
> -#define _IO_SHOWPOS 02000
> -#define _IO_SCIENTIFIC 04000
> -#define _IO_FIXED 010000
> -#define _IO_UNITBUF 020000
> -#define _IO_STDIO 040000
> -#define _IO_DONT_CLOSE 0100000
> -#define _IO_BOOLALPHA 0200000
> -
> /* _IO_pos_BAD is an off64_t value indicating error, unknown, or EOF. */
> #define _IO_pos_BAD ((off64_t) -1)
>
>
Ok.