From 047e75b485ad16a729083c210ba4064943d2e7c5 Mon Sep 17 00:00:00 2001 From: Andres Noetzli Date: Tue, 7 Aug 2018 23:24:07 -0700 Subject: Require Swig 3 (#2283) Removes some hacks due to Swig 2's incomplete C++11 support and adds checks for version 3 at configuration time as well as in swig.h --- src/base/Makefile.am | 3 +-- src/base/cvc4_assert.cpp | 5 ++--- src/base/exception.cpp | 2 +- src/base/exception.h | 4 +--- src/base/tls.h | 31 ------------------------------- 5 files changed, 5 insertions(+), 40 deletions(-) delete mode 100644 src/base/tls.h (limited to 'src/base') diff --git a/src/base/Makefile.am b/src/base/Makefile.am index 7dd6f47e5..3619b226e 100644 --- a/src/base/Makefile.am +++ b/src/base/Makefile.am @@ -28,8 +28,7 @@ libbase_la_SOURCES = \ listener.h \ modal_exception.h \ output.cpp \ - output.h \ - tls.h + output.h # listing {Debug,Trace}_tags too ensures that make doesn't auto-remove it # after building (if it does, we don't get the "cached" effect with diff --git a/src/base/cvc4_assert.cpp b/src/base/cvc4_assert.cpp index 1e92670b4..3af6a9909 100644 --- a/src/base/cvc4_assert.cpp +++ b/src/base/cvc4_assert.cpp @@ -20,14 +20,13 @@ #include "base/cvc4_assert.h" #include "base/output.h" -#include "base/tls.h" using namespace std; namespace CVC4 { #ifdef CVC4_DEBUG -//CVC4_THREAD_LOCAL const char* s_debugLastException = NULL; +//thread_local const char* s_debugLastException = NULL; #endif /* CVC4_DEBUG */ @@ -141,7 +140,7 @@ void AssertionException::construct(const char* header, const char* extra, */ void debugAssertionFailed(const AssertionException& thisException, const char* propagatingException) { - static CVC4_THREAD_LOCAL bool alreadyFired = false; + static thread_local bool alreadyFired = false; if(__builtin_expect( ( !std::uncaught_exception() ), true ) || alreadyFired) { throw thisException; diff --git a/src/base/exception.cpp b/src/base/exception.cpp index 0a651f773..831220a2b 100644 --- a/src/base/exception.cpp +++ b/src/base/exception.cpp @@ -28,7 +28,7 @@ using namespace std; namespace CVC4 { -CVC4_THREAD_LOCAL LastExceptionBuffer* LastExceptionBuffer::s_currentBuffer = NULL; +thread_local LastExceptionBuffer* LastExceptionBuffer::s_currentBuffer = NULL; LastExceptionBuffer::LastExceptionBuffer() : d_contents(NULL) {} diff --git a/src/base/exception.h b/src/base/exception.h index 983a59572..54f6aa92d 100644 --- a/src/base/exception.h +++ b/src/base/exception.h @@ -27,8 +27,6 @@ #include #include -#include "base/tls.h" - namespace CVC4 { class CVC4_PUBLIC Exception : public std::exception { @@ -163,7 +161,7 @@ private: char* d_contents; - static CVC4_THREAD_LOCAL LastExceptionBuffer* s_currentBuffer; + static thread_local LastExceptionBuffer* s_currentBuffer; }; /* class LastExceptionBuffer */ }/* CVC4 namespace */ diff --git a/src/base/tls.h b/src/base/tls.h deleted file mode 100644 index d80d66d30..000000000 --- a/src/base/tls.h +++ /dev/null @@ -1,31 +0,0 @@ -/********************* */ -/*! \file tls.h - ** \verbatim - ** Top contributors (to current version): - ** Andres Noetzli - ** This file is part of the CVC4 project. - ** Copyright (c) 2009-2018 by the authors listed in the file AUTHORS - ** in the top-level source directory) and their institutional affiliations. - ** All rights reserved. See the file COPYING in the top-level source - ** directory for licensing information.\endverbatim - ** - ** \brief Definiton of CVC4_THREAD_LOCAL - ** - ** This header defines CVC4_THREAD_LOCAL, which should be used instead of - ** thread_local because it is not supported by all build types (e.g. Swig). - **/ - -#include "cvc4_public.h" - -#ifndef __CVC4__BASE__TLS_H -#define __CVC4__BASE__TLS_H - -#if SWIG && (!defined(SWIG_VERSION) || SWIG_VERSION < 0x030000) -// SWIG versions older than 3.0 do not support thread_local, so just redefine -// CVC4_THREAD_LOCAL to be empty for those versions. -#define CVC4_THREAD_LOCAL -#else -#define CVC4_THREAD_LOCAL thread_local -#endif - -#endif /* __CVC4__BASE__TLS_H */ -- cgit v1.2.3