summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurray Cumming <murrayc@murrayc.com>2016-03-28 21:51:57 +0200
committerMurray Cumming <murrayc@murrayc.com>2016-03-28 21:51:57 +0200
commitcdfdb3d916ee9b03465b2fe2f85b9953d14d944d (patch)
treec5d9a5d6593b299e849190a0a1f33685a3e1023c
parent63c9c986ceb1e66c418f5863d74f078f0ec567ed (diff)
downloadglibmm-cdfdb3d916ee9b03465b2fe2f85b9953d14d944d.tar.gz
Move thread_local check into a GLIBMM_CXX_* macro, like other checks.
Bug #759791
-rw-r--r--build/cxx.m421
-rw-r--r--configure.ac7
-rw-r--r--glib/glibmm/dispatcher.cc14
-rw-r--r--glib/glibmm/exceptionhandler.cc10
4 files changed, 34 insertions, 18 deletions
diff --git a/build/cxx.m4 b/build/cxx.m4
index 22d24356..58e4f85e 100644
--- a/build/cxx.m4
+++ b/build/cxx.m4
@@ -236,3 +236,24 @@ AS_VAR_IF([glibmm_cv_cxx_can_use_namespaces_inside_externc], ['yes'],
[AC_DEFINE([GLIBMM_CAN_USE_NAMESPACES_INSIDE_EXTERNC], [1],
[Define if the compiler honors namespaces inside extern "C" blocks.])])[]dnl
])
+
+## GLIBMM_CXX_CAN_USE_THREAD_LOCAL
+##
+## Check for thread_local support
+##
+AC_DEFUN([GLIBMM_CXX_CAN_USE_THREAD_LOCAL],
+[dnl
+AC_CACHE_CHECK(
+ [whether the thread_local keyword is supported],
+ [glibmm_cv_cxx_can_use_thread_local],
+ [AC_COMPILE_IFELSE([AC_LANG_PROGRAM(
+[[
+thread_local int i=0;
+]], [])],
+ [glibmm_cv_cxx_can_use_thread_local=yes],
+ [glibmm_cv_cxx_can_use_thread_local=no])])
+
+AS_VAR_IF([glibmm_cv_cxx_can_use_thread_local], ['yes'],
+ [AC_DEFINE([GLIBMM_CAN_USE_THREAD_LOCAL], [1],
+ [Define if the thread_local keyword is supported.])])[]dnl
+])
diff --git a/configure.ac b/configure.ac
index 70f61ced..535348bc 100644
--- a/configure.ac
+++ b/configure.ac
@@ -104,14 +104,9 @@ GLIBMM_CXX_CAN_USE_DYNAMIC_CAST_IN_UNUSED_TEMPLATE_WITHOUT_DEFINITION
GLIBMM_CXX_CAN_ASSIGN_NON_EXTERN_C_FUNCTIONS_TO_EXTERN_C_CALLBACKS
GLIBMM_CXX_CAN_USE_NAMESPACES_INSIDE_EXTERNC
GLIBMM_CXX_ALLOWS_STATIC_INLINE_NPOS
+GLIBMM_CXX_CAN_USE_THREAD_LOCAL
GLIBMM_C_STD_TIME_T_IS_NOT_INT32
-# check for thread_local support
-AC_MSG_CHECKING([whether the thread_local keyword is supported])
-AC_COMPILE_IFELSE([AC_LANG_PROGRAM([thread_local int i=0;], [])],
- AC_DEFINE([GLIBMM_THREAD_LOCAL_ENABLED], [1], [thread_local keyword is available])
- AC_MSG_RESULT([yes]) , AC_MSG_RESULT([no]))
-
MM_ARG_ENABLE_DOCUMENTATION
MM_ARG_WITH_TAGFILE_DOC([libstdc++.tag], [mm-common-libstdc++])
MM_ARG_WITH_TAGFILE_DOC([libsigc++-2.0.tag], [sigc++-2.0])
diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc
index 9ee3b0c3..e21914a8 100644
--- a/glib/glibmm/dispatcher.cc
+++ b/glib/glibmm/dispatcher.cc
@@ -15,7 +15,7 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef GLIBMM_THREAD_LOCAL_ENABLED
+#ifndef GLIBMM_CAN_USE_THREAD_LOCAL
#include <glibmm/threads.h>
#endif
@@ -147,7 +147,7 @@ protected:
explicit DispatchNotifier(const Glib::RefPtr<MainContext>& context);
private:
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
static thread_local DispatchNotifier* thread_specific_instance_;
#else
static Glib::Threads::Private<DispatchNotifier> thread_specific_instance_;
@@ -175,7 +175,7 @@ private:
// static
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
thread_local DispatchNotifier* DispatchNotifier::thread_specific_instance_ = nullptr;
#else
Glib::Threads::Private<DispatchNotifier> DispatchNotifier::thread_specific_instance_;
@@ -282,7 +282,7 @@ DispatchNotifier*
DispatchNotifier::reference_instance(
const Glib::RefPtr<MainContext>& context, const Dispatcher* dispatcher)
{
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
DispatchNotifier* instance = thread_specific_instance_;
#else
DispatchNotifier* instance = thread_specific_instance_.get();
@@ -291,7 +291,7 @@ DispatchNotifier::reference_instance(
if (!instance)
{
instance = new DispatchNotifier(context);
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
thread_specific_instance_ = instance;
#else
thread_specific_instance_.replace(instance);
@@ -323,7 +323,7 @@ DispatchNotifier::reference_instance(
void
DispatchNotifier::unreference_instance(DispatchNotifier* notifier, const Dispatcher* dispatcher)
{
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
DispatchNotifier* const instance = thread_specific_instance_;
#else
DispatchNotifier* const instance = thread_specific_instance_.get();
@@ -344,7 +344,7 @@ DispatchNotifier::unreference_instance(DispatchNotifier* notifier, const Dispatc
{
g_return_if_fail(instance->ref_count_ == 0); // could be < 0 if messed up
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
delete thread_specific_instance_;
thread_specific_instance_ = nullptr;
#else
diff --git a/glib/glibmm/exceptionhandler.cc b/glib/glibmm/exceptionhandler.cc
index 7311bbe6..60809db9 100644
--- a/glib/glibmm/exceptionhandler.cc
+++ b/glib/glibmm/exceptionhandler.cc
@@ -19,7 +19,7 @@
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
-#ifndef GLIBMM_THREAD_LOCAL_ENABLED
+#ifndef GLIBMM_CAN_USE_THREAD_LOCAL
#include <glibmm/threads.h>
#endif
#include <glibmmconfig.h>
@@ -36,7 +36,7 @@ typedef sigc::signal<void> HandlerList;
// Each thread has its own list of exception handlers
// to avoid thread synchronization problems.
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
static thread_local HandlerList* thread_specific_handler_list = nullptr;
#else
static Glib::Threads::Private<HandlerList> thread_specific_handler_list;
@@ -92,7 +92,7 @@ namespace Glib
sigc::connection
add_exception_handler(const sigc::slot<void>& slot)
{
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
HandlerList* handler_list = thread_specific_handler_list;
#else
HandlerList* handler_list = thread_specific_handler_list.get();
@@ -101,7 +101,7 @@ add_exception_handler(const sigc::slot<void>& slot)
if (!handler_list)
{
handler_list = new HandlerList();
-#ifdef GLIBMM_THREAD_LOCAL_ENABLED
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
thread_specific_handler_list = handler_list;
#else
thread_specific_handler_list.set(handler_list);
@@ -129,7 +129,7 @@ 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
+#ifdef GLIBMM_CAN_USE_THREAD_LOCAL
if (HandlerList* const handler_list = thread_specific_handler_list)
#else
if(HandlerList *const handler_list = thread_specific_handler_list.get())