Further *BSD portability.

git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5958 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
Soren Jorvang 2010-07-23 23:51:34 +00:00
parent 2d06b4114b
commit 949b873dc8
16 changed files with 50 additions and 126 deletions

View File

@ -5,9 +5,7 @@
#define SDL_JOYSTICK_USBHID 1 #define SDL_JOYSTICK_USBHID 1
#ifdef __FreeBSD__ #define HAVE_USBHID_H 1
#define HAVE_USBHID_H
#endif
#define USBHID_NEW #define USBHID_NEW
#define USBHID_UCR_DATA #define USBHID_UCR_DATA

View File

@ -49,7 +49,8 @@
// MacOS // MacOS
#define SFML_SYSTEM_MACOS #define SFML_SYSTEM_MACOS
#elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) #elif defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || \
defined(__NetBSD__) || defined(__OpenBSD__)
// FreeBSD // FreeBSD
#define SFML_SYSTEM_FREEBSD #define SFML_SYSTEM_FREEBSD

View File

@ -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

View File

@ -244,7 +244,7 @@ elif sys.platform == 'win32':
else: else:
env['CCFLAGS'] += ['-pthread'] env['CCFLAGS'] += ['-pthread']
env['CCFLAGS'] += ['-Wno-deprecated'] # XXX <hash_map> env['CXXFLAGS'] += ['-Wno-deprecated'] # XXX <hash_map>
env['CPPPATH'].insert(0, '#') env['CPPPATH'].insert(0, '#')
env['LINKFLAGS'] += ['-pthread'] env['LINKFLAGS'] += ['-pthread']
conf = env.Configure(custom_tests = tests, config_h="#config.h") conf = env.Configure(custom_tests = tests, config_h="#config.h")

View File

@ -44,6 +44,8 @@ public:
INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized (AISampleRate:%i, DACSampleRate:%i)", AISampleRate, DACSampleRate); INFO_LOG(AUDIO_INTERFACE, "Mixer is initialized (AISampleRate:%i, DACSampleRate:%i)", AISampleRate, DACSampleRate);
} }
virtual ~CMixer() {}
// Called from audio threads // Called from audio threads
virtual unsigned int Mix(short* samples, unsigned int numSamples); virtual unsigned int Mix(short* samples, unsigned int numSamples);
virtual void Premix(short *samples, unsigned int numSamples) {} virtual void Premix(short *samples, unsigned int numSamples) {}

View File

@ -28,6 +28,7 @@
#include <io.h> #include <io.h>
#include <direct.h> // getcwd #include <direct.h> // getcwd
#else #else
#include <sys/param.h>
#include <sys/types.h> #include <sys/types.h>
#include <dirent.h> #include <dirent.h>
#include <errno.h> #include <errno.h>
@ -38,7 +39,6 @@
#include <CoreFoundation/CFString.h> #include <CoreFoundation/CFString.h>
#include <CoreFoundation/CFURL.h> #include <CoreFoundation/CFURL.h>
#include <CoreFoundation/CFBundle.h> #include <CoreFoundation/CFBundle.h>
#include <sys/param.h>
#endif #endif
#include <fstream> #include <fstream>
@ -48,7 +48,7 @@
#define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR) #define S_ISDIR(m) (((m)&S_IFMT) == S_IFDIR)
#endif #endif
#if defined __NetBSD__ || defined __FreeBSD__ || defined __OpenBSD__ #ifdef BSD4_4
#define stat64 stat // XXX #define stat64 stat // XXX
#endif #endif

View File

@ -90,7 +90,7 @@ void GetStringVA(std::string& _rOutBuffer, u32 strReg)
*pArgument++ = *pString++; *pArgument++ = *pString++;
*pArgument++ = *pString; *pArgument++ = *pString;
*pArgument = NULL; *pArgument = 0;
u64 Parameter; u64 Parameter;
if (ParameterCounter > 10) if (ParameterCounter > 10)

View File

