From 949b873dc8164a9cbfdb48d687263da95b4bfc66 Mon Sep 17 00:00:00 2001 From: Soren Jorvang Date: Fri, 23 Jul 2010 23:51:34 +0000 Subject: [PATCH] Further *BSD portability. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5958 8ced0084-cf51-0410-be5f-012b33b47a6e --- Externals/SDL/SDL/SDL_config_bsd.h | 4 +- Externals/SFML/include/SFML/Config.hpp | 3 +- Externals/WiiUse/Src/Makefile | 85 ------------------- SConstruct | 2 +- Source/Core/AudioCommon/Src/Mixer.h | 2 + Source/Core/Common/Src/FileUtil.cpp | 4 +- Source/Core/Core/Src/HLE/HLE_OS.cpp | 2 +- Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp | 2 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp | 2 +- .../Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp | 12 +-- .../Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h | 2 +- Source/Core/Core/Src/MemTools.cpp | 35 ++++---- Source/Core/DebuggerWX/Src/MemoryWindow.cpp | 2 +- Source/Core/DiscIO/Src/BannerLoader.cpp | 8 +- Source/Core/DolphinWX/Src/MainNoGUI.cpp | 2 +- .../Core/VideoCommon/Src/PixelShaderGen.cpp | 9 +- 16 files changed, 50 insertions(+), 126 deletions(-) delete mode 100644 Externals/WiiUse/Src/Makefile diff --git a/Externals/SDL/SDL/SDL_config_bsd.h b/Externals/SDL/SDL/SDL_config_bsd.h index 8755679298..552349837e 100644 --- a/Externals/SDL/SDL/SDL_config_bsd.h +++ b/Externals/SDL/SDL/SDL_config_bsd.h @@ -5,9 +5,7 @@ #define SDL_JOYSTICK_USBHID 1 -#ifdef __FreeBSD__ -#define HAVE_USBHID_H -#endif +#define HAVE_USBHID_H 1 #define USBHID_NEW #define USBHID_UCR_DATA diff --git a/Externals/SFML/include/SFML/Config.hpp b/Externals/SFML/include/SFML/Config.hpp index 63ff46c421..2a8cf123b3 100644 --- a/Externals/SFML/include/SFML/Config.hpp +++ b/Externals/SFML/include/SFML/Config.hpp @@ -49,7 +49,8 @@ // MacOS #define SFML_SYSTEM_MACOS -#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) +#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \ + defined(__NetBSD__) || defined(__OpenBSD__) // FreeBSD #define SFML_SYSTEM_FREEBSD diff --git a/Externals/WiiUse/Src/Makefile b/Externals/WiiUse/Src/Makefile deleted file mode 100644 index ff4d129bd5..0000000000 --- a/Externals/WiiUse/Src/Makefile +++ /dev/null @@ -1,85 +0,0 @@ -# -# wiiuse Makefile -# - -# -# Change this to your GCC version. -# -CC = gcc - -#################################################### -# -# You should not need to edit below this line. -# -#################################################### - -# -# Universal cflags -# -CFLAGS = -Wall -pipe -fPIC -funroll-loops - -ifeq ($(debug),1) - OBJ_PREFIX = debug - CFLAGS += -g -pg -DWITH_WIIUSE_DEBUG - -else - OBJ_PREFIX = release - CFLAGS += -O2 -endif - -OBJ_DIR = $(OBJ_PREFIX)-$(shell $(CC) -v 2>&1|grep ^Target:|cut -d' ' -f2) - -# -# Linking flags -# -LDFLAGS = -shared -lm -lbluetooth - -# -# Target binaries (always created as BIN) -# -BIN = ./$(OBJ_DIR)/libwiiuse.so - -# -# Inclusion paths. -# -INCLUDES = -I. - -# -# Generate a list of object files -# -OBJS = \ - $(OBJ_DIR)/io_nix.o \ - $(OBJ_DIR)/ir.o \ - $(OBJ_DIR)/wiiuse.o - -############################### -# -# Build targets. -# -############################### - -all: $(BIN) - -clean: - @-rm $(OBJS) 2> /dev/null - -distclean: - @-rm -r debug-* release-* 2> /dev/null - -install: - @if [ -e $(BIN) ]; then \ - cp -v $(BIN) /usr/lib ; \ - fi - @cp -v wiiuse.h /usr/include - -$(BIN): mkdir $(OBJS) - $(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) -o $(BIN) - -$(OBJ_DIR)/%.o: %.c - $(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@ - -mkdir: - @if [ ! -d $(OBJ_DIR) ]; then \ - mkdir $(OBJ_DIR); \ - fi - diff --git a/SConstruct b/SConstruct index 6df991161b..a6da1c4dfb 100644 --- a/SConstruct +++ b/SConstruct @@ -244,7 +244,7 @@ elif sys.platform == 'win32': else: env['CCFLAGS'] += ['-pthread'] - env['CCFLAGS'] += ['-Wno-deprecated'] # XXX + env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX env['CPPPATH'].insert(0, '#') env['LINKFLAGS'] += ['-pthread'] conf = env.Configure(custom_tests = tests, config_h="#config.h") diff --git a/Source/Core/AudioCommon/Src/Mixer.h b/Source/Core/AudioCommon/Src/Mixer.h index 9682054b57..c1bf17be1a 100644 --- a/Source/Core/AudioCommon/Src/Mixer.h +++ b/Source/Core/AudioCommon/Src/Mixer.h @@ -44,6 +44,8 @@ public: INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized (AISampleRate:%i, DACSampleRate:%i)", AISampleRate, DACSampleRate); } + virtual ~CMixer() {} + // Called from audio threads virtual unsigned int Mix(short* samples, unsigned int numSamples); virtual void Premix(short *samples, unsigned int numSamples) {} diff --git a/Source/Core/Common/Src/FileUtil.cpp b/Source/Core/Common/Src/FileUtil.cpp index 1080ae3f08..7722d4aab4 100644 --- a/Source/Core/Common/Src/FileUtil.cpp +++ b/Source/Core/Common/Src/FileUtil.cpp @@ -28,6 +28,7 @@ #include #include // getcwd #else +#include #include #include #include @@ -38,7 +39,6 @@ #include #include #include -#include #endif #include @@ -48,7 +48,7 @@ #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #endif -#if defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__ +#ifdef BSD4_4 #define stat64 stat // XXX #endif diff --git a/Source/Core/Core/Src/HLE/HLE_OS.cpp b/Source/Core/Core/Src/HLE/HLE_OS.cpp index 9b08e7a9eb..eebff67ece 100644 --- a/Source/Core/Core/Src/HLE/HLE_OS.cpp +++ b/Source/Core/Core/Src/HLE/HLE_OS.cpp @@ -90,7 +90,7 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg) *pArgument++ = *pString++; *pArgument++ = *pString; - *pArgument = NULL; + *pArgument = 0; u64 Parameter; if (ParameterCounter > 10) diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp index 8a541bc201..27010a0186 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE.cpp @@ -110,7 +110,7 @@ void Reset(bool _bHard) if (itr->second) { // Force close - itr->second->Close(NULL, true); + itr->second->Close(0, true); // Hardware should not be deleted unless it is a hard reset if (_bHard || !itr->second->IsHardware()) delete itr->second; diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp index 758684dd5a..b1d18789a3 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_FileIO.cpp @@ -288,7 +288,7 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap &p) { if (m_Mode) { - Open(NULL, m_Mode); + Open(0, m_Mode); if (m_pFileHandle) fseek(m_pFileHandle, m_Seek, SEEK_SET); } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp index 5d10198288..dcc7980f83 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_Device_usb.cpp @@ -37,9 +37,9 @@ CWII_IPC_HLE_Device_usb_oh1_57e_305::CWII_IPC_HLE_Device_usb_oh1_57e_305(u32 _De , m_HostMaxSCOSize(0) , m_HostNumACLPackets(0) , m_HostNumSCOPackets(0) - , m_HCIBuffer(NULL) + , m_HCIBuffer(0) , m_HCIPool(0) - , m_ACLBuffer(NULL) + , m_ACLBuffer(0) , m_ACLPool(0) , m_LastCmd(0) , m_FreqDividerMote(0) @@ -361,7 +361,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLPacket(u16 _ConnectionHandle, u // Invalidate ACL buffer m_ACLBuffer.m_address = 0; - m_ACLBuffer.m_buffer = NULL; + m_ACLBuffer.m_buffer = 0; } else if ((sizeof(UACLHeader) + _Size) > ACL_MAX_SIZE ) { @@ -411,7 +411,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::PurgeACLPool() WII_IPC_HLE_Interface::EnqReply(m_ACLBuffer.m_address); // Invalidate ACL buffer m_ACLBuffer.m_address = 0; - m_ACLBuffer.m_buffer = NULL; + m_ACLBuffer.m_buffer = 0; } } @@ -548,7 +548,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::AddEventToQueue(const SQueuedEvent& _e // Invalidate HCI buffer m_HCIBuffer.m_address = 0; - m_HCIBuffer.m_buffer = NULL; + m_HCIBuffer.m_buffer = 0; } else if (_event.m_size > HCI_MAX_SIZE) { @@ -593,7 +593,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::PurgeHCIPool() WII_IPC_HLE_Interface::EnqReply(m_HCIBuffer.m_address); // Invalidate ACL buffer m_HCIBuffer.m_address = 0; - m_HCIBuffer.m_buffer = NULL; + m_HCIBuffer.m_buffer = 0; } } diff --git a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h index fef983a961..4f561fa19e 100644 --- a/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h +++ b/Source/Core/Core/Src/IPC_HLE/WII_IPC_HLE_WiiMote.h @@ -234,7 +234,7 @@ private: void SignalChannel(u8* _pData, u32 _Size); void SendConnectionRequest(u16 _SCID, u16 _PSM); - void SendConfigurationRequest(u16 _SCID, u16 _pMTU = NULL, u16 _pFlushTimeOut = NULL); + void SendConfigurationRequest(u16 _SCID, u16 _pMTU = 0, u16 _pFlushTimeOut = 0); void SendDisconnectRequest(u16 _SCID); void ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size); diff --git a/Source/Core/Core/Src/MemTools.cpp b/Source/Core/Core/Src/MemTools.cpp index 301a4ee445..8e09680902 100644 --- a/Source/Core/Core/Src/MemTools.cpp +++ b/Source/Core/Core/Src/MemTools.cpp @@ -16,30 +16,35 @@ // http://code.google.com/p/dolphin-emu/ -#ifndef _WIN32 +#ifdef _WIN32 +#include +#else #include #include #include // Look in here for the context definition. -#ifdef __linux__ -#define CREG_RAX(ctx) (ctx)->gregs[REG_RAX] -#define CREG_RIP(ctx) (ctx)->gregs[REG_RIP] -#define CREG_EAX(ctx) (ctx)->gregs[REG_EAX] -#define CREG_EIP(ctx) (ctx)->gregs[REG_EIP] -#elif defined __APPLE__ +#endif + +#ifdef __APPLE__ #define CREG_RAX(ctx) (*(ctx))->__ss.__rax #define CREG_RIP(ctx) (*(ctx))->__ss.__rip #define CREG_EAX(ctx) (*(ctx))->__ss.__eax #define CREG_EIP(ctx) (*(ctx))->__ss.__eip -#else +#elif defined __FreeBSD__ #define CREG_RAX(ctx) (ctx)->mc_rax #define CREG_RIP(ctx) (ctx)->mc_rip #define CREG_EAX(ctx) (ctx)->mc_eax #define CREG_EIP(ctx) (ctx)->mc_eip -#endif - -#else -#include - +#elif defined __linux__ +#define CREG_RAX(ctx) (ctx)->gregs[REG_RAX] +#define CREG_RIP(ctx) (ctx)->gregs[REG_RIP] +#define CREG_EAX(ctx) (ctx)->gregs[REG_EAX] +#define CREG_EIP(ctx) (ctx)->gregs[REG_EIP] +#elif defined __NetBSD__ +#include +#define CREG_RAX(ctx) (ctx)->__gregs[_REG_RAX] +#define CREG_RIP(ctx) (ctx)->__gregs[_REG_RIP] +#define CREG_EAX(ctx) (ctx)->__gregs[_REG_EAX] +#define CREG_EIP(ctx) (ctx)->__gregs[_REG_EIP] #endif #include @@ -184,8 +189,8 @@ void sigsegv_handler(int signal, siginfo_t *info, void *raw_context) return; } ucontext_t *context = (ucontext_t *)raw_context; - int si_code = info->si_code; - if (si_code != SEGV_MAPERR && si_code != SEGV_ACCERR) + int sicode = info->si_code; + if (sicode != SEGV_MAPERR && sicode != SEGV_ACCERR) { // Huh? Return. return; diff --git a/Source/Core/DebuggerWX/Src/MemoryWindow.cpp b/Source/Core/DebuggerWX/Src/MemoryWindow.cpp index c6375ade4e..7d6b65fb30 100644 --- a/Source/Core/DebuggerWX/Src/MemoryWindow.cpp +++ b/Source/Core/DebuggerWX/Src/MemoryWindow.cpp @@ -324,7 +324,7 @@ void CMemoryWindow::onSearch(wxCommandEvent& event) { std::vector Dest;//May need a better name u32 size=0; int pad=rawData.size()%2;//If it's uneven - unsigned long i=0; + unsigned int i=0; long count=0; char copy[3]={0}; long newsize=0; diff --git a/Source/Core/DiscIO/Src/BannerLoader.cpp b/Source/Core/DiscIO/Src/BannerLoader.cpp index 168dbd31fb..64d3913317 100644 --- a/Source/Core/DiscIO/Src/BannerLoader.cpp +++ b/Source/Core/DiscIO/Src/BannerLoader.cpp @@ -27,16 +27,18 @@ #ifdef WIN32 #include #else +#include #include #include #endif -#ifdef __FreeBSD__ -#define ICONV_CONST const -#endif #ifndef ICONV_CONST +#if defined __FreeBSD__ || __NetBSD__ +#define ICONV_CONST const +#else #define ICONV_CONST #endif +#endif namespace DiscIO { diff --git a/Source/Core/DolphinWX/Src/MainNoGUI.cpp b/Source/Core/DolphinWX/Src/MainNoGUI.cpp index 8636c8a8be..0668020b68 100644 --- a/Source/Core/DolphinWX/Src/MainNoGUI.cpp +++ b/Source/Core/DolphinWX/Src/MainNoGUI.cpp @@ -146,7 +146,7 @@ void X11_MainLoop() X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win); #endif - Cursor blankCursor = NULL; + Cursor blankCursor = None; if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) { // make a blank cursor diff --git a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp index 6cc3029ff2..1c5a615f8e 100644 --- a/Source/Core/VideoCommon/Src/PixelShaderGen.cpp +++ b/Source/Core/VideoCommon/Src/PixelShaderGen.cpp @@ -33,8 +33,9 @@ PIXELSHADERUID last_pixel_shader_uid; // are set... void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) { + u32 numstages = bpmem.genMode.numtevstages + 1; u32 projtexcoords = 0; - for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; i++) + for (u32 i = 0; i < numstages; i++) { if (bpmem.tevorders[i/2].getEnable(i & 1)) { @@ -66,7 +67,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) int hdr = 4; u32 *pcurvalue = &uid->values[hdr]; - for (u32 i = 0; i < (u32)bpmem.genMode.numtevstages + 1; ++i) + for (u32 i = 0; i < numstages; ++i) { TevStageCombiner::ColorCombiner &cc = bpmem.combiners[i].colorC; TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC; @@ -80,7 +81,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) pcurvalue += 2; } - for (u32 i = 0; i < ((u32)bpmem.genMode.numtevstages+1) / 2; ++i) + for (u32 i = 0; i < numstages / 2; ++i) { u32 val0, val1; if (bpmem.tevorders[i].hex & 0x40) @@ -100,7 +101,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) } } - if ((bpmem.genMode.numtevstages + 1) & 1) { // odd + if (numstages & 1) { // odd u32 val0; if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x40) val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x3ff;