From: Mark Wielaard Date: Sun, 3 Jun 2018 07:28:10 +0000 (+0200) Subject: readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER). X-Git-Tag: elfutils-0.172~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e635a79cda230b646f70951d7e1f17325443e84d;p=thirdparty%2Felfutils.git readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER). 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 --- diff --git a/src/ChangeLog b/src/ChangeLog index cc12d836c..19f421077 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 0725313e4..a578b2764 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, "");