Skip to content

Commit

Permalink
Add CONFIG_NO_WORKER Makefile option
Browse files Browse the repository at this point in the history
This option eliminates the dependency on the pthread library. This mode is
already toggled on _WIN32 and/or EMSCRIPTEN is detected, here we just allow the
user to toggle it at will at the top level.

This slightly reduce the code size as well, and may allow compiling this
library in some embedded contexts where pthread is not available or is broken.
  • Loading branch information
nickva committed Aug 26, 2024
1 parent 6e2e68f commit fdc6ba3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ ifeq ($(shell $(CC) -o /dev/null compat/test-closefrom.c 2>/dev/null && echo 1),
DEFINES+=-DHAVE_CLOSEFROM
endif
endif
ifdef CONFIG_NO_WORKER
DEFINES+=-DCONFIG_NO_WORKER
endif

CFLAGS+=$(DEFINES)
CFLAGS_DEBUG=$(CFLAGS) -O0
Expand Down
2 changes: 1 addition & 1 deletion quickjs-libc.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ typedef sig_t sighandler_t;

#endif

#if !defined(_WIN32)
#if !defined(_WIN32) && !defined(CONFIG_NO_WORKER)
/* enable the os.Worker API. IT relies on POSIX threads */
#define USE_WORKER
#endif
Expand Down
2 changes: 1 addition & 1 deletion quickjs.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@

/* define to include Atomics.* operations which depend on the OS
threads */
#if !defined(EMSCRIPTEN)
#if !defined(EMSCRIPTEN) && !defined(CONFIG_NO_WORKER)
#define CONFIG_ATOMICS
#endif

Expand Down

0 comments on commit fdc6ba3

Please sign in to comment.