remove CXX11 config variables related to threads

This commit is contained in:
Sébastien Loriot 2021-08-13 16:44:53 +02:00
parent 63a764b79c
commit 6481cb23d9
4 changed files with 12 additions and 69 deletions

View File

@ -17,34 +17,21 @@
#ifdef CGAL_HAS_THREADS
# ifdef CGAL_CAN_USE_CXX11_ATOMIC
# include <atomic>
# define CGAL_ATOMIC_NS std
# else // not CGAL_CAN_USE_CXX11_ATOMIC
# if BOOST_VERSION >= 105300
# include <boost/atomic.hpp>
# define CGAL_ATOMIC_NS boost
# else // BOOST_VERSION < 105300
# define CGAL_NO_ATOMIC "Boost.Atomic was introduced in Boost-1.53".
# endif // BOOST_VERSION < 105300
# endif // not CGAL_CAN_USE_CXX11_ATOMIC
# ifndef CGAL_NO_ATOMIC
namespace CGAL {
namespace cpp11 {
using CGAL_ATOMIC_NS ::atomic;
namespace CGAL {
namespace cpp11 {
using std::atomic;
using CGAL_ATOMIC_NS ::memory_order_relaxed;
using CGAL_ATOMIC_NS ::memory_order_consume;
using CGAL_ATOMIC_NS ::memory_order_acquire;
using CGAL_ATOMIC_NS ::memory_order_release;
using CGAL_ATOMIC_NS ::memory_order_acq_rel;
using CGAL_ATOMIC_NS ::memory_order_seq_cst;
using std::memory_order_relaxed;
using std::memory_order_consume;
using std::memory_order_acquire;
using std::memory_order_release;
using std::memory_order_acq_rel;
using std::memory_order_seq_cst;
using CGAL_ATOMIC_NS ::atomic_thread_fence;
}
}
# endif // CGAL_ATOMIC_NS
using std::atomic_thread_fence;
} }
#else
# define CGAL_NO_ATOMIC "No atomic because CGAL_NO_THREADS is defined."
#endif // CGAL_HAS_THREADS

View File

@ -127,16 +127,6 @@
#include <boost/config.hpp>
#include <boost/version.hpp>
// Hack: Boost<1.55 does not detect correctly the C++11 features of ICC.
// We declare by hand two features that we need (variadic templates and
// rvalue references).
#if defined(__INTEL_COMPILER) && defined(__GXX_EXPERIMENTAL_CXX0X__)
# undef BOOST_NO_VARIADIC_TEMPLATES
# undef BOOST_NO_CXX11_VARIADIC_TEMPLATES
# undef BOOST_NO_RVALUE_REFERENCES
# undef BOOST_NO_CXX11_RVALUE_REFERENCES
#endif
#include <CGAL/version.h>
//----------------------------------------------------------------------//
@ -400,25 +390,6 @@ using std::max;
# endif
#endif
#if __has_feature(cxx_thread_local) || \
( (__GNUC__ > 0) && __cplusplus >= 201103L ) || \
( _MSC_VER >= 1900 )
// see also Installation/cmake/modules/config/support/CGAL_test_cpp_version.cpp
#define CGAL_CAN_USE_CXX11_THREAD_LOCAL
#endif
#if (__has_include(<mutex>) && __cplusplus >= 201103L ) | \
( (__GNUC__ > 0) && __cplusplus >= 201103L ) || \
( _MSC_VER >= 1700 )
#define CGAL_CAN_USE_CXX11_MUTEX
#endif
#if (__has_include(<atomic>) && __cplusplus >= 201103L ) || \
( (__GNUC__ > 0) && __cplusplus >= 201103L ) || \
( _MSC_VER >= 1700 )
#define CGAL_CAN_USE_CXX11_ATOMIC
#endif
#ifndef CGAL_HAS_THREADS
namespace CGAL { inline bool is_currently_single_threaded(){ return true; } }
#elif __has_include(<sys/single_threaded.h>)

View File

@ -13,14 +13,8 @@
#include <CGAL/config.h>
#ifdef CGAL_HAS_THREADS
#ifdef CGAL_CAN_USE_CXX11_MUTEX
#include <mutex>
#define CGAL_MUTEX std::mutex
#define CGAL_SCOPED_LOCK(M) std::unique_lock<std::mutex> scoped_lock(M)
#else
#include <boost/thread/mutex.hpp>
#define CGAL_MUTEX boost::mutex
#define CGAL_SCOPED_LOCK(M) boost::mutex::scoped_lock scoped_lock(M)
#endif
#endif
#endif // CGAL_MUTEX_H

View File

@ -112,16 +112,9 @@
#if !defined(CGAL_HAS_THREADS)
#define CGAL_MPZF_THREAD_LOCAL
#define CGAL_MPZF_TLS
#elif defined(CGAL_CAN_USE_CXX11_THREAD_LOCAL)
#else
#define CGAL_MPZF_THREAD_LOCAL thread_local
#define CGAL_MPZF_TLS thread_local
#elif defined(_MSC_VER)
#define CGAL_MPZF_THREAD_LOCAL __declspec(thread)
#define CGAL_MPZF_TLS
#else
#define CGAL_MPZF_THREAD_LOCAL __thread
#define CGAL_MPZF_TLS
// Too bad for the others
#endif
namespace CGAL {
namespace Mpzf_impl {
@ -162,7 +155,6 @@ template <class T, class = void> struct pool2 {
static T& ptr(T t) { t -= extra+1; return *reinterpret_cast<T*>(t); }
};
#if defined(CGAL_CAN_USE_CXX11_THREAD_LOCAL)
template <class T, class = void> struct pool3 {
static T pop() { T ret = data(); data() = ptr(data()); return ret; }
static void push(T t) { ptr(t) = data(); data() = t; }
@ -185,7 +177,6 @@ template <class T, class = void> struct pool3 {
}
static T& ptr(T t) { t -= extra+1; return *reinterpret_cast<T*>(t); }
};
#endif
// No caching
template <class T, class = void> struct no_pool {