Skip to content

Commit c9bc16d

Browse files
committed
Add support for WebAssembly compatibility
1 parent 774ba0f commit c9bc16d

File tree

2 files changed

+18
-8
lines changed

2 files changed

+18
-8
lines changed

src/distance-cpu.c

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -732,15 +732,21 @@ float int8_distance_l1_cpu (const void *v1, const void *v2, int n) {
732732
return true;
733733
}
734734
#else
735-
#include <sys/auxv.h>
736-
#include <asm/hwcap.h>
737-
bool cpu_supports_neon (void) {
738-
#ifdef AT_HWCAP
739-
return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0;
735+
#ifdef SQLITE_WASM_EXTRA_INIT
736+
bool cpu_supports_neon (void) {
737+
return false;
738+
}
740739
#else
741-
return false;
740+
#include <sys/auxv.h>
741+
#include <asm/hwcap.h>
742+
bool cpu_supports_neon (void) {
743+
#ifdef AT_HWCAP
744+
return (getauxval(AT_HWCAP) & HWCAP_NEON) != 0;
745+
#else
746+
return false;
747+
#endif
748+
}
742749
#endif
743-
}
744750
#endif
745751
#endif
746752

src/sqlite-vector.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
#include <stdbool.h>
2222
#include <stddef.h>
2323

24-
#if defined(_WIN32) || ((defined(__linux__) && !defined(__GLIBC__) && !defined(__ANDROID__)))
24+
#if defined(_WIN32) || ((defined(__linux__) && !defined(__GLIBC__) && !defined(__ANDROID__))) || defined(SQLITE_WASM_EXTRA_INIT)
25+
// Provide strcasestr function implementation for environments that lack it:
26+
// - Windows (MinGW, MSVC, etc.)
27+
// - Linux with non-glibc C libraries (musl, uclibc, etc.)
28+
// - WebAssembly builds
2529
char *strcasestr(const char *haystack, const char *needle) {
2630
if (!haystack || !needle) return NULL;
2731
if (!*needle) return (char *)haystack;

0 commit comments

Comments
 (0)