From patchwork Mon Feb 5 23:34:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Zack Weinberg X-Patchwork-Id: 869641 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=sourceware.org (client-ip=209.132.180.131; helo=sourceware.org; envelope-from=libc-alpha-return-90025-incoming=patchwork.ozlabs.org@sourceware.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b="WTOydTbk"; dkim-atps=neutral Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3zb3qW5HVLz9sBW for ; Tue, 6 Feb 2018 10:35:35 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:in-reply-to:references :content-transfer-encoding; q=dns; s=default; b=JWGDHoBGQPx9sGrc HrlLe+sSHqyIaOdM55NFWtxl21r4k6dDpcO9MvWwycD/OHUYJdaq7c7EivAYrkCa xvUWclgz1B+EZ3gffSEa5WrrPIwX0WhgrA1t906I7NUAJgjikcUvVMUlYJ/YJ0B/ /bR7HnFNFEqXP76+HeAPj4Dk7Dw= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:in-reply-to:references :content-transfer-encoding; s=default; bh=ToOjtIcrRfh2+JKVKquYdf 5qNKo=; b=WTOydTbknCFwmuMUwrf4r477CfRWr08nP4aDPVMsKDqf55NNvaYvFg LrXD2ErK+q9KzQYc4TNzJYLS8IWR7ZJZzp20YgnXoNNiqdN0rgcTglmINxp8QRrh F6ch3ZPvU4eQrf6x2yG+k/SzjMJ92JdrS4lB+SE7HGVBi5OthNKKg= Received: (qmail 79874 invoked by alias); 5 Feb 2018 23:35:06 -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 79683 invoked by uid 89); 5 Feb 2018 23:35:05 -0000 Authentication-Results: sourceware.org; auth=none 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= X-HELO: mailbackend.panix.com From: Zack Weinberg To: libc-alpha@sourceware.org Cc: fweimer@redhat.com, joseph@codesourcery.com Subject: [PATCH v2 4/5] Post-cleanup 1: move libio.h back out of bits/. Date: Mon, 5 Feb 2018 18:34:59 -0500 Message-Id: <66d4abc669e9eaa46e128656e686aa0b5eb6aa6c.1517872307.git.zackw@panix.com> In-Reply-To: References: MIME-Version: 1.0 In-Reply-To: References: 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. The distinction between libio.h and libioP.h should be preserved as long as include/stdio.h needs to include libio.h, and that's entangled with _IO_MTSAFE_IO. It might be feasible to merge iolibio.h into libioP.h at this point, but I'm not sure whether it's worth the trouble. * 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 rather than as . --- include/bits/libio.h | 45 ----------------------- include/stdio.h | 2 +- libio/bits/libio-ldbl.h | 29 --------------- libio/iolibio.h | 2 +- libio/{bits => }/libio.h | 96 ++++++++++++++++++++++++++++++++---------------- libio/libioP.h | 2 +- 6 files changed, 67 insertions(+), 109 deletions(-) delete mode 100644 include/bits/libio.h delete mode 100644 libio/bits/libio-ldbl.h rename libio/{bits => }/libio.h (87%) diff --git a/include/bits/libio.h b/include/bits/libio.h deleted file mode 100644 index 572395d5ffb..00000000000 --- a/include/bits/libio.h +++ /dev/null @@ -1,45 +0,0 @@ -#if !defined _ISOMAC && defined _IO_MTSAFE_IO -# include -#endif -#include - -#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 diff --git a/include/stdio.h b/include/stdio.h index 3b6da17d82f..f12b281b4d6 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -5,7 +5,7 @@ # include # ifndef _ISOMAC # define _LIBC_STDIO_H 1 -# include +# include /* Now define the internal interfaces. */ diff --git a/libio/bits/libio-ldbl.h b/libio/bits/libio-ldbl.h deleted file mode 100644 index aa39353ca50..00000000000 --- a/libio/bits/libio-ldbl.h +++ /dev/null @@ -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 - . */ - -#ifndef _BITS_LIBIO_LDBL_H -#define _BITS_LIBIO_LDBL_H 1 - -#ifndef _BITS_LIBIO_H -# error "Never include directly; use instead." -#endif - -__LDBL_REDIR_DECL (_IO_vfscanf) -__LDBL_REDIR_DECL (_IO_vfprintf) - -#endif diff --git a/libio/iolibio.h b/libio/iolibio.h index 7814b1d4e56..52731b65f91 100644 --- a/libio/iolibio.h +++ b/libio/iolibio.h @@ -2,7 +2,7 @@ #define _IOLIBIO_H 1 #include -#include +#include /* These emulate stdio functionality, but with a different name (_IO_ungetc instead of ungetc), and using _IO_FILE instead of FILE. */ diff --git a/libio/bits/libio.h b/libio/libio.h similarity index 87% rename from libio/bits/libio.h rename to libio/libio.h index cefc2c855b9..ff67e18c182 100644 --- a/libio/bits/libio.h +++ b/libio/libio.h @@ -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 +#if defined _IO_MTSAFE_IO && !defined _IO_lock_t_defined +# error "Someone forgot to include stdio-lock.h" +#endif + #include /* 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 + +__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 -# 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 +__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) + +#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 /* _BITS_LIBIO_H */ +#endif /* _LIBIO_H */ diff --git a/libio/libioP.h b/libio/libioP.h index ac66f95f8d4..8edc207277e 100644 --- a/libio/libioP.h +++ b/libio/libioP.h @@ -43,7 +43,7 @@ #include #include -#include +#include #include "iolibio.h" #ifdef __cplusplus