From 55977796f35735f606f301b20f4b09ec621cc0c1 Mon Sep 17 00:00:00 2001 From: Jeffrey Pfau Date: Thu, 10 Jul 2014 01:00:38 -0700 Subject: [PATCH] Move UNUSED macro to common.h --- src/arm/common.h | 2 ++ src/arm/isa-inlines.h | 2 -- src/debugger/cli-debugger.c | 26 +++++++++++++------------- src/debugger/gdb-stub.c | 10 +++++----- src/gba/gba-bios.c | 4 ++-- src/gba/gba-thread.c | 6 +++--- src/gba/gba-video.c | 14 +++++++------- src/gba/renderers/video-software.c | 2 -- src/platform/commandline.c | 2 +- src/platform/perf-main.c | 2 +- src/platform/sdl/sdl-audio.c | 2 +- src/platform/sdl/sdl-events.c | 2 +- src/util/patch-ips.c | 5 +---- src/util/patch-ups.c | 5 +---- src/util/patch.h | 2 +- src/util/threading.h | 2 +- 16 files changed, 40 insertions(+), 48 deletions(-) diff --git a/src/arm/common.h b/src/arm/common.h index a9ef1edfd..a46448148 100644 --- a/src/arm/common.h +++ b/src/arm/common.h @@ -11,6 +11,8 @@ #include #include +#define UNUSED(V) (void)(V) + #ifdef __POWERPC__ #define LOAD_32(DEST, ADDR, ARR) asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR)) #define LOAD_16(DEST, ADDR, ARR) asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR)) diff --git a/src/arm/isa-inlines.h b/src/arm/isa-inlines.h index 6d28d789c..8bf4d857e 100644 --- a/src/arm/isa-inlines.h +++ b/src/arm/isa-inlines.h @@ -5,8 +5,6 @@ #include "arm.h" -#define UNUSED(V) (void)(V) - #define DO_4(DIRECTIVE) \ DIRECTIVE, \ DIRECTIVE, \ diff --git a/src/debugger/cli-debugger.c b/src/debugger/cli-debugger.c index 56c83db90..1c290718d 100644 --- a/src/debugger/cli-debugger.c +++ b/src/debugger/cli-debugger.c @@ -83,13 +83,13 @@ static inline void _printPSR(union PSR psr) { } static void _handleDeath(int sig) { - (void)(sig); + UNUSED(sig); printf("No debugger attached!\n"); } static void _breakInto(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(debugger); - (void)(dv); + UNUSED(debugger); + UNUSED(dv); struct sigaction sa, osa; sa.sa_handler = _handleDeath; sigemptyset(&sa.sa_mask); @@ -105,18 +105,18 @@ static void _breakInto(struct CLIDebugger* debugger, struct DebugVector* dv) { } static void _continue(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(dv); + UNUSED(dv); debugger->d.state = DEBUGGER_RUNNING; } static void _next(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(dv); + UNUSED(dv); ARMRun(debugger->d.cpu); _printStatus(debugger, 0); } static void _print(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(debugger); + UNUSED(debugger); for ( ; dv; dv = dv->next) { printf(" %u", dv->intValue); } @@ -124,7 +124,7 @@ static void _print(struct CLIDebugger* debugger, struct DebugVector* dv) { } static void _printHex(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(debugger); + UNUSED(debugger); for ( ; dv; dv = dv->next) { printf(" 0x%08X", dv->intValue); } @@ -143,7 +143,7 @@ static inline void _printLine(struct CLIDebugger* debugger, uint32_t address, en } static void _printStatus(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(dv); + UNUSED(dv); int r; for (r = 0; r < 4; ++r) { printf("%08X %08X %08X %08X\n", @@ -164,7 +164,7 @@ static void _printStatus(struct CLIDebugger* debugger, struct DebugVector* dv) { } static void _quit(struct CLIDebugger* debugger, struct DebugVector* dv) { - (void)(dv); + UNUSED(dv); debugger->d.state = DEBUGGER_SHUTDOWN; } @@ -226,7 +226,7 @@ static void _setWatchpoint(struct CLIDebugger* debugger, struct DebugVector* dv) } static void _breakIntoDefault(int signal) { - (void)(signal); + UNUSED(signal); ARMDebuggerEnter(&_activeDebugger->d, DEBUGGER_ENTER_MANUAL); } @@ -507,7 +507,7 @@ static int _parse(struct CLIDebugger* debugger, const char* line, size_t count) } static char* _prompt(EditLine* el) { - (void)(el); + UNUSED(el); return "> "; } @@ -536,7 +536,7 @@ static void _commandLine(struct ARMDebugger* debugger) { } static void _reportEntry(struct ARMDebugger* debugger, enum DebuggerEntryReason reason) { - (void) (debugger); + UNUSED(debugger); switch (reason) { case DEBUGGER_ENTER_MANUAL: case DEBUGGER_ENTER_ATTACHED: @@ -554,7 +554,7 @@ static void _reportEntry(struct ARMDebugger* debugger, enum DebuggerEntryReason } static unsigned char _tabComplete(EditLine* elstate, int ch) { - (void)(ch); + UNUSED(ch); const LineInfo* li = el_line(elstate); const char* commandPtr; int cmd = 0, len = 0; diff --git a/src/debugger/gdb-stub.c b/src/debugger/gdb-stub.c index 76d9619c3..ee98ceb1c 100644 --- a/src/debugger/gdb-stub.c +++ b/src/debugger/gdb-stub.c @@ -172,7 +172,7 @@ static void _continue(struct GDBStub* stub, const char* message) { } } // TODO: parse message - (void) (message); + UNUSED(message); } static void _step(struct GDBStub* stub, const char* message) { @@ -180,7 +180,7 @@ static void _step(struct GDBStub* stub, const char* message) { snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGINT); _sendMessage(stub); // TODO: parse message - (void) (message); + UNUSED(message); } static void _readMemory(struct GDBStub* stub, const char* message) { @@ -204,7 +204,7 @@ static void _readMemory(struct GDBStub* stub, const char* message) { } static void _readGPRs(struct GDBStub* stub, const char* message) { - (void) (message); + UNUSED(message); int r; int i = 0; for (r = 0; r < 16; ++r) { @@ -264,7 +264,7 @@ static void _processQWriteCommand(struct GDBStub* stub, const char* message) { } static void _processVWriteCommand(struct GDBStub* stub, const char* message) { - (void) (message); + UNUSED(message); stub->outgoing[0] = '\0'; _sendMessage(stub); } @@ -287,7 +287,7 @@ static void _setBreakpoint(struct GDBStub* stub, const char* message) { uint32_t address = _readHex(readAddress, &i); readAddress += i + 1; uint32_t kind = _readHex(readAddress, &i); // We don't use this in hardware watchpoints - (void) (kind); + UNUSED(kind); ARMDebuggerSetBreakpoint(&stub->d, address); strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4); _sendMessage(stub); diff --git a/src/gba/gba-bios.c b/src/gba/gba-bios.c index cf071bc58..bd0308c9b 100644 --- a/src/gba/gba-bios.c +++ b/src/gba/gba-bios.c @@ -13,7 +13,7 @@ static void _unRl(struct GBA* gba, uint32_t source, uint8_t* dest); static void _RegisterRamReset(struct GBA* gba) { uint32_t registers = gba->cpu->gprs[0]; - (void)(registers); + UNUSED(registers); GBALog(gba, GBA_LOG_STUB, "RegisterRamReset unimplemented"); } @@ -27,7 +27,7 @@ static void _BgAffineSet(struct GBA* gba) { int offset = cpu->gprs[0]; int destination = cpu->gprs[1]; int diff = cpu->gprs[3]; - (void)(diff); // Are we supposed to use this? + UNUSED(diff); // Are we supposed to use this? float a, b, c, d; float rx, ry; while (i--) { diff --git a/src/gba/gba-thread.c b/src/gba/gba-thread.c index f6ba956da..523fefd50 100644 --- a/src/gba/gba-thread.c +++ b/src/gba/gba-thread.c @@ -22,9 +22,9 @@ static DWORD _contextKey; static INIT_ONCE _contextOnce = INIT_ONCE_STATIC_INIT; static BOOL CALLBACK _createTLS(PINIT_ONCE once, PVOID param, PVOID* context) { - (void) (once); - (void) (param); - (void) (context); + UNUSED(once); + UNUSED(param); + UNUSED(context); _contextKey = TlsAlloc(); return TRUE; } diff --git a/src/gba/gba-video.c b/src/gba/gba-video.c index ba018225a..72c0466e9 100644 --- a/src/gba/gba-video.c +++ b/src/gba/gba-video.c @@ -155,29 +155,29 @@ void GBAVideoWriteDISPSTAT(struct GBAVideo* video, uint16_t value) { } static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer) { - (void)(renderer); + UNUSED(renderer); // Nothing to do } static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer) { - (void)(renderer); + UNUSED(renderer); // Nothing to do } static uint16_t GBAVideoDummyRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) { - (void)(renderer); - (void)(address); + UNUSED(renderer); + UNUSED(address); return value; } static void GBAVideoDummyRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) { - (void)(renderer); - (void)(y); + UNUSED(renderer); + UNUSED(y); // Nothing to do } static void GBAVideoDummyRendererFinishFrame(struct GBAVideoRenderer* renderer) { - (void)(renderer); + UNUSED(renderer); // Nothing to do } diff --git a/src/gba/renderers/video-software.c b/src/gba/renderers/video-software.c index 4d513dfa8..13c9ba1ed 100644 --- a/src/gba/renderers/video-software.c +++ b/src/gba/renderers/video-software.c @@ -3,8 +3,6 @@ #include "gba.h" #include "gba-io.h" -#define UNUSED(X) (void) (X) - static const int _objSizes[32] = { 8, 8, 16, 16, diff --git a/src/platform/commandline.c b/src/platform/commandline.c index 03d2af2d0..ff3f1478f 100644 --- a/src/platform/commandline.c +++ b/src/platform/commandline.c @@ -122,7 +122,7 @@ void initParserForGraphics(struct SubParser* parser, struct GraphicsOpts* opts) } int _parseGraphicsArg(struct SubParser* parser, int option, const char* arg) { - (void) (arg); + UNUSED(arg); struct GraphicsOpts* graphicsOpts = parser->opts; switch (option) { case 'f': diff --git a/src/platform/perf-main.c b/src/platform/perf-main.c index b27e3ce75..5f4cfa8d7 100644 --- a/src/platform/perf-main.c +++ b/src/platform/perf-main.c @@ -110,7 +110,7 @@ static void _GBAPerfRunloop(struct GBAThread* context, int* frames) { } static void _GBAPerfShutdown(int signal) { - (void) (signal); + UNUSED(signal); pthread_mutex_lock(&_thread->stateMutex); _thread->state = THREAD_EXITING; pthread_mutex_unlock(&_thread->stateMutex); diff --git a/src/platform/sdl/sdl-audio.c b/src/platform/sdl/sdl-audio.c index a800edf8d..e49c05813 100644 --- a/src/platform/sdl/sdl-audio.c +++ b/src/platform/sdl/sdl-audio.c @@ -31,7 +31,7 @@ int GBASDLInitAudio(struct GBASDLAudio* context) { } void GBASDLDeinitAudio(struct GBASDLAudio* context) { - (void)(context); + UNUSED(context); SDL_PauseAudio(1); SDL_CloseAudio(); SDL_QuitSubSystem(SDL_INIT_AUDIO); diff --git a/src/platform/sdl/sdl-events.c b/src/platform/sdl/sdl-events.c index 80660b1f0..85d957afa 100644 --- a/src/platform/sdl/sdl-events.c +++ b/src/platform/sdl/sdl-events.c @@ -208,7 +208,7 @@ static void _GBASDLHandleJoyHat(struct GBAThread* context, const struct SDL_JoyH #if SDL_VERSION_ATLEAST(2, 0, 0) static void _GBASDLHandleWindowEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const struct SDL_WindowEvent* event) { - (void) (context); + UNUSED(context); switch (event->event) { case SDL_WINDOWEVENT_SIZE_CHANGED: sdlContext->windowUpdated = 1; diff --git a/src/util/patch-ips.c b/src/util/patch-ips.c index 91ed0bab6..a9738d65b 100644 --- a/src/util/patch-ips.c +++ b/src/util/patch-ips.c @@ -2,9 +2,6 @@ #include "util/patch.h" -#include -#include - static size_t _IPSOutputSize(struct Patch* patch, size_t inSize); static int _IPSApplyPatch(struct Patch* patch, void* out, size_t outSize); @@ -35,7 +32,7 @@ int loadPatchIPS(struct Patch* patch) { } size_t _IPSOutputSize(struct Patch* patch, size_t inSize) { - (void) (patch); + UNUSED(patch); return inSize; } diff --git a/src/util/patch-ups.c b/src/util/patch-ups.c index 102db6de1..5640145cd 100644 --- a/src/util/patch-ups.c +++ b/src/util/patch-ups.c @@ -3,9 +3,6 @@ #include "util/crc32.h" #include "util/patch.h" -#include -#include - enum { IN_CHECKSUM = -12, OUT_CHECKSUM = -8, @@ -65,7 +62,7 @@ int loadPatchUPS(struct Patch* patch) { } size_t _UPSOutputSize(struct Patch* patch, size_t inSize) { - (void) (inSize); + UNUSED(inSize); lseek(patch->patchfd, 4, SEEK_SET); if (_UPSDecodeLength(patch->patchfd) != inSize) { return 0; diff --git a/src/util/patch.h b/src/util/patch.h index 98b1cea9e..2941fce52 100644 --- a/src/util/patch.h +++ b/src/util/patch.h @@ -1,7 +1,7 @@ #ifndef PATCH_H #define PATCH_H -#include +#include "common.h" struct Patch { int patchfd; diff --git a/src/util/threading.h b/src/util/threading.h index 6e35e0348..54e09a960 100644 --- a/src/util/threading.h +++ b/src/util/threading.h @@ -90,7 +90,7 @@ static inline int ConditionInit(Condition* cond) { static inline int ConditionDeinit(Condition* cond) { // This is a no-op on Windows - (void)(cond); + UNUSED(cond); return 0; }