diff options
author | Abhishek Aggarwal <66322306+abhi-agg@users.noreply.github.com> | 2021-12-10 15:49:58 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-10 15:49:58 +0300 |
commit | 5a7f5c528b30f87a7235b1cd575ca79d01253d25 (patch) | |
tree | ca06a245bed217c786b96c5b1318ffcfb1acd521 | |
parent | 768aa689dda91f49024e647b5aee23e6b5d08556 (diff) |
More robust #if directive for activate/disable exception code (#95)
Merging then fixing by adding header.
-rw-r--r-- | intgemm/aligned.h | 8 | ||||
-rw-r--r-- | 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 <malloc.h> #endif -#if defined(_MSC_VER) ? !defined(_HAS_EXCEPTIONS) : !defined(__EXCEPTIONS) +#if defined(_MSC_VER) ? !_HAS_EXCEPTIONS : !__EXCEPTIONS #include <cstdlib> #endif @@ -22,15 +22,15 @@ template <class T> class AlignedVector { #ifdef _MSC_VER mem_ = static_cast<T*>(_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<void **>(&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; |