newHostVM: Fix linux/gcc compilation errors. PCSX2 doesn't work yet tho -- crashes on startup and I don't have a proper debug environment setup to trace and troubleshoot it.

git-svn-id: http://pcsx2.googlecode.com/svn/branches/newHostVM@3977 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
Jake.Stine 2010-10-27 23:58:10 +00:00
parent 4dec10976d
commit 283224290d
5 changed files with 22 additions and 19 deletions

View File

@ -146,7 +146,7 @@ set(UtilitiesHeaders
../../include/Utilities/HashMap.h
../../include/Utilities/lnx_memzero.h
../../include/Utilities/MemcpyFast.h
../../include/Utilities/MemsetFast.h
../../include/Utilities/MemsetFast.inl
../../include/Utilities/Path.h
../../include/Utilities/PageFaultSource.h
../../include/Utilities/pxCheckBox.h

View File

@ -18,10 +18,11 @@
#include <sys/mman.h>
#include <signal.h>
#include <errno.h>
static __ri void PageSizeAssertionTest( size_t size )
{
pxAssert( (__pagesize == getpagesize()), pxsFmt(
pxAssertMsg( (__pagesize == getpagesize()), pxsFmt(
"Internal system error: Operating system pagesize does not match compiled pagesize.\n\t"
L"\tOS Page Size: 0x%x (%d), Compiled Page Size: 0x%x (%u)",
getpagesize(), getpagesize(), __pagesize, __pagesize )
@ -64,26 +65,26 @@ void HostSys::MmapReset(void* base, size_t size)
// pretty well stops all PCSX2 threads anyway).
Munmap(base, size);
void* result = Mmap(base, size);
void* result = Mmap((uptr)base, size);
pxAssertRel (result != base, pxsFmt(
pxAssertRel ((uptr)result != (uptr)base, pxsFmt(
"Virtual memory decommit failed: memory at 0x%08X -> 0x%08X could not be remapped. "
"This is likely caused by multi-thread memory contention.", base, base+size
));
}
void* HostSys::Mmap(void* base, size_t size)
void* HostSys::Mmap(uptr base, size_t size)
{
PageSizeAssertionTest(size);
// MAP_ANONYMOUS - means we have no associated file handle (or device).
return mmap(base, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
return mmap((void*)base, size, PROT_EXEC | PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
}
void HostSys::Munmap(void* base, size_t size)
void HostSys::Munmap(uptr base, size_t size)
{
munmap(base, size);
munmap((void*)base, size);
}
void HostSys::MemProtect( void* baseaddr, size_t size, const PageProtectionMode& mode )
@ -103,20 +104,20 @@ void HostSys::MemProtect( void* baseaddr, size_t size, const PageProtectionMode&
switch(errno)
{
case EINVAL:
pxFailDev(pxsFmt(L"mprotect returned EINVAL @ 0x%08X -> 0x%08X (mode=%s)"),
baseaddr, (uptr)baseaddr+size, mode.ToString().c_str()
pxFailDev(pxsFmt(L"mprotect returned EINVAL @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr+size, mode.ToString().c_str())
);
break;
case ENOMEM:
throw Exception::OutOfMemory( psxFmt( L"mprotect failed @ 0x%08X -> 0x%08X (mode=%s)"),
baseaddr, (uptr)baseaddr+size, mode.ToString().c_str()
throw Exception::OutOfMemory( pxsFmt( L"mprotect failed @ 0x%08X -> 0x%08X (mode=%s)",
baseaddr, (uptr)baseaddr+size, mode.ToString().c_str())
);
break;
case EACCES:
break;
}
throw Exception::OutOfMemory()
throw Exception::OutOfMemory();
}
}

View File

@ -18,7 +18,8 @@
#include <sys/mman.h>
#include <signal.h>
#include "Common.h"
#include "System/PageFaultSource.h"
#include "Utilities/PageFaultSource.h"
extern void SignalExit(int sig);
@ -30,11 +31,11 @@ static void SysPageFaultSignalFilter( int signal, siginfo_t *siginfo, void * )
// Note: Use of most stdio functions isn't safe here. Avoid console logs,
// assertions, file logs, or just about anything else useful.
Source_PageFault.Dispatch( PageFaultInfo( (uptr)siginfo->si_addr & ~m_pagemask ) );
Source_PageFault->Dispatch( PageFaultInfo( (uptr)siginfo->si_addr & ~m_pagemask ) );
// resumes execution right where we left off (re-executes instruction that
// caused the SIGSEGV).
if( Source_PageFault.WasHandled() ) return;
if( Source_PageFault->WasHandled() ) return;
// Bad mojo! Completely invalid address.
// Instigate a trap if we're in a debugger, and if not then do a SIGKILL.
@ -45,6 +46,7 @@ static void SysPageFaultSignalFilter( int signal, siginfo_t *siginfo, void * )
void InstallSignalHandler()
{
Console.WriteLn("Installing POSIX SIGSEGV handler...");
struct sigaction sa;
sigemptyset(&sa.sa_mask);

View File

@ -510,14 +510,14 @@ u8* SysMmapEx(uptr base, u32 size, uptr bounds, const char *caller)
if( (Mem == NULL) || (bounds != 0 && (((uptr)Mem + size) > bounds)) )
{
if( base != NULL )
if( base )
{
DbgCon.Warning( "First try failed allocating %s at address 0x%x", caller, base );
// Let's try again at an OS-picked memory area, and then hope it meets needed
// boundschecking criteria below.
SafeSysMunmap( Mem, size );
Mem = (u8*)HostSys::Mmap( NULL, size );
Mem = (u8*)HostSys::Mmap( 0, size );
}
if( (bounds != 0) && (((uptr)Mem + size) > bounds) )

View File

@ -18,7 +18,7 @@
#include "PrecompiledHeader.h"
#include "Common.h"
#include "microVU.h"
#include "RecTypes.h"
#include "System/RecTypes.h"
// Include all the *.inl files (Needed because C++ sucks with templates and *.cpp files)
#include "microVU_Clamp.inl"