Merge commit '3a7f96fd99528968c39b5be81db067ca018d432b' into dev
This commit is contained in:
193
external/SDL/test/testatomic.c
vendored
193
external/SDL/test/testatomic.c
vendored
@@ -20,7 +20,7 @@
|
||||
*/
|
||||
|
||||
static const char *
|
||||
tf(SDL_bool _tf)
|
||||
tf(bool _tf)
|
||||
{
|
||||
static const char *t = "TRUE";
|
||||
static const char *f = "FALSE";
|
||||
@@ -38,7 +38,7 @@ static void RunBasicTest(void)
|
||||
SDL_SpinLock lock = 0;
|
||||
|
||||
SDL_AtomicInt v;
|
||||
SDL_bool tfret = SDL_FALSE;
|
||||
bool tfret = false;
|
||||
|
||||
SDL_Log("\nspin lock---------------------------------------\n\n");
|
||||
|
||||
@@ -49,30 +49,30 @@ static void RunBasicTest(void)
|
||||
|
||||
SDL_Log("\natomic -----------------------------------------\n\n");
|
||||
|
||||
SDL_AtomicSet(&v, 0);
|
||||
tfret = SDL_AtomicSet(&v, 10) == 0;
|
||||
SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = SDL_AtomicAdd(&v, 10) == 10;
|
||||
SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_SetAtomicInt(&v, 0);
|
||||
tfret = SDL_SetAtomicInt(&v, 10) == 0;
|
||||
SDL_Log("AtomicSet(10) tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
tfret = SDL_AddAtomicInt(&v, 10) == 10;
|
||||
SDL_Log("AtomicAdd(10) tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
|
||||
SDL_AtomicSet(&v, 0);
|
||||
SDL_SetAtomicInt(&v, 0);
|
||||
SDL_AtomicIncRef(&v);
|
||||
tfret = (SDL_AtomicGet(&v) == 1);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_GetAtomicInt(&v) == 1);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
SDL_AtomicIncRef(&v);
|
||||
tfret = (SDL_AtomicGet(&v) == 2);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_FALSE);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == SDL_TRUE);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
tfret = (SDL_GetAtomicInt(&v) == 2);
|
||||
SDL_Log("AtomicIncRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == false);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
tfret = (SDL_AtomicDecRef(&v) == true);
|
||||
SDL_Log("AtomicDecRef() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
|
||||
SDL_AtomicSet(&v, 10);
|
||||
tfret = (SDL_AtomicCompareAndSwap(&v, 0, 20) == SDL_FALSE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
value = SDL_AtomicGet(&v);
|
||||
tfret = (SDL_AtomicCompareAndSwap(&v, value, 20) == SDL_TRUE);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_AtomicGet(&v));
|
||||
SDL_SetAtomicInt(&v, 10);
|
||||
tfret = (SDL_CompareAndSwapAtomicInt(&v, 0, 20) == false);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
value = SDL_GetAtomicInt(&v);
|
||||
tfret = (SDL_CompareAndSwapAtomicInt(&v, value, 20) == true);
|
||||
SDL_Log("AtomicCAS() tfret=%s val=%d\n", tf(tfret), SDL_GetAtomicInt(&v));
|
||||
}
|
||||
|
||||
/**************************************************************************/
|
||||
@@ -117,10 +117,10 @@ static int SDLCALL adder(void *junk)
|
||||
unsigned long N = NInter;
|
||||
SDL_Log("Thread subtracting %d %lu times\n", CountInc, N);
|
||||
while (N--) {
|
||||
SDL_AtomicAdd(&good, -CountInc);
|
||||
SDL_AddAtomicInt(&good, -CountInc);
|
||||
bad -= CountInc;
|
||||
}
|
||||
SDL_AtomicAdd(&threadsRunning, -1);
|
||||
SDL_AddAtomicInt(&threadsRunning, -1);
|
||||
SDL_SignalSemaphore(threadDone);
|
||||
return 0;
|
||||
}
|
||||
@@ -135,13 +135,13 @@ static void runAdder(void)
|
||||
|
||||
threadDone = SDL_CreateSemaphore(0);
|
||||
|
||||
SDL_AtomicSet(&threadsRunning, NThreads);
|
||||
SDL_SetAtomicInt(&threadsRunning, NThreads);
|
||||
|
||||
for (i = 0; i < NThreads; i++) {
|
||||
threads[i] = SDL_CreateThread(adder, "Adder", NULL);
|
||||
}
|
||||
|
||||
while (SDL_AtomicGet(&threadsRunning) > 0) {
|
||||
while (SDL_GetAtomicInt(&threadsRunning) > 0) {
|
||||
SDL_WaitSemaphore(threadDone);
|
||||
}
|
||||
|
||||
@@ -167,65 +167,65 @@ static void RunEpicTest(void)
|
||||
SDL_assert(sizeof(atomicValue) >= 4);
|
||||
|
||||
SDL_Log("Check static initializer\n");
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 42);
|
||||
|
||||
SDL_assert(bad == 42);
|
||||
|
||||
SDL_Log("Test negative values\n");
|
||||
SDL_AtomicSet(&good, -5);
|
||||
v = SDL_AtomicGet(&good);
|
||||
SDL_SetAtomicInt(&good, -5);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == -5);
|
||||
|
||||
SDL_Log("Verify maximum value\n");
|
||||
SDL_AtomicSet(&good, CountTo);
|
||||
v = SDL_AtomicGet(&good);
|
||||
SDL_SetAtomicInt(&good, CountTo);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == CountTo);
|
||||
|
||||
SDL_Log("Test compare and exchange\n");
|
||||
|
||||
b = SDL_AtomicCompareAndSwap(&good, 500, 43);
|
||||
b = SDL_CompareAndSwapAtomicInt(&good, 500, 43);
|
||||
SDL_assert(!b); /* no swap since CountTo!=500 */
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == CountTo); /* ensure no swap */
|
||||
|
||||
b = SDL_AtomicCompareAndSwap(&good, CountTo, 44);
|
||||
b = SDL_CompareAndSwapAtomicInt(&good, CountTo, 44);
|
||||
SDL_assert(!!b); /* will swap */
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 44);
|
||||
|
||||
SDL_Log("Test Add\n");
|
||||
|
||||
v = SDL_AtomicAdd(&good, 1);
|
||||
v = SDL_AddAtomicInt(&good, 1);
|
||||
SDL_assert(v == 44);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 45);
|
||||
|
||||
v = SDL_AtomicAdd(&good, 10);
|
||||
v = SDL_AddAtomicInt(&good, 10);
|
||||
SDL_assert(v == 45);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 55);
|
||||
|
||||
SDL_Log("Test Add (Negative values)\n");
|
||||
|
||||
v = SDL_AtomicAdd(&good, -20);
|
||||
v = SDL_AddAtomicInt(&good, -20);
|
||||
SDL_assert(v == 55);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 35);
|
||||
|
||||
v = SDL_AtomicAdd(&good, -50); /* crossing zero down */
|
||||
v = SDL_AddAtomicInt(&good, -50); /* crossing zero down */
|
||||
SDL_assert(v == 35);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == -15);
|
||||
|
||||
v = SDL_AtomicAdd(&good, 30); /* crossing zero up */
|
||||
v = SDL_AddAtomicInt(&good, 30); /* crossing zero up */
|
||||
SDL_assert(v == -15);
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == 15);
|
||||
|
||||
SDL_Log("Reset before count down test\n");
|
||||
SDL_AtomicSet(&good, CountTo);
|
||||
v = SDL_AtomicGet(&good);
|
||||
SDL_SetAtomicInt(&good, CountTo);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_assert(v == CountTo);
|
||||
|
||||
bad = CountTo;
|
||||
@@ -234,7 +234,7 @@ static void RunEpicTest(void)
|
||||
SDL_Log("Counting down from %d, Expect %d remaining\n", CountTo, Expect);
|
||||
runAdder();
|
||||
|
||||
v = SDL_AtomicGet(&good);
|
||||
v = SDL_GetAtomicInt(&good);
|
||||
SDL_Log("Atomic %d Non-Atomic %d\n", v, bad);
|
||||
SDL_assert(v == Expect);
|
||||
/* We can't guarantee that bad != Expect, this would happen on a single core system, for example. */
|
||||
@@ -300,56 +300,56 @@ static void InitEventQueue(SDL_EventQueue *queue)
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_ENTRIES; ++i) {
|
||||
SDL_AtomicSet(&queue->entries[i].sequence, i);
|
||||
SDL_SetAtomicInt(&queue->entries[i].sequence, i);
|
||||
}
|
||||
SDL_AtomicSet(&queue->enqueue_pos, 0);
|
||||
SDL_AtomicSet(&queue->dequeue_pos, 0);
|
||||
SDL_SetAtomicInt(&queue->enqueue_pos, 0);
|
||||
SDL_SetAtomicInt(&queue->dequeue_pos, 0);
|
||||
#ifdef TEST_SPINLOCK_FIFO
|
||||
queue->lock = 0;
|
||||
SDL_AtomicSet(&queue->rwcount, 0);
|
||||
SDL_AtomicSet(&queue->watcher, 0);
|
||||
SDL_SetAtomicInt(&queue->rwcount, 0);
|
||||
SDL_SetAtomicInt(&queue->watcher, 0);
|
||||
#endif
|
||||
SDL_AtomicSet(&queue->active, 1);
|
||||
SDL_SetAtomicInt(&queue->active, 1);
|
||||
}
|
||||
|
||||
static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *event)
|
||||
static bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *event)
|
||||
{
|
||||
SDL_EventQueueEntry *entry;
|
||||
unsigned queue_pos;
|
||||
unsigned entry_seq;
|
||||
int delta;
|
||||
SDL_bool status;
|
||||
bool status;
|
||||
|
||||
#ifdef TEST_SPINLOCK_FIFO
|
||||
/* This is a gate so an external thread can lock the queue */
|
||||
SDL_LockSpinlock(&queue->lock);
|
||||
SDL_assert(SDL_AtomicGet(&queue->watcher) == 0);
|
||||
SDL_assert(SDL_GetAtomicInt(&queue->watcher) == 0);
|
||||
SDL_AtomicIncRef(&queue->rwcount);
|
||||
SDL_UnlockSpinlock(&queue->lock);
|
||||
#endif
|
||||
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->enqueue_pos);
|
||||
for (;;) {
|
||||
entry = &queue->entries[queue_pos & WRAP_MASK];
|
||||
entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence);
|
||||
entry_seq = (unsigned)SDL_GetAtomicInt(&entry->sequence);
|
||||
|
||||
delta = (int)(entry_seq - queue_pos);
|
||||
if (delta == 0) {
|
||||
/* The entry and the queue position match, try to increment the queue position */
|
||||
if (SDL_AtomicCompareAndSwap(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
/* We own the object, fill it! */
|
||||
entry->event = *event;
|
||||
SDL_AtomicSet(&entry->sequence, (int)(queue_pos + 1));
|
||||
status = SDL_TRUE;
|
||||
SDL_SetAtomicInt(&entry->sequence, (int)(queue_pos + 1));
|
||||
status = true;
|
||||
break;
|
||||
}
|
||||
} else if (delta < 0) {
|
||||
/* We ran into an old queue entry, which means it still needs to be dequeued */
|
||||
status = SDL_FALSE;
|
||||
status = false;
|
||||
break;
|
||||
} else {
|
||||
/* We ran into a new queue entry, get the new queue position */
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->enqueue_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,44 +359,44 @@ static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *ev
|
||||
return status;
|
||||
}
|
||||
|
||||
static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
|
||||
static bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
|
||||
{
|
||||
SDL_EventQueueEntry *entry;
|
||||
unsigned queue_pos;
|
||||
unsigned entry_seq;
|
||||
int delta;
|
||||
SDL_bool status;
|
||||
bool status;
|
||||
|
||||
#ifdef TEST_SPINLOCK_FIFO
|
||||
/* This is a gate so an external thread can lock the queue */
|
||||
SDL_LockSpinlock(&queue->lock);
|
||||
SDL_assert(SDL_AtomicGet(&queue->watcher) == 0);
|
||||
SDL_assert(SDL_GetAtomicInt(&queue->watcher) == 0);
|
||||
SDL_AtomicIncRef(&queue->rwcount);
|
||||
SDL_UnlockSpinlock(&queue->lock);
|
||||
#endif
|
||||
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->dequeue_pos);
|
||||
for (;;) {
|
||||
entry = &queue->entries[queue_pos & WRAP_MASK];
|
||||
entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence);
|
||||
entry_seq = (unsigned)SDL_GetAtomicInt(&entry->sequence);
|
||||
|
||||
delta = (int)(entry_seq - (queue_pos + 1));
|
||||
if (delta == 0) {
|
||||
/* The entry and the queue position match, try to increment the queue position */
|
||||
if (SDL_AtomicCompareAndSwap(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
if (SDL_CompareAndSwapAtomicInt(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos + 1))) {
|
||||
/* We own the object, fill it! */
|
||||
*event = entry->event;
|
||||
SDL_AtomicSet(&entry->sequence, (int)(queue_pos + MAX_ENTRIES));
|
||||
status = SDL_TRUE;
|
||||
SDL_SetAtomicInt(&entry->sequence, (int)(queue_pos + MAX_ENTRIES));
|
||||
status = true;
|
||||
break;
|
||||
}
|
||||
} else if (delta < 0) {
|
||||
/* We ran into an old queue entry, which means we've hit empty */
|
||||
status = SDL_FALSE;
|
||||
status = false;
|
||||
break;
|
||||
} else {
|
||||
/* We ran into a new queue entry, get the new queue position */
|
||||
queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos);
|
||||
queue_pos = (unsigned)SDL_GetAtomicInt(&queue->dequeue_pos);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -406,13 +406,13 @@ static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
|
||||
return status;
|
||||
}
|
||||
|
||||
static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event)
|
||||
static bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event)
|
||||
{
|
||||
SDL_EventQueueEntry *entry;
|
||||
unsigned queue_pos;
|
||||
unsigned entry_seq;
|
||||
int delta;
|
||||
SDL_bool status = SDL_FALSE;
|
||||
bool status = false;
|
||||
|
||||
SDL_LockMutex(queue->mutex);
|
||||
|
||||
@@ -427,7 +427,7 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event
|
||||
/* We own the object, fill it! */
|
||||
entry->event = *event;
|
||||
entry->sequence.value = (int)(queue_pos + 1);
|
||||
status = SDL_TRUE;
|
||||
status = true;
|
||||
} else if (delta < 0) {
|
||||
/* We ran into an old queue entry, which means it still needs to be dequeued */
|
||||
} else {
|
||||
@@ -439,13 +439,13 @@ static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event
|
||||
return status;
|
||||
}
|
||||
|
||||
static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
|
||||
static bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
|
||||
{
|
||||
SDL_EventQueueEntry *entry;
|
||||
unsigned queue_pos;
|
||||
unsigned entry_seq;
|
||||
int delta;
|
||||
SDL_bool status = SDL_FALSE;
|
||||
bool status = false;
|
||||
|
||||
SDL_LockMutex(queue->mutex);
|
||||
|
||||
@@ -460,7 +460,7 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
|
||||
/* We own the object, fill it! */
|
||||
*event = entry->event;
|
||||
entry->sequence.value = (int)(queue_pos + MAX_ENTRIES);
|
||||
status = SDL_TRUE;
|
||||
status = true;
|
||||
} else if (delta < 0) {
|
||||
/* We ran into an old queue entry, which means we've hit empty */
|
||||
} else {
|
||||
@@ -478,8 +478,8 @@ typedef struct
|
||||
int index;
|
||||
char padding1[SDL_CACHELINE_SIZE - (sizeof(SDL_EventQueue *) + sizeof(int)) % SDL_CACHELINE_SIZE];
|
||||
int waits;
|
||||
SDL_bool lock_free;
|
||||
char padding2[SDL_CACHELINE_SIZE - sizeof(int) - sizeof(SDL_bool)];
|
||||
bool lock_free;
|
||||
char padding2[SDL_CACHELINE_SIZE - sizeof(int) - sizeof(bool)];
|
||||
SDL_Thread *thread;
|
||||
} WriterData;
|
||||
|
||||
@@ -488,8 +488,8 @@ typedef struct
|
||||
SDL_EventQueue *queue;
|
||||
int counters[NUM_WRITERS];
|
||||
int waits;
|
||||
SDL_bool lock_free;
|
||||
char padding[SDL_CACHELINE_SIZE - (sizeof(SDL_EventQueue *) + sizeof(int) * NUM_WRITERS + sizeof(int) + sizeof(SDL_bool)) % SDL_CACHELINE_SIZE];
|
||||
bool lock_free;
|
||||
char padding[SDL_CACHELINE_SIZE - (sizeof(SDL_EventQueue *) + sizeof(int) * NUM_WRITERS + sizeof(int) + sizeof(bool)) % SDL_CACHELINE_SIZE];
|
||||
SDL_Thread *thread;
|
||||
} ReaderData;
|
||||
|
||||
@@ -537,7 +537,7 @@ static int SDLCALL FIFO_Reader(void *_data)
|
||||
if (DequeueEvent_LockFree(queue, &event)) {
|
||||
WriterData *writer = (WriterData *)event.user.data1;
|
||||
++data->counters[writer->index];
|
||||
} else if (SDL_AtomicGet(&queue->active)) {
|
||||
} else if (SDL_GetAtomicInt(&queue->active)) {
|
||||
++data->waits;
|
||||
SDL_Delay(0);
|
||||
} else {
|
||||
@@ -550,7 +550,7 @@ static int SDLCALL FIFO_Reader(void *_data)
|
||||
if (DequeueEvent_Mutex(queue, &event)) {
|
||||
WriterData *writer = (WriterData *)event.user.data1;
|
||||
++data->counters[writer->index];
|
||||
} else if (SDL_AtomicGet(&queue->active)) {
|
||||
} else if (SDL_GetAtomicInt(&queue->active)) {
|
||||
++data->waits;
|
||||
SDL_Delay(0);
|
||||
} else {
|
||||
@@ -568,10 +568,10 @@ static int SDLCALL FIFO_Watcher(void *_data)
|
||||
{
|
||||
SDL_EventQueue *queue = (SDL_EventQueue *)_data;
|
||||
|
||||
while (SDL_AtomicGet(&queue->active)) {
|
||||
while (SDL_GetAtomicInt(&queue->active)) {
|
||||
SDL_LockSpinlock(&queue->lock);
|
||||
SDL_AtomicIncRef(&queue->watcher);
|
||||
while (SDL_AtomicGet(&queue->rwcount) > 0) {
|
||||
while (SDL_GetAtomicInt(&queue->rwcount) > 0) {
|
||||
SDL_Delay(0);
|
||||
}
|
||||
/* Do queue manipulation here... */
|
||||
@@ -585,7 +585,7 @@ static int SDLCALL FIFO_Watcher(void *_data)
|
||||
}
|
||||
#endif /* TEST_SPINLOCK_FIFO */
|
||||
|
||||
static void RunFIFOTest(SDL_bool lock_free)
|
||||
static void RunFIFOTest(bool lock_free)
|
||||
{
|
||||
SDL_EventQueue queue;
|
||||
SDL_Thread *fifo_thread = NULL;
|
||||
@@ -645,7 +645,7 @@ static void RunFIFOTest(SDL_bool lock_free)
|
||||
}
|
||||
|
||||
/* Shut down the queue so readers exit */
|
||||
SDL_AtomicSet(&queue.active, 0);
|
||||
SDL_SetAtomicInt(&queue.active, 0);
|
||||
|
||||
/* Wait for the readers */
|
||||
for (i = 0; i < NUM_READERS; ++i) {
|
||||
@@ -704,7 +704,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
SDLTest_CommonState *state;
|
||||
int i;
|
||||
SDL_bool enable_threads = SDL_TRUE;
|
||||
bool enable_threads = true;
|
||||
|
||||
/* Initialize test framework */
|
||||
state = SDLTest_CommonCreateState(argv, 0);
|
||||
@@ -712,9 +712,6 @@ int main(int argc, char *argv[])
|
||||
return 1;
|
||||
}
|
||||
|
||||
/* Enable standard application logging */
|
||||
SDL_SetLogPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
|
||||
|
||||
/* Parse commandline */
|
||||
for (i = 1; i < argc;) {
|
||||
int consumed;
|
||||
@@ -723,7 +720,7 @@ int main(int argc, char *argv[])
|
||||
if (consumed == 0) {
|
||||
consumed = -1;
|
||||
if (SDL_strcasecmp(argv[i], "--no-threads") == 0) {
|
||||
enable_threads = SDL_FALSE;
|
||||
enable_threads = false;
|
||||
consumed = 1;
|
||||
}
|
||||
}
|
||||
@@ -740,7 +737,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
RunBasicTest();
|
||||
|
||||
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
|
||||
if (SDL_GetEnvironmentVariable(SDL_GetEnvironment(), "SDL_TESTS_QUICK") != NULL) {
|
||||
SDL_Log("Not running slower tests");
|
||||
return 0;
|
||||
}
|
||||
@@ -750,9 +747,9 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
/* This test is really slow, so don't run it by default */
|
||||
#if 0
|
||||
RunFIFOTest(SDL_FALSE);
|
||||
RunFIFOTest(false);
|
||||
#endif
|
||||
RunFIFOTest(SDL_TRUE);
|
||||
RunFIFOTest(true);
|
||||
SDL_Quit();
|
||||
SDLTest_CommonDestroyState(state);
|
||||
return 0;
|
||||
|
||||
Reference in New Issue
Block a user