diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 89ee5f2..4e2733f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -386,3 +386,18 @@ jobs: run: | cd $GITHUB_WORKSPACE make --debug test + + openbsd: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: build + test + uses: vmactions/openbsd-vm@v1 + with: + usesh: true + prepare: | + pkg_add cmake + run: | + cmake -B build + cmake --build build -j $(sysctl -n hw.ncpu) + ./build/qjs -qd diff --git a/CMakeLists.txt b/CMakeLists.txt index d485cf0..7e4cbc4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -145,10 +145,7 @@ if(BUILD_QJS_LIBC) list(APPEND qjs_sources quickjs-libc.c) endif() list(APPEND qjs_defines _GNU_SOURCE) -list(APPEND qjs_libs qjs) -if(NOT WIN32) - list(APPEND qjs_libs dl) -endif() +list(APPEND qjs_libs qjs ${CMAKE_DL_LIBS}) if(NOT MSVC) list(APPEND qjs_libs m pthread) endif() diff --git a/qjs.c b/qjs.c index 4bedc8b..47e207e 100644 --- a/qjs.c +++ b/qjs.c @@ -135,13 +135,10 @@ static inline size_t js_trace_malloc_usable_size(void *ptr) return malloc_size(ptr); #elif defined(_WIN32) return _msize(ptr); -#elif defined(EMSCRIPTEN) - return 0; #elif defined(__linux__) return malloc_usable_size(ptr); #else - /* change this to `return 0;` if compilation fails */ - return malloc_usable_size(ptr); + return 0; #endif } @@ -257,13 +254,10 @@ static const JSMallocFunctions trace_mf = { malloc_size, #elif defined(_WIN32) (size_t (*)(const void *))_msize, -#elif defined(EMSCRIPTEN) - NULL, #elif defined(__linux__) || defined(__CYGWIN__) (size_t (*)(const void *))malloc_usable_size, #else - /* change this to `NULL,` if compilation fails */ - malloc_usable_size, + NULL, #endif }; diff --git a/quickjs-libc.c b/quickjs-libc.c index 08eb00d..c871a16 100644 --- a/quickjs-libc.c +++ b/quickjs-libc.c @@ -73,12 +73,15 @@ typedef sig_t sighandler_t; #endif #endif /* __APPLE__ */ +#if defined(__OpenBSD__) +typedef sig_t sighandler_t; +extern char **environ; #endif -#if !defined(_WIN32) /* enable the os.Worker API. IT relies on POSIX threads */ #define USE_WORKER -#endif + +#endif /* _WIN32 */ #ifdef USE_WORKER #include @@ -3584,8 +3587,12 @@ void js_std_set_worker_new_context_func(JSContext *(*func)(JSRuntime *rt)) #define OS_PLATFORM "js" #elif defined(__CYGWIN__) #define OS_PLATFORM "cygwin" -#else +#elif defined(__linux__) #define OS_PLATFORM "linux" +#elif defined(__OpenBSD__) +#define OS_PLATFORM "openbsd" +#else +#define OS_PLATFORM "unknown" #endif #define OS_FLAG(x) JS_PROP_INT32_DEF(#x, x, JS_PROP_CONFIGURABLE ) diff --git a/quickjs.c b/quickjs.c index de9ad3e..956c05e 100644 --- a/quickjs.c +++ b/quickjs.c @@ -1646,13 +1646,10 @@ static inline size_t js_def_malloc_usable_size(void *ptr) return malloc_size(ptr); #elif defined(_WIN32) return _msize(ptr); -#elif defined(EMSCRIPTEN) - return 0; #elif defined(__linux__) return malloc_usable_size(ptr); #else - /* change this to `return 0;` if compilation fails */ - return malloc_usable_size(ptr); + return 0; #endif } @@ -1720,13 +1717,10 @@ static const JSMallocFunctions def_malloc_funcs = { malloc_size, #elif defined(_WIN32) (size_t (*)(const void *))_msize, -#elif defined(EMSCRIPTEN) - NULL, #elif defined(__linux__) || defined (__CYGWIN__) (size_t (*)(const void *))malloc_usable_size, #else - /* change this to `NULL,` if compilation fails */ - malloc_usable_size, + NULL, #endif };