From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 48260 invoked by alias); 4 Jun 2018 16:55:05 -0000 Mailing-List: contact elfutils-devel-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Post: List-Help: List-Subscribe: Sender: elfutils-devel-owner@sourceware.org Received: (qmail 48207 invoked by uid 89); 4 Jun 2018 16:55:04 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Checked: by ClamAV 0.99.4 on sourceware.org X-Virus-Found: No X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=H*Ad:U*mark, U*mark X-Spam-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on sourceware.org X-Spam-Level: X-HELO: gnu.wildebeest.org Received: from wildebeest.demon.nl (HELO gnu.wildebeest.org) (212.238.236.112) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 04 Jun 2018 16:55:03 +0000 Received: from tarox.wildebeest.org (tarox.wildebeest.org [172.31.17.39]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id D34F13002044; Mon, 4 Jun 2018 18:55:00 +0200 (CEST) Received: by tarox.wildebeest.org (Postfix, from userid 1000) id 4FA54418ABBF; Mon, 4 Jun 2018 18:55:00 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: Mark Wielaard Subject: [PATCH] readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER). Date: Mon, 04 Jun 2018 16:55:00 -0000 Message-Id: <1528131293-2191-1-git-send-email-mark@klomp.org> X-Mailer: git-send-email 1.8.3.1 X-Spam-Flag: NO X-IsSubscribed: yes X-SW-Source: 2018-q2/txt/msg00145.txt.bz2 We only call printf on stdout from one thread, so we don't need internal stdio locking for stdout. On my machine eu-readelf -N --debug-dump=info libxul.so > /dev/null goes from 65 seconds to 63 seconds. Signed-off-by: Mark Wielaard --- src/ChangeLog | 4 ++++ src/readelf.c | 5 +++++ 2 files changed, 9 insertions(+) diff --git a/src/ChangeLog b/src/ChangeLog index cc12d83..19f4210 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,7 @@ +2018-06-04 Mark Wielaard + + * readelf.c (main): Call __fsetlocking (stdout, FSETLOCKING_BYCALLER). + 2018-05-31 Mark Wielaard * readelf.c (print_debug_units): Print the dwo name and id when diff --git a/src/readelf.c b/src/readelf.c index 0725313..a578b27 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -35,6 +35,8 @@ #include #include #include +#include +#include #include #include #include @@ -310,6 +312,9 @@ static void dump_archive_index (Elf *, const char *); int main (int argc, char *argv[]) { + /* We use no threads here which can interfere with handling a stream. */ + (void) __fsetlocking (stdout, FSETLOCKING_BYCALLER); + /* Set locale. */ setlocale (LC_ALL, ""); -- 1.8.3.1