Post-cleanup 1: move libio.h back out of bits/.

We can't go very far with libio cleanups as long as we still have
_IO_MTSAFE_IO, and I am not tackling that in this patch series,
but we can at least make the maze of stdio-related headers a
little less complicated.

In this patch, libio.h moves back out of bits/ into the top level of
the libio subdirectory, and is merged with libio/bits/libio-ldbl.h
(which also used to be installed) and include/libio.h.  Since almost
no files include libio.h directly, this is quite straightforward.

libio.h is now always used with _LIBC defined, so all of the _LIBC ||
_GLIBCPP_USE_WCHAR_T conditionals are unnecessary.  Similarly, the
ifdef nest surrounding the definition of _IO_fwide_maybe_incompatible
can collapse down to a single SHLIB_COMPAT check.  I also took the
opportunity to add some checks for configuration botches to libio.h.

Installed stripped libraries are unchanged by this patch.

        * libio/bits/libio.h: Move back to libio/libio.h and adjust
        multiple-include guard to match.
        Merge contents of libio/bits/libio-ldbl.h and include/libio.h
        into this file.
        Remove preprocessor conditionals that are always true and/or
        redundant to other preprocessor conditionals in the same nest.
        Include shlib-compat.h unconditionally.
        Error out if _LIBC is not defined, or if _ISOMAC is defined,
        or if _IO_MTSAFE_IO is defined but _IO_lock_t_defined is not
        defined after including stdio.h.
        Use __BEGIN_DECLS/__END_DECLS.

        * libio/bits/libio-ldbl.h, include/bits/libio.h: Delete file.
        * include/stdio.h, libio/iolibio.h, libio/libioP.h: Include
        libio.h as <libio/libio.h> rather than as <bits/libio.h>.
This commit is contained in:
Zack Weinberg 2018-02-05 13:09:15 -05:00
parent a4fea3f2c3
commit 6c6c962a20
7 changed files with 93 additions and 118 deletions

View File

@ -1,3 +1,21 @@
2018-02-07 Zack Weinberg <zackw@panix.com>
* libio/bits/libio.h: Move back to libio/libio.h and adjust
multiple-include guard to match.
Merge contents of libio/bits/libio-ldbl.h and include/libio.h
into this file.
Remove preprocessor conditionals that are always true and/or
redundant to other preprocessor conditionals in the same nest.
Include shlib-compat.h unconditionally.
Error out if _LIBC is not defined, or if _ISOMAC is defined,
or if _IO_MTSAFE_IO is defined but _IO_lock_t_defined is not
defined after including stdio.h.
Use __BEGIN_DECLS/__END_DECLS.
* libio/bits/libio-ldbl.h, include/bits/libio.h: Delete file.
* include/stdio.h, libio/iolibio.h, libio/libioP.h: Include
libio.h as <libio/libio.h> rather than as <bits/libio.h>.
2018-02-07 Zack Weinberg <zackw@panix.com>
* libio/bits/types/__fpos_t.h, libio/bits/types/__fpos64_t.h:
@ -22,14 +40,14 @@
and _IO_cookie_io_functions_t as cookie_io_functions_t.
Define _STDIO_USES_IOSTREAM, __HAVE_COLUMN, and _IO_file_flags
here, in the "compatibility defines" section. Remove an #if 0
block. Use the "body" macros from bits/types/struct_FILE.h to
block. Use the "body" macros from bits/types/struct_FILE.h to
define _IO_getc_unlocked, _IO_putc_unlocked, _IO_feof_unlocked,
and _IO_ferror_unlocked.
Move prototypes of __uflow and __overflow...
* libio/stdio.h: ...here. Don't include bits/libio.h.
Don't define _STDIO_USES_IOSTREAM. Get __gnuc_va_list
directly from stdarg.h. Include bits/types/__fpos_t.h,
directly from stdarg.h. Include bits/types/__fpos_t.h,
bits/types/__fpos64_t.h, bits/types/struct_FILE.h,
and, when __USE_GNU, bits/types/cookie_io_functions_t.h.
Use __gnuc_va_list, not _G_va_list; __fpos_t, not _G_fpos_t;
@ -49,19 +67,18 @@
* libio/libioP.h: Add multiple-include guard.
Include stdio.h and bits/libio.h before iolibio.h.
* include/bits/types/__fpos_t.h, include/bits/types/__fpos64_t.h
* include/bits/types/__fpos_t.h, include/bits/types/__fpos64_t.h
* include/bits/types/cookie_io_functions_t.h
* include/bits/types/struct_FILE.h: New wrappers.
* bits/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h:
Get definitions of _G_fpos_t and _G_fpos64_t from
bits/types/__fpos_t.h and bits/types/__fpos64_t.h
respectively. Remove improper-inclusion guards.
Get definitions of _G_fpos_t and _G_fpos64_t from
bits/types/__fpos_t.h and bits/types/__fpos64_t.h
respectively. Remove improper-inclusion guards.
* conform/data/stdio.h-data: Update expectations of va_list.
* conform/data/stdio.h-data: Update expectations of va_list.
* scripts/check-installed-headers.sh: Remove special case for
libio.h and _G_config.h.
libio.h and _G_config.h.
2018-02-07 Joseph Myers <joseph@codesourcery.com>

