diff options
author | Kenneth Heafield <github@kheafield.com> | 2021-12-10 16:04:25 +0300 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2021-12-10 16:04:25 +0300 |
commit | 84d03709ab39f8b531eb455dedd341c09d29acaf (patch) | |
tree | f4e82bbc86ab8282b90000adaef79c8e27061114 | |
parent | 5a7f5c528b30f87a7235b1cd575ca79d01253d25 (diff) |
Simplify exceptions if statements, ensure headers
I see #if !_HAS_EXCEPTIONS and #if _HAS_EXCEPTIONS in official headers
so assume this is fine.
-rw-r--r-- | intgemm/aligned.h | 8 | ||||
-rw-r--r-- | intgemm/intgemm.cc | 2 |
2 files changed, 6 insertions, 4 deletions
diff --git a/intgemm/aligned.h b/intgemm/aligned.h index 08acfe7..ccd3aff 100644 --- a/intgemm/aligned.h +++ b/intgemm/aligned.h @@ -2,10 +2,12 @@ #include <cstdlib> #include <new> #ifdef _MSC_VER +// Ensure _HAS_EXCEPTIONS is defined +#include <vcruntime.h> #include <malloc.h> #endif -#if defined(_MSC_VER) ? !_HAS_EXCEPTIONS : !__EXCEPTIONS +#if !(defined(_MSC_VER) ? (_HAS_EXCEPTIONS) : (__EXCEPTIONS)) #include <cstdlib> #endif @@ -22,7 +24,7 @@ template <class T> class AlignedVector { #ifdef _MSC_VER mem_ = static_cast<T*>(_aligned_malloc(size * sizeof(T), alignment)); if (!mem_) { -# if _HAS_EXCEPTIONS != 0 +# if _HAS_EXCEPTIONS throw std::bad_alloc(); # else std::abort(); @@ -30,7 +32,7 @@ template <class T> class AlignedVector { } #else if (posix_memalign(reinterpret_cast<void **>(&mem_), alignment, size * sizeof(T))) { -# if __EXCEPTIONS != 0 +# if __EXCEPTIONS throw std::bad_alloc(); # else std::abort(); diff --git a/intgemm/intgemm.cc b/intgemm/intgemm.cc index 340021f..d374aa0 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) ? (_HAS_EXCEPTIONS != 0) : (__EXCEPTIONS != 0) +#if defined(_MSC_VER) ? (_HAS_EXCEPTIONS) : (__EXCEPTIONS) throw UnsupportedCPU(); #else std::cerr << "intgemm does not support this CPU" << std::endl; |