add CLAY_DISABLE_SIMD flag to conditionally disable SIMD includes (#251)

This commit is contained in:
johan0A 2025-02-06 21:41:38 +01:00 committed by GitHub
parent bd2ce4b833
commit 7a84facec9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

8
clay.h
View File

@ -15,9 +15,9 @@
#include <stddef.h>
// SIMD includes on supported platforms
#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64)
#if !defined(CLAY_DISABLE_SIMD) && (defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64))
#include <emmintrin.h>
#elif __aarch64__
#elif !defined(CLAY_DISABLE_SIMD) && defined(__aarch64__)
#include <arm_neon.h>
#endif
@ -1384,7 +1384,7 @@ void Clay__CloseElement(void) {
}
bool Clay__MemCmp(const char *s1, const char *s2, int32_t length);
#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64)
#if !defined(CLAY_DISABLE_SIMD) && (defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64))
bool Clay__MemCmp(const char *s1, const char *s2, int32_t length) {
while (length >= 16) {
__m128i v1 = _mm_loadu_si128((const __m128i *)s1);
@ -1410,7 +1410,7 @@ bool Clay__MemCmp(const char *s1, const char *s2, int32_t length);
return true;
}
#elif defined(__aarch64__)
#elif !defined(CLAY_DISABLE_SIMD) && defined(__aarch64__)
bool Clay__MemCmp(const char *s1, const char *s2, int32_t length) {
while (length >= 16) {
uint8x16_t v1 = vld1q_u8((const uint8_t *)s1);