@ -110,7 +110,7 @@ void Reset(bool _bHard)
if (itr->second) if (itr->second)
{ {
// Force close // Force close
itr->second->Close(NULL, true); itr->second->Close(0, true);
// Hardware should not be deleted unless it is a hard reset // Hardware should not be deleted unless it is a hard reset
if (_bHard || !itr->second->IsHardware()) if (_bHard || !itr->second->IsHardware())
delete itr->second; delete itr->second;

View File

@ -288,7 +288,7 @@ void CWII_IPC_HLE_Device_FileIO::DoState(PointerWrap &p)
{ {
if (m_Mode) if (m_Mode)
{ {
Open(NULL, m_Mode); Open(0, m_Mode);
if (m_pFileHandle) if (m_pFileHandle)
fseek(m_pFileHandle, m_Seek, SEEK_SET); fseek(m_pFileHandle, m_Seek, SEEK_SET);
} }

View File

@ -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_HostMaxSCOSize(0)
, m_HostNumACLPackets(0) , m_HostNumACLPackets(0)
, m_HostNumSCOPackets(0) , m_HostNumSCOPackets(0)
, m_HCIBuffer(NULL) , m_HCIBuffer(0)
, m_HCIPool(0) , m_HCIPool(0)
, m_ACLBuffer(NULL) , m_ACLBuffer(0)
, m_ACLPool(0) , m_ACLPool(0)
, m_LastCmd(0) , m_LastCmd(0)
, m_FreqDividerMote(0) , m_FreqDividerMote(0)
@ -361,7 +361,7 @@ void CWII_IPC_HLE_Device_usb_oh1_57e_305::SendACLPacket(u16 _ConnectionHandle, u
// Invalidate ACL buffer // Invalidate ACL buffer
m_ACLBuffer.m_address = 0; m_ACLBuffer.m_address = 0;
m_ACLBuffer.m_buffer = NULL; m_ACLBuffer.m_buffer = 0;
} }
else if ((sizeof(UACLHeader) + _Size) > ACL_MAX_SIZE ) 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); WII_IPC_HLE_Interface::EnqReply(m_ACLBuffer.m_address);
// Invalidate ACL buffer // Invalidate ACL buffer
m_ACLBuffer.m_address = 0; 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 // Invalidate HCI buffer
m_HCIBuffer.m_address = 0; m_HCIBuffer.m_address = 0;
m_HCIBuffer.m_buffer = NULL; m_HCIBuffer.m_buffer = 0;
} }
else if (_event.m_size > HCI_MAX_SIZE) 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); WII_IPC_HLE_Interface::EnqReply(m_HCIBuffer.m_address);
// Invalidate ACL buffer // Invalidate ACL buffer
m_HCIBuffer.m_address = 0; m_HCIBuffer.m_address = 0;
m_HCIBuffer.m_buffer = NULL; m_HCIBuffer.m_buffer = 0;
} }
} }

View File

@ -234,7 +234,7 @@ private:
void SignalChannel(u8* _pData, u32 _Size); void SignalChannel(u8* _pData, u32 _Size);
void SendConnectionRequest(u16 _SCID, u16 _PSM); 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 SendDisconnectRequest(u16 _SCID);
void ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size); void ReceiveConnectionReq(u8 _Ident, u8* _pData, u32 _Size);

View File

