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 1 if thread safety support is enabled. If thread safety support is not enabled then this macro is left undefined. Signed-off-by: Aaron Merey <[email protected]> --- v2: Leave _ELFUTILS_THREAD_SAFE undefined if thread safety support is not enabled. Add a NEWS entry. NEWS | 6 ++++++ config/version.h.in | 5 +++++ configure.ac | 5 +++++ 3 files changed, 16 insertions(+) diff --git a/NEWS b/NEWS index 1e01e327..d811dbe3 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,9 @@ +Version 0.196 + +version.h: New macro _ELFUTILS_THREAD_SAFE added to <elfutils/version.h>. + Defined to 1 when the elfutils libraries are built with thread + safety support enabled. Otherwise it is left undefined. + Version 0.195 "Handwritten" CONTRIBUTING: elfutils has adopted a policy on the use of Large Language diff --git a/config/version.h.in b/config/version.h.in index 34e62c3b..6bf3b077 100644 --- a/config/version.h.in +++ b/config/version.h.in @@ -32,6 +32,11 @@ #define _ELFUTILS_VERSION @eu_version@ +/* _ELFUTILS_THREAD_SAFE is defined to 1 when the elfutils libraries + are built with thread safety support enabled. Otherwise it is left + undefined. */ +@eu_thread_safe@ + #define _ELFUTILS_PREREQ(major, minor) \ (_ELFUTILS_VERSION >= ((major) * 1000 + (minor))) diff --git a/configure.ac b/configure.ac index fbe039d5..9bf50d87 100644 --- a/configure.ac +++ b/configure.ac @@ -82,6 +82,11 @@ 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="#define _ELFUTILS_THREAD_SAFE 1"], + [eu_thread_safe="/* _ELFUTILS_THREAD_SAFE is not defined. */"]) +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
