From 5a7f5c528b30f87a7235b1cd575ca79d01253d25 Mon Sep 17 00:00:00 2001 From: Abhishek Aggarwal <66322306+abhi-agg@users.noreply.github.com> Date: Fri, 10 Dec 2021 13:49:58 +0100 Subject: More robust #if directive for activate/disable exception code (#95) Merging then fixing by adding header. --- intgemm/aligned.h | 8 ++++---- intgemm/intgemm.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/intgemm/aligned.h b/intgemm/aligned.h index 112aeee..08acfe7 100644 --- a/intgemm/aligned.h +++ b/intgemm/aligned.h @@ -5,7 +5,7 @@ #include #endif -#if defined(_MSC_VER) ? !defined(_HAS_EXCEPTIONS) : !defined(__EXCEPTIONS) +#if defined(_MSC_VER) ? !_HAS_EXCEPTIONS : !__EXCEPTIONS #include #endif @@ -22,15 +22,15 @@ template class AlignedVector { #ifdef _MSC_VER mem_ = static_cast(_aligned_malloc(size * sizeof(T), alignment)); if (!mem_) { -# ifdef __EXCEPTIONS +# if _HAS_EXCEPTIONS != 0 throw std::bad_alloc(); # else std::abort(); # endif } -#else +#else if (posix_memalign(reinterpret_cast(&mem_), alignment, size * sizeof(T))) { -# ifdef __EXCEPTIONS +# if __EXCEPTIONS != 0 throw std::bad_alloc(); # else std::abort(); diff --git a/intgemm/intgemm.cc b/intgemm/intgemm.cc index e5fe1b0..340021f 100644 --- a/intgemm/intgemm.cc +++ b/intgemm/intgemm.cc @@ -117,7 +117,7 @@ CPUType GetCPUID() { const CPUType kCPU = GetCPUID(); void UnsupportedCPUError() { -#if defined(_MSC_VER) ? defined(_HAS_EXCEPTIONS) : defined(__EXCEPTIONS) +#if defined(_MSC_VER) ? (_HAS_EXCEPTIONS != 0) : (__EXCEPTIONS != 0) throw UnsupportedCPU(); #else std::cerr << "intgemm does not support this CPU" << std::endl; -- cgit v1.2.3