aboutsummaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
Diffstat (limited to 'libc')
-rw-r--r--libc/src/string/memory_utils/op_generic.h15
-rw-r--r--libc/test/UnitTest/FEnvSafeTest.cpp2
2 files changed, 14 insertions, 3 deletions
diff --git a/libc/src/string/memory_utils/op_generic.h b/libc/src/string/memory_utils/op_generic.h
index 010f218..a86cbd8 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<uint8_t, 16> {};
+struct alignas(32) generic_v256 : public cpp::array<uint8_t, 32> {};
+struct alignas(64) generic_v512 : public cpp::array<uint8_t, 64> {};
+} // namespace LIBC_NAMESPACE_DECL
+#endif
#else
namespace LIBC_NAMESPACE_DECL {
@@ -159,7 +169,8 @@ template <typename T> struct Memset {
LIBC_INLINE static void block(Ptr dst, uint8_t value) {
if constexpr (is_scalar_v<T> || is_vector_v<T>) {
- store<T>(dst, splat<T>(value));
+ // Avoid ambiguous call due to ADL
+ generic::store<T>(dst, splat<T>(value));
} else if constexpr (is_array_v<T>) {
using value_type = typename T::value_type;
const auto Splat = splat<value_type>(value);
diff --git a/libc/test/UnitTest/FEnvSafeTest.cpp b/libc/test/UnitTest/FEnvSafeTest.cpp
index 2730de3..4393f9d 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<const FPState &>(before_fenv);
const FPState &after_state = reinterpret_cast<const FPState &>(after_fenv);