View File

@ -1,45 +0,0 @@
#if !defined _ISOMAC && defined _IO_MTSAFE_IO
# include <stdio-lock.h>
#endif
#include <libio/bits/libio.h>
#ifndef _ISOMAC
#ifndef _LIBC_LIBIO_H
#define _LIBC_LIBIO_H
libc_hidden_proto (__overflow)
libc_hidden_proto (__underflow)
libc_hidden_proto (__uflow)
libc_hidden_proto (__woverflow)
libc_hidden_proto (__wunderflow)
libc_hidden_proto (__wuflow)
libc_hidden_proto (_IO_free_backup_area)
libc_hidden_proto (_IO_free_wbackup_area)
libc_hidden_proto (_IO_padn)
libc_hidden_proto (_IO_putc)
libc_hidden_proto (_IO_sgetn)
libc_hidden_proto (_IO_vfprintf)
libc_hidden_proto (_IO_vfscanf)
#ifdef _IO_MTSAFE_IO
# undef _IO_peekc
# undef _IO_flockfile
# undef _IO_funlockfile
# undef _IO_ftrylockfile
# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
# if _IO_lock_inexpensive
# define _IO_flockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_lock (*(_fp)->_lock)
# define _IO_funlockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_unlock (*(_fp)->_lock)
# else
# define _IO_flockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
# define _IO_funlockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
# endif
#endif /* _IO_MTSAFE_IO */
#endif
#endif

View File

@ -5,7 +5,7 @@
# include <libio/stdio.h>
# ifndef _ISOMAC
# define _LIBC_STDIO_H 1
# include <bits/libio.h>
# include <libio/libio.h>
/* Now define the internal interfaces. */

View File

@ -1,29 +0,0 @@
/* -mlong-double-64 compatibility mode for libio functions.
Copyright (C) 2006-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _BITS_LIBIO_LDBL_H
#define _BITS_LIBIO_LDBL_H 1
#ifndef _BITS_LIBIO_H
# error "Never include <bits/libio-ldbl.h> directly; use <libio.h> instead."
#endif
__LDBL_REDIR_DECL (_IO_vfscanf)
__LDBL_REDIR_DECL (_IO_vfprintf)
#endif

View File

@ -2,7 +2,7 @@
#define _IOLIBIO_H 1
#include <stdio.h>
#include <bits/libio.h>
#include <libio/libio.h>
/* These emulate stdio functionality, but with a different name
(_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */

View File

