diff options
author | Tom Schoonjans <Tom.Schoonjans@diamond.ac.uk> | 2016-03-28 16:05:01 +0100 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2016-03-28 21:43:53 +0200 |
commit | 63c9c986ceb1e66c418f5863d74f078f0ec567ed (patch) | |
tree | db5ac48ad9e2a15a19c2afeb619ead0d54b815be /glib/glibmm/exceptionhandler.cc | |
parent | 65d87a5c951e07e5dee41453fe53b5433c05bcca (diff) | |
download | glibmm-63c9c986ceb1e66c418f5863d74f078f0ec567ed.tar.gz |
Build: Use Threads::Private hen thread_local keyword is not supported.
This fix is necessary for compilation of glibmm on OS X, as the clang
compiler that currently ships with XCode currently does not support this
keyword. Bug #759791
Diffstat (limited to 'glib/glibmm/exceptionhandler.cc')
-rw-r--r-- | glib/glibmm/exceptionhandler.cc | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/glib/glibmm/exceptionhandler.cc b/glib/glibmm/exceptionhandler.cc index c12e199a..7311bbe6 100644 --- a/glib/glibmm/exceptionhandler.cc +++ b/glib/glibmm/exceptionhandler.cc @@ -19,6 +19,9 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ +#ifndef GLIBMM_THREAD_LOCAL_ENABLED +#include <glibmm/threads.h> +#endif #include <glibmmconfig.h> #include <glibmm/error.h> #include <glibmm/exceptionhandler.h> @@ -33,7 +36,11 @@ typedef sigc::signal<void> HandlerList; // Each thread has its own list of exception handlers // to avoid thread synchronization problems. +#ifdef GLIBMM_THREAD_LOCAL_ENABLED static thread_local HandlerList* thread_specific_handler_list = nullptr; +#else +static Glib::Threads::Private<HandlerList> thread_specific_handler_list; +#endif static void glibmm_exception_warning(const GError* error) @@ -85,12 +92,20 @@ namespace Glib sigc::connection add_exception_handler(const sigc::slot<void>& slot) { +#ifdef GLIBMM_THREAD_LOCAL_ENABLED HandlerList* handler_list = thread_specific_handler_list; +#else + HandlerList* handler_list = thread_specific_handler_list.get(); +#endif if (!handler_list) { handler_list = new HandlerList(); +#ifdef GLIBMM_THREAD_LOCAL_ENABLED thread_specific_handler_list = handler_list; +#else + thread_specific_handler_list.set(handler_list); +#endif } handler_list->slots().push_front(slot); @@ -114,7 +129,11 @@ exception_handlers_invoke() noexcept // handled. If there are no more handlers in the list and the exception // is still unhandled, call glibmm_unexpected_exception(). +#ifdef GLIBMM_THREAD_LOCAL_ENABLED if (HandlerList* const handler_list = thread_specific_handler_list) +#else + if(HandlerList *const handler_list = thread_specific_handler_list.get()) +#endif { HandlerList::iterator pslot = handler_list->slots().begin(); |