From 636c946531c3c1e1c113b509b06a84a973b591a1 Mon Sep 17 00:00:00 2001 From: Nick Vatamaniuc Date: Mon, 12 Feb 2024 05:28:00 -0500 Subject: [PATCH] FreeBSD QuickJS Patch (#203) --- Makefile | 9 +++++++++ qjs.c | 2 ++ quickjs-libc.c | 9 ++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 03d77ed..ead045f 100644 --- 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 bcee957..0332895 100644 --- a/qjs.c +++ b/qjs.c @@ -36,6 +36,8 @@ #include #elif defined(__linux__) #include +#elif defined(__FreeBSD__) +#include #endif #include "cutils.h" diff --git a/quickjs-libc.c b/quickjs-libc.c index 7eea0d7..2e77950 100644 --- a/quickjs-libc.c +++ b/quickjs-libc.c @@ -47,8 +47,15 @@ #include #include -#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 #define environ (*_NSGetEnviron())