diff options
author | 2022-12-06 17:20:37 -0800 | |
---|---|---|
committer | 2022-12-06 17:21:07 -0800 | |
commit | 41d778fbfbee6e97c6ac355938086b30a8b29f56 (patch) | |
tree | 3448d665f0952d18884f7a610b797f2704df318b /src/bun.js/bindings/glibc-versions-hack.cpp | |
parent | 5f3a6f2bf3b91c6c4fa0ad7f4197863ef6980889 (diff) | |
download | bun-41d778fbfbee6e97c6ac355938086b30a8b29f56.tar.gz bun-41d778fbfbee6e97c6ac355938086b30a8b29f56.tar.zst bun-41d778fbfbee6e97c6ac355938086b30a8b29f56.zip |
dlsym pow
Diffstat (limited to 'src/bun.js/bindings/glibc-versions-hack.cpp')
-rw-r--r-- | src/bun.js/bindings/glibc-versions-hack.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/bun.js/bindings/glibc-versions-hack.cpp b/src/bun.js/bindings/glibc-versions-hack.cpp index 345321b94..73b096011 100644 --- a/src/bun.js/bindings/glibc-versions-hack.cpp +++ b/src/bun.js/bindings/glibc-versions-hack.cpp @@ -6,6 +6,7 @@ #include <stdarg.h> #include <math.h> #include <errno.h> +#include <dlfcn.h> #ifndef _STAT_VER #if defined(__aarch64__) @@ -34,7 +35,6 @@ 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_pow(double x, double y); extern "C" double __real_exp(double x); extern "C" double __real_log(double x); @@ -54,13 +54,14 @@ extern "C" int __wrap_fcntl64(int fd, int cmd, ...) va_end(va); } -// I couldn't figure out what has changed in pow, exp, log in glibc 2.29. -// Interestingly despite compiling with -fno-omit-frame-pointer, GCC -// optimises the following to a jmp anyway. - extern "C" double __wrap_pow(double x, double y) { - return __real_pow(x, y); + static void* pow_ptr = nullptr; + if (UNLIKELY(pow_ptr == nullptr)) { + pow_ptr = dlsym(RTLD_DEFAULT, "pow"); + } + + return ((double (*)(double, double))pow_ptr)(x, y); } extern "C" double __wrap_exp(double x) |