]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
readelf: Call __fsetlocking (stdout, FSETLOCKING_BYCALLER).
authorMark Wielaard <mark@klomp.org>
Sun, 3 Jun 2018 07:28:10 +0000 (09:28 +0200)
committerMark Wielaard <mark@klomp.org>
Mon, 4 Jun 2018 16:53:43 +0000 (18:53 +0200)
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 <mark@klomp.org>
src/ChangeLog
src/readelf.c

index cc12d836c36cf7eda6961511a69315ada770c2a2..19f4210773ccf1aafffed13f0ab2913a60d64b52 100644 (file)
@@ -1,3 +1,7 @@
+2018-06-04  Mark Wielaard  <mark@klomp.org>
+
+       * readelf.c (main): Call __fsetlocking (stdout, FSETLOCKING_BYCALLER).
+
 2018-05-31  Mark Wielaard  <mark@klomp.org>
 
        * readelf.c (print_debug_units): Print the dwo name and id when
index 0725313e4845aa2918a062acede28cbc1cf78a31..a578b27640863f35e8929325df82e8b9689d0a56 100644 (file)
@@ -35,6 +35,8 @@
 #include <locale.h>
 #include <stdarg.h>
 #include <stdbool.h>
+#include <stdio.h>
+#include <stdio_ext.h>
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
@@ -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, "");