@ -16,30 +16,35 @@
// http://code.google.com/p/dolphin-emu/ // http://code.google.com/p/dolphin-emu/
#ifndef _WIN32 #ifdef _WIN32
#include <windows.h>
#else
#include <stdio.h> #include <stdio.h>
#include <signal.h> #include <signal.h>
#include <sys/ucontext.h> // Look in here for the context definition. #include <sys/ucontext.h> // Look in here for the context definition.
#ifdef __linux__ #endif
#define CREG_RAX(ctx) (ctx)->gregs[REG_RAX]
#define CREG_RIP(ctx) (ctx)->gregs[REG_RIP] #ifdef __APPLE__
#define CREG_EAX(ctx) (ctx)->gregs[REG_EAX]
#define CREG_EIP(ctx) (ctx)->gregs[REG_EIP]
#elif defined __APPLE__
#define CREG_RAX(ctx) (*(ctx))->__ss.__rax #define CREG_RAX(ctx) (*(ctx))->__ss.__rax
#define CREG_RIP(ctx) (*(ctx))->__ss.__rip #define CREG_RIP(ctx) (*(ctx))->__ss.__rip
#define CREG_EAX(ctx) (*(ctx))->__ss.__eax #define CREG_EAX(ctx) (*(ctx))->__ss.__eax
#define CREG_EIP(ctx) (*(ctx))->__ss.__eip #define CREG_EIP(ctx) (*(ctx))->__ss.__eip
#else #elif defined __FreeBSD__
#define CREG_RAX(ctx) (ctx)->mc_rax #define CREG_RAX(ctx) (ctx)->mc_rax
#define CREG_RIP(ctx) (ctx)->mc_rip #define CREG_RIP(ctx) (ctx)->mc_rip
#define CREG_EAX(ctx) (ctx)->mc_eax #define CREG_EAX(ctx) (ctx)->mc_eax
#define CREG_EIP(ctx) (ctx)->mc_eip #define CREG_EIP(ctx) (ctx)->mc_eip
#endif #elif defined __linux__
#define CREG_RAX(ctx) (ctx)->gregs[REG_RAX]
#else #define CREG_RIP(ctx) (ctx)->gregs[REG_RIP]
#include <windows.h> #define CREG_EAX(ctx) (ctx)->gregs[REG_EAX]
#define CREG_EIP(ctx) (ctx)->gregs[REG_EIP]
#elif defined __NetBSD__
#include <sys/siginfo.h>
#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 #endif
#include <vector> #include <vector>
@ -184,8 +189,8 @@ void sigsegv_handler(int signal, siginfo_t *info, void *raw_context)
return; return;
} }
ucontext_t *context = (ucontext_t *)raw_context; ucontext_t *context = (ucontext_t *)raw_context;
int si_code = info->si_code; int sicode = info->si_code;
if (si_code != SEGV_MAPERR && si_code != SEGV_ACCERR) if (sicode != SEGV_MAPERR && sicode != SEGV_ACCERR)
{ {
// Huh? Return. // Huh? Return.
return; return;

View File

@ -324,7 +324,7 @@ void CMemoryWindow::onSearch(wxCommandEvent& event) {
std::vector<u8> Dest;//May need a better name std::vector<u8> Dest;//May need a better name
u32 size=0; u32 size=0;
int pad=rawData.size()%2;//If it's uneven int pad=rawData.size()%2;//If it's uneven
unsigned long i=0; unsigned int i=0;
long count=0; long count=0;
char copy[3]={0}; char copy[3]={0};
long newsize=0; long newsize=0;

View File

@ -27,16 +27,18 @@
#ifdef WIN32 #ifdef WIN32
#include <Windows.h> #include <Windows.h>
#else #else
#include <sys/param.h>
#include <iconv.h> #include <iconv.h>
#include <errno.h> #include <errno.h>
#endif #endif
#ifdef __FreeBSD__
#define ICONV_CONST const
#endif
#ifndef ICONV_CONST #ifndef ICONV_CONST
#if defined __FreeBSD__ || __NetBSD__
#define ICONV_CONST const
#else
#define ICONV_CONST #define ICONV_CONST
#endif #endif
#endif
namespace DiscIO namespace DiscIO
{ {

View File

@ -146,7 +146,7 @@ void X11_MainLoop()
X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win); X11Utils::XRRConfiguration *XRRConfig = new X11Utils::XRRConfiguration(dpy, win);
#endif #endif
Cursor blankCursor = NULL; Cursor blankCursor = None;
if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor) if (SConfig::GetInstance().m_LocalCoreStartupParameter.bHideCursor)
{ {
// make a blank cursor // make a blank cursor

View File

@ -33,8 +33,9 @@ PIXELSHADERUID last_pixel_shader_uid;
// are set... // are set...
void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable) void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
{ {
u32 numstages = bpmem.genMode.numtevstages + 1;
u32 projtexcoords = 0; 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)) if (bpmem.tevorders[i/2].getEnable(i & 1))
{ {
@ -66,7 +67,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
int hdr = 4; int hdr = 4;
u32 *pcurvalue = &uid->values[hdr]; 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::ColorCombiner &cc = bpmem.combiners[i].colorC;
TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC; TevStageCombiner::AlphaCombiner &ac = bpmem.combiners[i].alphaC;
@ -80,7 +81,7 @@ void GetPixelShaderId(PIXELSHADERUID *uid, u32 texturemask, u32 dstAlphaEnable)
pcurvalue += 2; 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; u32 val0, val1;
if (bpmem.tevorders[i].hex & 0x40) 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; u32 val0;
if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x40) if (bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x40)
val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x3ff; val0 = bpmem.tevorders[bpmem.genMode.numtevstages/2].hex & 0x3ff;