All: MSVS2015 fixes (via zeromus)

This commit is contained in:
Jeffrey Pfau 2015-06-06 21:08:13 -07:00
parent bbcf40e0e7
commit 12505766e1
6 changed files with 49 additions and 12 deletions

View File

@ -91,7 +91,7 @@ struct ARMDebugger {
bool (*setSoftwareBreakpoint)(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t* opcode);
bool (*clearSoftwareBreakpoint)(struct ARMDebugger*, uint32_t address, enum ExecutionMode mode, uint32_t opcode);
__attribute__((format (printf, 3, 4)))
ATTRIBUTE_FORMAT(printf, 3, 4)
void (*log)(struct ARMDebugger*, enum DebuggerLogLevel, const char* format, ...);
};

View File

@ -216,10 +216,10 @@ void GBAGetGameTitle(struct GBA* gba, char* out);
void GBAFrameStarted(struct GBA* gba);
void GBAFrameEnded(struct GBA* gba);
__attribute__((format (printf, 3, 4)))
ATTRIBUTE_FORMAT(printf,3,4)
void GBALog(struct GBA* gba, enum GBALogLevel level, const char* format, ...);
__attribute__((format (printf, 3, 4)))
ATTRIBUTE_FORMAT(printf, 3, 4)
void GBADebuggerLogShim(struct ARMDebugger* debugger, enum DebuggerLogLevel level, const char* format, ...);
#endif

View File

@ -74,6 +74,9 @@ DECL_BITS(RTCCommandData, Magic, 0, 4);
DECL_BITS(RTCCommandData, Command, 4, 3);
DECL_BIT(RTCCommandData, Reading, 7);
#ifdef _MSC_VER
#pragma pack(push,1)
#endif
struct GBARTC {
int bytesRemaining;
int transferStep;
@ -83,7 +86,10 @@ struct GBARTC {
RTCCommandData command;
RTCControl control;
uint8_t time[7];
} __attribute__((packed));
} ATTRIBUTE_PACKED;
#ifdef _MSC_VER
#pragma pack(pop)
#endif
struct GBARumble {
void (*setRumble)(struct GBARumble*, int enable);

View File

@ -118,7 +118,7 @@ static THREAD_ENTRY _GBAThreadRun(void* context) {
struct Patch patch;
struct GBACheatDevice cheatDevice;
struct GBAThread* threadContext = context;
struct ARMComponent* components[GBA_COMPONENT_MAX] = {};
struct ARMComponent* components[GBA_COMPONENT_MAX] = {0};
struct GBARRContext* movie = 0;
int numComponents = GBA_COMPONENT_MAX;

View File

@ -18,8 +18,24 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#ifdef _MSC_VER
#ifdef _WIN64
typedef int64_t off_t;
typedef int64_t ssize_t;
#else
typedef int32_t off_t;
typedef int32_t ssize_t;
#endif
#define restrict __restrict
#define SSIZE_MAX ((ssize_t) SIZE_MAX)
#define strcasecmp _stricmp
#define strncasecmp _strnicmp
#define ftruncate _chsize
#else
#include <strings.h>
#include <unistd.h>
#endif
#include "version.h"
@ -67,29 +83,44 @@
#define CLEAR_BITS(SRC, START, END) ((SRC) & ~MAKE_MASK(START, END))
#define FILL_BITS(SRC, START, END) ((SRC) | MAKE_MASK(START, END))
#ifdef _MSC_VER
#define ATTRIBUTE_UNUSED
#define ATTRIBUTE_FORMAT(X, Y, Z)
#define ATTRIBUTE_PACKED
#else
#define ATTRIBUTE_UNUSED __attribute__((unused))
#define ATTRIBUTE_FORMAT(X, Y, Z) __attribute__((format(X, Y, Z)))
#define ATTRIBUTE_PACKED __attribute__((packed))
#endif
#define DECL_BITFIELD(NAME, TYPE) typedef TYPE NAME
#define DECL_BITS(TYPE, FIELD, START, SIZE) \
__attribute__((unused)) static inline TYPE TYPE ## Is ## FIELD (TYPE src) { \
ATTRIBUTE_UNUSED static inline TYPE TYPE ## Is ## FIELD (TYPE src) { \
return CHECK_BITS(src, (START), (START) + (SIZE)); \
} \
__attribute__((unused)) static inline TYPE TYPE ## Get ## FIELD (TYPE src) { \
ATTRIBUTE_UNUSED static inline TYPE TYPE ## Get ## FIELD (TYPE src) { \
return EXT_BITS(src, (START), (START) + (SIZE)); \
} \
__attribute__((unused)) static inline TYPE TYPE ## Clear ## FIELD (TYPE src) { \
ATTRIBUTE_UNUSED static inline TYPE TYPE ## Clear ## FIELD (TYPE src) { \
return CLEAR_BITS(src, (START), (START) + (SIZE)); \
} \
__attribute__((unused)) static inline TYPE TYPE ## Fill ## FIELD (TYPE src) { \
ATTRIBUTE_UNUSED static inline TYPE TYPE ## Fill ## FIELD (TYPE src) { \
return FILL_BITS(src, (START), (START) + (SIZE)); \
} \
__attribute__((unused)) static inline TYPE TYPE ## Set ## FIELD (TYPE src, TYPE bits) { \
ATTRIBUTE_UNUSED static inline TYPE TYPE ## Set ## FIELD (TYPE src, TYPE bits) { \
return INS_BITS(src, (START), (START) + (SIZE), bits); \
}
#define DECL_BIT(TYPE, FIELD, BIT) DECL_BITS(TYPE, FIELD, BIT, 1)
#ifdef _MSC_VER
#define LIKELY(X) __builtin_expect(!!(X), 1)
#define UNLIKELY(X) __builtin_expect(!!(X), 0)
#else
#define LIKELY(X) (!!(X))
#define UNLIKELY(X) (!!(X))
#endif
#define ROR(I, ROTATE) ((((uint32_t) (I)) >> ROTATE) | ((uint32_t) (I) << ((-ROTATE) & 31)))

View File

@ -93,7 +93,7 @@ ssize_t _vfmRead(struct VFile* vf, void* buffer, size_t size) {
size = vfm->size - vfm->offset;
}
memcpy(buffer, vfm->mem + vfm->offset, size);
memcpy(buffer, (void*) ((uintptr_t) vfm->mem + vfm->offset), size);
vfm->offset += size;
return size;
}
@ -105,7 +105,7 @@ ssize_t _vfmWrite(struct VFile* vf, const void* buffer, size_t size) {
size = vfm->size - vfm->offset;
}
memcpy(vfm->mem + vfm->offset, buffer, size);
memcpy((void*) ((uintptr_t) vfm->mem + vfm->offset), buffer, size);
vfm->offset += size;
return size;
}