Fix up Linux compiling after the last few commits. Add in my latest attempt at SysPageFaultExceptionFilter.

git-svn-id: http://pcsx2-playground.googlecode.com/svn/trunk@546 a6443dda-0b58-4228-96e9-037be469359c
This commit is contained in:
arcum42 2009-01-03 03:20:02 +00:00 committed by Gregory Hainaut
parent 86ade26968
commit bbfb6ac41a
6 changed files with 46 additions and 18 deletions

View File

@ -146,9 +146,14 @@ typedef union _LARGE_INTEGER
#define PCSX2_ALIGNED16_DECL(x) x
// Define some handy equivalents of MSVC++ specific functions.
// (I'm assuming this sort of template use works in GCC -
// (I'm assuming this sort of template use works in GCC -Air
// Yes, if you add the right includes. --arcum42
#ifdef __cplusplus
#ifndef _MSC_VER
#include <stdio.h>
#include <stdarg.h>
#include <cstring>
template <size_t Size>
__forceinline int vsprintf_s(char (&dest)[Size], const char* fmt, va_list args )
@ -163,7 +168,7 @@ __forceinline int sprintf_s(char (&dest)[Size], const char* fmt, ... )
{
va_list list;
va_start( list, dest );
int retval = vsprintf_s( dest, fmt, args );
int retval = vsprintf_s( dest, fmt, list );
va_end( list );

View File

@ -128,17 +128,17 @@ static __forceinline void print_flags(char *name, u32 num, char *flag_names[16])
{
int i;
DevCon::MsgLn("%s:", name);
DevCon::WriteLn("%s:", name);
if (flag_names != NULL)
{
for(i=0; i<=15; i++)
DevCon::MsgLn("%s %x: %x", flag_names[i], (1<<i), get_flag(num, i));
DevCon::WriteLn("%s %x: %x", flag_names[i], (1<<i), get_flag(num, i));
}
else
{
for(i=0; i<=15; i++)
DevCon::MsgLn("%x: %x", (1<<i), get_flag(num, i));
DevCon::WriteLn("%x: %x", (1<<i), get_flag(num, i));
}
}

View File

@ -92,6 +92,17 @@ namespace Console
return false;
}
// Writes an unformatted string of text to the console (fast!)
// A newline is automatically appended.
__forceinline bool __fastcall MsgLn( Colors color, const char* fmt )
{
SetColor( color );
Write( fmt );
ClearColor();
Newline();
return false;
}
static __forceinline void __fastcall _WriteLn( Colors color, const char* fmt, va_list args )
{
char msg[2048];

View File

@ -419,13 +419,13 @@ __forceinline u32 mtgsThreadObject::_gifTransferDummy( GIF_PATH pathidx, const u
DevCon::Msg( "path1 hack! " );
}
}
#ifdef PCSX2_GSRING_SAMPLING_STATS
__asm
{
__endfunc:
nop;
__endfunc:
nop;
}
#endif
return size;
}

View File

@ -2595,12 +2595,7 @@ static u8* m_psAllMem = NULL;
int memInit()
{
#ifdef __LINUX__
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = &SysPageFaultExceptionFilter;
sigaction(SIGSEGV, &sa, NULL);
InstallLinuxExceptionHandler();
#endif
if (!vtlb_Init()) return -1;
@ -2928,14 +2923,29 @@ int SysPageFaultExceptionFilter(EXCEPTION_POINTERS* eps)
}
#else
#include "errno.h"
__forceinline void __fastcall InstallLinuxExceptionHandler()
{
struct sigaction sa;
sigemptyset(&sa.sa_mask);
sa.sa_flags = SA_SIGINFO;
sa.sa_sigaction = &SysPageFaultExceptionFilter;
sigaction(SIGSEGV, &sa, NULL);
}
// Linux implementation of SIGSEGV handler. Bind it using sigaction().
// This is my shot in the dark. Probably needs some work. Good luck! (air)
__forceinline void __fastcall SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * )
{
//Console::Error("SysPageFaultExceptionFilter!");
int err;
u32 pagesize = getpagesize();
//DevCon::Error("SysPageFaultExceptionFilter!");
// get bad virtual address
u32 offset = (u8*)info->si_addr - psM;
uptr pageoffset = ( offset / pagesize ) * pagesize;
if (offset>=Ps2MemSize::Base)
{
@ -2944,8 +2954,9 @@ __forceinline void __fastcall SysPageFaultExceptionFilter( int signal, siginfo_t
assert( false );
}
mprotect(&psM[offset], 1, PROT_READ|PROT_WRITE);
err = mprotect( &psM[pageoffset], pagesize, PROT_READ | PROT_WRITE );
if (err) DevCon::Error("SysPageFaultExceptionFilter: %s", strerror(errno));
offset>>=12;
psMPWC[(offset/32)]|=(1<<(offset&31));

View File

@ -236,6 +236,7 @@ void memClearPageAddr(u32 vaddr);
void memShutdown();
#ifdef __LINUX__
void SysPageFaultExceptionFilter( int signal, siginfo_t *info, void * );
void __fastcall InstallLinuxExceptionHandler();
#endif
#ifdef _WIN32