Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Worker API on mingw if winpthread is present #440

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ if(WIN32)
endif()
list(APPEND qjs_libs qjs ${CMAKE_DL_LIBS})
find_package(Threads)
if(MINGW AND CMAKE_USE_PTHREADS_INIT)
list(APPEND qjs_defines USE_WINPTHREAD)
endif()
if(NOT CMAKE_SYSTEM_NAME STREQUAL "WASI")
list(APPEND qjs_libs ${CMAKE_THREAD_LIBS_INIT})
endif()
Expand Down Expand Up @@ -235,7 +238,7 @@ endif()
#

# run-test262 uses pthreads.
if(NOT WIN32 AND NOT EMSCRIPTEN)
if((NOT WIN32 AND NOT EMSCRIPTEN) OR (MINGW AND CMAKE_USE_PTHREADS_INIT))
add_executable(run-test262
quickjs-libc.c
run-test262.c
Expand Down
5 changes: 4 additions & 1 deletion quickjs-libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@
#define rmdir _rmdir
#define getcwd _getcwd
#define chdir _chdir
#ifdef USE_WINPTHREAD
#define pipe(fds) _pipe(fds,1024, _O_BINARY)
#endif
#else
#include <sys/ioctl.h>
#if !defined(__wasi__)
Expand All @@ -80,7 +83,7 @@ extern char **environ;

#endif /* _WIN32 */

#if !defined(_WIN32) && !defined(__wasi__)
#if (!defined(_WIN32) || defined(USE_WINPTHREAD)) && !defined(__wasi__)
/* enable the os.Worker API. IT relies on POSIX threads */
#define USE_WORKER
#endif
Expand Down
Loading