early-access version 2847

This commit is contained in:
pineappleEA
2022-07-19 05:48:31 +02:00
parent ba74a2373c
commit 05e3c38e7f
498 changed files with 16027 additions and 27028 deletions

View File

@@ -471,6 +471,9 @@ static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
return status;
}
static SDL_sem *writersDone;
static SDL_sem *readersDone;
typedef struct
{
SDL_EventQueue *queue;
@@ -479,7 +482,6 @@ typedef struct
int waits;
SDL_bool lock_free;
char padding2[SDL_CACHELINE_SIZE-sizeof(int)-sizeof(SDL_bool)];
SDL_Thread *thread;
} WriterData;
typedef struct
@@ -489,7 +491,6 @@ typedef struct
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];
SDL_Thread *thread;
} ReaderData;
static int SDLCALL FIFO_Writer(void* _data)
@@ -522,6 +523,7 @@ static int SDLCALL FIFO_Writer(void* _data)
}
}
}
SDL_SemPost(writersDone);
return 0;
}
@@ -558,6 +560,7 @@ static int SDLCALL FIFO_Reader(void* _data)
}
}
}
SDL_SemPost(readersDone);
return 0;
}
@@ -587,7 +590,6 @@ static int SDLCALL FIFO_Watcher(void* _data)
static void RunFIFOTest(SDL_bool lock_free)
{
SDL_EventQueue queue;
SDL_Thread *fifo_thread = NULL;
WriterData writerData[NUM_WRITERS];
ReaderData readerData[NUM_READERS];
Uint32 start, end;
@@ -599,6 +601,9 @@ static void RunFIFOTest(SDL_bool lock_free)
SDL_Log("\nFIFO test---------------------------------------\n\n");
SDL_Log("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
readersDone = SDL_CreateSemaphore(0);
writersDone = SDL_CreateSemaphore(0);
SDL_memset(&queue, 0xff, sizeof(queue));
InitEventQueue(&queue);
@@ -611,7 +616,7 @@ static void RunFIFOTest(SDL_bool lock_free)
#ifdef TEST_SPINLOCK_FIFO
/* Start a monitoring thread */
if (lock_free) {
fifo_thread = SDL_CreateThread(FIFO_Watcher, "FIFOWatcher", &queue);
SDL_CreateThread(FIFO_Watcher, "FIFOWatcher", &queue);
}
#endif
@@ -623,7 +628,7 @@ static void RunFIFOTest(SDL_bool lock_free)
SDL_snprintf(name, sizeof (name), "FIFOReader%d", i);
readerData[i].queue = &queue;
readerData[i].lock_free = lock_free;
readerData[i].thread = SDL_CreateThread(FIFO_Reader, name, &readerData[i]);
SDL_CreateThread(FIFO_Reader, name, &readerData[i]);
}
/* Start up the writers */
@@ -635,12 +640,12 @@ static void RunFIFOTest(SDL_bool lock_free)
writerData[i].queue = &queue;
writerData[i].index = i;
writerData[i].lock_free = lock_free;
writerData[i].thread = SDL_CreateThread(FIFO_Writer, name, &writerData[i]);
SDL_CreateThread(FIFO_Writer, name, &writerData[i]);
}
/* Wait for the writers */
for (i = 0; i < NUM_WRITERS; ++i) {
SDL_WaitThread(writerData[i].thread, NULL);
SDL_SemWait(writersDone);
}
/* Shut down the queue so readers exit */
@@ -648,15 +653,13 @@ static void RunFIFOTest(SDL_bool lock_free)
/* Wait for the readers */
for (i = 0; i < NUM_READERS; ++i) {
SDL_WaitThread(readerData[i].thread, NULL);
SDL_SemWait(readersDone);
}
end = SDL_GetTicks();
/* Wait for the FIFO thread */
if (fifo_thread) {
SDL_WaitThread(fifo_thread, NULL);
}
SDL_DestroySemaphore(readersDone);
SDL_DestroySemaphore(writersDone);
if (!lock_free) {
SDL_DestroyMutex(queue.mutex);
@@ -706,12 +709,6 @@ main(int argc, char *argv[])
SDL_LogSetPriority(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO);
RunBasicTest();
if (SDL_getenv("SDL_TESTS_QUICK") != NULL) {
SDL_Log("Not running slower tests");
return 0;
}
RunEpicTest();
/* This test is really slow, so don't run it by default */
#if 0