public inbox for elfutils@sourceware.org
 help / color / mirror / Atom feed
From: Ulf Hermann <ulf.hermann@qt.io>
To: <elfutils-devel@sourceware.org>
Subject: [PATCH] Define unlocked io functions to locked ones if they are unavailable
Date: Thu, 04 May 2017 09:38:00 -0000	[thread overview]
Message-ID: <8e62b4c5-7e06-0afd-e54a-7ce4cd80ad42@qt.io> (raw)

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

                 reply	other threads:[~2017-05-04  9:19 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8e62b4c5-7e06-0afd-e54a-7ce4cd80ad42@qt.io \
    --to=ulf.hermann@qt.io \
    --cc=elfutils-devel@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).