Move UNUSED macro to common.h

This commit is contained in:
Jeffrey Pfau 2014-07-10 01:00:38 -07:00
parent 0a48d4cc2f
commit 55977796f3
16 changed files with 40 additions and 48 deletions

View File

@ -11,6 +11,8 @@
#include <string.h> #include <string.h>
#include <unistd.h> #include <unistd.h>
#define UNUSED(V) (void)(V)
#ifdef __POWERPC__ #ifdef __POWERPC__
#define LOAD_32(DEST, ADDR, ARR) asm("lwbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR)) #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)) #define LOAD_16(DEST, ADDR, ARR) asm("lhbrx %0, %1, %2" : "=r"(DEST) : "r"(ADDR), "r"(ARR))

View File

@ -5,8 +5,6 @@
#include "arm.h" #include "arm.h"
#define UNUSED(V) (void)(V)
#define DO_4(DIRECTIVE) \ #define DO_4(DIRECTIVE) \
DIRECTIVE, \ DIRECTIVE, \
DIRECTIVE, \ DIRECTIVE, \

View File

@ -83,13 +83,13 @@ static inline void _printPSR(union PSR psr) {
} }
static void _handleDeath(int sig) { static void _handleDeath(int sig) {
(void)(sig); UNUSED(sig);
printf("No debugger attached!\n"); printf("No debugger attached!\n");
} }
static void _breakInto(struct CLIDebugger* debugger, struct DebugVector* dv) { static void _breakInto(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(debugger); UNUSED(debugger);
(void)(dv); UNUSED(dv);
struct sigaction sa, osa; struct sigaction sa, osa;
sa.sa_handler = _handleDeath; sa.sa_handler = _handleDeath;
sigemptyset(&sa.sa_mask); 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) { static void _continue(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(dv); UNUSED(dv);
debugger->d.state = DEBUGGER_RUNNING; debugger->d.state = DEBUGGER_RUNNING;
} }
static void _next(struct CLIDebugger* debugger, struct DebugVector* dv) { static void _next(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(dv); UNUSED(dv);
ARMRun(debugger->d.cpu); ARMRun(debugger->d.cpu);
_printStatus(debugger, 0); _printStatus(debugger, 0);
} }
static void _print(struct CLIDebugger* debugger, struct DebugVector* dv) { static void _print(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(debugger); UNUSED(debugger);
for ( ; dv; dv = dv->next) { for ( ; dv; dv = dv->next) {
printf(" %u", dv->intValue); 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) { static void _printHex(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(debugger); UNUSED(debugger);
for ( ; dv; dv = dv->next) { for ( ; dv; dv = dv->next) {
printf(" 0x%08X", dv->intValue); 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) { static void _printStatus(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(dv); UNUSED(dv);
int r; int r;
for (r = 0; r < 4; ++r) { for (r = 0; r < 4; ++r) {
printf("%08X %08X %08X %08X\n", 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) { static void _quit(struct CLIDebugger* debugger, struct DebugVector* dv) {
(void)(dv); UNUSED(dv);
debugger->d.state = DEBUGGER_SHUTDOWN; debugger->d.state = DEBUGGER_SHUTDOWN;
} }
@ -226,7 +226,7 @@ static void _setWatchpoint(struct CLIDebugger* debugger, struct DebugVector* dv)
} }
static void _breakIntoDefault(int signal) { static void _breakIntoDefault(int signal) {
(void)(signal); UNUSED(signal);
ARMDebuggerEnter(&_activeDebugger->d, DEBUGGER_ENTER_MANUAL); 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) { static char* _prompt(EditLine* el) {
(void)(el); UNUSED(el);
return "> "; return "> ";
} }
@ -536,7 +536,7 @@ static void _commandLine(struct ARMDebugger* debugger) {
} }
static void _reportEntry(struct ARMDebugger* debugger, enum DebuggerEntryReason reason) { static void _reportEntry(struct ARMDebugger* debugger, enum DebuggerEntryReason reason) {
(void) (debugger); UNUSED(debugger);
switch (reason) { switch (reason) {
case DEBUGGER_ENTER_MANUAL: case DEBUGGER_ENTER_MANUAL:
case DEBUGGER_ENTER_ATTACHED: case DEBUGGER_ENTER_ATTACHED:
@ -554,7 +554,7 @@ static void _reportEntry(struct ARMDebugger* debugger, enum DebuggerEntryReason
} }
static unsigned char _tabComplete(EditLine* elstate, int ch) { static unsigned char _tabComplete(EditLine* elstate, int ch) {
(void)(ch); UNUSED(ch);
const LineInfo* li = el_line(elstate); const LineInfo* li = el_line(elstate);
const char* commandPtr; const char* commandPtr;
int cmd = 0, len = 0; int cmd = 0, len = 0;

View File

@ -172,7 +172,7 @@ static void _continue(struct GDBStub* stub, const char* message) {
} }
} }
// TODO: parse message // TODO: parse message
(void) (message); UNUSED(message);
} }
static void _step(struct GDBStub* stub, const char* 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); snprintf(stub->outgoing, GDB_STUB_MAX_LINE - 4, "S%02x", SIGINT);
_sendMessage(stub); _sendMessage(stub);
// TODO: parse message // TODO: parse message
(void) (message); UNUSED(message);
} }
static void _readMemory(struct GDBStub* stub, const char* 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) { static void _readGPRs(struct GDBStub* stub, const char* message) {
(void) (message); UNUSED(message);
int r; int r;
int i = 0; int i = 0;
for (r = 0; r < 16; ++r) { 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) { static void _processVWriteCommand(struct GDBStub* stub, const char* message) {
(void) (message); UNUSED(message);
stub->outgoing[0] = '\0'; stub->outgoing[0] = '\0';
_sendMessage(stub); _sendMessage(stub);
} }
@ -287,7 +287,7 @@ static void _setBreakpoint(struct GDBStub* stub, const char* message) {
uint32_t address = _readHex(readAddress, &i); uint32_t address = _readHex(readAddress, &i);
readAddress += i + 1; readAddress += i + 1;
uint32_t kind = _readHex(readAddress, &i); // We don't use this in hardware watchpoints uint32_t kind = _readHex(readAddress, &i); // We don't use this in hardware watchpoints
(void) (kind); UNUSED(kind);
ARMDebuggerSetBreakpoint(&stub->d, address); ARMDebuggerSetBreakpoint(&stub->d, address);
strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4); strncpy(stub->outgoing, "OK", GDB_STUB_MAX_LINE - 4);
_sendMessage(stub); _sendMessage(stub);

View File

@ -13,7 +13,7 @@ static void _unRl(struct GBA* gba, uint32_t source, uint8_t* dest);
static void _RegisterRamReset(struct GBA* gba) { static void _RegisterRamReset(struct GBA* gba) {
uint32_t registers = gba->cpu->gprs[0]; uint32_t registers = gba->cpu->gprs[0];
(void)(registers); UNUSED(registers);
GBALog(gba, GBA_LOG_STUB, "RegisterRamReset unimplemented"); GBALog(gba, GBA_LOG_STUB, "RegisterRamReset unimplemented");
} }
@ -27,7 +27,7 @@ static void _BgAffineSet(struct GBA* gba) {
int offset = cpu->gprs[0]; int offset = cpu->gprs[0];
int destination = cpu->gprs[1]; int destination = cpu->gprs[1];
int diff = cpu->gprs[3]; 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 a, b, c, d;
float rx, ry; float rx, ry;
while (i--) { while (i--) {

View File

@ -22,9 +22,9 @@ static DWORD _contextKey;
static INIT_ONCE _contextOnce = INIT_ONCE_STATIC_INIT; static INIT_ONCE _contextOnce = INIT_ONCE_STATIC_INIT;
static BOOL CALLBACK _createTLS(PINIT_ONCE once, PVOID param, PVOID* context) { static BOOL CALLBACK _createTLS(PINIT_ONCE once, PVOID param, PVOID* context) {
(void) (once); UNUSED(once);
(void) (param); UNUSED(param);
(void) (context); UNUSED(context);
_contextKey = TlsAlloc(); _contextKey = TlsAlloc();
return TRUE; return TRUE;
} }

View File

@ -155,29 +155,29 @@ void GBAVideoWriteDISPSTAT(struct GBAVideo* video, uint16_t value) {
} }
static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer) { static void GBAVideoDummyRendererInit(struct GBAVideoRenderer* renderer) {
(void)(renderer); UNUSED(renderer);
// Nothing to do // Nothing to do
} }
static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer) { static void GBAVideoDummyRendererDeinit(struct GBAVideoRenderer* renderer) {
(void)(renderer); UNUSED(renderer);
// Nothing to do // Nothing to do
} }
static uint16_t GBAVideoDummyRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) { static uint16_t GBAVideoDummyRendererWriteVideoRegister(struct GBAVideoRenderer* renderer, uint32_t address, uint16_t value) {
(void)(renderer); UNUSED(renderer);
(void)(address); UNUSED(address);
return value; return value;
} }
static void GBAVideoDummyRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) { static void GBAVideoDummyRendererDrawScanline(struct GBAVideoRenderer* renderer, int y) {
(void)(renderer); UNUSED(renderer);
(void)(y); UNUSED(y);
// Nothing to do // Nothing to do
} }
static void GBAVideoDummyRendererFinishFrame(struct GBAVideoRenderer* renderer) { static void GBAVideoDummyRendererFinishFrame(struct GBAVideoRenderer* renderer) {
(void)(renderer); UNUSED(renderer);
// Nothing to do // Nothing to do
} }

View File

@ -3,8 +3,6 @@
#include "gba.h" #include "gba.h"
#include "gba-io.h" #include "gba-io.h"
#define UNUSED(X) (void) (X)
static const int _objSizes[32] = { static const int _objSizes[32] = {
8, 8, 8, 8,
16, 16, 16, 16,

View File

@ -122,7 +122,7 @@ void initParserForGraphics(struct SubParser* parser, struct GraphicsOpts* opts)
} }
int _parseGraphicsArg(struct SubParser* parser, int option, const char* arg) { int _parseGraphicsArg(struct SubParser* parser, int option, const char* arg) {
(void) (arg); UNUSED(arg);
struct GraphicsOpts* graphicsOpts = parser->opts; struct GraphicsOpts* graphicsOpts = parser->opts;
switch (option) { switch (option) {
case 'f': case 'f':

View File

@ -110,7 +110,7 @@ static void _GBAPerfRunloop(struct GBAThread* context, int* frames) {
} }
static void _GBAPerfShutdown(int signal) { static void _GBAPerfShutdown(int signal) {
(void) (signal); UNUSED(signal);
pthread_mutex_lock(&_thread->stateMutex); pthread_mutex_lock(&_thread->stateMutex);
_thread->state = THREAD_EXITING; _thread->state = THREAD_EXITING;
pthread_mutex_unlock(&_thread->stateMutex); pthread_mutex_unlock(&_thread->stateMutex);

View File

@ -31,7 +31,7 @@ int GBASDLInitAudio(struct GBASDLAudio* context) {
} }
void GBASDLDeinitAudio(struct GBASDLAudio* context) { void GBASDLDeinitAudio(struct GBASDLAudio* context) {
(void)(context); UNUSED(context);
SDL_PauseAudio(1); SDL_PauseAudio(1);
SDL_CloseAudio(); SDL_CloseAudio();
SDL_QuitSubSystem(SDL_INIT_AUDIO); SDL_QuitSubSystem(SDL_INIT_AUDIO);

View File

@ -208,7 +208,7 @@ static void _GBASDLHandleJoyHat(struct GBAThread* context, const struct SDL_JoyH
#if SDL_VERSION_ATLEAST(2, 0, 0) #if SDL_VERSION_ATLEAST(2, 0, 0)
static void _GBASDLHandleWindowEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const struct SDL_WindowEvent* event) { static void _GBASDLHandleWindowEvent(struct GBAThread* context, struct GBASDLEvents* sdlContext, const struct SDL_WindowEvent* event) {
(void) (context); UNUSED(context);
switch (event->event) { switch (event->event) {
case SDL_WINDOWEVENT_SIZE_CHANGED: case SDL_WINDOWEVENT_SIZE_CHANGED:
sdlContext->windowUpdated = 1; sdlContext->windowUpdated = 1;

View File

@ -2,9 +2,6 @@
#include "util/patch.h" #include "util/patch.h"
#include <stdint.h>
#include <unistd.h>
static size_t _IPSOutputSize(struct Patch* patch, size_t inSize); static size_t _IPSOutputSize(struct Patch* patch, size_t inSize);
static int _IPSApplyPatch(struct Patch* patch, void* out, size_t outSize); 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) { size_t _IPSOutputSize(struct Patch* patch, size_t inSize) {
(void) (patch); UNUSED(patch);
return inSize; return inSize;
} }

View File

@ -3,9 +3,6 @@
#include "util/crc32.h" #include "util/crc32.h"
#include "util/patch.h" #include "util/patch.h"
#include <stdint.h>
#include <unistd.h>
enum { enum {
IN_CHECKSUM = -12, IN_CHECKSUM = -12,
OUT_CHECKSUM = -8, OUT_CHECKSUM = -8,
@ -65,7 +62,7 @@ int loadPatchUPS(struct Patch* patch) {
} }
size_t _UPSOutputSize(struct Patch* patch, size_t inSize) { size_t _UPSOutputSize(struct Patch* patch, size_t inSize) {
(void) (inSize); UNUSED(inSize);
lseek(patch->patchfd, 4, SEEK_SET); lseek(patch->patchfd, 4, SEEK_SET);
if (_UPSDecodeLength(patch->patchfd) != inSize) { if (_UPSDecodeLength(patch->patchfd) != inSize) {
return 0; return 0;

View File

@ -1,7 +1,7 @@
#ifndef PATCH_H #ifndef PATCH_H
#define PATCH_H #define PATCH_H
#include <string.h> #include "common.h"
struct Patch { struct Patch {
int patchfd; int patchfd;

View File

@ -90,7 +90,7 @@ static inline int ConditionInit(Condition* cond) {
static inline int ConditionDeinit(Condition* cond) { static inline int ConditionDeinit(Condition* cond) {
// This is a no-op on Windows // This is a no-op on Windows
(void)(cond); UNUSED(cond);
return 0; return 0;
} }