From bf57209f9e1c9f9f639c2d63c7674c3757750eb5 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 16 Dec 2016 16:08:06 +0200 Subject: Work around unexportable thread-local variables on Win32 --- butl/utility | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'butl/utility') 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 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; } } -- cgit v1.1