kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
Log | Files | Refs | README

commit 07e4dc5314a8c1dcaf82af8eeca978599788b790
parent 3b6fbe11381012e3d70efac8592e65b459c54fe4
Author: d.levin256@gmail.com <d.levin256@gmail.com>
Date:   Tue, 13 Oct 2020 12:22:08 +0100

MSVC2019 fixes

Diffstat:
Minclude/kfr/cident.h | 4++++
Minclude/kfr/cometa/function.hpp | 4++--
Minclude/kfr/testo/testo.hpp | 16+++++++++++++---
3 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/include/kfr/cident.h b/include/kfr/cident.h @@ -367,7 +367,11 @@ extern char* gets(char* __s); #define CMT_NODEBUG #define CMT_INLINE /*inline*/ __forceinline #define CMT_INLINE_MEMBER __forceinline +#if _MSC_VER >= 1927 +#define CMT_INLINE_LAMBDA [[msvc::forceinline]] +#else #define CMT_INLINE_LAMBDA +#endif #define CMT_NOINLINE __declspec(noinline) #define CMT_FLATTEN #define CMT_RESTRICT __restrict diff --git a/include/kfr/cometa/function.hpp b/include/kfr/cometa/function.hpp @@ -135,7 +135,7 @@ struct function<R(Args...)> template <typename Ret, typename... Args, typename T, typename Fn, typename DefFn = fn_noop> CMT_INLINE function<Ret(Args...)> cdispatch(cvals_t<T>, identity<T>, Fn&&, DefFn&& deffn = DefFn()) { - return [=](Args... args) CMT_INLINE_MEMBER -> Ret { return deffn(std::forward<Args>(args)...); }; + return [=](Args... args) CMT_INLINE_LAMBDA -> Ret { return deffn(std::forward<Args>(args)...); }; } template <typename Ret, typename... Args, typename T, T v0, T... values, typename Fn, @@ -146,7 +146,7 @@ inline function<Ret(Args...)> cdispatch(cvals_t<T, v0, values...>, identity<T> v if (value == v0) { return [=](Args... args) - CMT_INLINE_MEMBER -> Ret { return fn(cval_t<T, v0>(), std::forward<Args>(args)...); }; + CMT_INLINE_LAMBDA -> Ret { return fn(cval_t<T, v0>(), std::forward<Args>(args)...); }; } else { diff --git a/include/kfr/testo/testo.hpp b/include/kfr/testo/testo.hpp @@ -64,10 +64,18 @@ inline std::string number_to_string(const mpfr::number& reference, int precision template <typename T> inline double ulp_distance(long double reference, T test) { - if (__builtin_isnan(test) && __builtin_isnan(reference)) +#if defined CMT_COMPILER_MSVC && !defined CMT_COMPILER_CLANG +#define TESTO__ISNAN(x) std::isnan(x) +#define TESTO__ISINF(x) std::isinf(x) +#else +#define TESTO__ISNAN(x) __builtin_isnan(x) +#define TESTO__ISINF(x) __builtin_isinf(x) +#endif + + if (TESTO__ISNAN(test) && TESTO__ISNAN(reference)) return 0.0; - if (__builtin_isinf(test) && - (__builtin_isinf(reference) || std::fabs(reference) > std::numeric_limits<T>::max())) + if (TESTO__ISINF(test) && + (TESTO__ISINF(reference) || std::fabs(reference) > std::numeric_limits<T>::max())) { if ((reference < 0 && test < 0) || (reference > 0 && test > 0)) return 0.0; @@ -78,6 +86,8 @@ inline double ulp_distance(long double reference, T test) T next = std::nexttoward(test, std::numeric_limits<long double>::infinity()); long double ulp = test80 - static_cast<long double>(next); return std::abs(static_cast<double>((reference - test80) / ulp)); +#undef TESTO__ISNAN +#undef TESTO__ISINF } #endif