Currently there is no API for applications to detect whether elfutils
libraries are built with thread safety support enabled (via the
--enable-thread-safety configure option).

Add macro _ELFUTILS_THREAD_SAFE to version.h.  This macro is set to zero
if thread safety support is not enabled and non-zero if it is.

Signed-off-by: Aaron Merey <[email protected]>
---
 config/version.h.in | 4 ++++
 configure.ac        | 3 +++
 2 files changed, 7 insertions(+)

diff --git a/config/version.h.in b/config/version.h.in
index 34e62c3b..b78de404 100644
--- a/config/version.h.in
+++ b/config/version.h.in
@@ -32,6 +32,10 @@
 
 #define _ELFUTILS_VERSION      @eu_version@
 
+/* Non-zero if elfutils libraries were built with thread safety support
+   enabled.  */
+#define _ELFUTILS_THREAD_SAFE  @eu_thread_safe@
+
 #define _ELFUTILS_PREREQ(major, minor) \
   (_ELFUTILS_VERSION >= ((major) * 1000 + (minor)))
 
diff --git a/configure.ac b/configure.ac
index fbe039d5..bb9ea555 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,6 +82,9 @@ AS_IF([test "$use_locks" = yes],
 
 AH_TEMPLATE([USE_LOCKS], [Defined if libraries should be thread-safe.])
 
+AS_IF([test "$use_locks" = yes], [eu_thread_safe=1], [eu_thread_safe=0])
+AC_SUBST([eu_thread_safe])
+
 # Provided by gnulib's m4/std-gnu11.m4 for autoconf pre 2.70
 AC_PROG_CC
 AS_IF([test "x$ac_cv_prog_cc_c11" = "xno"],
-- 
2.54.0

Reply via email to