From 003cfc63c69b3e900de768317354dfb80bbf6a55 Mon Sep 17 00:00:00 2001 From: notaz Date: Sat, 3 Jan 2015 02:22:14 +0200 Subject: [PATCH] mingw build fixes --- Makefile.libretro | 4 ++- frontend/libretro.c | 4 +-- frontend/main.c | 31 ++++++++++++++++---- frontend/plugin.c | 47 ++++++++++++++++++------------- libpcsxcore/cdriso.c | 2 ++ libpcsxcore/cdrom.c | 4 +-- libpcsxcore/memmap_win32.c | 2 +- libpcsxcore/new_dynarec/emu_if.c | 4 +-- libpcsxcore/new_dynarec/pcsxmem.c | 2 +- libpcsxcore/new_dynarec/pcsxmem.h | 2 +- libpcsxcore/plugins.h | 19 +++++-------- plugins/cdrcimg/cdrcimg.c | 10 ++++++- plugins/dfinput/main.c | 15 +++++++--- plugins/dfsound/spu.c | 13 ++------- plugins/dfsound/stdafx.h | 20 +++++-------- plugins/dfsound/xa.c | 4 +++ 16 files changed, 107 insertions(+), 76 deletions(-) diff --git a/Makefile.libretro b/Makefile.libretro index ae95639f..d566e23a 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -172,7 +172,9 @@ else endif CFLAGS += -fPIC -ifneq ($(platform),qnx) +ifeq ($(platform),win) + MAIN_LDLIBS += -lws2_32 +else ifneq ($(platform),qnx) LDLIBS += -lpthread MAIN_LDLIBS += -ldl endif diff --git a/frontend/libretro.c b/frontend/libretro.c index b636f498..5bc54438 100644 --- a/frontend/libretro.c +++ b/frontend/libretro.c @@ -1,5 +1,5 @@ /* - * (C) notaz, 2012 + * (C) notaz, 2012,2014,2015 * * This work is licensed under the terms of the GNU GPLv2 or later. * See the COPYING file in the top-level directory. @@ -602,7 +602,7 @@ static void extract_directory(char *buf, const char *path, size_t size) } } -#ifdef __QNX__ +#if defined(__QNX__) || defined(_WIN32) /* Blackberry QNX doesn't have strcasestr */ /* diff --git a/frontend/main.c b/frontend/main.c index 426ef138..bdea1b51 100644 --- a/frontend/main.c +++ b/frontend/main.c @@ -8,12 +8,12 @@ #include #include #include -#include -#include -#include #include #include #include +#ifndef _WIN32 +#include +#endif #include "main.h" #include "plugin.h" @@ -141,7 +141,7 @@ void emu_set_default_config(void) spu_config.iXAPitch = 0; spu_config.iVolume = 768; spu_config.iTempo = 0; -#if defined(__arm__) && !defined(__ARM_ARCH_7A__) /* XXX */ +#if defined(__arm__) && !defined(__ARM_ARCH_7A__) /* XXX GPH hack */ spu_config.iUseReverb = 0; spu_config.iUseInterpolation = 0; spu_config.iTempo = 1; @@ -452,6 +452,10 @@ void emu_core_ask_exit(void) } #ifndef NO_FRONTEND + +#include +#include + static void create_profile_dir(const char *directory) { char path[MAXPATHLEN]; @@ -766,7 +770,7 @@ int emu_save_state(int slot) return ret; ret = SaveState(fname); -#ifndef __ARM_ARCH_7A__ /* XXX */ +#if defined(__arm__) && !defined(__ARM_ARCH_7A__) /* XXX GPH hack */ sync(); #endif SysPrintf("* %s \"%s\" [%d]\n", @@ -968,7 +972,7 @@ static const int builtin_plugin_ids[] = { void *SysLoadLibrary(const char *lib) { const char *tmp = strrchr(lib, '/'); - void *ret; + void *ret = NULL; int i; SysPrintf("plugin: %s\n", lib); @@ -980,9 +984,14 @@ void *SysLoadLibrary(const char *lib) { return (void *)(long)(PLUGIN_DL_BASE + builtin_plugin_ids[i]); } +#ifndef _WIN32 ret = dlopen(lib, RTLD_NOW); if (ret == NULL) SysMessage("dlopen: %s", dlerror()); +#else + /* no external plugin support, abi is no longer + * compatible with psemu/pcsx anyway */ +#endif return ret; } @@ -992,11 +1001,19 @@ void *SysLoadSym(void *lib, const char *sym) { if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins)) return plugin_link(plugid - PLUGIN_DL_BASE, sym); +#ifndef _WIN32 return dlsym(lib, sym); +#else + return NULL; +#endif } const char *SysLibError() { +#ifndef _WIN32 return dlerror(); +#else + return "not supported"; +#endif } void SysCloseLibrary(void *lib) { @@ -1005,6 +1022,8 @@ void SysCloseLibrary(void *lib) { if (PLUGIN_DL_BASE <= plugid && plugid < PLUGIN_DL_BASE + ARRAY_SIZE(builtin_plugins)) return; +#ifndef _WIN32 dlclose(lib); +#endif } diff --git a/frontend/plugin.c b/frontend/plugin.c index cf3d575d..d9eb04a4 100644 --- a/frontend/plugin.c +++ b/frontend/plugin.c @@ -15,31 +15,38 @@ #include "../libpcsxcore/system.h" #include "../plugins/cdrcimg/cdrcimg.h" +#ifndef _WIN32 +#define CALLBACK +#else +#define WIN32_LEAN_AND_MEAN +#include +#endif + static int dummy_func() { return 0; } /* SPU */ -extern long SPUopen(void); -extern long SPUinit(void); -extern long SPUshutdown(void); -extern long SPUclose(void); -extern void SPUplaySample(unsigned char); -extern void SPUwriteRegister(unsigned long, unsigned short, unsigned int); -extern unsigned short SPUreadRegister(unsigned long); -extern void SPUwriteDMA(unsigned short); -extern unsigned short SPUreadDMA(void); -extern void SPUwriteDMAMem(unsigned short *, int, unsigned int); -extern void SPUreadDMAMem(unsigned short *, int, unsigned int); -extern void SPUplayADPCMchannel(void *); -extern void SPUregisterCallback(void (*cb)(void)); -extern void SPUregisterScheduleCb(void (*cb)(unsigned int)); -extern long SPUconfigure(void); -extern long SPUtest(void); -extern void SPUabout(void); -extern long SPUfreeze(unsigned int, void *, unsigned int); -extern void SPUasync(unsigned int, unsigned int); -extern int SPUplayCDDAchannel(short *, int); +extern long CALLBACK SPUopen(void); +extern long CALLBACK SPUinit(void); +extern long CALLBACK SPUshutdown(void); +extern long CALLBACK SPUclose(void); +extern void CALLBACK SPUplaySample(unsigned char); +extern void CALLBACK SPUwriteRegister(unsigned long, unsigned short, unsigned int); +extern unsigned short CALLBACK SPUreadRegister(unsigned long); +extern void CALLBACK SPUwriteDMA(unsigned short); +extern unsigned short CALLBACK SPUreadDMA(void); +extern void CALLBACK SPUwriteDMAMem(unsigned short *, int, unsigned int); +extern void CALLBACK SPUreadDMAMem(unsigned short *, int, unsigned int); +extern void CALLBACK SPUplayADPCMchannel(void *); +extern void CALLBACK SPUregisterCallback(void (*cb)(void)); +extern void CALLBACK SPUregisterScheduleCb(void (*cb)(unsigned int)); +extern long CALLBACK SPUconfigure(void); +extern long CALLBACK SPUtest(void); +extern void CALLBACK SPUabout(void); +extern long CALLBACK SPUfreeze(unsigned int, void *, unsigned int); +extern void CALLBACK SPUasync(unsigned int, unsigned int); +extern int CALLBACK SPUplayCDDAchannel(short *, int); /* PAD */ static long PADreadPort1(PadDataS *pad) diff --git a/libpcsxcore/cdriso.c b/libpcsxcore/cdriso.c index b733f5b1..09aed17d 100644 --- a/libpcsxcore/cdriso.c +++ b/libpcsxcore/cdriso.c @@ -26,9 +26,11 @@ #include "ppf.h" #ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN #include #include #define strcasecmp _stricmp +#define usleep(x) Sleep((x) / 1000) #else #include #include diff --git a/libpcsxcore/cdrom.c b/libpcsxcore/cdrom.c index b6868557..3a2eb1f6 100644 --- a/libpcsxcore/cdrom.c +++ b/libpcsxcore/cdrom.c @@ -126,7 +126,7 @@ unsigned char Test23[] = { 0x43, 0x58, 0x44, 0x32, 0x39 ,0x34, 0x30, 0x51 }; #define STATUS_ERROR (1<<0) // 0x01 /* Errors */ -#define ERROR_NOT_READY (1<<7) // 0x80 +#define ERROR_NOTREADY (1<<7) // 0x80 #define ERROR_INVALIDCMD (1<<6) // 0x40 #define ERROR_INVALIDARG (1<<5) // 0x20 @@ -984,7 +984,7 @@ void cdrInterrupt() { case DRIVESTATE_PREPARE_CD: SetResultSize(2); cdr.Result[0] = cdr.StatP | STATUS_ERROR; - cdr.Result[1] = ERROR_NOT_READY; + cdr.Result[1] = ERROR_NOTREADY; cdr.Stat = DiskError; break; } diff --git a/libpcsxcore/memmap_win32.c b/libpcsxcore/memmap_win32.c index f4dbdd61..294f0589 100644 --- a/libpcsxcore/memmap_win32.c +++ b/libpcsxcore/memmap_win32.c @@ -2,7 +2,7 @@ #include #include -#include "mman.h" +#include "memmap.h" #ifndef FILE_MAP_EXECUTE #define FILE_MAP_EXECUTE 0x0020 diff --git a/libpcsxcore/new_dynarec/emu_if.c b/libpcsxcore/new_dynarec/emu_if.c index b7a24890..092c8ae9 100644 --- a/libpcsxcore/new_dynarec/emu_if.c +++ b/libpcsxcore/new_dynarec/emu_if.c @@ -305,7 +305,7 @@ static int ari64_init() { extern void (*psxCP2[64])(); extern void psxNULL(); - extern u_char *out; + extern unsigned char *out; size_t i; new_dynarec_init(); @@ -438,7 +438,7 @@ int new_dynarec_hacks; void *psxH_ptr; void *zeromem_ptr; u8 zero_mem[0x1000]; -u_char *out; +unsigned char *out; void *mem_rtab; void *scratch_buf_ptr; void new_dynarec_init() { (void)ari64_execute; } diff --git a/libpcsxcore/new_dynarec/pcsxmem.c b/libpcsxcore/new_dynarec/pcsxmem.c index d5c32be4..9376ff47 100644 --- a/libpcsxcore/new_dynarec/pcsxmem.c +++ b/libpcsxcore/new_dynarec/pcsxmem.c @@ -292,7 +292,7 @@ void new_dyna_pcsx_mem_load_state(void) map_rcnt_rcount2(rcnts[2].mode); } -int pcsxmem_is_handler_dynamic(u_int addr) +int pcsxmem_is_handler_dynamic(unsigned int addr) { if ((addr & 0xfffff000) != 0x1f801000) return 0; diff --git a/libpcsxcore/new_dynarec/pcsxmem.h b/libpcsxcore/new_dynarec/pcsxmem.h index 99bb5d4f..72892a8e 100644 --- a/libpcsxcore/new_dynarec/pcsxmem.h +++ b/libpcsxcore/new_dynarec/pcsxmem.h @@ -6,4 +6,4 @@ void new_dyna_pcsx_mem_reset(void); void new_dyna_pcsx_mem_load_state(void); void new_dyna_pcsx_mem_shutdown(void); -int pcsxmem_is_handler_dynamic(u_int addr); +int pcsxmem_is_handler_dynamic(unsigned int addr); diff --git a/libpcsxcore/plugins.h b/libpcsxcore/plugins.h index e6ac694d..132df907 100644 --- a/libpcsxcore/plugins.h +++ b/libpcsxcore/plugins.h @@ -33,24 +33,19 @@ extern "C" { typedef void* HWND; #define CALLBACK -typedef long (*GPUopen)(unsigned long *, char *, char *); -typedef long (*SPUopen)(void); -typedef long (*PADopen)(unsigned long *); -typedef long (*NETopen)(unsigned long *); -typedef long (*SIO1open)(unsigned long *); - #else +#define WIN32_LEAN_AND_MEAN #include -typedef long (CALLBACK* GPUopen)(HWND); -typedef long (CALLBACK* SPUopen)(HWND); -typedef long (CALLBACK* PADopen)(HWND); -typedef long (CALLBACK* NETopen)(HWND); -typedef long (CALLBACK* SIO1open)(HWND); - #endif +typedef long (CALLBACK *GPUopen)(unsigned long *, char *, char *); +typedef long (CALLBACK *SPUopen)(void); +typedef long (CALLBACK *PADopen)(unsigned long *); +typedef long (CALLBACK *NETopen)(unsigned long *); +typedef long (CALLBACK *SIO1open)(unsigned long *); + #include "spu.h" #include "psemu_plugin_defs.h" diff --git a/plugins/cdrcimg/cdrcimg.c b/plugins/cdrcimg/cdrcimg.c index 0ec14dbb..76cdfbaa 100644 --- a/plugins/cdrcimg/cdrcimg.c +++ b/plugins/cdrcimg/cdrcimg.c @@ -12,7 +12,13 @@ #include #include #include +#ifndef _WIN32 +#define CALLBACK #include +#else +#define WIN32_LEAN_AND_MEAN +#include +#endif #include "cdrcimg.h" @@ -44,7 +50,7 @@ static struct { static int current_block, current_sect_in_blk; struct CdrStat; -extern long CDR__getStatus(struct CdrStat *stat); +extern long CALLBACK CDR__getStatus(struct CdrStat *stat); struct CdrStat { @@ -279,6 +285,7 @@ static long CDRinit(void) return -1; } } +#ifndef _WIN32 if (pBZ2_bzBuffToBuffDecompress == NULL) { void *h = dlopen("/usr/lib/libbz2.so.1", RTLD_LAZY); if (h == NULL) @@ -291,6 +298,7 @@ static long CDRinit(void) } } } +#endif return 0; } diff --git a/plugins/dfinput/main.c b/plugins/dfinput/main.c index 73b2bda9..475ea073 100644 --- a/plugins/dfinput/main.c +++ b/plugins/dfinput/main.c @@ -8,6 +8,13 @@ * See the COPYING file in the top-level directory. */ +#ifndef _WIN32 +#define CALLBACK +#else +#define WIN32_LEAN_AND_MEAN +#include +#endif + #include "main.h" unsigned char CurPad, CurByte, CurCmd, CmdLen; @@ -15,10 +22,10 @@ unsigned char CurPad, CurByte, CurCmd, CmdLen; /* since this is not a proper plugin, so we'll hook emu internals in a hackish way like this */ extern void *PAD1_startPoll, *PAD1_poll; extern void *PAD2_startPoll, *PAD2_poll; -extern unsigned char PAD1__startPoll(int pad); -extern unsigned char PAD2__startPoll(int pad); -extern unsigned char PAD1__poll(unsigned char value); -extern unsigned char PAD2__poll(unsigned char value); +extern unsigned char CALLBACK PAD1__startPoll(int pad); +extern unsigned char CALLBACK PAD2__startPoll(int pad); +extern unsigned char CALLBACK PAD1__poll(unsigned char value); +extern unsigned char CALLBACK PAD2__poll(unsigned char value); static int old_controller_type1 = -1, old_controller_type2 = -1; diff --git a/plugins/dfsound/spu.c b/plugins/dfsound/spu.c index 835555de..d39bbc16 100644 --- a/plugins/dfsound/spu.c +++ b/plugins/dfsound/spu.c @@ -18,6 +18,9 @@ * * ***************************************************************************/ +#ifndef _WIN32 +#include // gettimeofday in xa.c +#endif #include "stdafx.h" #define _IN_SPU @@ -28,16 +31,6 @@ #include "arm_features.h" #include "spu_config.h" -#ifdef ENABLE_NLS -#include -#include -#define _(x) gettext(x) -#define N_(x) (x) -#else -#define _(x) (x) -#define N_(x) (x) -#endif - #ifdef __ARM_ARCH_7A__ #define ssat32_to_16(v) \ asm("ssat %0,#16,%1" : "=r" (v) : "r" (v)) diff --git a/plugins/dfsound/stdafx.h b/plugins/dfsound/stdafx.h index 8993bb35..7e220290 100644 --- a/plugins/dfsound/stdafx.h +++ b/plugins/dfsound/stdafx.h @@ -15,26 +15,20 @@ * * ***************************************************************************/ -#ifndef _MACOSX -#include "config.h" -#endif #include #include -#include -#include -#include -#include -#include -#define RRand(range) (random()%range) #include -#include -#include +#ifdef _WIN32 +#define WIN32_LEAN_AND_MEAN +#include +#else #undef CALLBACK #define CALLBACK #define DWORD unsigned int -#define LOWORD(l) ((unsigned short)(l)) -#define HIWORD(l) ((unsigned short)(((unsigned int)(l) >> 16) & 0xFFFF)) +#define LOWORD(l) ((unsigned short)(l)) +#define HIWORD(l) ((unsigned short)(((unsigned int)(l) >> 16) & 0xFFFF)) +#endif #ifndef INLINE #define INLINE static inline diff --git a/plugins/dfsound/xa.c b/plugins/dfsound/xa.c index 704847b4..9b7ed5a9 100644 --- a/plugins/dfsound/xa.c +++ b/plugins/dfsound/xa.c @@ -90,9 +90,13 @@ INLINE void MixXA(int ns_to) static unsigned long timeGetTime_spu() { +#ifdef _WIN32 + return GetTickCount(); +#else struct timeval tv; gettimeofday(&tv, 0); // well, maybe there are better ways return tv.tv_sec * 1000 + tv.tv_usec/1000; // to do that, but at least it works +#endif } //////////////////////////////////////////////////////////////////////// -- 2.39.2