Skip to content

Threaded emscripten support #571

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

Open
wants to merge 1 commit into
base: emscripten_testing
Choose a base branch
from
Open
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,10 @@ else ifeq ($(platform), emscripten)
CC = emcc
CXX = em++
HAVE_NEON = 0

ifneq ($(pthread),0)
CPUFLAGS += -pthread
LDFLAGS += -lpthread
endif
COREFLAGS += -DOS_LINUX
STATIC_LINKING = 1
# Windows
Expand Down
13 changes: 13 additions & 0 deletions libretro/libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -490,6 +490,15 @@ static void EmuThreadFunction(void)
return;
}

#ifdef EMSCRIPTEN
/* Emscripten is very strict about function signatures */
static void *EmuThreadFunctionWrapper(void* param)
{
EmuThreadFunction();
return NULL;
}
#endif

static void reinit_gfx_plugin(void)
{
#ifdef HAVE_PARALLEL_RDP
Expand Down Expand Up @@ -2000,7 +2009,11 @@ void retro_run (void)
{
if(!emuThreadRunning)
{
#ifdef EMSCRIPTEN
pthread_create(&emuThread, NULL, &EmuThreadFunctionWrapper, NULL);
#else
pthread_create(&emuThread, NULL, &EmuThreadFunction, NULL);
#endif
emuThreadRunning = true;
}
}
Expand Down