aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--libbutl/utility.cxx14
-rw-r--r--libbutl/utility.mxx27
2 files changed, 33 insertions, 8 deletions
diff --git a/libbutl/utility.cxx b/libbutl/utility.cxx
index d6a21c6..c23d3f5 100644
--- a/libbutl/utility.cxx
+++ b/libbutl/utility.cxx
@@ -51,11 +51,21 @@ namespace butl
#else
__thread
#endif
- bool exception_unwinding_dtor_ = false;
+#if defined(__GLIBC__) && \
+ defined(__GLIBC_MINOR__) && \
+ (__GLIBC__ < 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 17)
+ int
+#else
+ bool
+#endif
+ exception_unwinding_dtor_ = false;
#ifdef _WIN32
- bool&
+ bool
exception_unwinding_dtor () {return exception_unwinding_dtor_;}
+
+ void
+ exception_unwinding_dtor (bool v) {exception_unwinding_dtor_ = v;}
#endif
#endif
diff --git a/libbutl/utility.mxx b/libbutl/utility.mxx
index 251471a..78c9355 100644
--- a/libbutl/utility.mxx
+++ b/libbutl/utility.mxx
@@ -422,17 +422,32 @@ LIBBUTL_MODEXPORT namespace butl
#else
__thread
#endif
- bool exception_unwinding_dtor_;
+ // Work around glibc bug #14898.
+ //
+#if defined(__GLIBC__) && \
+ defined(__GLIBC_MINOR__) && \
+ (__GLIBC__ < 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ < 17)
+ int
+#else
+ bool
+#endif
+ exception_unwinding_dtor_;
// On Windows one cannot export a thread-local variable so we have to
- // use a wrapper functions.
+ // use wrapper functions.
//
#ifdef _WIN32
- LIBBUTL_SYMEXPORT bool&
+ LIBBUTL_SYMEXPORT bool
exception_unwinding_dtor ();
+
+ LIBBUTL_SYMEXPORT void
+ exception_unwinding_dtor (bool);
#else
- inline bool&
+ inline bool
exception_unwinding_dtor () {return exception_unwinding_dtor_;}
+
+ inline void
+ exception_unwinding_dtor (bool v) {exception_unwinding_dtor_ = v;}
#endif
template <typename F>
@@ -443,9 +458,9 @@ LIBBUTL_MODEXPORT namespace butl
{
if (std::uncaught_exception ())
{
- exception_unwinding_dtor () = true;
+ exception_unwinding_dtor (true);
f_ ();
- exception_unwinding_dtor () = false;
+ exception_unwinding_dtor (false);
}
}