From: Morgan Deters Date: Tue, 28 Sep 2010 20:09:33 +0000 (+0000) Subject: fix TLS support for platforms (e.g. Mac OS X) where __thread storage class doesn... X-Git-Tag: cvc5-1.0.0~8845 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=5e9d8abe7c70181333dd6c1572aa74662cd71018;p=cvc5.git 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 --- 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 */