Skip to content

Commit 3f4532d

Browse files
committed
Add FreeBSD support
1 parent 6bd95a0 commit 3f4532d

File tree

4 files changed

+22
-5
lines changed

4 files changed

+22
-5
lines changed

.github/workflows/ci.yml

+15
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,18 @@ jobs:
401401
cmake -B build
402402
cmake --build build -j $(sysctl -n hw.ncpu)
403403
./build/qjs -qd
404+
405+
freebsd:
406+
runs-on: ubuntu-latest
407+
steps:
408+
- uses: actions/checkout@v3
409+
- name: build + test
410+
uses: vmactions/freebsd-vm@v1
411+
with:
412+
usesh: true
413+
prepare: |
414+
pkg install -y cmake
415+
run: |
416+
cmake -B build
417+
cmake --build build -j $(sysctl -n hw.ncpu)
418+
./build/qjs -qd

qjs.c

+3-1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@
3838
#include <malloc/malloc.h>
3939
#elif defined(__linux__) || defined(__CYGWIN__)
4040
#include <malloc.h>
41+
#elif defined(__FreeBSD__)
42+
#include <malloc_np.h>
4143
#endif
4244

4345
#include "cutils.h"
@@ -135,7 +137,7 @@ static inline size_t js_trace_malloc_usable_size(void *ptr)
135137
return malloc_size(ptr);
136138
#elif defined(_WIN32)
137139
return _msize(ptr);
138-
#elif defined(__linux__)
140+
#elif defined(__linux__) || defined(__FreeBSD__)
139141
return malloc_usable_size(ptr);
140142
#else
141143
return 0;

quickjs-libc.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,11 @@
6767

6868
#if defined(__APPLE__)
6969
typedef sig_t sighandler_t;
70-
#if !defined(environ)
7170
#include <crt_externs.h>
7271
#define environ (*_NSGetEnviron())
7372
#endif
74-
#endif /* __APPLE__ */
7573

76-
#if defined(__OpenBSD__)
74+
#if defined(__OpenBSD__) || defined(__FreeBSD__)
7775
typedef sig_t sighandler_t;
7876
extern char **environ;
7977
#endif
@@ -3591,6 +3589,8 @@ void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt))
35913589
#define OS_PLATFORM "linux"
35923590
#elif defined(__OpenBSD__)
35933591
#define OS_PLATFORM "openbsd"
3592+
#elif defined(__FreeBSD__)
3593+
#define OS_PLATFORM "freebsd"
35943594
#else
35953595
#define OS_PLATFORM "unknown"
35963596
#endif

quickjs.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1646,7 +1646,7 @@ static inline size_t js_def_malloc_usable_size(void *ptr)
16461646
return malloc_size(ptr);
16471647
#elif defined(_WIN32)
16481648
return _msize(ptr);
1649-
#elif defined(__linux__)
1649+
#elif defined(__linux__) || defined(__FreeBSD__)
16501650
return malloc_usable_size(ptr);
16511651
#else
16521652
return 0;

0 commit comments

Comments
 (0)