From patchwork Wed Feb 14 18:13:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joseph Myers X-Patchwork-Id: 25937 Received: (qmail 113480 invoked by alias); 14 Feb 2018 18:13:07 -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 113468 invoked by uid 89); 14 Feb 2018 18:13:07 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.5 required=5.0 tests=AWL, BAYES_00, GIT_PATCH_0, GIT_PATCH_1, GIT_PATCH_2, GIT_PATCH_3, RCVD_IN_DNSWL_NONE, SPF_PASS, URIBL_RED autolearn=ham version=3.3.2 spammy= X-HELO: relay1.mentorg.com Date: Wed, 14 Feb 2018 18:13:00 +0000 From: Joseph Myers To: Subject: Fix -Os ferror_unlocked linknamespace, localplt issues (bug 15105, bug 19463) Message-ID: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 X-ClientProxiedBy: svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) To svr-ies-mbx-01.mgc.mentorg.com (139.181.222.1) Continuing the fixes for linknamespace and localplt test failures with -Os that arise from functions not being inlined in that case, this patch fixes such failures for ferror_unlocked. This is relative to a tree with (pending review) applied, but has only trivial textual dependence on that patch. The usual approach is followed of adding __ferror_unlocked (inlined when ferror_unlocked is), making calls use it when required for namespace reasons (only one such call), and using libc_hidden_proto / libc_hidden_weak for the ferror_unlocked weak alias when only localplt but not namespace issues are involved. Tested for x86_64 (both without -Os to make sure that case continues to work, and with -Os to make sure all the relevant linknamespace and localplt test failures are resolved). Because of other such failures that remain after this patch, neither of the bugs can yet be closed. 2018-02-14 Joseph Myers [BZ #15105] [BZ #19463] * libio/ferror_u.c (ferror_unlocked): Rename to __ferror_unlocked and define as weak alias of __ferror_unlocked. Use libc_hidden_weak. * include/stdio.h [!_ISOMAC] (ferror_unlocked): Use libc_hidden_proto. [!_ISOMAC] (__ferror_unlocked) New declaration, and inline function if [__USE_EXTERN_INLINES]. * time/getdate.c (__getdate_r): Call __ferror_unlocked instead of ferror_unlocked. Reviewed-by: Adhemerval Zanella diff --git a/include/stdio.h b/include/stdio.h index 7ab3ddd..de99120 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -181,6 +181,8 @@ extern __typeof (fputs_unlocked) __fputs_unlocked; libc_hidden_proto (__fputs_unlocked) libc_hidden_proto (feof_unlocked) extern __typeof (feof_unlocked) __feof_unlocked attribute_hidden; +libc_hidden_proto (ferror_unlocked) +extern __typeof (ferror_unlocked) __ferror_unlocked attribute_hidden; libc_hidden_proto (fmemopen) /* The prototype needs repeating instead of using __typeof to use __THROW in C++ tests. */ @@ -207,6 +209,12 @@ __NTH (__feof_unlocked (FILE *__stream)) { return __feof_unlocked_body (__stream); } + +__extern_inline int +__NTH (__ferror_unlocked (FILE *__stream)) +{ + return __ferror_unlocked_body (__stream); +} # endif # endif /* not _ISOMAC */ diff --git a/libio/ferror_u.c b/libio/ferror_u.c index afd0bef..3eaf84e 100644 --- a/libio/ferror_u.c +++ b/libio/ferror_u.c @@ -30,8 +30,10 @@ #undef ferror_unlocked int -ferror_unlocked (_IO_FILE *fp) +__ferror_unlocked (_IO_FILE *fp) { CHECK_FILE (fp, EOF); return _IO_ferror_unlocked (fp); } +weak_alias (__ferror_unlocked, ferror_unlocked) +libc_hidden_weak (ferror_unlocked) diff --git a/time/getdate.c b/time/getdate.c index 29ad760..e568149 100644 --- a/time/getdate.c +++ b/time/getdate.c @@ -206,7 +206,7 @@ __getdate_r (const char *string, struct tm *tp) free (line); /* Check for errors. */ - if (ferror_unlocked (fp)) + if (__ferror_unlocked (fp)) { fclose (fp); return 5;