diff options
Diffstat (limited to 'src/bun.js/bindings/c-bindings.cpp')
-rw-r--r-- | src/bun.js/bindings/c-bindings.cpp | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/src/bun.js/bindings/c-bindings.cpp b/src/bun.js/bindings/c-bindings.cpp index ff4c8c4e7..f53ff52cc 100644 --- a/src/bun.js/bindings/c-bindings.cpp +++ b/src/bun.js/bindings/c-bindings.cpp @@ -1,4 +1,5 @@ // when we don't want to use @cInclude, we can just stick wrapper functions here +#include "root.h" #include <sys/resource.h> #include <cstdint> #include <unistd.h> @@ -6,6 +7,32 @@ #include <sys/stat.h> #include <sys/signal.h> +#if CPU(X86_64) +#include <cstring> +#include <cpuid.h> + +extern "C" void bun_warn_avx_missing(const char* url) +{ + __builtin_cpu_init(); + if (__builtin_cpu_supports("avx")) { + return; + } + + static constexpr const char* str = "warn: CPU lacks AVX support, strange crashes may occur. Reinstall Bun or use *-baseline build:\n "; + const size_t len = strlen(str); + + char buf[512]; + strcpy(buf, str); + strcpy(buf + len, url); + strcpy(buf + len + strlen(url), "\n\0"); + write(STDERR_FILENO, buf, strlen(buf)); +} +#else +extern "C" void bun_warn_avx_missing(char* url) +{ +} +#endif + extern "C" int32_t get_process_priority(uint32_t pid) { return getpriority(PRIO_PROCESS, pid); @@ -48,4 +75,4 @@ extern "C" ssize_t bun_sysconf__SC_CLK_TCK() #else return 0; #endif -}
\ No newline at end of file +} |