aboutsummaryrefslogtreecommitdiff
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
parent26df7ca8926c67311f5ca1fbfc04e2c374c3e1a3 (diff)
downloadbun-599f63c2047b5adcc3cd774a8ad89a52150d24b2.tar.gz
bun-599f63c2047b5adcc3cd774a8ad89a52150d24b2.tar.zst
bun-599f63c2047b5adcc3cd774a8ad89a52150d24b2.zip
Support macOS 10.15
Fixes #1266 Fixes #1323 Fixes #2154
-rw-r--r--src/bun.js/bindings/workaround-missing-symbols.cpp (renamed from src/bun.js/bindings/glibc-versions-hack.cpp)79
1 files changed, 75 insertions, 4 deletions
diff --git a/src/bun.js/bindings/glibc-versions-hack.cpp b/src/bun.js/bindings/workaround-missing-symbols.cpp
index 33d94c809..1904eb9d8 100644
--- a/src/bun.js/bindings/glibc-versions-hack.cpp
+++ b/src/bun.js/bindings/workaround-missing-symbols.cpp
@@ -1,3 +1,7 @@
+#ifndef UNLIKELY
+#define UNLIKELY(x) __builtin_expect(!!(x), 0)
+#endif
+
// if linux
#if defined(__linux__)
@@ -8,10 +12,6 @@
#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
@@ -182,3 +182,74 @@ extern "C" int __wrap_mknodat(int dirfd, const char* path, __mode_t mode, __dev_
}
#endif
+
+// macOS
+#if defined(__APPLE__)
+
+#include <dlfcn.h>
+
+extern "C" int pthread_self_is_exiting_np()
+{
+ static void* pthread_self_is_exiting_np_ptr = nullptr;
+ static bool pthread_self_is_exiting_np_ptr_initialized = false;
+ if (UNLIKELY(!pthread_self_is_exiting_np_ptr_initialized)) {
+ pthread_self_is_exiting_np_ptr_initialized = true;
+ pthread_self_is_exiting_np_ptr = dlsym(RTLD_DEFAULT, "pthread_self_is_exiting_np");
+ }
+
+ if (UNLIKELY(pthread_self_is_exiting_np_ptr == nullptr))
+ return 0;
+
+ return ((int (*)())pthread_self_is_exiting_np_ptr)();
+}
+
+extern "C" int posix_spawn_file_actions_addchdir_np(
+ void* file_actions,
+ const char* path)
+{
+ static void* posix_spawn_file_actions_addchdir_np_ptr = nullptr;
+ static bool posix_spawn_file_actions_addchdir_np_ptr_initialized = false;
+ if (UNLIKELY(!posix_spawn_file_actions_addchdir_np_ptr_initialized)) {
+ posix_spawn_file_actions_addchdir_np_ptr_initialized = true;
+ posix_spawn_file_actions_addchdir_np_ptr = dlsym(RTLD_DEFAULT, "posix_spawn_file_actions_addchdir_np");
+ }
+
+ if (UNLIKELY(posix_spawn_file_actions_addchdir_np_ptr == nullptr))
+ return 0;
+
+ return ((int (*)(void*, const char*))posix_spawn_file_actions_addchdir_np_ptr)(file_actions, path);
+}
+
+extern "C" int posix_spawn_file_actions_addinherit_np(void* ptr,
+ int status)
+{
+ static void* posix_spawn_file_actions_addinherit_np_ptr = nullptr;
+ static bool posix_spawn_file_actions_addinherit_np_ptr_initialized = false;
+ if (UNLIKELY(!posix_spawn_file_actions_addinherit_np_ptr_initialized)) {
+ posix_spawn_file_actions_addinherit_np_ptr_initialized = true;
+ posix_spawn_file_actions_addinherit_np_ptr = dlsym(RTLD_DEFAULT, "posix_spawn_file_actions_addinherit_np");
+ }
+
+ if (UNLIKELY(posix_spawn_file_actions_addinherit_np_ptr == nullptr))
+ return 0;
+
+ return ((int (*)(void*, int))posix_spawn_file_actions_addinherit_np_ptr)(ptr, status);
+}
+
+extern "C" int posix_spawn_file_actions_addfchdir_np(void* ptr,
+ int fd)
+{
+ static void* posix_spawn_file_actions_addfchdir_np_ptr = nullptr;
+ static bool posix_spawn_file_actions_addfchdir_np_ptr_initialized = false;
+ if (UNLIKELY(!posix_spawn_file_actions_addfchdir_np_ptr_initialized)) {
+ posix_spawn_file_actions_addfchdir_np_ptr_initialized = true;
+ posix_spawn_file_actions_addfchdir_np_ptr = dlsym(RTLD_DEFAULT, "posix_spawn_file_actions_addfchdir_np");
+ }
+
+ if (UNLIKELY(posix_spawn_file_actions_addfchdir_np_ptr == nullptr))
+ return 0;
+
+ return ((int (*)(void*, int))posix_spawn_file_actions_addfchdir_np_ptr)(ptr, fd);
+}
+
+#endif