]> git.kaiwu.me - quickjs.git/commitdiff
FreeBSD QuickJS Patch (#203)
authorNick Vatamaniuc <nickva@users.noreply.github.com>
Mon, 12 Feb 2024 10:28:00 +0000 (05:28 -0500)
committerGitHub <noreply@github.com>
Mon, 12 Feb 2024 10:28:00 +0000 (11:28 +0100)
Makefile
qjs.c
quickjs-libc.c

index 03d77ed3e423ac64043918ccefcfac6315e7680c..ead045fe5756348552fb5e0f8a43eabcdf1f9a75 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -25,6 +25,9 @@
 ifeq ($(shell uname -s),Darwin)
 CONFIG_DARWIN=y
 endif
+ifeq ($(shell uname -s),FreeBSD)
+CONFIG_FREEBSD=y
+endif
 # Windows cross compilation from Linux
 #CONFIG_WIN32=y
 # use link time optimization (smaller and faster executables but slower build)
@@ -57,6 +60,12 @@ ifdef CONFIG_DARWIN
 CONFIG_CLANG=y
 CONFIG_DEFAULT_AR=y
 endif
+ifdef CONFIG_FREEBSD
+# use clang instead of gcc
+CONFIG_CLANG=y
+CONFIG_DEFAULT_AR=y
+CONFIG_LTO=
+endif
 
 ifdef CONFIG_WIN32
   ifdef CONFIG_M32
diff --git a/qjs.c b/qjs.c
index bcee95762d8d245ad9832e3e0adb0cf84423e9a9..033289598371acf259a00c5da3a09db7c675d67d 100644 (file)
--- a/qjs.c
+++ b/qjs.c
@@ -36,6 +36,8 @@
 #include <malloc/malloc.h>
 #elif defined(__linux__)
 #include <malloc.h>
+#elif defined(__FreeBSD__)
+#include <malloc_np.h>
 #endif
 
 #include "cutils.h"
index 7eea0d716a0d4c640b91c77bf23f22e078cdf5b1..2e779504f60e8af6182dfce6d51a68b3416b9db5 100644 (file)
 #include <sys/ioctl.h>
 #include <sys/wait.h>
 
-#if defined(__APPLE__)
+#if defined(__FreeBSD__)
+extern char **environ;
+#endif
+
+#if defined(__APPLE__) || defined(__FreeBSD__)
 typedef sig_t sighandler_t;
+#endif
+
+#if defined(__APPLE__)
 #if !defined(environ)
 #include <crt_externs.h>
 #define environ (*_NSGetEnviron())