aboutsummaryrefslogtreecommitdiff
path: root/butl/utility
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2016-12-16 16:08:06 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2016-12-16 16:08:06 +0200
commitbf57209f9e1c9f9f639c2d63c7674c3757750eb5 (patch)
tree77465a98ef25e6dd852fbe574007345a7a22c832 /butl/utility
parentcc878f4e2b4bc6622742136dcb45e2ad912714f7 (diff)
Work around unexportable thread-local variables on Win32
Diffstat (limited to 'butl/utility')
-rw-r--r--butl/utility18
1 files changed, 14 insertions, 4 deletions
diff --git a/butl/utility b/butl/utility
index 02d9331..b290153 100644
--- a/butl/utility
+++ b/butl/utility
@@ -188,14 +188,24 @@ namespace butl
// True means we are in the body of a destructor that is being called as
// part of the exception stack unwindining.
//
- LIBBUTL_EXPORT
extern
#ifdef BUTL_CXX11_THREAD_LOCAL
thread_local
#else
__thread
#endif
- bool exception_unwinding_dtor;
+ bool exception_unwinding_dtor_;
+
+ // On Windows one cannot export a thread-local variable so we have to
+ // use a wrapper functions.
+ //
+#ifdef _WIN32
+ LIBBUTL_EXPORT bool&
+ exception_unwinding_dtor ();
+#else
+ inline bool&
+ exception_unwinding_dtor () {return exception_unwinding_dtor_;}
+#endif
template <typename F>
struct exception_guard
@@ -205,9 +215,9 @@ namespace butl
{
if (std::uncaught_exception ())
{
- exception_unwinding_dtor = true;
+ exception_unwinding_dtor () = true;
f_ ();
- exception_unwinding_dtor = false;
+ exception_unwinding_dtor () = false;
}
}