mirror of
https://github.com/holub/mame
synced 2025-04-29 11:30:28 +03:00
setjmp / longjmp doesn't play nice in 64-bit debug compiles in a modern core, so use c++ exceptions to mimic the behavior. probably could be improved.
This commit is contained in:
parent
967fcc8ee7
commit
f4c871d85f
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
#include "../../../lib/softfloat/milieu.h"
|
#include "../../../lib/softfloat/milieu.h"
|
||||||
#include "../../../lib/softfloat/softfloat.h"
|
#include "../../../lib/softfloat/softfloat.h"
|
||||||
#include <setjmp.h>
|
|
||||||
|
|
||||||
|
|
||||||
/* MMU constants */
|
/* MMU constants */
|
||||||
@ -28,52 +27,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Address error */
|
|
||||||
/* sigjmp() on Mac OS X and *BSD in general saves signal contexts and is super-slow, use sigsetjmp() to tell it not to */
|
|
||||||
#ifdef _BSD_SETJMP_H
|
|
||||||
#define m68ki_set_address_error_trap(m68k) \
|
|
||||||
if(sigsetjmp(m68k->aerr_trap, 0) != 0) \
|
|
||||||
{ \
|
|
||||||
m68ki_exception_address_error(m68k); \
|
|
||||||
if(m68k->stopped) \
|
|
||||||
{ \
|
|
||||||
if (m68k->remaining_cycles > 0) \
|
|
||||||
m68k->remaining_cycles = 0; \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
|
#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
|
||||||
if((ADDR)&1) \
|
if((ADDR)&1) \
|
||||||
{ \
|
{ \
|
||||||
m68k->aerr_address = ADDR; \
|
m68k->aerr_address = ADDR; \
|
||||||
m68k->aerr_write_mode = WRITE_MODE; \
|
m68k->aerr_write_mode = WRITE_MODE; \
|
||||||
m68k->aerr_fc = FC; \
|
m68k->aerr_fc = FC; \
|
||||||
siglongjmp(m68k->aerr_trap, 1); \
|
throw 10; \
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
#define m68ki_set_address_error_trap(m68k) \
|
|
||||||
SETJMP_GNUC_PROTECT(); \
|
|
||||||
if(setjmp(m68k->aerr_trap) != 0) \
|
|
||||||
{ \
|
|
||||||
m68ki_exception_address_error(m68k); \
|
|
||||||
if(m68k->stopped) \
|
|
||||||
{ \
|
|
||||||
if (m68k->remaining_cycles > 0) \
|
|
||||||
m68k->remaining_cycles = 0; \
|
|
||||||
return; \
|
|
||||||
} \
|
|
||||||
}
|
|
||||||
|
|
||||||
#define m68ki_check_address_error(m68k, ADDR, WRITE_MODE, FC) \
|
|
||||||
if((ADDR)&1) \
|
|
||||||
{ \
|
|
||||||
m68k->aerr_address = ADDR; \
|
|
||||||
m68k->aerr_write_mode = WRITE_MODE; \
|
|
||||||
m68k->aerr_fc = FC; \
|
|
||||||
longjmp(m68k->aerr_trap, 1); \
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -286,11 +247,8 @@ public:
|
|||||||
int reset_cycles;
|
int reset_cycles;
|
||||||
UINT32 tracing;
|
UINT32 tracing;
|
||||||
|
|
||||||
#ifdef _BSD_SETJMP_H
|
int m_address_error;
|
||||||
sigjmp_buf aerr_trap;
|
|
||||||
#else
|
|
||||||
jmp_buf aerr_trap;
|
|
||||||
#endif
|
|
||||||
UINT32 aerr_address;
|
UINT32 aerr_address;
|
||||||
UINT32 aerr_write_mode;
|
UINT32 aerr_write_mode;
|
||||||
UINT32 aerr_fc;
|
UINT32 aerr_fc;
|
||||||
@ -314,7 +272,6 @@ public:
|
|||||||
address_space *program;
|
address_space *program;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* Redirect memory calls */
|
/* Redirect memory calls */
|
||||||
|
|
||||||
typedef delegate<UINT8 (offs_t)> m68k_read8_delegate;
|
typedef delegate<UINT8 (offs_t)> m68k_read8_delegate;
|
||||||
|
@ -769,7 +769,19 @@ inline void m68000_base_device::cpu_execute(void)
|
|||||||
if(!stopped)
|
if(!stopped)
|
||||||
{
|
{
|
||||||
/* Return point if we had an address error */
|
/* Return point if we had an address error */
|
||||||
m68ki_set_address_error_trap(this); /* auto-disable (see m68kcpu.h) */
|
check_address_error:
|
||||||
|
if (m_address_error==1)
|
||||||
|
{
|
||||||
|
m_address_error = 0;
|
||||||
|
m68ki_exception_address_error(this);
|
||||||
|
if(stopped)
|
||||||
|
{
|
||||||
|
if (remaining_cycles > 0)
|
||||||
|
remaining_cycles = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Main loop. Keep going until we run out of clock cycles */
|
/* Main loop. Keep going until we run out of clock cycles */
|
||||||
while (remaining_cycles > 0)
|
while (remaining_cycles > 0)
|
||||||
@ -787,6 +799,8 @@ inline void m68000_base_device::cpu_execute(void)
|
|||||||
/* Record previous program counter */
|
/* Record previous program counter */
|
||||||
REG_PPC(this) = REG_PC(this);
|
REG_PPC(this) = REG_PC(this);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
if (!pmmu_enabled)
|
if (!pmmu_enabled)
|
||||||
{
|
{
|
||||||
run_mode = RUN_MODE_NORMAL;
|
run_mode = RUN_MODE_NORMAL;
|
||||||
@ -866,6 +880,18 @@ inline void m68000_base_device::cpu_execute(void)
|
|||||||
// remaining_cycles -= cyc_exception[EXCEPTION_BUS_ERROR] - cyc_instruction[ir];
|
// remaining_cycles -= cyc_exception[EXCEPTION_BUS_ERROR] - cyc_instruction[ir];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
catch (int error)
|
||||||
|
{
|
||||||
|
if (error==10)
|
||||||
|
{
|
||||||
|
m_address_error = 1;
|
||||||
|
goto check_address_error;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
throw;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* Trace m68k_exception, if necessary */
|
/* Trace m68k_exception, if necessary */
|
||||||
m68ki_exception_if_trace(this); /* auto-disable (see m68kcpu.h) */
|
m68ki_exception_if_trace(this); /* auto-disable (see m68kcpu.h) */
|
||||||
@ -2600,7 +2626,6 @@ m68000_base_device::m68000_base_device(const machine_config &mconfig, const char
|
|||||||
|
|
||||||
void m68000_base_device::clear_all()
|
void m68000_base_device::clear_all()
|
||||||
{
|
{
|
||||||
|
|
||||||
cpu_type= 0;
|
cpu_type= 0;
|
||||||
// dasm_type= 0;
|
// dasm_type= 0;
|
||||||
for (int i=0;i<16;i++)
|
for (int i=0;i<16;i++)
|
||||||
@ -2659,7 +2684,7 @@ void m68000_base_device::clear_all()
|
|||||||
reset_cycles = 0;
|
reset_cycles = 0;
|
||||||
tracing = 0;
|
tracing = 0;
|
||||||
|
|
||||||
// aerr_trap = 0;
|
m_address_error = 0;
|
||||||
|
|
||||||
aerr_address = 0;
|
aerr_address = 0;
|
||||||
aerr_write_mode = 0;
|
aerr_write_mode = 0;
|
||||||
|
@ -31,7 +31,7 @@ class m68000_base_device;
|
|||||||
|
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <setjmp.h>
|
|
||||||
|
|
||||||
/* ======================================================================== */
|
/* ======================================================================== */
|
||||||
/* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */
|
/* ==================== ARCHITECTURE-DEPENDANT DEFINES ==================== */
|
||||||
|
Loading…
Reference in New Issue
Block a user