all repos — mgba @ eb21dd722f3660e0f832e11225048304a15b1d07

mGBA Game Boy Advance Emulator

GBA: Move logging construct into GBA struct
Jeffrey Pfau jeffrey@endrift.com
Thu, 05 Mar 2015 20:42:37 -0800
commit

eb21dd722f3660e0f832e11225048304a15b1d07

parent

3f9abf2b05396e7219a7e9a6034c95b74cb0c055

4 files changed, 11 insertions(+), 7 deletions(-)

jump to
M src/gba/gba.csrc/gba/gba.c

@@ -547,10 +547,10 @@ MutexLock(&threadContext->stateMutex);

threadContext->state = THREAD_CRASHED; MutexUnlock(&threadContext->stateMutex); } - if (threadContext->logHandler) { - threadContext->logHandler(threadContext, level, format, args); - return; - } + } + if (gba->logHandler) { + gba->logHandler(threadContext, level, format, args); + return; } vprintf(format, args);
M src/gba/gba.hsrc/gba/gba.h

@@ -90,8 +90,11 @@ };

struct GBA; struct GBARotationSource; +struct GBAThread; struct Patch; struct VFile; + +typedef void (*GBALogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args); struct GBATimer { uint16_t reload;

@@ -141,7 +144,8 @@ struct VFile* biosVf;

const char* activeFile; - int logLevel; + GBALogHandler logHandler; + enum GBALogLevel logLevel; enum GBAIdleLoopOptimization idleOptimization; uint32_t idleLoop;
M src/gba/supervisor/thread.csrc/gba/supervisor/thread.c

@@ -134,6 +134,7 @@ ARMInit(&cpu);

gba.sync = &threadContext->sync; threadContext->gba = &gba; gba.logLevel = threadContext->logLevel; + gba.logHandler = threadContext->logHandler; gba.idleOptimization = threadContext->idleOptimization; #ifdef USE_PTHREADS pthread_setspecific(_contextKey, threadContext);
M src/gba/supervisor/thread.hsrc/gba/supervisor/thread.h

@@ -20,7 +20,6 @@ struct GBACheatSet;

struct GBAOptions; typedef void (*ThreadCallback)(struct GBAThread* threadContext); -typedef void (*LogHandler)(struct GBAThread*, enum GBALogLevel, const char* format, va_list args); enum ThreadState { THREAD_INITIALIZED = -1,

@@ -95,7 +94,7 @@ Condition stateCond;

enum ThreadState savedState; int interruptDepth; - LogHandler logHandler; + GBALogHandler logHandler; int logLevel; ThreadCallback startCallback; ThreadCallback cleanCallback;