From patchwork Tue Dec 26 06:10:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 25100 Received: (qmail 79065 invoked by alias); 26 Dec 2017 06:11:01 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 78998 invoked by uid 89); 26 Dec 2017 06:11:01 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-25.7 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, KAM_SHORT, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 spammy=cruft X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: fweimer@redhat.com Subject: [PATCH 3/3] Don't include libio.h from stdio.h. Date: Tue, 26 Dec 2017 01:10:52 -0500 Message-Id: <20171226061052.20907-4-zackw@panix.com> In-Reply-To: <20171226061052.20907-1-zackw@panix.com> References: <20171226061052.20907-1-zackw@panix.com> MIME-Version: 1.0 The only thing stdio.h really needed libio.h for was the complete definition of the FILE struct. This is moved to bits/types/struct_FILE.h, along with just enough ancillary definitions for the inlines in bits/stdio.h. stdio.h itself leaves FILE as an opaque typedef; bits/types/struct_FILE.h will only be read when the inlines are active. Code within glibc that needs to see libio internal definitions should, for the time being, include . Once we stop shipping libio.h as an exposed header, we can fold libio.h, libioP.h, and iolibio.h together and much cruft will become unneccessary. Unlike the earlier patch where I had us stop shipping libio.h entirely, I left the struct _IO_FILE / struct _IO_FILE_complete distinction strictly alone in this patch, so it shouldn't break old ABI compatibility. This is still quite messy, particularly where it touches on the _IO_MTSAFE_IO mess; close review would be appreciated. More automatic PLT bypassing is added for fwide, flockfile, and funlockfile; the earlier patches were apparently not thorough enough. * libio/stdio.h: Don't include bits/libio.h. Don't define getc or putc as macros. Declare __underflow, __uflow, and __overflow here. * libio/bits/types/struct_FILE.h: New header containing the complete definitions of struct _IO_FILE and struct _IO_FILE_complete and a few ancillary definitions. * libio/Makefile: Install bits/types/struct_FILE.h. * libio/bits/stdio.h: Add multiple inclusion guard. Include bits/types/struct_FILE.h. Use getc, not _IO_getc; putc, not _IO_putc; __getc_unlocked_body, not _IO_getc_unlocked; __putc_unlocked_body, not _IO_putc_unlocked; __feof_unlocked_body, not _IO_feof_unlocked; __ferror_unlocked_body, not _IO_ferror_unlocked. * libio/bits/stdio2.h: Add multiple inclusion guard. Use getc_unlocked, not _IO_getc_unlocked. * libio/bits/libio.h: Allow inclusion by libioP.h, not stdio.h. Move __HAVE_COLUMN and _IO_file_flags to the set of compatibility defines. Get definition of _IO_FILE and fallback definition of _IO_lock_t from bits/types/struct_FILE.h. Use macros from bits/types/struct_FILE.h for _IO_getc_unlocked, _IO_putc_unlocked, _IO_feof_unlocked, and _IO_ferror_unlocked. Remove some #if 0 blocks and redundant prototypes. Only provide non-thread-safe fallback definitions of several macros when neither _IO_MTSAFE_IO nor _LIBC is defined. Avoid unwanted macro expansion when declaring _IO_flockfile and _IO_funlockfile. * libio/libioP.h: Add multiple-include guard. Include stdio.h and bits/libio.h. * libio/strfile.h: Include libio/libioP.h. * include/bits/libio.h: Move the libc_hidden_proto declarations for __woverflow, __wunderflow, __wuflow, _IO_free_backup_area, _IO_free_wbackup_area, _IO_padn, _IO_putc, _IO_sgetn, _IO_vfprintf, and _IO_vfscanf back here. Add libc_hidden_proto declarations for _IO_flockfile, _IO_ftrylockfile, and _IO_funlockfile. * include/stdio.h: Use __gnuc_va_list instead of _G_va_list, __ssize_t instead of _IO_ssize_t, and FILE instead of _IO_FILE. Don't redefine _IO_peekc. Don't macro-redirect putc. Define _IO_USER_LOCK here. Add libc_hidden_proto declarations for __flockfile, __funlockfile, and __ftrylockfile. When IS_IN(libc), macro-redirect flockfile to __flockfile and funlockfile to __funlockfile. When IS_IN(libc) and _IO_MTSAFE_IO, macro-redirect __flockfile to _IO_flockfile and __funlockfile to _IO_funlockfile. Use __flockfile and __funlockfile in the expensive-lock variants of _IO_flockfile and _IO_funlockfile. * include/stdio_ext.h: Define _IO_USER_LOCK here. * include/wchar.h: When IS_IN(libc), macro-redirect fwide to _IO_fwide. * include/bits/types/struct_FILE.h: New wrapper. * argp/argp-fmtstream.c, argp/argp-help.c, misc/err.c, misc/error.c: Use fwide, not _IO_fwide. * resolv/res_init.c: Use ferror_unlocked, not _IO_ferror_unlocked. * stdio-common/scanf.c: Use __vfscanf, not _IO_vfscanf. * stdio-common/tstgetln.c: Get ssize_t from sys/types.h. * csu/init.c, libio/__fbufsize.c, libio/__flbf.c, libio/__fpending.c * libio/__freadable.c, libio/__fwritable.c, libio/__fwriting.c * malloc/malloc.c, misc/err.c, misc/error.c, stdio-common/perror.c Include libio/libioP.h instead of, or in addition to, stdio.h. * libio/fwide.c: #undef fwide before defining it as a function. * stdio-common/flockfile.c: Include stdio.h and libio/libioP.h and remove unnecessary headers. #undef flockfile, __flockfile, and _IO_flockfile before defining __flockfile as a function. Make _IO_flockfile a strong alias. Add libc_hidden_def for __flockfile and _IO_flockfile. * stdio-common/ftrylockfile.c, stdio-common/funlockfile.c * sysdeps/pthread/flockfile.c, sysdeps/pthread/ftrylockfile.c * sysdeps/pthread/funlockfile.c: Similarly. --- NEWS | 18 +++--- argp/argp-fmtstream.c | 4 +- argp/argp-help.c | 2 +- csu/init.c | 2 +- include/bits/libio.h | 21 ++++++- include/bits/types/struct_FILE.h | 1 + include/stdio.h | 94 +++++++++++++++---------------- include/stdio_ext.h | 2 + include/wchar.h | 6 ++ libio/Makefile | 5 +- libio/__fbufsize.c | 1 + libio/__flbf.c | 1 + libio/__fpending.c | 1 + libio/__freadable.c | 1 + libio/__freading.c | 1 + libio/__fwritable.c | 1 + libio/__fwriting.c | 1 + libio/bits/libio.h | 116 ++++++--------------------------------- libio/bits/stdio.h | 31 +++++++---- libio/bits/stdio2.h | 7 ++- libio/bits/types/struct_FILE.h | 97 ++++++++++++++++++++++++++++++++ libio/fwide.c | 2 + libio/libioP.h | 8 ++- libio/stdio.h | 16 ++---- libio/strfile.h | 1 + malloc/malloc.c | 1 + misc/err.c | 5 +- misc/error.c | 3 +- resolv/res_init.c | 2 +- stdio-common/flockfile.c | 9 ++- stdio-common/ftrylockfile.c | 9 ++- stdio-common/funlockfile.c | 10 +++- stdio-common/perror.c | 2 + stdio-common/scanf.c | 2 +- stdio-common/tstgetln.c | 3 +- sysdeps/pthread/flockfile.c | 7 ++- sysdeps/pthread/ftrylockfile.c | 8 ++- sysdeps/pthread/funlockfile.c | 7 ++- 38 files changed, 300 insertions(+), 208 deletions(-) create mode 100644 include/bits/types/struct_FILE.h create mode 100644 libio/bits/types/struct_FILE.h diff --git a/NEWS b/NEWS index 7a75891e6b..7c97b797fa 100644 --- a/NEWS +++ b/NEWS @@ -110,19 +110,19 @@ Deprecated and removed features, and other changes affecting compatibility: * The tilepro-*-linux-gnu configuration is no longer supported. -* The nonstandard header files and <_G_config.h> are deprecated - and will be removed in a future release. Software that is still using - either header should be updated to use standard interfaces - instead. +* The nonstandard header files and <_G_config.h> are deprecated. + no longer includes either of them, and they will be removed in a + future release. Software that is still using these headers, or their + contents, should be updated to use standard interfaces instead. libio.h was originally the header for a set of supported GNU extensions, but they have not been maintained as such in many years, they are now - standing in the way of improvements to stdio, and we don't think there are - any remaining external users. _G_config.h was never intended for public - use, but predates the bits convention. + standing in the way of improvements to stdio, and we are not aware of any + remaining external users. _G_config.h was never intended for public use, + but predates the "bits" convention for private-but-installed headers. -* The C++ name mangling for interfaces involving the types fpos_t and - fpos64_t has changed. + As a side-effect of this deprecation, the C++ name mangling for interfaces + involving the types fpos_t and fpos64_t has changed. Changes to build and runtime requirements: diff --git a/argp/argp-fmtstream.c b/argp/argp-fmtstream.c index eeb7520429..38044544d3 100644 --- a/argp/argp-fmtstream.c +++ b/argp/argp-fmtstream.c @@ -147,7 +147,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) size_t i; for (i = 0; i < pad; i++) { - if (_IO_fwide (fs->stream, 0) > 0) + if (fwide (fs->stream, 0) > 0) putwc_unlocked (L' ', fs->stream); else putc_unlocked (' ', fs->stream); @@ -310,7 +310,7 @@ __argp_fmtstream_update (argp_fmtstream_t fs) *nl++ = ' '; else for (i = 0; i < fs->wmargin; ++i) - if (_IO_fwide (fs->stream, 0) > 0) + if (fwide (fs->stream, 0) > 0) putwc_unlocked (L' ', fs->stream); else putc_unlocked (' ', fs->stream); diff --git a/argp/argp-help.c b/argp/argp-help.c index ab8eeb95a0..124708bbc9 100644 --- a/argp/argp-help.c +++ b/argp/argp-help.c @@ -1870,7 +1870,7 @@ __argp_failure (const struct argp_state *state, int status, int errnum, #endif } - if (_IO_fwide (stream, 0) > 0) + if (fwide (stream, 0) > 0) putwc_unlocked (L'\n', stream); else putc_unlocked ('\n', stream); diff --git a/csu/init.c b/csu/init.c index c50bb35e65..d1f622a016 100644 --- a/csu/init.c +++ b/csu/init.c @@ -18,7 +18,7 @@ #if defined __GNUC__ && __GNUC__ >= 2 -#include +#include /* This records which stdio is linked against in the application. */ const int _IO_stdin_used = _G_IO_IO_FILE_VERSION; diff --git a/include/bits/libio.h b/include/bits/libio.h index 40b6851fe9..e12c746995 100644 --- a/include/bits/libio.h +++ b/include/bits/libio.h @@ -1 +1,20 @@ -#include +#ifndef _BITS_LIBIO_H +# include +# ifndef _ISOMAC + +libc_hidden_proto (__woverflow) +libc_hidden_proto (__wunderflow) +libc_hidden_proto (__wuflow) +libc_hidden_proto (_IO_flockfile) +libc_hidden_proto (_IO_free_backup_area) +libc_hidden_proto (_IO_free_wbackup_area) +libc_hidden_proto (_IO_ftrylockfile) +libc_hidden_proto (_IO_funlockfile) +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 +#endif diff --git a/include/bits/types/struct_FILE.h b/include/bits/types/struct_FILE.h new file mode 100644 index 0000000000..971407292b --- /dev/null +++ b/include/bits/types/struct_FILE.h @@ -0,0 +1 @@ +#include diff --git a/include/stdio.h b/include/stdio.h index 8c8580766c..13cd932009 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -15,26 +15,26 @@ extern int __snprintf (char *__restrict __s, size_t __maxlen, __attribute__ ((__format__ (__printf__, 3, 4))); libc_hidden_proto (__snprintf) extern int __vsnprintf (char *__restrict __s, size_t __maxlen, - const char *__restrict __format, _G_va_list __arg) + const char *__restrict __format, __gnuc_va_list __arg) __attribute__ ((__format__ (__printf__, 3, 0))); libc_hidden_proto (__vsnprintf) extern int __vfscanf (FILE *__restrict __s, const char *__restrict __format, - _G_va_list __arg) + __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))); libc_hidden_proto (__vfscanf) extern int __vscanf (const char *__restrict __format, - _G_va_list __arg) + __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 1, 0))); -extern _IO_ssize_t __getline (char **__lineptr, size_t *__n, - FILE *__stream) attribute_hidden; -extern _IO_ssize_t __getdelim (char **__lineptr, size_t *__n, - int __delim, FILE *__stream); +extern __ssize_t __getline (char **__lineptr, size_t *__n, + FILE *__stream) attribute_hidden; +extern __ssize_t __getdelim (char **__lineptr, size_t *__n, + int __delim, FILE *__stream); libc_hidden_proto (__getdelim) extern int __vsscanf (const char *__restrict __s, const char *__restrict __format, - _G_va_list __arg) + __gnuc_va_list __arg) __attribute__ ((__format__ (__scanf__, 2, 0))); libc_hidden_proto (__vsscanf) @@ -42,23 +42,23 @@ extern int __sprintf_chk (char *, int, size_t, const char *, ...) __THROW; extern int __snprintf_chk (char *, size_t, int, size_t, const char *, ...) __THROW; extern int __vsprintf_chk (char *, int, size_t, const char *, - _G_va_list) __THROW; + __gnuc_va_list) __THROW; extern int __vsnprintf_chk (char *, size_t, int, size_t, const char *, - _G_va_list) __THROW; + __gnuc_va_list) __THROW; extern int __printf_chk (int, const char *, ...); extern int __fprintf_chk (FILE *, int, const char *, ...); -extern int __vprintf_chk (int, const char *, _G_va_list); -extern int __vfprintf_chk (FILE *, int, const char *, _G_va_list); +extern int __vprintf_chk (int, const char *, __gnuc_va_list); +extern int __vfprintf_chk (FILE *, int, const char *, __gnuc_va_list); extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp); extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp); extern int __asprintf_chk (char **, int, const char *, ...) __THROW; -extern int __vasprintf_chk (char **, int, const char *, _G_va_list) __THROW; +extern int __vasprintf_chk (char **, int, const char *, __gnuc_va_list) __THROW; extern int __dprintf_chk (int, int, const char *, ...); -extern int __vdprintf_chk (int, int, const char *, _G_va_list); +extern int __vdprintf_chk (int, int, const char *, __gnuc_va_list); extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) __THROW; extern int __obstack_vprintf_chk (struct obstack *, int, const char *, - _G_va_list) __THROW; + __gnuc_va_list) __THROW; extern int __isoc99_fscanf (FILE *__restrict __stream, const char *__restrict __format, ...) __wur; @@ -67,12 +67,12 @@ extern int __isoc99_sscanf (const char *__restrict __s, const char *__restrict __format, ...) __THROW; extern int __isoc99_vfscanf (FILE *__restrict __s, const char *__restrict __format, - _G_va_list __arg) __wur; + __gnuc_va_list __arg) __wur; extern int __isoc99_vscanf (const char *__restrict __format, - _G_va_list __arg) __wur; + __gnuc_va_list __arg) __wur; extern int __isoc99_vsscanf (const char *__restrict __s, const char *__restrict __format, - _G_va_list __arg) __THROW; + __gnuc_va_list __arg) __THROW; libc_hidden_proto (__isoc99_vsscanf) libc_hidden_proto (__isoc99_vfscanf) @@ -116,14 +116,17 @@ libc_hidden_proto (__fortify_fail) libc_hidden_proto (__fortify_fail_abort) /* Acquire ownership of STREAM. */ -extern void __flockfile (FILE *__stream) attribute_hidden; +extern void __flockfile (FILE *__stream); +libc_hidden_proto (__flockfile) /* Relinquish the ownership granted for STREAM. */ -extern void __funlockfile (FILE *__stream) attribute_hidden; +extern void __funlockfile (FILE *__stream); +libc_hidden_proto (__funlockfile) /* Try to acquire ownership of STREAM but do not block if it is not possible. */ extern int __ftrylockfile (FILE *__stream); +libc_hidden_proto (__ftrylockfile) extern int __getc_unlocked (FILE *__fp); extern wint_t __getwc_unlocked (FILE *__fp); @@ -137,18 +140,18 @@ extern const char *const _sys_errlist_internal[] attribute_hidden; extern int _sys_nerr_internal attribute_hidden; # if IS_IN (libc) -extern _IO_FILE *_IO_new_fopen (const char*, const char*); +extern FILE *_IO_new_fopen (const char*, const char*); # define fopen(fname, mode) _IO_new_fopen (fname, mode) -extern _IO_FILE *_IO_new_fdopen (int, const char*); +extern FILE *_IO_new_fdopen (int, const char*); # define fdopen(fd, mode) _IO_new_fdopen (fd, mode) -extern int _IO_new_fclose (_IO_FILE*); +extern int _IO_new_fclose (FILE *); # define fclose(fp) _IO_new_fclose (fp) -extern int _IO_fputs (const char*, _IO_FILE*); +extern int _IO_fputs (const char*, FILE *); libc_hidden_proto (_IO_fputs) # define fputs(str, fp) _IO_fputs (str, fp) -extern int _IO_new_fsetpos (_IO_FILE *, const _IO_fpos_t *); +extern int _IO_new_fsetpos (FILE *, const fpos_t *); # define fsetpos(fp, posp) _IO_new_fsetpos (fp, posp) -extern int _IO_new_fgetpos (_IO_FILE *, _IO_fpos_t *); +extern int _IO_new_fgetpos (FILE *, fpos_t *); # define fgetpos(fp, posp) _IO_new_fgetpos (fp, posp) # endif @@ -215,45 +218,38 @@ libc_hidden_proto (__gen_tempfd) 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) + +#if IS_IN (libc) +# undef flockfile +# define flockfile(s) __flockfile (s) +# undef funlockfile +# define funlockfile(s) __funlockfile (s) +#endif #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_USER_LOCK 0x8000 # 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) + do { if (((_fp)->_flags & _IO_USER_LOCK) == 0) __flockfile (_fp) } while (0) # define _IO_funlockfile(_fp) \ - if (((_fp)->_flags & _IO_USER_LOCK) == 0) _IO_funlockfile (_fp) + do { if (((_fp)->_flags & _IO_USER_LOCK) == 0) __funlockfile (_fp) } while (0) # endif -#endif /* _IO_MTSAFE_IO */ -#if IS_IN (libc) -# undef flockfile -# define flockfile(s) _IO_flockfile (s) -# undef funlockfile -# define funlockfile(s) _IO_funlockfile (s) -# undef putc -# define putc(c, fp) _IO_putc (c, fp) -#endif +# undef __flockfile +# define __flockfile(s) _IO_flockfile (s) +# undef __funlockfile +# define __funlockfile(s) _IO_funlockfile (s) + +#endif /* _IO_MTSAFE_IO */ # endif /* not _ISOMAC */ #endif /* stdio.h */ diff --git a/include/stdio_ext.h b/include/stdio_ext.h index 29c6e68cdb..7c07d780d1 100644 --- a/include/stdio_ext.h +++ b/include/stdio_ext.h @@ -3,6 +3,8 @@ # ifndef _ISOMAC +# define _IO_USER_LOCK 0x8000 + libc_hidden_proto (__fsetlocking) #define __fsetlocking(fp, type) \ diff --git a/include/wchar.h b/include/wchar.h index 1db0ac8278..64157f46ed 100644 --- a/include/wchar.h +++ b/include/wchar.h @@ -260,5 +260,11 @@ extern size_t __mbsrtowcs_l (wchar_t *dst, const char **src, size_t len, # define mbsinit(state) ((state)->__count == 0) # define __mbsinit(state) ((state)->__count == 0) +# if IS_IN (libc) +extern __typeof (fwide) _IO_fwide; +# undef fwide +# define fwide(s, m) _IO_fwide (s, m) +# endif + # endif #endif diff --git a/libio/Makefile b/libio/Makefile index b0cf4d44fc..3c85afb0f6 100644 --- a/libio/Makefile +++ b/libio/Makefile @@ -25,8 +25,9 @@ include ../Makeconfig headers := stdio.h libio.h _G_config.h \ bits/stdio.h bits/libio.h bits/_G_config.h \ bits/sys_errlist.h bits/stdio2.h bits/stdio-ldbl.h bits/libio-ldbl.h \ - bits/types/FILE.h bits/types/__FILE.h bits/types/__fpos_t.h \ - bits/types/__fpos64_t.h bits/types/cookie_io_functions_t.h + bits/types/FILE.h bits/types/__FILE.h bits/types/struct_FILE.h \ + bits/types/__fpos_t.h bits/types/__fpos64_t.h \ + bits/types/cookie_io_functions_t.h routines := \ filedoalloc iofclose iofdopen iofflush iofgetpos iofgets iofopen \ diff --git a/libio/__fbufsize.c b/libio/__fbufsize.c index 74d2ebbe81..fc91a71195 100644 --- a/libio/__fbufsize.c +++ b/libio/__fbufsize.c @@ -16,6 +16,7 @@ . */ #include +#include size_t __fbufsize (FILE *fp) diff --git a/libio/__flbf.c b/libio/__flbf.c index 929175df70..96a29950e7 100644 --- a/libio/__flbf.c +++ b/libio/__flbf.c @@ -16,6 +16,7 @@ . */ #include +#include int __flbf (FILE *fp) diff --git a/libio/__fpending.c b/libio/__fpending.c index e957839985..33d1f0c5a1 100644 --- a/libio/__fpending.c +++ b/libio/__fpending.c @@ -16,6 +16,7 @@ . */ #include +#include size_t __fpending (FILE *fp) diff --git a/libio/__freadable.c b/libio/__freadable.c index 3bde42a729..750d74340c 100644 --- a/libio/__freadable.c +++ b/libio/__freadable.c @@ -16,6 +16,7 @@ . */ #include +#include int __freadable (FILE *fp) diff --git a/libio/__freading.c b/libio/__freading.c index f16f42679f..db77952e6f 100644 --- a/libio/__freading.c +++ b/libio/__freading.c @@ -16,6 +16,7 @@ . */ #include +#include int __freading (FILE *fp) diff --git a/libio/__fwritable.c b/libio/__fwritable.c index 1584aec68f..704c656ddd 100644 --- a/libio/__fwritable.c +++ b/libio/__fwritable.c @@ -16,6 +16,7 @@ . */ #include +#include int __fwritable (FILE *fp) diff --git a/libio/__fwriting.c b/libio/__fwriting.c index 1769d2107e..3acbbe439c 100644 --- a/libio/__fwriting.c +++ b/libio/__fwriting.c @@ -16,6 +16,7 @@ . */ #include +#include int __fwriting (FILE *fp) diff --git a/libio/bits/libio.h b/libio/bits/libio.h index 05668c4280..28ac017c6c 100644 --- a/libio/bits/libio.h +++ b/libio/bits/libio.h @@ -28,11 +28,12 @@ #ifndef _BITS_LIBIO_H #define _BITS_LIBIO_H 1 -#if !defined _STDIO_H && !defined _LIBIO_H +#if !defined _LIBIO_H && !defined _LIBIOP_H # error "Never include directly; use instead." #endif #include +#include #include /* ALL of these should be defined in _G_config.h */ @@ -50,9 +51,13 @@ #define _IO_wint_t wint_t #define _IO_va_list __gnuc_va_list +/* compatibility defines */ #define _STDIO_USES_IOSTREAM #define _IO_UNIFIED_JUMPTABLES 1 +#define __HAVE_COLUMN +#define _IO_file_flags _flags +/* open modes */ #define _IOS_INPUT 1 #define _IOS_OUTPUT 2 #define _IOS_ATEND 4 @@ -121,14 +126,7 @@ #define _IO_BOOLALPHA 0200000 -struct _IO_jump_t; struct _IO_FILE; - -/* During the build of glibc itself, _IO_lock_t will already have been - defined by internal headers. */ -#ifndef _IO_lock_t_defined -typedef void _IO_lock_t; -#endif - +struct _IO_jump_t; /* A streammarker remembers a position in a buffer. */ @@ -139,16 +137,6 @@ struct _IO_marker { it points to _buf->Gbase()+_pos. FIXME comment */ /* if _pos < 0, it points to _buf->eBptr()+_pos. FIXME comment */ int _pos; -#if 0 - void set_streampos(streampos sp) { _spos = sp; } - void set_offset(int offset) { _pos = offset; _spos = (streampos)(-2); } - public: - streammarker(streambuf *sb); - ~streammarker(); - int saving() { return _spos == -2; } - int delta(streammarker&); - int delta(); -#endif }; /* This is the structure from the libstdc++ codecvt class. */ @@ -217,73 +205,6 @@ struct _IO_wide_data }; #endif -struct _IO_FILE { - int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ -#define _IO_file_flags _flags - - /* The following pointers correspond to the C++ streambuf protocol. */ - /* Note: Tk uses the _IO_read_ptr and _IO_read_end fields directly. */ - char* _IO_read_ptr; /* Current read pointer */ - char* _IO_read_end; /* End of get area. */ - char* _IO_read_base; /* Start of putback+get area. */ - char* _IO_write_base; /* Start of put area. */ - char* _IO_write_ptr; /* Current put pointer. */ - char* _IO_write_end; /* End of put area. */ - char* _IO_buf_base; /* Start of reserve area. */ - char* _IO_buf_end; /* End of reserve area. */ - /* The following fields are used to support backing up and undo. */ - char *_IO_save_base; /* Pointer to start of non-current get area. */ - char *_IO_backup_base; /* Pointer to first valid character of backup area */ - char *_IO_save_end; /* Pointer to end of non-current get area. */ - - struct _IO_marker *_markers; - - struct _IO_FILE *_chain; - - int _fileno; -#if 0 - int _blksize; -#else - int _flags2; -#endif - _IO_off_t _old_offset; /* This used to be _offset but it's too small. */ - -#define __HAVE_COLUMN /* temporary */ - /* 1+column number of pbase(); 0 is unknown. */ - unsigned short _cur_column; - signed char _vtable_offset; - char _shortbuf[1]; - - /* char* _save_gptr; char* _save_egptr; */ - - _IO_lock_t *_lock; -#ifdef _IO_USE_OLD_IO_FILE -}; - -struct _IO_FILE_complete -{ - struct _IO_FILE _file; -#endif -#if defined _G_IO_IO_FILE_VERSION && _G_IO_IO_FILE_VERSION == 0x20001 - _IO_off64_t _offset; -# if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T - /* Wide character stream stuff. */ - struct _IO_codecvt *_codecvt; - struct _IO_wide_data *_wide_data; - struct _IO_FILE *_freeres_list; - void *_freeres_buf; -# else - void *__pad1; - void *__pad2; - void *__pad3; - void *__pad4; -# endif - size_t __pad5; - int _mode; - /* Make sure we don't get into trouble again. */ - char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; -#endif -}; #ifndef __cplusplus typedef struct _IO_FILE _IO_FILE; @@ -325,9 +246,6 @@ extern void _IO_cookie_init (struct _IO_cookie_file *__cfile, int __read_write, extern "C" { #endif -extern int __underflow (_IO_FILE *); -extern int __uflow (_IO_FILE *); -extern int __overflow (_IO_FILE *, int); #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T extern _IO_wint_t __wunderflow (_IO_FILE *); extern _IO_wint_t __wuflow (_IO_FILE *); @@ -340,17 +258,12 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t); # define _IO_BE(expr, res) (expr) #endif -#define _IO_getc_unlocked(_fp) \ - (_IO_BE ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end, 0) \ - ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++) +#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_putc_unlocked(_ch, _fp) \ - (_IO_BE ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end, 0) \ - ? __overflow (_fp, (unsigned char) (_ch)) \ - : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) +#define _IO_putc_unlocked(_ch, _fp) __putc_unlocked_body (_ch, _fp) #if defined _LIBC || defined _GLIBCPP_USE_WCHAR_T # define _IO_getwc_unlocked(_fp) \ @@ -366,8 +279,8 @@ extern _IO_wint_t __woverflow (_IO_FILE *, _IO_wint_t); : (_IO_wint_t) (*(_fp)->_wide_data->_IO_write_ptr++ = (_wch))) #endif -#define _IO_feof_unlocked(__fp) (((__fp)->_flags & _IO_EOF_SEEN) != 0) -#define _IO_ferror_unlocked(__fp) (((__fp)->_flags & _IO_ERR_SEEN) != 0) +#define _IO_feof_unlocked(_fp) __feof_unlocked_body (_fp) +#define _IO_ferror_unlocked(_fp) __ferror_unlocked_body (_fp) extern int _IO_getc (_IO_FILE *__fp); extern int _IO_putc (int __c, _IO_FILE *__fp); @@ -380,11 +293,13 @@ extern int _IO_peekc_locked (_IO_FILE *__fp); #define _IO_PENDING_OUTPUT_COUNT(_fp) \ ((_fp)->_IO_write_ptr - (_fp)->_IO_write_base) -extern void _IO_flockfile (_IO_FILE *) __THROW; -extern void _IO_funlockfile (_IO_FILE *) __THROW; +/* These might have macro definitions while building libc itself. */ +extern void (_IO_flockfile) (_IO_FILE *) __THROW; +extern void (_IO_funlockfile) (_IO_FILE *) __THROW; extern int _IO_ftrylockfile (_IO_FILE *) __THROW; #define _IO_peekc(_fp) _IO_peekc_unlocked (_fp) +#if !defined _LIBC && !defined _IO_MTSAFE_IO #define _IO_flockfile(_fp) /**/ #define _IO_funlockfile(_fp) /**/ #define _IO_ftrylockfile(_fp) /**/ @@ -394,6 +309,7 @@ extern int _IO_ftrylockfile (_IO_FILE *) __THROW; #ifndef _IO_cleanup_region_end #define _IO_cleanup_region_end(_Doit) /**/ #endif +#endif #define _IO_need_lock(_fp) \ (((_fp)->_flags2 & _IO_FLAGS2_NEED_LOCK) != 0) diff --git a/libio/bits/stdio.h b/libio/bits/stdio.h index 601fc27569..7218f5de0a 100644 --- a/libio/bits/stdio.h +++ b/libio/bits/stdio.h @@ -16,10 +16,15 @@ License along with the GNU C Library; if not, see . */ +#ifndef _BITS_STDIO_H +#define _BITS_STDIO_H 1 + #ifndef _STDIO_H # error "Never include directly; use instead." #endif +#include + #ifndef __extern_inline # define __STDIO_INLINE inline #else @@ -43,7 +48,7 @@ vprintf (const char *__restrict __fmt, __gnuc_va_list __arg) __STDIO_INLINE int getchar (void) { - return _IO_getc (stdin); + return getc (stdin); } @@ -52,7 +57,7 @@ getchar (void) __STDIO_INLINE int fgetc_unlocked (FILE *__fp) { - return _IO_getc_unlocked (__fp); + return __getc_unlocked_body (__fp); } # endif /* misc */ @@ -62,14 +67,14 @@ fgetc_unlocked (FILE *__fp) __STDIO_INLINE int getc_unlocked (FILE *__fp) { - return _IO_getc_unlocked (__fp); + return __getc_unlocked_body (__fp); } /* This is defined in POSIX.1:1996. */ __STDIO_INLINE int getchar_unlocked (void) { - return _IO_getc_unlocked (stdin); + return __getc_unlocked_body (stdin); } # endif /* POSIX */ @@ -78,7 +83,7 @@ getchar_unlocked (void) __STDIO_INLINE int putchar (int __c) { - return _IO_putc (__c, stdout); + return putc (__c, stdout); } @@ -87,7 +92,7 @@ putchar (int __c) __STDIO_INLINE int fputc_unlocked (int __c, FILE *__stream) { - return _IO_putc_unlocked (__c, __stream); + return __putc_unlocked_body (__c, __stream); } # endif /* misc */ @@ -97,14 +102,14 @@ fputc_unlocked (int __c, FILE *__stream) __STDIO_INLINE int putc_unlocked (int __c, FILE *__stream) { - return _IO_putc_unlocked (__c, __stream); + return __putc_unlocked_body (__c, __stream); } /* This is defined in POSIX.1:1996. */ __STDIO_INLINE int putchar_unlocked (int __c) { - return _IO_putc_unlocked (__c, stdout); + return __putc_unlocked_body (__c, stdout); } # endif /* POSIX */ @@ -124,14 +129,14 @@ getline (char **__lineptr, size_t *__n, FILE *__stream) __STDIO_INLINE int __NTH (feof_unlocked (FILE *__stream)) { - return _IO_feof_unlocked (__stream); + return __feof_unlocked_body (__stream); } /* Faster versions when locking is not required. */ __STDIO_INLINE int __NTH (ferror_unlocked (FILE *__stream)) { - return _IO_ferror_unlocked (__stream); + return __ferror_unlocked_body (__stream); } # endif /* misc */ @@ -151,7 +156,7 @@ __NTH (ferror_unlocked (FILE *__stream)) for (__cnt = (size_t) (size) * (size_t) (n); \ __cnt > 0; --__cnt) \ { \ - int __c = _IO_getc_unlocked (__stream); \ + int __c = getc_unlocked (__stream); \ if (__c == EOF) \ break; \ *__ptr++ = __c; \ @@ -174,7 +179,7 @@ __NTH (ferror_unlocked (FILE *__stream)) size_t __cnt; \ for (__cnt = (size_t) (size) * (size_t) (n); \ __cnt > 0; --__cnt) \ - if (_IO_putc_unlocked (*__ptr++, __stream) == EOF) \ + if (putc_unlocked (*__ptr++, __stream) == EOF) \ break; \ ((size_t) (size) * (size_t) (n) - __cnt) \ / (size_t) (size); }) \ @@ -188,3 +193,5 @@ __NTH (ferror_unlocked (FILE *__stream)) /* Define helper macro. */ #undef __STDIO_INLINE + +#endif /* bits/stdio.h. */ diff --git a/libio/bits/stdio2.h b/libio/bits/stdio2.h index 16fd38aebb..43847111b2 100644 --- a/libio/bits/stdio2.h +++ b/libio/bits/stdio2.h @@ -16,6 +16,9 @@ License along with the GNU C Library; if not, see . */ +#ifndef _BITS_STDIO2_H +#define _BITS_STDIO2_H 1 + #ifndef _STDIO_H # error "Never include directly; use instead." #endif @@ -368,7 +371,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; @@ -379,3 +382,5 @@ fread_unlocked (void *__restrict __ptr, size_t __size, size_t __n, return __fread_unlocked_alias (__ptr, __size, __n, __stream); } #endif + +#endif /* bits/stdio2.h. */ diff --git a/libio/bits/types/struct_FILE.h b/libio/bits/types/struct_FILE.h new file mode 100644 index 0000000000..18dbba4687 --- /dev/null +++ b/libio/bits/types/struct_FILE.h @@ -0,0 +1,97 @@ +#ifndef __struct_FILE_defined +#define __struct_FILE_defined 1 + +/* Caution: The contents of this file are not part of the official + stdio.h API. However, much of it is part of the official *binary* + interface, and therefore cannot be changed. */ + +#if defined _IO_USE_OLD_IO_FILE && !defined _LIBC +# error "_IO_USE_OLD_IO_FILE should only be defined when building libc itself" +#endif + +#if defined _IO_lock_t_defined && !defined _LIBC +# error "_IO_lock_t_defined should only be defined when building libc itself" +#endif + +#include + +struct _IO_FILE; +struct _IO_marker; +struct _IO_codecvt; +struct _IO_wide_data; + +/* During the build of glibc itself, _IO_lock_t will already have been + defined by internal headers. */ +#ifndef _IO_lock_t_defined +typedef void _IO_lock_t; +#endif + +struct _IO_FILE +{ + int _flags; /* High-order word is _IO_MAGIC; rest is flags. */ + + /* The following pointers correspond to the C++ streambuf protocol. */ + char *_IO_read_ptr; /* Current read pointer */ + char *_IO_read_end; /* End of get area. */ + char *_IO_read_base; /* Start of putback+get area. */ + char *_IO_write_base; /* Start of put area. */ + char *_IO_write_ptr; /* Current put pointer. */ + char *_IO_write_end; /* End of put area. */ + char *_IO_buf_base; /* Start of reserve area. */ + char *_IO_buf_end; /* End of reserve area. */ + + /* The following fields are used to support backing up and undo. */ + char *_IO_save_base; /* Pointer to start of non-current get area. */ + char *_IO_backup_base; /* Pointer to first valid character of backup area */ + char *_IO_save_end; /* Pointer to end of non-current get area. */ + + struct _IO_marker *_markers; + + struct _IO_FILE *_chain; + + int _fileno; + int _flags2; + __off_t _old_offset; /* This used to be _offset but it's too small. */ + + /* 1+column number of pbase(); 0 is unknown. */ + unsigned short _cur_column; + signed char _vtable_offset; + char _shortbuf[1]; + + _IO_lock_t *_lock; +#ifdef _IO_USE_OLD_IO_FILE +}; + +struct _IO_FILE_complete +{ + struct _IO_FILE _file; +#endif + __off64_t _offset; + /* Wide character stream stuff. */ + struct _IO_codecvt *_codecvt; + struct _IO_wide_data *_wide_data; + struct _IO_FILE *_freeres_list; + void *_freeres_buf; + size_t __pad5; + int _mode; + /* Make sure we don't get into trouble again. */ + char _unused2[15 * sizeof (int) - 4 * sizeof (void *) - sizeof (size_t)]; +}; + +/* These macros are used by bits/stdio.h and libio.h. */ +#define __getc_unlocked_body(_fp) \ + (__glibc_unlikely ((_fp)->_IO_read_ptr >= (_fp)->_IO_read_end) \ + ? __uflow (_fp) : *(unsigned char *) (_fp)->_IO_read_ptr++) + +#define __putc_unlocked_body(_ch, _fp) \ + (__glibc_unlikely ((_fp)->_IO_write_ptr >= (_fp)->_IO_write_end) \ + ? __overflow (_fp, (unsigned char) (_ch)) \ + : (unsigned char) (*(_fp)->_IO_write_ptr++ = (_ch))) + +#define _IO_EOF_SEEN 0x10 +#define __feof_unlocked_body(_fp) (((_fp)->_flags & _IO_EOF_SEEN) != 0) + +#define _IO_ERR_SEEN 0x20 +#define __ferror_unlocked_body(_fp) (((_fp)->_flags & _IO_ERR_SEEN) != 0) + +#endif diff --git a/libio/fwide.c b/libio/fwide.c index d725d43fe1..4229532e49 100644 --- a/libio/fwide.c +++ b/libio/fwide.c @@ -28,6 +28,8 @@ #include #include +#undef fwide + int fwide (_IO_FILE *fp, int mode) { diff --git a/libio/libioP.h b/libio/libioP.h index 0613439ad4..914caac34f 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -24,6 +24,9 @@ This exception applies to code released by its copyright holders in files containing the exception. */ +#ifndef _LIBIOP_H +#define _LIBIOP_H 1 + /* NOTE: libio is now exclusively used only by glibc since libstdc++ has its own implementation. As a result, functions that were implemented for C++ (like *sputn) may no longer have C++ semantics. This is of course only @@ -33,12 +36,13 @@ FIXME: All of the C++ cruft eventually needs to go away. */ #include - +#include #include #include #include +#include #include "iolibio.h" #ifdef __cplusplus @@ -876,3 +880,5 @@ IO_validate_vtable (const struct _IO_jump_t *vtable) _IO_vtable_check (); return vtable; } + +#endif /* libioP.h. */ diff --git a/libio/stdio.h b/libio/stdio.h index 8cf6412993..0da68d797d 100644 --- a/libio/stdio.h +++ b/libio/stdio.h @@ -845,19 +845,11 @@ extern void funlockfile (FILE *__stream) __THROW; # include #endif -/* Internal definitions used by optimizing inlines. */ -#include +/* Slow-path routines used by the optimized inline functions in bits/stdio.h. */ +extern int __underflow (FILE *); +extern int __uflow (FILE *); +extern int __overflow (FILE *, int); -/* The C standard explicitly says this can be a macro, - so we always do the optimization for it. */ -#define getc(_fp) _IO_getc (_fp) - -/* The C standard explicitly says this can be a macro, - so we always do the optimization for it. */ -#define putc(_ch, _fp) _IO_putc (_ch, _fp) - -/* If we are compiling with optimizing read this file. It contains - several optimizing inline functions and macros. */ #ifdef __USE_EXTERN_INLINES # include #endif diff --git a/libio/strfile.h b/libio/strfile.h index 494526b142..9325394e98 100644 --- a/libio/strfile.h +++ b/libio/strfile.h @@ -25,6 +25,7 @@ in files containing the exception. */ #include +#include typedef void *(*_IO_alloc_type) (_IO_size_t); typedef void (*_IO_free_type) (void*); diff --git a/malloc/malloc.c b/malloc/malloc.c index 6253fbe58b..c6cae3676c 100644 --- a/malloc/malloc.c +++ b/malloc/malloc.c @@ -222,6 +222,7 @@ #include #include /* needed for malloc_stats */ +#include /* needed for cancellation handling in malloc_stats */ #include #include diff --git a/misc/err.c b/misc/err.c index d96778adac..79437835b6 100644 --- a/misc/err.c +++ b/misc/err.c @@ -23,6 +23,7 @@ #include #include #include +#include extern char *__progname; @@ -84,7 +85,7 @@ void vwarnx (const char *format, __gnuc_va_list ap) { flockfile (stderr); - if (_IO_fwide (stderr, 0) > 0) + if (fwide (stderr, 0) > 0) { __fwprintf (stderr, L"%s: ", __progname); convert_and_print (format, ap); @@ -107,7 +108,7 @@ vwarn (const char *format, __gnuc_va_list ap) int error = errno; flockfile (stderr); - if (_IO_fwide (stderr, 0) > 0) + if (fwide (stderr, 0) > 0) { __fwprintf (stderr, L"%s: ", __progname); if (format) diff --git a/misc/error.c b/misc/error.c index de11b7a09b..491c0f7efd 100644 --- a/misc/error.c +++ b/misc/error.c @@ -39,6 +39,7 @@ # include # include # include +# include # define mbsrtowcs __mbsrtowcs # define USE_UNLOCKED_IO 0 # define _GL_ATTRIBUTE_FORMAT_PRINTF(a, b) @@ -197,7 +198,7 @@ static void _GL_ATTRIBUTE_FORMAT_PRINTF (3, 0) _GL_ARG_NONNULL ((3)) error_tail (int status, int errnum, const char *message, va_list args) { #if _LIBC - if (_IO_fwide (stderr, 0) > 0) + if (fwide (stderr, 0) > 0) { size_t len = strlen (message) + 1; wchar_t *wmessage = NULL; diff --git a/resolv/res_init.c b/resolv/res_init.c index 4e1f9fe8de..a595e9b5a6 100644 --- a/resolv/res_init.c +++ b/resolv/res_init.c @@ -313,7 +313,7 @@ res_vinit_1 (FILE *fp, struct resolv_conf_parser *parser) ssize_t ret = __getline (&parser->buffer, &buffer_size, fp); if (ret <= 0) { - if (_IO_ferror_unlocked (fp)) + if (ferror_unlocked (fp)) return false; else break; diff --git a/stdio-common/flockfile.c b/stdio-common/flockfile.c index 4080ecfcc8..e9c58a351f 100644 --- a/stdio-common/flockfile.c +++ b/stdio-common/flockfile.c @@ -17,7 +17,10 @@ . */ #include +#include +#undef flockfile +#undef __flockfile #undef _IO_flockfile void @@ -25,5 +28,7 @@ __flockfile (FILE *stream) { /* Do nothing. Using this version does not do any locking. */ } -weak_alias (__flockfile, flockfile); -weak_alias (__flockfile, _IO_flockfile) +strong_alias (__flockfile, _IO_flockfile) +weak_alias (__flockfile, flockfile) +libc_hidden_def (__flockfile) +libc_hidden_def (_IO_flockfile) diff --git a/stdio-common/ftrylockfile.c b/stdio-common/ftrylockfile.c index 366ad31c6a..1352a10592 100644 --- a/stdio-common/ftrylockfile.c +++ b/stdio-common/ftrylockfile.c @@ -17,7 +17,10 @@ . */ #include +#include +#undef ftrylockfile +#undef __ftrylockfile #undef _IO_ftrylockfile int @@ -26,5 +29,7 @@ __ftrylockfile (FILE *stream) /* Do nothing. Using this version does not do any locking. */ return 1; } -weak_alias (__ftrylockfile, ftrylockfile); -weak_alias (__ftrylockfile, _IO_ftrylockfile) +strong_alias (__ftrylockfile, _IO_ftrylockfile) +weak_alias (__ftrylockfile, ftrylockfile) +libc_hidden_def (__ftrylockfile) +libc_hidden_def (_IO_ftrylockfile) diff --git a/stdio-common/funlockfile.c b/stdio-common/funlockfile.c index 2204fde094..15de582236 100644 --- a/stdio-common/funlockfile.c +++ b/stdio-common/funlockfile.c @@ -17,7 +17,10 @@ . */ #include +#include +#undef funlockfile +#undef __funlockfile #undef _IO_funlockfile void @@ -25,5 +28,8 @@ __funlockfile (FILE *stream) { /* Do nothing. Using this version does not do any locking. */ } -weak_alias (__funlockfile, _IO_funlockfile) -weak_alias (__funlockfile, funlockfile); +strong_alias (__funlockfile, _IO_funlockfile) +weak_alias (__funlockfile, funlockfile) +libc_hidden_def (__funlockfile) +libc_hidden_def (_IO_funlockfile) + diff --git a/stdio-common/perror.c b/stdio-common/perror.c index 98cf1c40da..2fdbf5add9 100644 --- a/stdio-common/perror.c +++ b/stdio-common/perror.c @@ -21,6 +21,8 @@ #include #include +#include + static void perror_internal (FILE *fp, const char *s, int errnum) { diff --git a/stdio-common/scanf.c b/stdio-common/scanf.c index 385fba667f..f50e2a32cb 100644 --- a/stdio-common/scanf.c +++ b/stdio-common/scanf.c @@ -28,7 +28,7 @@ __scanf (const char *format, ...) int done; va_start (arg, format); - done = _IO_vfscanf (stdin, format, arg, NULL); + done = __vfscanf (stdin, format, arg); va_end (arg); return done; diff --git a/stdio-common/tstgetln.c b/stdio-common/tstgetln.c index 79ab90c7cc..d6a0eb9ed1 100644 --- a/stdio-common/tstgetln.c +++ b/stdio-common/tstgetln.c @@ -16,8 +16,7 @@ . */ #include -#undef ssize_t -#define ssize_t _IO_ssize_t +#include int main (int argc, char *argv[]) diff --git a/sysdeps/pthread/flockfile.c b/sysdeps/pthread/flockfile.c index 14c1be1d80..e422e1aa02 100644 --- a/sysdeps/pthread/flockfile.c +++ b/sysdeps/pthread/flockfile.c @@ -18,8 +18,11 @@ #include #include -#include +#include +#undef flockfile +#undef __flockfile +#undef _IO_flockfile void __flockfile (FILE *stream) @@ -29,3 +32,5 @@ __flockfile (FILE *stream) } strong_alias (__flockfile, _IO_flockfile) weak_alias (__flockfile, flockfile) +libc_hidden_def (__flockfile) +libc_hidden_def (_IO_flockfile) diff --git a/sysdeps/pthread/ftrylockfile.c b/sysdeps/pthread/ftrylockfile.c index c1d9da662c..d8b1a2a562 100644 --- a/sysdeps/pthread/ftrylockfile.c +++ b/sysdeps/pthread/ftrylockfile.c @@ -16,11 +16,13 @@ License along with the GNU C Library; if not, see . */ -#include #include #include -#include +#include +#undef ftrylockfile +#undef __ftrylockfile +#undef _IO_ftrylockfile int __ftrylockfile (FILE *stream) @@ -29,3 +31,5 @@ __ftrylockfile (FILE *stream) } strong_alias (__ftrylockfile, _IO_ftrylockfile) weak_alias (__ftrylockfile, ftrylockfile) +libc_hidden_def (__ftrylockfile) +libc_hidden_def (_IO_ftrylockfile) diff --git a/sysdeps/pthread/funlockfile.c b/sysdeps/pthread/funlockfile.c index 9f5463448f..5e75d54d60 100644 --- a/sysdeps/pthread/funlockfile.c +++ b/sysdeps/pthread/funlockfile.c @@ -18,8 +18,11 @@ #include #include -#include +#include +#undef funlockfile +#undef __funlockfile +#undef _IO_funlockfile void __funlockfile (FILE *stream) @@ -28,3 +31,5 @@ __funlockfile (FILE *stream) } strong_alias (__funlockfile, _IO_funlockfile) weak_alias (__funlockfile, funlockfile) +libc_hidden_def (__funlockfile) +libc_hidden_def (_IO_funlockfile)