This commit is contained in:
AzaezelX 2022-03-23 01:43:08 -05:00
parent ee4253c982
commit 2614274639
1225 changed files with 148950 additions and 51674 deletions

View file

@ -1,5 +1,5 @@
/*
Copyright (C) 1997-2020 Sam Lantinga <slouken@libsdl.org>
Copyright (C) 1997-2022 Sam Lantinga <slouken@libsdl.org>
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
@ -19,13 +19,13 @@
*/
static
char *
tf(SDL_bool tf)
const char *
tf(SDL_bool _tf)
{
static char *t = "TRUE";
static char *f = "FALSE";
static const char *t = "TRUE";
static const char *f = "FALSE";
if (tf)
if (_tf)
{
return t;
}
@ -353,7 +353,7 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev
}
#ifdef TEST_SPINLOCK_FIFO
SDL_AtomicDecRef(&queue->rwcount);
(void) SDL_AtomicDecRef(&queue->rwcount);
#endif
return status;
}
@ -400,7 +400,7 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
}
#ifdef TEST_SPINLOCK_FIFO
SDL_AtomicDecRef(&queue->rwcount);
(void) SDL_AtomicDecRef(&queue->rwcount);
#endif
return status;
}
@ -473,8 +473,6 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
static SDL_sem *writersDone;
static SDL_sem *readersDone;
static SDL_atomic_t writersRunning;
static SDL_atomic_t readersRunning;
typedef struct
{
@ -525,7 +523,6 @@ static int SDLCALL FIFO_Writer(void* _data)
}
}
}
SDL_AtomicAdd(&writersRunning, -1);
SDL_SemPost(writersDone);
return 0;
}
@ -563,7 +560,6 @@ static int SDLCALL FIFO_Reader(void* _data)
}
}
}
SDL_AtomicAdd(&readersRunning, -1);
SDL_SemPost(readersDone);
return 0;
}
@ -581,7 +577,7 @@ static int SDLCALL FIFO_Watcher(void* _data)
SDL_Delay(0);
}
/* Do queue manipulation here... */
SDL_AtomicDecRef(&queue->watcher);
(void) SDL_AtomicDecRef(&queue->watcher);
SDL_AtomicUnlock(&queue->lock);
/* Wait a bit... */
@ -627,7 +623,6 @@ static void RunFIFOTest(SDL_bool lock_free)
/* Start the readers first */
SDL_Log("Starting %d readers\n", NUM_READERS);
SDL_zeroa(readerData);
SDL_AtomicSet(&readersRunning, NUM_READERS);
for (i = 0; i < NUM_READERS; ++i) {
char name[64];
SDL_snprintf(name, sizeof (name), "FIFOReader%d", i);
@ -639,7 +634,6 @@ static void RunFIFOTest(SDL_bool lock_free)
/* Start up the writers */
SDL_Log("Starting %d writers\n", NUM_WRITERS);
SDL_zeroa(writerData);
SDL_AtomicSet(&writersRunning, NUM_WRITERS);
for (i = 0; i < NUM_WRITERS; ++i) {
char name[64];
SDL_snprintf(name, sizeof (name), "FIFOWriter%d", i);
@ -650,7 +644,7 @@ static void RunFIFOTest(SDL_bool lock_free)
}
/* Wait for the writers */
while (SDL_AtomicGet(&writersRunning) > 0) {
for (i = 0; i < NUM_WRITERS; ++i) {
SDL_SemWait(writersDone);
}
@ -658,7 +652,7 @@ static void RunFIFOTest(SDL_bool lock_free)
SDL_AtomicSet(&queue.active, 0);
/* Wait for the readers */
while (SDL_AtomicGet(&readersRunning) > 0) {
for (i = 0; i < NUM_READERS; ++i) {
SDL_SemWait(readersDone);
}