diff options
author | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-25 17:59:46 +0300 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@gmail.com> | 2018-07-30 18:12:24 +0300 |
commit | 885cc4cf9a1d5c167e4cbd26c3294d8b1ad400d8 (patch) | |
tree | cb7f2b6ef98c6ce346f2378096bc9d32a3e5606e /intern/cycles | |
parent | b59d85b5a56c020c7b86b0cca4dc38e4950550f9 (diff) |
Build: require C11/C++11 for all operating systems in master.
This is in preparation of upgrading our library dependencies, some of which
need C++11. We already use C++11 in blender2.8 and for Windows and macOS, so
this just affects Linux.
On many distributions this will not require any changes, on some
install_deps.sh will need to be run again to rebuild libraries.
Differential Revision: https://developer.blender.org/D3568
Diffstat (limited to 'intern/cycles')
-rw-r--r-- | intern/cycles/CMakeLists.txt | 25 | ||||
-rw-r--r-- | intern/cycles/util/util_defines.h | 10 | ||||
-rw-r--r-- | intern/cycles/util/util_foreach.h | 9 | ||||
-rw-r--r-- | intern/cycles/util/util_function.h | 18 | ||||
-rw-r--r-- | intern/cycles/util/util_map.h | 27 | ||||
-rw-r--r-- | intern/cycles/util/util_set.h | 32 | ||||
-rw-r--r-- | intern/cycles/util/util_static_assert.h | 22 | ||||
-rw-r--r-- | intern/cycles/util/util_thread.cpp | 8 | ||||
-rw-r--r-- | intern/cycles/util/util_thread.h | 24 | ||||
-rw-r--r-- | intern/cycles/util/util_vector.h | 4 |
10 files changed, 15 insertions, 164 deletions
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt index 0740aa51039..00ac8e7e182 100644 --- a/intern/cycles/CMakeLists.txt +++ b/intern/cycles/CMakeLists.txt @@ -224,31 +224,6 @@ endif() # TODO(sergey): Consider removing it, only causes confusion in interface. set(WITH_CYCLES_DEVICE_MULTI TRUE) -if(CYCLES_STANDALONE_REPOSITORY) - TEST_UNORDERED_MAP_SUPPORT() -endif() -if(WITH_CXX11) - add_definitions(-DCYCLES_STD_UNORDERED_MAP) -elseif(HAVE_STD_UNORDERED_MAP_HEADER) - if(HAVE_UNORDERED_MAP_IN_STD_NAMESPACE) - add_definitions(-DCYCLES_STD_UNORDERED_MAP) - else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - add_definitions(-DCYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) - else() - add_definitions(-DCYCLES_NO_UNORDERED_MAP) - message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") - endif() - endif() -else() - if(HAVE_UNORDERED_MAP_IN_TR1_NAMESPACE) - add_definitions(-DCYCLES_TR1_UNORDERED_MAP) - else() - add_definitions(-DCYCLES_NO_UNORDERED_MAP) - message(STATUS "Replacing unordered_map/set with map/set (warning: slower!)") - endif() -endif() - # Logging capabilities using GLog library. if(WITH_CYCLES_LOGGING) add_definitions(-DWITH_CYCLES_LOGGING) diff --git a/intern/cycles/util/util_defines.h b/intern/cycles/util/util_defines.h index d994d4e08f4..1a09f659eb1 100644 --- a/intern/cycles/util/util_defines.h +++ b/intern/cycles/util/util_defines.h @@ -87,18 +87,10 @@ # define UNLIKELY(x) (x) #endif -#if defined(__cplusplus) && ((__cplusplus >= 201103L) || (defined(_MSC_VER) && _MSC_VER >= 1800)) -# define HAS_CPP11_FEATURES -#endif - #if defined(__GNUC__) || defined(__clang__) -# if defined(HAS_CPP11_FEATURES) /* Some magic to be sure we don't have reference in the type. */ template<typename T> static inline T decltype_helper(T x) { return x; } -# define TYPEOF(x) decltype(decltype_helper(x)) -# else -# define TYPEOF(x) typeof(x) -# endif +# define TYPEOF(x) decltype(decltype_helper(x)) #endif /* Causes warning: diff --git a/intern/cycles/util/util_foreach.h b/intern/cycles/util/util_foreach.h index 03fcefc67b9..2a74ff0a55d 100644 --- a/intern/cycles/util/util_foreach.h +++ b/intern/cycles/util/util_foreach.h @@ -17,13 +17,8 @@ #ifndef __UTIL_FOREACH_H__ #define __UTIL_FOREACH_H__ -/* Use Boost to get nice foreach() loops for STL data structures. */ +/* Nice foreach() loops for STL data structures. */ -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# define foreach(x, y) for(x : y) -#else -# include <boost/foreach.hpp> -# define foreach BOOST_FOREACH -#endif +#define foreach(x, y) for(x : y) #endif /* __UTIL_FOREACH_H__ */ diff --git a/intern/cycles/util/util_function.h b/intern/cycles/util/util_function.h index 958f8b4008c..f3cc00329ad 100644 --- a/intern/cycles/util/util_function.h +++ b/intern/cycles/util/util_function.h @@ -17,18 +17,12 @@ #ifndef __UTIL_FUNCTION_H__ #define __UTIL_FUNCTION_H__ -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include <functional> -#else -# include <boost/bind.hpp> -# include <boost/function.hpp> -#endif +#include <functional> CCL_NAMESPACE_BEGIN -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# define function_bind std::bind -# define function_null nullptr +#define function_bind std::bind +#define function_null nullptr using std::function; using std::placeholders::_1; using std::placeholders::_2; @@ -39,11 +33,7 @@ using std::placeholders::_6; using std::placeholders::_7; using std::placeholders::_8; using std::placeholders::_9; -#else -using boost::function; -# define function_bind boost::bind -# define function_null NULL -#endif + CCL_NAMESPACE_END #endif /* __UTIL_FUNCTION_H__ */ diff --git a/intern/cycles/util/util_map.h b/intern/cycles/util/util_map.h index b3d887f093c..3c9288417cf 100644 --- a/intern/cycles/util/util_map.h +++ b/intern/cycles/util/util_map.h @@ -18,38 +18,13 @@ #define __UTIL_MAP_H__ #include <map> - -#if defined(CYCLES_TR1_UNORDERED_MAP) -# include <tr1/unordered_map> -#endif - -#if defined(CYCLES_STD_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -# include <unordered_map> -#endif - -#if !defined(CYCLES_NO_UNORDERED_MAP) && !defined(CYCLES_TR1_UNORDERED_MAP) && \ - !defined(CYCLES_STD_UNORDERED_MAP) && !defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) // NOLINT -# error One of: CYCLES_NO_UNORDERED_MAP, CYCLES_TR1_UNORDERED_MAP,\ - CYCLES_STD_UNORDERED_MAP, CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE must be defined! // NOLINT -#endif - +#include <unordered_map> CCL_NAMESPACE_BEGIN using std::map; using std::pair; - -#if defined(CYCLES_NO_UNORDERED_MAP) -typedef std::map unordered_map; -#endif - -#if defined(CYCLES_TR1_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -using std::tr1::unordered_map; -#endif - -#if defined(CYCLES_STD_UNORDERED_MAP) using std::unordered_map; -#endif CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_set.h b/intern/cycles/util/util_set.h index 1d010e19996..298e1f7729a 100644 --- a/intern/cycles/util/util_set.h +++ b/intern/cycles/util/util_set.h @@ -18,24 +18,7 @@ #define __UTIL_SET_H__ #include <set> -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include <unordered_set> -#else -# if defined(CYCLES_TR1_UNORDERED_MAP) -# include <tr1/unordered_set> -# endif -# if defined(CYCLES_STD_UNORDERED_MAP) || \ - defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -# include <unordered_set> -# endif -# if !defined(CYCLES_NO_UNORDERED_MAP) && \ - !defined(CYCLES_TR1_UNORDERED_MAP) && \ - !defined(CYCLES_STD_UNORDERED_MAP) && \ - !defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -# error One of: CYCLES_NO_UNORDERED_MAP, CYCLES_TR1_UNORDERED_MAP,\ - CYCLES_STD_UNORDERED_MAP, CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE must be defined! // NOLINT -# endif -#endif +#include <unordered_set> #if defined(_MSC_VER) && (_MSC_VER >= 1900) # include <iterator> @@ -44,19 +27,8 @@ CCL_NAMESPACE_BEGIN using std::set; -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -using std::unordered_set; -#else -# if defined(CYCLES_NO_UNORDERED_MAP) -typedef std::set unordered_set; -# endif -# if defined(CYCLES_TR1_UNORDERED_MAP) || defined(CYCLES_STD_UNORDERED_MAP_IN_TR1_NAMESPACE) -using std::tr1::unordered_set; -# endif -# if defined(CYCLES_STD_UNORDERED_MAP) using std::unordered_set; -# endif -#endif + CCL_NAMESPACE_END #endif /* __UTIL_SET_H__ */ diff --git a/intern/cycles/util/util_static_assert.h b/intern/cycles/util/util_static_assert.h index e90049254de..dc3cb3f6ecc 100644 --- a/intern/cycles/util/util_static_assert.h +++ b/intern/cycles/util/util_static_assert.h @@ -22,27 +22,7 @@ CCL_NAMESPACE_BEGIN /* TODO(sergey): In theory CUDA might work with own static assert * implementation since it's just pure C++. */ -#ifndef __KERNEL_GPU__ -# if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -/* C++11 has built-in static_assert() */ -# elif defined(static_assert) -/* Some platforms might have static_assert() defined even tho their - * C++ support wouldn't be declared to be C++11. - */ -# else /* C++11 or MSVC2015 */ -template <bool Test> class StaticAssertFailure; -template <> class StaticAssertFailure<true> {}; -# define _static_assert_private_glue_impl(A, B) A ## B -# define _static_assert_glue(A, B) _static_assert_private_glue_impl(A, B) -# ifdef __COUNTER__ -# define static_assert(condition, message) \ - enum {_static_assert_glue(q_static_assert_result, __COUNTER__) = sizeof(StaticAssertFailure<!!(condition)>)} // NOLINT -# else /* __COUNTER__ */ -# define static_assert(condition, message) \ - enum {_static_assert_glue(q_static_assert_result, __LINE__) = sizeof(StaticAssertFailure<!!(condition)>)} // NOLINT -# endif /* __COUNTER__ */ -# endif /* C++11 or MSVC2015 */ -#else /* __KERNEL_GPU__ */ +#ifdef __KERNEL_GPU__ # ifndef static_assert # define static_assert(statement, message) # endif diff --git a/intern/cycles/util/util_thread.cpp b/intern/cycles/util/util_thread.cpp index c66aa484264..16a8591a8a9 100644 --- a/intern/cycles/util/util_thread.cpp +++ b/intern/cycles/util/util_thread.cpp @@ -26,11 +26,7 @@ thread::thread(function<void(void)> run_cb, int group) joined_(false), group_(group) { -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) thread_ = std::thread(&thread::run, this); -#else - pthread_create(&pthread_id_, NULL, run, (void*)this); -#endif } thread::~thread() @@ -64,7 +60,6 @@ void *thread::run(void *arg) bool thread::join() { joined_ = true; -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) try { thread_.join(); return true; @@ -72,9 +67,6 @@ bool thread::join() catch (const std::system_error&) { return false; } -#else - return pthread_join(pthread_id_, NULL) == 0; -#endif } CCL_NAMESPACE_END diff --git a/intern/cycles/util/util_thread.h b/intern/cycles/util/util_thread.h index 77b51d37ea0..f39fcfb4279 100644 --- a/intern/cycles/util/util_thread.h +++ b/intern/cycles/util/util_thread.h @@ -17,15 +17,10 @@ #ifndef __UTIL_THREAD_H__ #define __UTIL_THREAD_H__ -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) -# include <thread> -# include <mutex> -# include <condition_variable> -# include <functional> -#else -# include <boost/thread.hpp> -# include <pthread.h> -#endif +#include <thread> +#include <mutex> +#include <condition_variable> +#include <functional> #include <queue> #ifdef _WIN32 @@ -42,16 +37,9 @@ CCL_NAMESPACE_BEGIN -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) typedef std::mutex thread_mutex; typedef std::unique_lock<std::mutex> thread_scoped_lock; typedef std::condition_variable thread_condition_variable; -#else -/* use boost for mutexes */ -typedef boost::mutex thread_mutex; -typedef boost::mutex::scoped_lock thread_scoped_lock; -typedef boost::condition_variable thread_condition_variable; -#endif /* own pthread based implementation, to avoid boost version conflicts with * dynamically loaded blender plugins */ @@ -66,11 +54,7 @@ public: protected: function<void(void)> run_cb_; -#if (__cplusplus > 199711L) || (defined(_MSC_VER) && _MSC_VER >= 1800) std::thread thread_; -#else - pthread_t pthread_id_; -#endif bool joined_; int group_; }; diff --git a/intern/cycles/util/util_vector.h b/intern/cycles/util/util_vector.h index 569f503b66e..0b33221ad4d 100644 --- a/intern/cycles/util/util_vector.h +++ b/intern/cycles/util/util_vector.h @@ -59,11 +59,7 @@ public: void shrink_to_fit(void) { -#if __cplusplus < 201103L - vector<value_type>().swap(*this); -#else std::vector<value_type, allocator_type>::shrink_to_fit(); -#endif } void free_memory(void) |