commit f1cd342ce5911a84caa58e1ab160f55f72121abc
parent 3f9ce496f04527431a6fd074db2641385ced8aea
Author: Nick Vatamaniuc <nickva@users.noreply.github.com>
Date: Mon, 12 Feb 2024 05:28:00 -0500
FreeBSD QuickJS Patch (#203)
Diffstat:
3 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/quickjs/Makefile b/quickjs/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/quickjs/qjs.c b/quickjs/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"
diff --git a/quickjs/quickjs-libc.c b/quickjs/quickjs-libc.c
@@ -51,8 +51,15 @@
#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())