mirror of
https://github.com/love2d/megasource.git
synced 2026-08-19 12:14:41 +02:00
update SDL3 to latest commit
This commit is contained in:
@@ -31,7 +31,7 @@ static SDLTest_CommonState *state;
|
||||
static void DoWork(const int workticks) /* "Work" */
|
||||
{
|
||||
const SDL_ThreadID tid = SDL_GetCurrentThreadID();
|
||||
const SDL_bool is_reader = tid != mainthread;
|
||||
const bool is_reader = tid != mainthread;
|
||||
const char *typestr = is_reader ? "Reader" : "Writer";
|
||||
|
||||
SDL_Log("%s Thread %" SDL_PRIu64 ": ready to work\n", typestr, tid);
|
||||
@@ -54,7 +54,7 @@ static int SDLCALL
|
||||
ReaderRun(void *data)
|
||||
{
|
||||
SDL_Log("Reader Thread %" SDL_PRIu64 ": starting up", SDL_GetCurrentThreadID());
|
||||
while (!SDL_AtomicGet(&doterminate)) {
|
||||
while (!SDL_GetAtomicInt(&doterminate)) {
|
||||
DoWork(worktime);
|
||||
}
|
||||
SDL_Log("Reader Thread %" SDL_PRIu64 ": exiting!\n", SDL_GetCurrentThreadID());
|
||||
@@ -71,10 +71,8 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&doterminate, 0);
|
||||
SDL_SetAtomicInt(&doterminate, 0);
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
@@ -133,12 +131,12 @@ int main(int argc, char *argv[])
|
||||
threads = SDL_malloc(nb_threads * sizeof(SDL_Thread*));
|
||||
|
||||
/* Load the SDL library */
|
||||
if (SDL_Init(0) < 0) {
|
||||
if (!SDL_Init(0)) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s\n", SDL_GetError());
|
||||
return 1;
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&doterminate, 0);
|
||||
SDL_SetAtomicInt(&doterminate, 0);
|
||||
|
||||
rwlock = SDL_CreateRWLock();
|
||||
if (!rwlock) {
|
||||
@@ -159,11 +157,11 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
while (!SDL_AtomicGet(&doterminate) && (SDL_GetTicks() < ((Uint64) timeout))) {
|
||||
while (!SDL_GetAtomicInt(&doterminate) && (SDL_GetTicks() < ((Uint64) timeout))) {
|
||||
DoWork(writerworktime);
|
||||
}
|
||||
|
||||
SDL_AtomicSet(&doterminate, 1);
|
||||
SDL_SetAtomicInt(&doterminate, 1);
|
||||
SDL_Log("Waiting on reader threads to terminate...");
|
||||
for (i = 0; i < nb_threads; ++i) {
|
||||
SDL_WaitThread(threads[i], NULL);
|
||||
@@ -171,8 +169,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
SDL_Log("Reader threads have terminated, quitting!");
|
||||
SDL_DestroyRWLock(rwlock);
|
||||
SDLTest_CommonDestroyState(state);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user