From 323ce0f0b06bca785959913e75e1f51d383c351a Mon Sep 17 00:00:00 2001 From: Michalis Spyrou Date: Fri, 30 Nov 2018 16:30:43 +0000 Subject: COMPMID-1819 Add option to build library with -fno-exceptions Change-Id: I3de6bb33746d52f8d8c337ab7776eccee8c205fb Reviewed-on: https://review.mlplatform.org/328 Reviewed-by: Georgios Pinitas Reviewed-by: Pablo Marquez Tested-by: Arm Jenkins --- arm_compute/core/Error.h | 6 ++++++ arm_compute/core/utils/misc/Cast.h | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'arm_compute') diff --git a/arm_compute/core/Error.h b/arm_compute/core/Error.h index f137be6ecb..64bfbd2787 100644 --- a/arm_compute/core/Error.h +++ b/arm_compute/core/Error.h @@ -347,4 +347,10 @@ Status create_error(ErrorCode error_code, const char *function, const char *file #define ARM_COMPUTE_ERROR_ON_LOC(cond, func, file, line) \ ARM_COMPUTE_ERROR_ON_LOC_MSG(cond, func, file, line, #cond) +#ifndef ARM_COMPUTE_EXCEPTIONS_DISABLED +#define ARM_COMPUTE_THROW(ex) throw(ex) +#else /* ARM_COMPUTE_EXCEPTIONS_DISABLED */ +#define ARM_COMPUTE_THROW(ex) (ex), std::abort() +#endif /* ARM_COMPUTE_EXCEPTIONS_DISABLED */ + #endif /* __ARM_COMPUTE_ERROR_H__ */ diff --git a/arm_compute/core/utils/misc/Cast.h b/arm_compute/core/utils/misc/Cast.h index 5d9d1b0eca..ae594c96b4 100644 --- a/arm_compute/core/utils/misc/Cast.h +++ b/arm_compute/core/utils/misc/Cast.h @@ -48,7 +48,7 @@ inline Target polymorphic_cast(Source *v) { if(dynamic_cast(v) == nullptr) { - throw std::bad_cast(); + ARM_COMPUTE_THROW(std::bad_cast()); } return static_cast(v); } @@ -88,7 +88,7 @@ std::unique_ptr polymorphic_cast_unique_ptr(std::unique_ptr(v.get()) == nullptr) { - throw std::bad_cast(); + ARM_COMPUTE_THROW(std::bad_cast()); } auto r = static_cast(v.release()); return std::unique_ptr(r, std::move(v.get_deleter())); -- cgit v1.2.1