aboutsummaryrefslogtreecommitdiff
path: root/libbutl
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2020-07-29 11:22:46 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2020-07-29 11:22:46 +0200
commiteee51fe3a4ed1b822a1c5d79b9a1b653cae59dff (patch)
treed9a1e257130b5dabede89b49f006ea0f4093af33 /libbutl
parent4edbb58c7f2bf1185c30021dbcdabb9553c22857 (diff)
Work around glibc bug #14898 (GitHub issue #2)
Diffstat (limited to 'libbutl')
-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);
}
}