10 #ifndef EIGEN_CORE_UTIL_ASSERT_H
11 #define EIGEN_CORE_UTIL_ASSERT_H
30 #if !defined(EIGEN_NO_DEBUG) && (!defined(EIGEN_GPU_COMPILE_PHASE) || !defined(EIGEN_NO_DEBUG_GPU))
34 #ifndef EIGEN_USE_CUSTOM_PLAIN_ASSERT
36 #define EIGEN_USE_CUSTOM_PLAIN_ASSERT 0
39 #if EIGEN_USE_CUSTOM_PLAIN_ASSERT
41 #ifndef EIGEN_HAS_BUILTIN_FILE
48 #if (EIGEN_HAS_BUILTIN(__builtin_FILE) && (EIGEN_COMP_CLANG || !defined(EIGEN_CUDA_ARCH))) || \
49 (EIGEN_GNUC_STRICT_AT_LEAST(5, 0, 0) && (EIGEN_COMP_NVCC >= 110000 || !defined(EIGEN_CUDA_ARCH))) || \
50 (EIGEN_COMP_MSVC >= 1926 && (!EIGEN_COMP_NVCC || EIGEN_COMP_NVCC >= 110000))
51 #define EIGEN_HAS_BUILTIN_FILE 1
53 #define EIGEN_HAS_BUILTIN_FILE 0
57 #if EIGEN_HAS_BUILTIN_FILE
58 # define EIGEN_BUILTIN_FILE __builtin_FILE()
59 # define EIGEN_BUILTIN_LINE __builtin_LINE()
62 # define EIGEN_BUILTIN_FILE __FILE__
63 # define EIGEN_BUILTIN_LINE __LINE__
71 # define EIGEN_BUILTIN_FUNCTION __FUNCSIG__
73 # define EIGEN_BUILTIN_FUNCTION __PRETTY_FUNCTION__
75 # define EIGEN_BUILTIN_FUNCTION __func__
82 template<
typename EnableIf = void,
typename... EmptyArgs>
83 struct assert_handler_impl {
85 static inline void run(
const char* expression,
const char* file,
unsigned line,
const char*
function) {
86 #ifdef EIGEN_GPU_COMPILE_PHASE
90 printf(
"Assertion failed at %s:%u in %s: %s\n",
91 file ==
nullptr ?
"<file>" : file,
93 function ==
nullptr ?
"<function>" :
function,
102 fprintf(stderr,
"Assertion failed at %s:%u in %s: %s\n",
103 file ==
nullptr ?
"<file>" : file,
105 function ==
nullptr ?
"<function>" :
function,
122 template<
typename... EmptyArgs>
123 struct assert_handler_impl<
124 void_t<decltype(__assert_fail(
125 (const char*)
nullptr,
126 (
const char*)
nullptr,
128 (
const char*)
nullptr,
129 std::declval<EmptyArgs>()...
130 ))>, EmptyArgs... > {
132 static inline void run(
const char* expression,
const char* file,
unsigned line,
const char*
function) {
134 __assert_fail(expression, file, line,
function, std::declval<EmptyArgs>()...);
139 inline void __assert_handler(
const char* expression,
const char* file,
unsigned line,
const char*
function) {
140 assert_handler_impl<>::run(expression, file, line,
function);
146 #define eigen_plain_assert(expression) \
147 (EIGEN_PREDICT_FALSE(!(expression)) ? \
148 Eigen::internal::__assert_handler(#expression, \
149 EIGEN_BUILTIN_FILE, \
150 EIGEN_BUILTIN_LINE, \
151 EIGEN_BUILTIN_FUNCTION) : (void)0)
156 #define eigen_plain_assert(condition) assert(condition)
162 #define eigen_plain_assert(condition) ((void)0)
#define EIGEN_DEVICE_FUNC
#define EIGEN_DONT_INLINE