@ -25,11 +25,22 @@
This exception applies to code released by its copyright holders
in files containing the exception. */
#ifndef _BITS_LIBIO_H
#define _BITS_LIBIO_H 1
#ifndef _LIBIO_H
#define _LIBIO_H 1
#ifndef _LIBC
# error "libio.h should only be included when building glibc itself"
#endif
#ifdef _ISOMAC
# error "libio.h should not be included under _ISOMAC"
#endif
#include <stdio.h>
#if defined _IO_MTSAFE_IO && !defined _IO_lock_t_defined
# error "Someone forgot to include stdio-lock.h"
#endif
#include <bits/_G_config.h>
/* ALL of these should be defined in _G_config.h */
#define _IO_fpos_t __fpos_t
@ -46,6 +57,10 @@
#define _IO_wint_t wint_t
#define _IO_va_list __gnuc_va_list
#include <shlib-compat.h>
__BEGIN_DECLS
/* compatibility defines */
#define _STDIO_USES_IOSTREAM
#define _IO_UNIFIED_JUMPTABLES 1
@ -143,7 +158,6 @@ enum __codecvt_result
__codecvt_noconv
};
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
/* The order of the elements in the following struct must match the order
of the virtual functions in the libstdc++ codecvt class. */
struct _IO_codecvt
@ -198,7 +212,6 @@ struct _IO_wide_data
const struct _IO_jump_t *_wide_vtable;
};
#endif
#ifndef __cplusplus
@ -236,17 +249,10 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write,
void *__cookie, _IO_cookie_io_functions_t __fns);
#endif
#ifdef __cplusplus
extern "C" {
#endif
extern int __underflow (_IO_FILE *);
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
extern _IO_wint_t __wunderflow (_IO_FILE *);
extern _IO_wint_t __wuflow (_IO_FILE *);
extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
#endif
#if __GNUC__ >= 3
# define _IO_BE(expr, res) __builtin_expect ((expr), res)
@ -261,7 +267,6 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
: *(unsigned char *) (_fp)->_IO_read_ptr)
#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp)
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
# define _IO_getwc_unlocked(_fp) \
(_IO_BE ((_fp)->_wide_data == NULL \
|| ((_fp)->_wide_data->_IO_read_ptr \
@ -273,7 +278,6 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t);
>= (_fp)->_wide_data->_IO_write_end), 0) \
? __woverflow (_fp, _wch) \
: (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch)))
#endif
#define _IO_feof_unlocked(_fp) __feof_unlocked_body (_fp)
#define _IO_ferror_unlocked(_fp) __ferror_unlocked_body (_fp)
@ -319,28 +323,25 @@ extern _IO_off64_t _IO_seekpos (_IO_FILE *, _IO_off64_t, int);
extern void _IO_free_backup_area (_IO_FILE *) __THROW;
#if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T
extern _IO_wint_t _IO_getwc (_IO_FILE *__fp);
extern _IO_wint_t _IO_putwc (wchar_t __wc, _IO_FILE *__fp);
extern int _IO_fwide (_IO_FILE *__fp, int __mode) __THROW;
# if __GNUC__ >= 2
/* While compiling glibc we have to handle compatibility with very old
versions. */
# if defined _LIBC && defined SHARED
# include <shlib-compat.h>
# if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
# define _IO_fwide_maybe_incompatible \
#if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_1)
# define _IO_fwide_maybe_incompatible \
(__builtin_expect (&_IO_stdin_used == NULL, 0))
extern const int _IO_stdin_used;
weak_extern (_IO_stdin_used);
# endif
# endif
# ifndef _IO_fwide_maybe_incompatible
# define _IO_fwide_maybe_incompatible (0)
# endif
#else
# define _IO_fwide_maybe_incompatible (0)
#endif
/* A special optimized version of the function above. It optimizes the
case of initializing an unoriented byte stream. */
# define _IO_fwide(__fp, __mode) \
#define _IO_fwide(__fp, __mode) \
({ int __result = (__mode); \
if (__result < 0 && ! _IO_fwide_maybe_incompatible) \
{ \
@ -354,7 +355,6 @@ weak_extern (_IO_stdin_used);
else \
__result = _IO_fwide (__fp, __result); \
__result; })
# endif
extern int _IO_vfwscanf (_IO_FILE * __restrict, const wchar_t * __restrict,
_IO_va_list, int *__restrict);
@ -362,14 +362,46 @@ extern int _IO_vfwprintf (_IO_FILE *__restrict, const wchar_t *__restrict,
_IO_va_list);
extern _IO_ssize_t _IO_wpadn (_IO_FILE *, wint_t, _IO_ssize_t);
extern void _IO_free_wbackup_area (_IO_FILE *) __THROW;
#endif
#ifdef __LDBL_COMPAT
# include <bits/libio-ldbl.h>
__LDBL_REDIR_DECL (_IO_vfscanf)
__LDBL_REDIR_DECL (_IO_vfprintf)
#endif
#ifdef __cplusplus
}
#endif
libc_hidden_proto (__overflow)
libc_hidden_proto (__underflow)
libc_hidden_proto (__uflow)
libc_hidden_proto (__woverflow)
libc_hidden_proto (__wunderflow)
libc_hidden_proto (__wuflow)
libc_hidden_proto (_IO_free_backup_area)
libc_hidden_proto (_IO_free_wbackup_area)
libc_hidden_proto (_IO_padn)
libc_hidden_proto (_IO_putc)
libc_hidden_proto (_IO_sgetn)
libc_hidden_proto (_IO_vfprintf)
libc_hidden_proto (_IO_vfscanf)
#endif /* _BITS_LIBIO_H */
#ifdef _IO_MTSAFE_IO
# undef _IO_peekc
# undef _IO_flockfile
# undef _IO_funlockfile
# undef _IO_ftrylockfile
# define _IO_peekc(_fp) _IO_peekc_locked (_fp)
# if _IO_lock_inexpensive
# define _IO_flockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_lock (*(_fp)->_lock)
# define _IO_funlockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_lock_unlock (*(_fp)->_lock)
# else
# define _IO_flockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_flockfile (_fp)
# define _IO_funlockfile(_fp) \
if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp)
# endif
#endif /* _IO_MTSAFE_IO */
__END_DECLS
#endif /* _LIBIO_H */

View File

@ -43,7 +43,7 @@
#include <math_ldbl_opt.h>
#include <stdio.h>
#include <bits/libio.h>
#include <libio/libio.h>
#include "iolibio.h"
#ifdef __cplusplus