diff options
author | 2023-01-05 00:22:48 -0800 | |
---|---|---|
committer | 2023-01-05 00:24:53 -0800 | |
commit | 3005d9e3487a40c6e5bba99bc37e0944a2c25e3f (patch) | |
tree | 290ac283e7e259fc3b9fd3230b910548ce0f81cb | |
parent | 7f96f72d65005f3d51ff7500cdc3ef75878c0ae7 (diff) | |
download | bun-3005d9e3487a40c6e5bba99bc37e0944a2c25e3f.tar.gz bun-3005d9e3487a40c6e5bba99bc37e0944a2c25e3f.tar.zst bun-3005d9e3487a40c6e5bba99bc37e0944a2c25e3f.zip |
Really fix #1722
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | src/bun.js/bindings/glibc-versions-hack.cpp | 42 |
2 files changed, 41 insertions, 3 deletions
@@ -442,7 +442,7 @@ STATIC_MUSL_FLAG ?= WRAP_SYMBOLS_ON_LINUX = ifeq ($(OS_NAME), linux) -WRAP_SYMBOLS_ON_LINUX = -Wl,--wrap=fcntl -Wl,--wrap=fcntl64 -Wl,--wrap=stat64 -Wl,--wrap=pow -Wl,--wrap=exp -Wl,--wrap=log \ +WRAP_SYMBOLS_ON_LINUX = -Wl,--wrap=fcntl -Wl,--wrap=fcntl64 -Wl,--wrap=stat64 -Wl,--wrap=pow -Wl,--wrap=exp -Wl,--wrap=log -Wl,--wrap=log2 \ -Wl,--wrap=lstat \ -Wl,--wrap=stat \ -Wl,--wrap=fstat \ diff --git a/src/bun.js/bindings/glibc-versions-hack.cpp b/src/bun.js/bindings/glibc-versions-hack.cpp index 1cfce5fb4..1be279202 100644 --- a/src/bun.js/bindings/glibc-versions-hack.cpp +++ b/src/bun.js/bindings/glibc-versions-hack.cpp @@ -40,8 +40,41 @@ extern "C" int __wrap_statx(int fd, const char* path, int flags, } extern "C" int __real_fcntl(int fd, int cmd, ...); -extern "C" double __real_exp(double x); -extern "C" double __real_log(double x); +typedef double (*MathFunction)(double); + +static inline double __real_exp(double x) +{ + static MathFunction function = nullptr; + if (UNLIKELY(function == nullptr)) { + function = reinterpret_cast<MathFunction>(dlsym(nullptr, "exp")); + if (UNLIKELY(function == nullptr)) + abort(); + } + + return function(x); +} +static inline double __real_log(double x) +{ + static MathFunction function = nullptr; + if (UNLIKELY(function == nullptr)) { + function = reinterpret_cast<MathFunction>(dlsym(nullptr, "log")); + if (UNLIKELY(function == nullptr)) + abort(); + } + + return function(x); +} +static inline double __real_log2(double x) +{ + static MathFunction function = nullptr; + if (UNLIKELY(function == nullptr)) { + function = reinterpret_cast<MathFunction>(dlsym(nullptr, "log2")); + if (UNLIKELY(function == nullptr)) + abort(); + } + + return function(x); +} extern "C" int __wrap_fcntl(int fd, int cmd, ...) { @@ -79,6 +112,11 @@ extern "C" double __wrap_log(double x) return __real_log(x); } +extern "C" double __wrap_log2(double x) +{ + return __real_log2(x); +} + #ifndef _MKNOD_VER #define _MKNOD_VER 1 #endif |