[PATCH] Define fputs_unlocked to fputs if it is not available

Ulf Hermann ulf.hermann@qt.io
Wed Feb 22 14:05:00 GMT 2017


Using fputs_unlocked over fputs is a nice optimization, but ultimately
the result is the same. So, if we don't have fputs_unlocked we can just
use fputs instead.

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

diff --git a/ChangeLog b/ChangeLog
index d1e36f6..dd9b9ac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2017-02-22  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* configure.ac: Add check for fputs_unlocked.
+
+2017-02-22  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* configure.ac: Add check GNU-style basename.
 
 2017-02-22  Ulf Hermann  <ulf.hermann@qt.io>
diff --git a/configure.ac b/configure.ac
index 889f88c..8119e07 100644
--- a/configure.ac
+++ b/configure.ac
@@ -305,6 +305,10 @@ AC_CHECK_DECLS([basename],[],[],
                 #include <string.h>])
 AM_CONDITIONAL(HAVE_BASENAME, [test "x$ac_cv_have_decl_basename" = "xyes"])
 
+AC_CHECK_DECLS([fputs_unlocked],[],[],
+               [#define _GNU_SOURCE
+                #include <stdio.h>])
+
 AC_CHECK_LIB([stdc++], [__cxa_demangle], [dnl
 AC_DEFINE([USE_DEMANGLE], [1], [Defined if demangling is enabled])])
 AM_CONDITIONAL(DEMANGLE, test "x$ac_cv_lib_stdcpp___cxa_demangle" = "xyes")
diff --git a/lib/ChangeLog b/lib/ChangeLog
index a8d9b91..d9aabfa 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,5 +1,10 @@
 2017-02-22  Ulf Hermann  <ulf.hermann@qt.io>
 
+	* system.h: Define fputs_unlocked to fputs if
+	!HAVE_DECL_FPUTS_UNLOCKED.
+
+2017-02-22  Ulf Hermann  <ulf.hermann@qt.io>
+
 	* Makefile.am (libeu_a_SOURCES): Add basname.c if no GNU-style
 	basename is available.
 	* basename.c: New file.
diff --git a/lib/system.h b/lib/system.h
index 7539e11..dc78997 100644
--- a/lib/system.h
+++ b/lib/system.h
@@ -84,6 +84,10 @@ int vasprintf (char **strp, const char *fmt, va_list ap);
 char *basename (const char *path);
 #endif
 
+#if !HAVE_DECL_FPUTS_UNLOCKED
+#define fputs_unlocked(str, stream) fputs (str, stream)
+#endif
+
 /* A special gettext function we use if the strings are too short.  */
 #define sgettext(Str) \
   ({ const char *__res = strrchr (gettext (Str), '|');			      \
-- 
2.1.4



More information about the Elfutils-devel mailing list