From 5e9d8abe7c70181333dd6c1572aa74662cd71018 Mon Sep 17 00:00:00 2001 From: Morgan Deters Date: Tue, 28 Sep 2010 20:09:33 +0000 Subject: [PATCH] fix TLS support for platforms (e.g. Mac OS X) where __thread storage class doesn't exist, and clean up a few things in NodeManager --- src/expr/node_manager.cpp | 2 +- src/expr/node_manager.h | 5 +++-- src/util/tls.h.in | 15 ++++++++++++++- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/expr/node_manager.cpp b/src/expr/node_manager.cpp index 31b848885..5d99fb31e 100644 --- a/src/expr/node_manager.cpp +++ b/src/expr/node_manager.cpp @@ -39,7 +39,7 @@ using __gnu_cxx::hash_set; namespace CVC4 { -CVC4_THREADLOCAL(NodeManager*) NodeManager::s_current = 0; +CVC4_THREADLOCAL(NodeManager*) NodeManager::s_current = NULL; /** * This class sets it reference argument to true and ensures that it gets set diff --git a/src/expr/node_manager.h b/src/expr/node_manager.h index 5fb7c57ad..4f658c507 100644 --- a/src/expr/node_manager.h +++ b/src/expr/node_manager.h @@ -562,11 +562,12 @@ public: */ class NodeManagerScope { /** The old NodeManager, to be restored on destruction. */ - NodeManager *d_oldNodeManager; + NodeManager* d_oldNodeManager; public: - NodeManagerScope(NodeManager* nm) : d_oldNodeManager(NodeManager::s_current) { + NodeManagerScope(NodeManager* nm) : + d_oldNodeManager(NodeManager::s_current) { NodeManager::s_current = nm; Debug("current") << "node manager scope: " << NodeManager::s_current << "\n"; diff --git a/src/util/tls.h.in b/src/util/tls.h.in index 29a52497a..80eac93b0 100644 --- a/src/util/tls.h.in +++ b/src/util/tls.h.in @@ -24,6 +24,8 @@ #ifndef __CVC4__TLS_H #define __CVC4__TLS_H +#line 28 "@srcdir@/tls.h.in" + #if @CVC4_TLS_SUPPORTED@ # define CVC4_THREADLOCAL(__type) @CVC4_TLS@ __type # define CVC4_THREADLOCAL_PUBLIC(__type) @CVC4_TLS@ CVC4_PUBLIC __type @@ -49,7 +51,7 @@ public: pthread_key_create(&d_key, ThreadLocalImpl::cleanup); } - ThreadLocalImpl(T t) { + ThreadLocalImpl(const T& t) { pthread_key_create(&d_key, ThreadLocalImpl::cleanup); pthread_setspecific(d_key, const_cast(reinterpret_cast(t))); } @@ -73,6 +75,10 @@ public: } };/* class ThreadLocalImpl */ +template +class ThreadLocalImpl { +};/* class ThreadLocalImpl */ + template class ThreadLocal : public ThreadLocalImpl { typedef ThreadLocalImpl super; @@ -81,6 +87,13 @@ public: ThreadLocal() : super() {} ThreadLocal(const T& t) : super(t) {} ThreadLocal(const ThreadLocal& tl) : super(tl) {} + + ThreadLocal& operator=(const T& t) { + return static_cast< ThreadLocal& >(super::operator=(t)); + } + ThreadLocal& operator=(const ThreadLocal& tl) { + return static_cast< ThreadLocal& >(super::operator=(tl)); + } };/* class ThreadLocal */ }/* CVC4 namespace */ -- 2.30.2