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
This commit is contained in:
@@ -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)
|
||||
|
@@ -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:
|
||||
|
@@ -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__ */
|
||||
|
@@ -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__ */
|
||||
|
@@ -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
|
||||
|
||||
|
@@ -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__ */
|
||||
|
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -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_;
|
||||
};
|
||||
|
@@ -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)
|
||||
|
Reference in New Issue
Block a user