Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion libc/test/UnitTest/FEnvSafeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ void FEnvSafeTest::expect_fenv_eq(const fenv_t &before_fenv,
EXPECT_EQ(before_state.ControlWord, after_state.ControlWord);
EXPECT_EQ(before_state.StatusWord, after_state.StatusWord);

#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__)
#elif defined(LIBC_TARGET_ARCH_IS_X86) && !defined(__APPLE__) && \
!defined(LIBC_COMPILER_IS_MSVC)
using LIBC_NAMESPACE::fputil::internal::FPState;
const FPState &before_state = reinterpret_cast<const FPState &>(before_fenv);
const FPState &after_state = reinterpret_cast<const FPState &>(after_fenv);
Expand Down
14 changes: 10 additions & 4 deletions libc/test/UnitTest/FPMatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {

bool match(T actualValue) {
actual = actualValue;
#ifndef LIBC_COMPILER_IS_MSVC
if constexpr (cpp::is_complex_type_same<T, _Complex float>())
return matchComplex<float>();
else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
Expand All @@ -134,14 +135,18 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
#ifdef LIBC_TYPES_HAS_CFLOAT16
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
return matchComplex<float16>();
#endif
#endif // LIBC_TYPES_HAS_CFLOAT16
#ifdef LIBC_TYPES_HAS_CFLOAT128
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
return matchComplex<float128>();
#endif
#endif // LIBC_TYPES_HAS_CFLOAT128
#else // LIBC_COMPILER_IS_MSVC
return true;
#endif // LIBC_COMPILER_IS_MSVC
}

void explainError() override {
#ifndef LIBC_COMPILER_IS_MSVC
if constexpr (cpp::is_complex_type_same<T, _Complex float>())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does MSVC reject the _Complex type entirely or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, MSVC does not support complex or _Complex at all. They do have their own complex types defined in their complex.h. We will deal with complex support for MSVC later when we need those in LLVM/Clang.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's a different magic type can we typedef it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's their own struct:

#ifndef _C_COMPLEX_T
    #define _C_COMPLEX_T
    typedef struct _C_double_complex
    {
        double _Val[2];
    } _C_double_complex;

    typedef struct _C_float_complex
    {
        float _Val[2];
    } _C_float_complex;

    typedef struct _C_ldouble_complex
    {
        long double _Val[2];
    } _C_ldouble_complex;
#endif

typedef _C_double_complex  _Dcomplex;
typedef _C_float_complex   _Fcomplex;
typedef _C_ldouble_complex _Lcomplex;

So we will need to clean up quite a bit to not using complex and _Complex directly, probably changing everything into our own typedefs cfloat32, cfloat64 similar to our current cfloat16 and cfloat128.

return explainErrorComplex<float>();
else if constexpr (cpp::is_complex_type_same<T, _Complex double>())
Expand All @@ -151,11 +156,12 @@ template <typename T, TestCond Condition> class CFPMatcher : public Matcher<T> {
#ifdef LIBC_TYPES_HAS_CFLOAT16
else if constexpr (cpp::is_complex_type_same<T, cfloat16>())
return explainErrorComplex<float16>();
#endif
#endif // LIBC_TYPES_HAS_CFLOAT16
#ifdef LIBC_TYPES_HAS_CFLOAT128
else if constexpr (cpp::is_complex_type_same<T, cfloat128>())
return explainErrorComplex<float128>();
#endif
#endif // LIBC_TYPES_HAS_CFLOAT128
#endif // LIBC_COMPILER_IS_MSVC
}
};

Expand Down
Loading