From 27e7fd18f1c337c409f2a567697b27bcd0c09f8b Mon Sep 17 00:00:00 2001 From: Benjamin Barenblat Date: Wed, 7 Jul 2021 17:12:12 -0400 Subject: Support manually disabling exceptions Rename EIGEN_EXCEPTIONS to EIGEN_USE_EXCEPTIONS, and allow disabling exceptions with -DEIGEN_USE_EXCEPTIONS=0. --- Eigen/src/Core/util/Macros.h | 15 +++++++++------ Eigen/src/Core/util/Memory.h | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) (limited to 'Eigen/src/Core/util') diff --git a/Eigen/src/Core/util/Macros.h b/Eigen/src/Core/util/Macros.h index fca94a989..1f90847f9 100644 --- a/Eigen/src/Core/util/Macros.h +++ b/Eigen/src/Core/util/Macros.h @@ -959,9 +959,8 @@ #undef EIGEN_INTERNAL_DEBUGGING #endif - #ifdef EIGEN_EXCEPTIONS - #undef EIGEN_EXCEPTIONS - #endif + #undef EIGEN_USE_EXCEPTIONS + #define EIGEN_USE_EXCEPTIONS 0 #endif #if defined(SYCL_DEVICE_ONLY) @@ -1378,12 +1377,16 @@ namespace Eigen { EIGEN_MAKE_SCALAR_BINARY_OP_ONTHERIGHT(METHOD,OPNAME) -#if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_CUDA_ARCH) && !defined(EIGEN_EXCEPTIONS) && !defined(EIGEN_USE_SYCL) && !defined(EIGEN_HIP_DEVICE_COMPILE) - #define EIGEN_EXCEPTIONS +#ifndef EIGEN_USE_EXCEPTIONS + #if (defined(_CPPUNWIND) || defined(__EXCEPTIONS)) && !defined(EIGEN_CUDA_ARCH) && !defined(EIGEN_USE_SYCL) && !defined(EIGEN_HIP_DEVICE_COMPILE) + #define EIGEN_USE_EXCEPTIONS 1 + #else + #define EIGEN_USE_EXCEPTIONS 0 + #endif #endif -#ifdef EIGEN_EXCEPTIONS +#if EIGEN_USE_EXCEPTIONS # define EIGEN_THROW_X(X) throw X # define EIGEN_THROW throw # define EIGEN_TRY try diff --git a/Eigen/src/Core/util/Memory.h b/Eigen/src/Core/util/Memory.h index 875318cdb..7a8afba99 100644 --- a/Eigen/src/Core/util/Memory.h +++ b/Eigen/src/Core/util/Memory.h @@ -66,7 +66,7 @@ namespace internal { EIGEN_DEVICE_FUNC inline void throw_std_bad_alloc() { - #ifdef EIGEN_EXCEPTIONS + #if EIGEN_USE_EXCEPTIONS throw std::bad_alloc(); #else std::size_t huge = static_cast(-1); -- cgit v1.2.3