thread: Put all important SDL_CreateThread internal data into SDL_Thread.

This avoids the need to malloc something extra, use a semaphore, etc, and
fixes Emscripten with pthreads support, which might not spin up a web worker
until after SDL_CreateThread returns and thus can't wait on a semaphore at
this point in any case.

Fixes Bugzilla #5064.
This commit is contained in:
Ryan C. Gordon 2020-03-26 22:14:59 -04:00
parent abdc5cbf24
commit 46bb47cf04
8 changed files with 44 additions and 97 deletions

View file

@ -76,7 +76,7 @@ RunThread(void *data)
#ifdef __ANDROID__
Android_JNI_SetupThread();
#endif
SDL_RunThread(data);
SDL_RunThread((SDL_Thread *) data);
return NULL;
}
@ -88,7 +88,7 @@ static SDL_bool checked_setname = SDL_FALSE;
static int (*ppthread_setname_np)(pthread_t, const char*) = NULL;
#endif
int
SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
SDL_SYS_CreateThread(SDL_Thread * thread)
{
pthread_attr_t type;
@ -117,7 +117,7 @@ SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
}
/* Create the thread and go! */
if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
if (pthread_create(&thread->handle, &type, RunThread, thread) != 0) {
return SDL_SetError("Not enough resources to create thread");
}