update SDL3 to latest commit

This commit is contained in:
Sasha Szpakowski
2024-10-06 20:30:44 -03:00
parent 1b0fdc338b
commit 9e5eb1b018
1426 changed files with 242456 additions and 103496 deletions
+9 -16
View File
@@ -37,7 +37,8 @@ quit(int rc)
static int SDLCALL
SubThreadFunc(void *data)
{
while (!*(int volatile *)data) {
SDL_AtomicInt *flag = (SDL_AtomicInt *)data;
while (!SDL_GetAtomicInt(flag)) {
SDL_Delay(10);
}
return 0;
@@ -47,7 +48,7 @@ static int SDLCALL
ThreadFunc(void *data)
{
SDL_Thread *sub_threads[NUMTHREADS];
int flags[NUMTHREADS];
SDL_AtomicInt flags[NUMTHREADS];
int i;
int tid = (int)(uintptr_t)data;
@@ -56,18 +57,18 @@ ThreadFunc(void *data)
for (i = 0; i < NUMTHREADS; i++) {
char name[64];
(void)SDL_snprintf(name, sizeof(name), "Child%d_%d", tid, i);
flags[i] = 0;
SDL_SetAtomicInt(&flags[i], 0);
sub_threads[i] = SDL_CreateThread(SubThreadFunc, name, &flags[i]);
}
SDL_Log("Thread '%d' waiting for signal\n", tid);
while (SDL_AtomicGet(&time_for_threads_to_die[tid]) != 1) {
while (SDL_GetAtomicInt(&time_for_threads_to_die[tid]) != 1) {
; /* do nothing */
}
SDL_Log("Thread '%d' sending signals to subthreads\n", tid);
for (i = 0; i < NUMTHREADS; i++) {
flags[i] = 1;
SDL_SetAtomicInt(&flags[i], 1);
SDL_WaitThread(sub_threads[i], NULL);
}
@@ -88,16 +89,8 @@ int main(int argc, char *argv[])
return 1;
}
/* Enable standard application logging */
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
/* Load the SDL library */
if (SDL_Init(0) < 0) {
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
return 1;
}
if (!SDLTest_CommonDefaultArgs(state, argc, argv)) {
SDL_Quit();
SDLTest_CommonDestroyState(state);
return 1;
}
@@ -106,7 +99,7 @@ int main(int argc, char *argv[])
for (i = 0; i < NUMTHREADS; i++) {
char name[64];
(void)SDL_snprintf(name, sizeof(name), "Parent%d", i);
SDL_AtomicSet(&time_for_threads_to_die[i], 0);
SDL_SetAtomicInt(&time_for_threads_to_die[i], 0);
threads[i] = SDL_CreateThread(ThreadFunc, name, (void *)(uintptr_t)i);
if (threads[i] == NULL) {
@@ -116,7 +109,7 @@ int main(int argc, char *argv[])
}
for (i = 0; i < NUMTHREADS; i++) {
SDL_AtomicSet(&time_for_threads_to_die[i], 1);
SDL_SetAtomicInt(&time_for_threads_to_die[i], 1);
}
for (i = 0; i < NUMTHREADS; i++) {