summaryrefslogtreecommitdiff
path: root/libio/bits/stdio2.h
diff options
context:
space:
mode:
authorZack Weinberg <zackw@panix.com>2017-04-20 11:21:30 -0400
committerZack Weinberg <zackw@panix.com>2017-06-20 20:33:19 -0400
commitbdf5e4f8bdd50e276b9ed77181087312da849ec2 (patch)
tree63af5c5367e087dfc0e334ef4f1032d8ffea5c78 /libio/bits/stdio2.h
parentdf1fabcb39fddbe0a26a0d3f2cefba541d78cb25 (diff)
downloadglibc-zack/headers-cleanups.tar.gz
Don't install libio.h or _G_config.h.zack/headers-cleanups
This is an experimental patch which removes libio.h (and _G_config.h) from the set of application-exposed headers. After this change, the public stdio.h does not define any symbols whose names begin with _G_ nor _IO_, except that when optimizing, the guts of struct _IO_FILE and three of the flag constants are visible (see bits/stdio.h and bits/types/FILE_internals.h). There is a small amount of code duplication in bits/stdio.h, of macro bodies from libio.h that are no longer available. A number of internal .c files that were manually doing PLT bypass for flockfile/funlockfile can now rely on include/stdio.h to do it for them. It passes the testsuite on x86_64-linux, but it needs a great deal of additional testing; in particular I'm almost certain I broke the support for old-format (GLIBC_2.0) struct _IO_FILE, which is configured out on this target. Testing this properly would require someone to get their hands on _really_ old binaries, compiled against glibc 2.0, possibly statically-linked-but-using-NSS. Unfortunately, libc.so cannot be expected to be binary identical. However, this should be ready to feed into archive rebuilds to find out what applications break. Substantial clean-ups to the libio implementation are possible if this sticks, but I haven't done 'em; this is intended to be minimal. * libio/Makefile: Don't install libio.h or _G_config.h. Do install bits/types/FILE_internals.h, bits/types/cookie_io_functions_t.h, and bits/types/__fpos_t.h. * libio/stdio.h: Don't include libio.h. Get __gnuc_va_list directly from stdarg.h, __fpos_t and __fpos64_t from bits/types/__fpos_t.h, and the cookie types from bits/types/cookie_io_functions_t.h. Change all uses of _G_va_list, _G_fpos_t, _G_fpos64_t, _IO_FILE, _IO_cookie_io_functions_t, and _IO_ssize_t to __gnuc_va_list, __fpos_t, __fpos64_t, FILE, cookie_io_functions_t, and __ssize_t respectively. Do not define getc nor putc as macros. Define BUFSIZ as literal 8192. * libio/bits/types/FILE_internals.h: New header. Provide complete definition of struct _IO_FILE (the complete version) here. Duplicate definitions of _IO_EOF_SEEN, _IO_ERR_SEEN, and _IO_USER_LOCK here, with value assertions if they are already defined. * libio/bits/types/__fpos_t.h: New header. Define __fpos_t and __fpos64_t here. * libio/bits/types/cookie_io_functions_t.h: New header. Define cookie_read_function_t, cookie_write_function_t, cookie_seek_function_t, cookie_close_function_t, and cookie_io_functions_t here. * libio/libio.h: Include features.h first thing, then error out if either _LIBC or __USE_GNU is not defined, or if _ISOMAC is defined. Inline all of _G_config.h except _G_HAVE_MREMAP here. Get definitions of __mbstate_t, __fpos_t, __fpos64_t, struct _IO_FILE, and the cookie-related types from the relevant bits/types headers. Get definition of NULL from stddef.h. Make all #ifdef _LIBC and #if __GNUC__ >= (2,3) blocks unconditional. Remove all #if 0 and #ifdef __cplusplus blocks. Change all uses of _G_va_list, _G_fpos_t, and _G_fpos64_t to __gnuc_va_list, __fpos_t, __fpos64_t respectively. Provide definitions of _STDIO_USES_IOSTREAM, __HAVE_COLUMN, _IO_file_flags, __io_read_fn, __io_write_fn, __io_seek_fn, __io_close_fn, _IO_cookie_io_functions_t for the sake of the implementation. When _IO_USE_OLD_IO_FILE is defined, define struct _IO_FILE_old. * libio/libioP.h: When _IO_USE_OLD_IO_FILE is defined, define struct _IO_FILE_old_plus. Only declare _IO_old_file_init_internal when _IO_USE_OLD_IO_FILE is defined, and have it take an argument of type struct _IO_FILE_old_plus. * libio/oldfileops.c: Change all uses of _IO_FILE to _IO_FILE_old, _IO_FILE_plus to _IO_FILE_old_plus, _IO_FILE_complete to _IO_FILE, and _IO_FILE_complete_plus to _IO_FILE_plus. Then adjust types to match caller/callee's expectations. * libio/oldiofdopen.c, libio/oldiofopen.c, libio/oldiopopen.c * libio/oldstdfiles.c: Likewise. * sysdeps/generic/_G_config.h, sysdeps/unix/sysv/linux/_G_config.h: Only provide definition or non-definition of _G_HAVE_MREMAP. * sysdeps/ieee754/ldbl-opt/nldbl-iovfscanf.c: Delete file. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Remove iovfscanf. * sysdeps/ieee754/ldbl-opt/nldbl-compat.c: Define __nldbl__IO_vsprintf as alias to __nldbl_vsprintf instead of the other way around. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h: Change all uses of _G_va_list to __gnuc_va_list. Remove NLDBL_DECL for _IO_vfscanf. * sysdeps/ieee754/ldbl-opt/nldbl-fscanf.c * sysdeps/ieee754/ldbl-opt/nldbl-scanf.c * sysdeps/ieee754/ldbl-opt/nldbl-vfscanf.c * sysdeps/ieee754/ldbl-opt/nldbl-vscanf.c: Use __nldbl_vfscanf, not __nldbl__IO_vfscanf. * libio/bits/stdio.h: Add multiple-inclusion guard. Include bits/types/FILE_internals.h. Declare __uflow and __overflow here. Remove redundant __USE_EXTERN_INLINES ifdef. Change all uses of _G_va_list to __gnuc_va_list and _IO_ssize_t to __ssize_t. (getchar): Use getc, not _IO_getc. (__getc_unlocked, __putc_unlocked): New inlines, duplicating the bodies of _IO_getc_unlocked and _IO_putc_unlocked. (fgetc_unlocked, getc_unlocked, getchar_unlocked, fread_unlocked): Use __getc_unlocked. (fputc_unlocked, putc_unlocked, putchar_unlocked, fwrite_unlocked): Use __putc_unlocked. (feof_unlocked): Duplicate the body of _IO_feof_unlocked here. (ferror_unlocked): Duplicate the body of _IO_ferror_unlocked here. * libio/bits/stdio2.h: Change all uses of _G_va_list to __gnuc_va_list. (fread_unlocked): Use __getc_unlocked. * libio/bits/types/FILE.h, libio/bits/types/__FILE.h: Explain in comments why the name _IO_FILE is used. * include/stdio.h: Change all uses of _G_va_list to __gnuc_va_list, _IO_ssize_t to __size_t, _IO_FILE to FILE, and _IO_fpos_t to __fpos_t. When IS_IN (libc), redirect flockfile and funlockfile to __flockfile and __funlockfile respectively. When _IO_MTSAFE_IO and not _ISOMAC, include stdio-lock.h before stdio.h proper. * include/stdio_ext.h: Include bits/types/FILE_internals.h for the sake of the inline definition of __fsetlocking. * include/libio.h: Adjust #ifdef nest to activate multiple-include optimization. * include/bits/types/FILE_internals.h, include/bits/types/__fpos_t.h * include/bits/types/cookie_io_functions_t.h: New trivial wrappers. * include/bits/stdio.h: New wrapper; mark __uflow and __overflow as hidden for intra-libc callers. * csu/init.c: Include libio.h, not _G_config.h. * grp/fgetgrent_r.c, grp/putgrent.c, gshadow/fgetsgent_r.c * gshadow/putsgent.c, misc/getpass.c, misc/getttyent.c * misc/mntent_r.c, posix/getopt.c, pwd/fgetpwent_r.c * shadow/fgetspent_r.c, shadow/putspent.c: Don't include libio/iolibio.h. Don't redefine flockfile or funlockfile. Don't use _IO_flockfile or _IO_funlockfile. * libio/__fbufsize.c, libio/__flbf.c, libio/__fpending.c * libio/__freadable.c, libio/__freading.c, libio/__fwritable.c * libio/__fwriting.c, malloc/malloc.c: Include libio.h. * misc/err.c: Include libio.h. Don't redefine flockfile or funlockfile. * stdio-common/tstgetln.c: Include sys/types.h. Don't redefine ssize_t. * conform/data/stdio.h-data: va_list may be defined as __gnuc_va_list, not _G_va_list. * benchtests/strcoll-inputs/filelist#en_US.UTF-8: Remove _G_config.h.
Diffstat (limited to 'libio/bits/stdio2.h')
-rw-r--r--libio/bits/stdio2.h31
1 files changed, 16 insertions, 15 deletions
diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h
index e9f9d6952b..2d5cb5c03d 100644
--- a/libio/bits/stdio2.h
+++ b/libio/bits/stdio2.h
@@ -24,7 +24,7 @@ extern int __sprintf_chk (char *__restrict __s, int __flag, size_t __slen,
const char *__restrict __format, ...) __THROW;
extern int __vsprintf_chk (char *__restrict __s, int __flag, size_t __slen,
const char *__restrict __format,
- _G_va_list __ap) __THROW;
+ __gnuc_va_list __ap) __THROW;
#ifdef __va_arg_pack
__fortify_function int
@@ -41,7 +41,7 @@ __NTH (sprintf (char *__restrict __s, const char *__restrict __fmt, ...))
__fortify_function int
__NTH (vsprintf (char *__restrict __s, const char *__restrict __fmt,
- _G_va_list __ap))
+ __gnuc_va_list __ap))
{
return __builtin___vsprintf_chk (__s, __USE_FORTIFY_LEVEL - 1,
__bos (__s), __fmt, __ap);
@@ -54,7 +54,7 @@ extern int __snprintf_chk (char *__restrict __s, size_t __n, int __flag,
...) __THROW;
extern int __vsnprintf_chk (char *__restrict __s, size_t __n, int __flag,
size_t __slen, const char *__restrict __format,
- _G_va_list __ap) __THROW;
+ __gnuc_va_list __ap) __THROW;
# ifdef __va_arg_pack
__fortify_function int
@@ -72,7 +72,7 @@ __NTH (snprintf (char *__restrict __s, size_t __n,
__fortify_function int
__NTH (vsnprintf (char *__restrict __s, size_t __n,
- const char *__restrict __fmt, _G_va_list __ap))
+ const char *__restrict __fmt, __gnuc_va_list __ap))
{
return __builtin___vsnprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1,
__bos (__s), __fmt, __ap);
@@ -86,9 +86,10 @@ extern int __fprintf_chk (FILE *__restrict __stream, int __flag,
const char *__restrict __format, ...);
extern int __printf_chk (int __flag, const char *__restrict __format, ...);
extern int __vfprintf_chk (FILE *__restrict __stream, int __flag,
- const char *__restrict __format, _G_va_list __ap);
+ const char *__restrict __format,
+ __gnuc_va_list __ap);
extern int __vprintf_chk (int __flag, const char *__restrict __format,
- _G_va_list __ap);
+ __gnuc_va_list __ap);
# ifdef __va_arg_pack
__fortify_function int
@@ -111,7 +112,7 @@ printf (const char *__restrict __fmt, ...)
# endif
__fortify_function int
-vprintf (const char *__restrict __fmt, _G_va_list __ap)
+vprintf (const char *__restrict __fmt, __gnuc_va_list __ap)
{
#ifdef __USE_EXTERN_INLINES
return __vfprintf_chk (stdout, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
@@ -122,7 +123,7 @@ vprintf (const char *__restrict __fmt, _G_va_list __ap)
__fortify_function int
vfprintf (FILE *__restrict __stream,
- const char *__restrict __fmt, _G_va_list __ap)
+ const char *__restrict __fmt, __gnuc_va_list __ap)
{
return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
}
@@ -131,7 +132,7 @@ vfprintf (FILE *__restrict __stream,
extern int __dprintf_chk (int __fd, int __flag, const char *__restrict __fmt,
...) __attribute__ ((__format__ (__printf__, 3, 4)));
extern int __vdprintf_chk (int __fd, int __flag,
- const char *__restrict __fmt, _G_va_list __arg)
+ const char *__restrict __fmt, __gnuc_va_list __arg)
__attribute__ ((__format__ (__printf__, 3, 0)));
# ifdef __va_arg_pack
@@ -147,7 +148,7 @@ dprintf (int __fd, const char *__restrict __fmt, ...)
# endif
__fortify_function int
-vdprintf (int __fd, const char *__restrict __fmt, _G_va_list __ap)
+vdprintf (int __fd, const char *__restrict __fmt, __gnuc_va_list __ap)
{
return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
}
@@ -159,7 +160,7 @@ extern int __asprintf_chk (char **__restrict __ptr, int __flag,
const char *__restrict __fmt, ...)
__THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur;
extern int __vasprintf_chk (char **__restrict __ptr, int __flag,
- const char *__restrict __fmt, _G_va_list __arg)
+ const char *__restrict __fmt, __gnuc_va_list __arg)
__THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur;
extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
int __flag, const char *__restrict __format,
@@ -168,7 +169,7 @@ extern int __obstack_printf_chk (struct obstack *__restrict __obstack,
extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack,
int __flag,
const char *__restrict __format,
- _G_va_list __args)
+ __gnuc_va_list __args)
__THROW __attribute__ ((__format__ (__printf__, 3, 0)));
# ifdef __va_arg_pack
@@ -205,14 +206,14 @@ __NTH (obstack_printf (struct obstack *__restrict __obstack,
__fortify_function int
__NTH (vasprintf (char **__restrict __ptr, const char *__restrict __fmt,
- _G_va_list __ap))
+ __gnuc_va_list __ap))
{
return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap);
}
__fortify_function int
__NTH (obstack_vprintf (struct obstack *__restrict __obstack,
- const char *__restrict __fmt, _G_va_list __ap))
+ const char *__restrict __fmt, __gnuc_va_list __ap))
{
return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt,
__ap);
@@ -368,7 +369,7 @@ fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n,
for (; __cnt > 0; --__cnt)
{
- int __c = _IO_getc_unlocked (__stream);
+ int __c = __getc_unlocked (__stream);
if (__c == EOF)
break;
*__cptr++ = __c;