mirror of
https://github.com/lovell/sharp.git
synced 2025-12-19 07:15:08 +01:00
Prevent use of linux-x64 binaries with v1 microarchitecture
This commit is contained in:
@@ -33,6 +33,7 @@ Napi::Object init(Napi::Env env, Napi::Object exports) {
|
||||
exports.Set("block", Napi::Function::New(env, block));
|
||||
exports.Set("_maxColourDistance", Napi::Function::New(env, _maxColourDistance));
|
||||
exports.Set("_isUsingJemalloc", Napi::Function::New(env, _isUsingJemalloc));
|
||||
exports.Set("_isUsingX64V2", Napi::Function::New(env, _isUsingX64V2));
|
||||
exports.Set("stats", Napi::Function::New(env, stats));
|
||||
return exports;
|
||||
}
|
||||
|
||||
@@ -267,3 +267,20 @@ Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info) {
|
||||
return Napi::Boolean::New(env, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GNUC__) && defined(__x86_64__)
|
||||
// Are SSE 4.2 intrinsics available at runtime?
|
||||
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
__asm__ __volatile__("cpuid"
|
||||
: "=a"(eax), "=b"(ebx), "=c"(ecx), "=d"(edx)
|
||||
: "a"(1));
|
||||
return Napi::Boolean::New(env, (ecx & 1U << 20) != 0);
|
||||
}
|
||||
#else
|
||||
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info) {
|
||||
Napi::Env env = info.Env();
|
||||
return Napi::Boolean::New(env, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -15,5 +15,6 @@ Napi::Value format(const Napi::CallbackInfo& info);
|
||||
void block(const Napi::CallbackInfo& info);
|
||||
Napi::Value _maxColourDistance(const Napi::CallbackInfo& info);
|
||||
Napi::Value _isUsingJemalloc(const Napi::CallbackInfo& info);
|
||||
Napi::Value _isUsingX64V2(const Napi::CallbackInfo& info);
|
||||
|
||||
#endif // SRC_UTILITIES_H_
|
||||
|
||||
Reference in New Issue
Block a user