00cc9309cb
de6e324bdseparate emu thread10d3daf86Roms List improvements95d202f37Let's make the rom list process on a separate thread so the emulator doesnt take ages to load.fc306967fWow the ROM Header was just completely busted. Game list view works nowbad1691eefuck this shit2b59e5f46game list in progressd26417b83remappable inputs in progressac4af8106inpute72abc240update readme430139dc9Qt6 frontend3080d4d45Fix this small bug too08cd13b85Cop0 unused functions do not actually pose a threat (as per manual). They don't do anything, so shall we.61bb4fb44make idle loop detection a little more specific with where the load goesb037de4c3SAZDFsdff12e81e73eneed to figure out why n64-systemtest loops indefinitely at some address that appears to be valid (i think it's me not invalidating the cache properly)204f0e13bidle skipping seems to work!cb8bb634asdkfjlasdf58e5c89c1Fix compilation issue on my machine (no idea)24fb2898eattempting more serious idle skipping214719577Place rsp.Step inside cached interpreter. Gains about 3 more fpsbb97dcc23mmmmm920b77d38wjkhasdfjhkasdf430ccdab4it's a start...4f42a673aCached interpreter plays Mario 64. Start looking into RSP as wellc9a030787idle skipping works!5fbda03cenew idea366637abaIdle skipping... maybe?609fa2fb0Cache instructions implemented but broken lmao. Commented out for nowe140a6d12- Stop using inheritance for CPU, instead use composition. - Introduce KAIZEN_JIT_ENABLED optional define instead of relying on __aarch64__ and the like. - More cache work68e613057prep cache impl811b4d809fix clang formatfda755f7didkd5024ebbfsmall MI refactor in preparation of (eventually) implementing the RDRAM interface properly694b45341Merge commit '206dcdedf195fb320913584180edb12c7731e396' as 'external/SDL'206dcdedfSquashed 'external/SDL/' content from commit 4d17b99d0a4d16e1cb4need to update sdl848b19920Fix compilation errordb61b5299Merge commit 'e94a94559f28e49678fbcf72199a5258137b0fe9' as 'external/imgui'e94a94559Squashed 'external/imgui/' content from commit 02e9b8cac52edb3757need to update imguic1a705e86Emulate weird JALR behaviour4b4c32f4bFix exception for "unusable COP1" in 4 instructions i missed accidentally (again)df5828142Bug putting 0s in the log everywheref8b580048Make isviewer a sink to file8241e9735Fix exception for "unusable COP1" in 4 instructions i missed accidentallyb29715f20small changesd9a620bc1make use of my new small utility library0d1aa938eAdd 'external/ircolib/' from commit 'ce3cd726c8df8388d554abf8bb55d55020eb4450'e64eb40b3Fuck git git-subtree-dir: external/ircolib git-subtree-split:de6e324bde
213 lines
5.8 KiB
C
213 lines
5.8 KiB
C
/*
|
|
Copyright (C) 1997-2026 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
|
|
arising from the use of this software.
|
|
|
|
Permission is granted to anyone to use this software for any purpose,
|
|
including commercial applications, and to alter it and redistribute it
|
|
freely.
|
|
*/
|
|
|
|
/* Test the thread and mutex locking functions
|
|
Also exercises the system's signal/thread interaction
|
|
*/
|
|
|
|
#include <signal.h>
|
|
#include <stdlib.h> /* for atexit() */
|
|
|
|
#include <SDL3/SDL.h>
|
|
#include <SDL3/SDL_main.h>
|
|
#include <SDL3/SDL_test.h>
|
|
|
|
static SDL_Mutex *mutex = NULL;
|
|
static SDL_ThreadID mainthread;
|
|
static SDL_AtomicInt doterminate;
|
|
static int nb_threads = 6;
|
|
static SDL_Thread **threads;
|
|
static int worktime = 1000;
|
|
static SDLTest_CommonState *state;
|
|
|
|
/**
|
|
* SDL_Quit() shouldn't be used with atexit() directly because
|
|
* calling conventions may differ...
|
|
*/
|
|
static void
|
|
SDL_Quit_Wrapper(void)
|
|
{
|
|
SDL_Quit();
|
|
SDLTest_CommonDestroyState(state);
|
|
}
|
|
|
|
static void printid(void)
|
|
{
|
|
SDL_Log("Thread %" SDL_PRIu64 ": exiting", SDL_GetCurrentThreadID());
|
|
}
|
|
|
|
static void terminate(int sig)
|
|
{
|
|
(void)signal(SIGINT, terminate);
|
|
SDL_SetAtomicInt(&doterminate, 1);
|
|
}
|
|
|
|
static void closemutex(int sig)
|
|
{
|
|
SDL_ThreadID id = SDL_GetCurrentThreadID();
|
|
int i;
|
|
SDL_Log("Thread %" SDL_PRIu64 ": Cleaning up...", id == mainthread ? 0 : id);
|
|
SDL_SetAtomicInt(&doterminate, 1);
|
|
if (threads) {
|
|
for (i = 0; i < nb_threads; ++i) {
|
|
SDL_WaitThread(threads[i], NULL);
|
|
}
|
|
SDL_free(threads);
|
|
threads = NULL;
|
|
}
|
|
SDL_DestroyMutex(mutex);
|
|
/* Let 'main()' return normally */
|
|
if (sig != 0) {
|
|
exit(sig);
|
|
}
|
|
}
|
|
|
|
static int SDLCALL
|
|
Run(void *data)
|
|
{
|
|
SDL_ThreadID current_thread = SDL_GetCurrentThreadID();
|
|
|
|
if (current_thread == mainthread) {
|
|
(void)signal(SIGTERM, closemutex);
|
|
}
|
|
SDL_Log("Thread %" SDL_PRIu64 ": starting up", current_thread);
|
|
while (!SDL_GetAtomicInt(&doterminate)) {
|
|
SDL_Log("Thread %" SDL_PRIu64 ": ready to work", current_thread);
|
|
SDL_LockMutex(mutex);
|
|
SDL_Log("Thread %" SDL_PRIu64 ": start work!", current_thread);
|
|
SDL_Delay(1 * worktime);
|
|
SDL_Log("Thread %" SDL_PRIu64 ": work done!", current_thread);
|
|
SDL_UnlockMutex(mutex);
|
|
|
|
/* If this sleep isn't done, then threads may starve */
|
|
SDL_Delay(10);
|
|
}
|
|
if (current_thread == mainthread && SDL_GetAtomicInt(&doterminate)) {
|
|
SDL_Log("Thread %" SDL_PRIu64 ": raising SIGTERM", current_thread);
|
|
(void)raise(SIGTERM);
|
|
}
|
|
SDL_Log("Thread %" SDL_PRIu64 ": exiting!", current_thread);
|
|
return 0;
|
|
}
|
|
|
|
#ifndef _WIN32
|
|
static Uint32 hit_timeout(void *param, SDL_TimerID timerID, Uint32 interval) {
|
|
SDL_Log("Hit timeout! Sending SIGINT!");
|
|
(void)raise(SIGINT);
|
|
return 0;
|
|
}
|
|
#endif
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
int i;
|
|
#ifndef _WIN32
|
|
int timeout = 0;
|
|
#endif
|
|
|
|
/* Initialize test framework */
|
|
state = SDLTest_CommonCreateState(argv, 0);
|
|
if (!state) {
|
|
return 1;
|
|
}
|
|
|
|
/* Parse commandline */
|
|
for (i = 1; i < argc;) {
|
|
int consumed;
|
|
|
|
consumed = SDLTest_CommonArg(state, i);
|
|
if (!consumed) {
|
|
if (SDL_strcmp(argv[i], "--nbthreads") == 0) {
|
|
if (argv[i + 1]) {
|
|
char *endptr;
|
|
nb_threads = SDL_strtol(argv[i + 1], &endptr, 0);
|
|
if (endptr != argv[i + 1] && *endptr == '\0' && nb_threads > 0) {
|
|
consumed = 2;
|
|
}
|
|
}
|
|
} else if (SDL_strcmp(argv[i], "--worktime") == 0) {
|
|
if (argv[i + 1]) {
|
|
char *endptr;
|
|
nb_threads = SDL_strtol(argv[i + 1], &endptr, 0);
|
|
if (endptr != argv[i + 1] && *endptr == '\0' && nb_threads > 0) {
|
|
consumed = 2;
|
|
}
|
|
}
|
|
#ifndef _WIN32
|
|
} else if (SDL_strcmp(argv[i], "--timeout") == 0) {
|
|
if (argv[i + 1]) {
|
|
char *endptr;
|
|
timeout = SDL_strtol(argv[i + 1], &endptr, 0);
|
|
if (endptr != argv[i + 1] && *endptr == '\0' && timeout > 0) {
|
|
consumed = 2;
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
}
|
|
if (consumed <= 0) {
|
|
static const char *options[] = {
|
|
"[--nbthreads NB]",
|
|
"[--worktime ms]",
|
|
#ifndef _WIN32
|
|
"[--timeout ms]",
|
|
#endif
|
|
NULL,
|
|
};
|
|
SDLTest_CommonLogUsage(state, argv[0], options);
|
|
exit(1);
|
|
}
|
|
|
|
i += consumed;
|
|
}
|
|
|
|
threads = SDL_malloc(nb_threads * sizeof(SDL_Thread*));
|
|
|
|
/* Load the SDL library */
|
|
if (!SDL_Init(0)) {
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "%s", SDL_GetError());
|
|
exit(1);
|
|
}
|
|
(void)atexit(SDL_Quit_Wrapper);
|
|
|
|
SDL_SetAtomicInt(&doterminate, 0);
|
|
|
|
mutex = SDL_CreateMutex();
|
|
if (!mutex) {
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create mutex: %s", SDL_GetError());
|
|
exit(1);
|
|
}
|
|
|
|
mainthread = SDL_GetCurrentThreadID();
|
|
SDL_Log("Main thread: %" SDL_PRIu64, mainthread);
|
|
(void)atexit(printid);
|
|
for (i = 0; i < nb_threads; ++i) {
|
|
char name[64];
|
|
(void)SDL_snprintf(name, sizeof(name), "Worker%d", i);
|
|
threads[i] = SDL_CreateThread(Run, name, NULL);
|
|
if (threads[i] == NULL) {
|
|
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't create thread!");
|
|
}
|
|
}
|
|
|
|
#ifndef _WIN32
|
|
if (timeout) {
|
|
SDL_AddTimer(timeout, hit_timeout, NULL);
|
|
}
|
|
#endif
|
|
|
|
(void)signal(SIGINT, terminate);
|
|
Run(NULL);
|
|
|
|
return 0; /* Never reached */
|
|
}
|