diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h index 010f2187a4ffd..a86cbd8bcfc72 100644 --- a/libc/src/string/memory_utils/op_generic.h +++ b/libc/src/string/memory_utils/op_generic.h @@ -41,12 +41,22 @@ static_assert((UINTPTR_MAX == 4294967295U) || "We currently only support 32- or 64-bit platforms"); #ifdef LIBC_COMPILER_IS_MSVC - +#ifdef LIBC_TARGET_ARCH_IS_X86 namespace LIBC_NAMESPACE_DECL { using generic_v128 = __m128i; using generic_v256 = __m256i; using generic_v512 = __m512i; } // namespace LIBC_NAMESPACE_DECL +#else +// Special handling when target does not have real vector types. +// We can potentially use uint8x16_t etc. However, MSVC does not provide +// subscript operation. +namespace LIBC_NAMESPACE_DECL { +struct alignas(16) generic_v128 : public cpp::array {}; +struct alignas(32) generic_v256 : public cpp::array {}; +struct alignas(64) generic_v512 : public cpp::array {}; +} // namespace LIBC_NAMESPACE_DECL +#endif #else namespace LIBC_NAMESPACE_DECL { @@ -159,7 +169,8 @@ template struct Memset { LIBC_INLINE static void block(Ptr dst, uint8_t value) { if constexpr (is_scalar_v || is_vector_v) { - store(dst, splat(value)); + // Avoid ambiguous call due to ADL + generic::store(dst, splat(value)); } else if constexpr (is_array_v) { using value_type = typename T::value_type; const auto Splat = splat(value); diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp index 2730de350b39a..4393f9d5e5c3b 100644 --- a/libc/test/UnitTest/FEnvSafeTest.cpp +++ b/libc/test/UnitTest/FEnvSafeTest.cpp @@ -43,7 +43,7 @@ void FEnvSafeTest::set_fenv(const fenv_t &fenv) { void FEnvSafeTest::expect_fenv_eq(const fenv_t &before_fenv, const fenv_t &after_fenv) { -#if defined(LIBC_TARGET_ARCH_IS_AARCH64) +#if defined(LIBC_TARGET_ARCH_IS_AARCH64) && !defined(LIBC_COMPILER_IS_MSVC) using FPState = LIBC_NAMESPACE::fputil::FEnv::FPState; const FPState &before_state = reinterpret_cast(before_fenv); const FPState &after_state = reinterpret_cast(after_fenv);