aboutsummaryrefslogtreecommitdiff
path: root/src/bun.js/bindings/glibc-versions-hack.cpp
diff options
context:
space:
mode:
authorGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-24 15:07:15 -0800
committerGravatar Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> 2023-02-24 15:07:27 -0800
commit599f63c2047b5adcc3cd774a8ad89a52150d24b2 (patch)
treeb77b16d700024a0540c513cae73f0073c9da27a2 /src/bun.js/bindings/glibc-versions-hack.cpp
parent26df7ca8926c67311f5ca1fbfc04e2c374c3e1a3 (diff)
downloadbun-599f63c2047b5adcc3cd774a8ad89a52150d24b2.tar.gz
bun-599f63c2047b5adcc3cd774a8ad89a52150d24b2.tar.zst
bun-599f63c2047b5adcc3cd774a8ad89a52150d24b2.zip
Support macOS 10.15
Fixes #1266 Fixes #1323 Fixes #2154
Diffstat (limited to 'src/bun.js/bindings/glibc-versions-hack.cpp')
-rw-r--r--src/bun.js/bindings/glibc-versions-hack.cpp184
1 files changed, 0 insertions, 184 deletions
diff --git a/src/bun.js/bindings/glibc-versions-hack.cpp b/src/bun.js/bindings/glibc-versions-hack.cpp
deleted file mode 100644
index 33d94c809..000000000
--- a/src/bun.js/bindings/glibc-versions-hack.cpp
+++ /dev/null
@@ -1,184 +0,0 @@
-// if linux
-#if defined(__linux__)
-
-#include <fcntl.h>
-// #include <sys/stat.h>
-#include <stdarg.h>
-#include <math.h>
-#include <errno.h>
-#include <dlfcn.h>
-
-#ifndef UNLIKELY
-#define UNLIKELY(x) __builtin_expect(!!(x), 0)
-#endif
-
-#ifndef _STAT_VER
-#if defined(__aarch64__)
-#define _STAT_VER 0
-#elif defined(__x86_64__)
-#define _STAT_VER 1
-#else
-#define _STAT_VER 3
-#endif
-#endif
-
-#if defined(__x86_64__)
-// Force older versions of symbols
-__asm__(".symver pow,pow@GLIBC_2.2.5");
-__asm__(".symver log,log@GLIBC_2.2.5");
-#endif
-
-// ban statx, for now
-extern "C" int __wrap_statx(int fd, const char* path, int flags,
- unsigned int mask, struct statx* buf)
-{
- errno = ENOSYS;
-#ifdef BUN_DEBUG
- abort();
-#endif
- return -1;
-}
-
-extern "C" int __real_fcntl(int fd, int cmd, ...);
-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, ...)
-{
- va_list va;
- va_start(va, cmd);
- return __real_fcntl(fd, cmd, va_arg(va, void*));
- va_end(va);
-}
-
-extern "C" int __wrap_fcntl64(int fd, int cmd, ...)
-{
- va_list va;
- va_start(va, cmd);
- return __real_fcntl(fd, cmd, va_arg(va, void*));
- va_end(va);
-}
-
-extern "C" double __wrap_pow(double x, double 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)
-{
- return __real_exp(x);
-}
-
-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
-
-extern "C" int __lxstat(int ver, const char* filename, struct stat* stat);
-extern "C" int __wrap_lstat(const char* filename, struct stat* stat)
-{
- return __lxstat(_STAT_VER, filename, stat);
-}
-
-extern "C" int __xstat(int ver, const char* filename, struct stat* stat);
-extern "C" int __wrap_stat(const char* filename, struct stat* stat)
-{
- return __xstat(_STAT_VER, filename, stat);
-}
-
-extern "C" int __fxstat(int ver, int fd, struct stat* stat);
-extern "C" int __wrap_fstat(int fd, struct stat* stat)
-{
- return __fxstat(_STAT_VER, fd, stat);
-}
-
-extern "C" int __fxstatat(int ver, int dirfd, const char* path, struct stat* stat, int flags);
-extern "C" int __wrap_fstatat(int dirfd, const char* path, struct stat* stat, int flags)
-{
- return __fxstatat(_STAT_VER, dirfd, path, stat, flags);
-}
-
-extern "C" int __lxstat64(int ver, const char* filename, struct stat64* stat);
-extern "C" int __wrap_lstat64(const char* filename, struct stat64* stat)
-{
- return __lxstat64(_STAT_VER, filename, stat);
-}
-
-extern "C" int __xstat64(int ver, const char* filename, struct stat64* stat);
-extern "C" int __wrap_stat64(const char* filename, struct stat64* stat)
-{
- return __xstat64(_STAT_VER, filename, stat);
-}
-
-extern "C" int __fxstat64(int ver, int fd, struct stat64* stat);
-extern "C" int __wrap_fstat64(int fd, struct stat64* stat)
-{
- return __fxstat64(_STAT_VER, fd, stat);
-}
-
-extern "C" int __fxstatat64(int ver, int dirfd, const char* path, struct stat64* stat, int flags);
-extern "C" int __wrap_fstatat64(int dirfd, const char* path, struct stat64* stat, int flags)
-{
- return __fxstatat64(_STAT_VER, dirfd, path, stat, flags);
-}
-
-extern "C" int __xmknod(int ver, const char* path, __mode_t mode, __dev_t dev);
-extern "C" int __wrap_mknod(const char* path, __mode_t mode, __dev_t dev)
-{
- return __xmknod(_MKNOD_VER, path, mode, dev);
-}
-
-extern "C" int __xmknodat(int ver, int dirfd, const char* path, __mode_t mode, __dev_t dev);
-extern "C" int __wrap_mknodat(int dirfd, const char* path, __mode_t mode, __dev_t dev)
-{
- return __xmknodat(_MKNOD_VER, dirfd, path, mode, dev);
-}
-
-#endif