This is the mail archive of the elfutils-devel@sourceware.org mailing list for the elfutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Define unlocked io functions to locked ones if they are unavailable


The locked IO functions will still do the job, albeit a bit slower.

Signed-off-by: Ulf Hermann <ulf.hermann@qt.io>
---
 ChangeLog       |  4 ++++
 configure.ac    |  4 ++++
 lib/ChangeLog   |  5 +++++
 lib/eu-config.h | 28 ++++++++++++++++++++++++++++
 4 files changed, 41 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index d43eeb6..29013e8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* configure.ac: Check for unlocked I/O functions.
+
 2017-04-28  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* configure.ac: Determine the binary format we're building natively.
diff --git a/configure.ac b/configure.ac
index f04a6c8..0432bb1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -590,6 +590,10 @@ AM_CONDITIONAL(HAVE_FEATURES_H, [test "x$ac_cv_header_features_h" = "xyes"])
 AC_CHECK_HEADERS(stdio_ext.h)
 AM_CONDITIONAL(HAVE_STDIO_EXT_H, [test "x$ac_cv_header_stdio_ext_h" = "xyes"])
 
+AC_CHECK_DECLS([feof_unlocked, ferror_unlocked, fputc_unlocked, fputs_unlocked,
+		fwrite_unlocked, putc_unlocked, putchar_unlocked],
+		[], [], [[#include <stdio.h>]])
+
 dnl Check if we have <linux/bpf.h> for EM_BPF disassembly.
 AC_CHECK_HEADERS(linux/bpf.h)
 AM_CONDITIONAL(HAVE_LINUX_BPF_H, [test "x$ac_cv_header_linux_bpf_h" = "xyes"])
diff --git a/lib/ChangeLog b/lib/ChangeLog
index ecc6179..321513c 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,8 @@
+2017-05-04  Ulf Hermann  <ulf.hermann@qt.io>
+
+	* eu-config.h: Define unlocked I/O functions to locked ones if they
+	are unavailable.
+
 2017-04-27  Ulf Hermann  <ulf.hermann@qt.io>
 
 	* eu-config.h: Define attribute_hidden to be empty if the compiler
diff --git a/lib/eu-config.h b/lib/eu-config.h
index e69b213..6530044 100644
--- a/lib/eu-config.h
+++ b/lib/eu-config.h
@@ -206,4 +206,32 @@ asm (".section predict_data, \"aw\"; .previous\n"
 # define funlockfile(fp) /* nop */
 #endif
 
+#if !HAVE_DECL_FEOF_UNLOCKED
+#define feof_unlocked(x) feof (x)
+#endif
+
+#if !HAVE_DECL_FERROR_UNLOCKED
+#define ferror_unlocked(x) ferror (x)
+#endif
+
+#if !HAVE_DECL_FPUTC_UNLOCKED
+#define fputc_unlocked(x,y) fputc (x,y)
+#endif
+
+#if !HAVE_DECL_FPUTS_UNLOCKED
+#define fputs_unlocked(x,y) fputs (x,y)
+#endif
+
+#if !HAVE_DECL_FWRITE_UNLOCKED
+#define fwrite_unlocked(w,x,y,z) fwrite (w,x,y,z)
+#endif
+
+#if !HAVE_DECL_PUTC_UNLOCKED
+#define putc_unlocked(x,y) putc (x,y)
+#endif
+
+#if !HAVE_DECL_PUTCHAR_UNLOCKED
+#define putchar_unlocked(x) putchar (x)
+#endif
+
 #endif	/* eu-config.h */
-- 
2.1.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]