This commit is contained in:
Nekotekina 2015-04-04 19:00:02 +03:00
parent 1c82e8b1d5
commit 26b5eebc17
4 changed files with 47 additions and 25 deletions

View file

@ -13,6 +13,8 @@ typedef void(atexit_func_t)(vm::psv::ptr<void>);
std::vector<std::function<void(ARMv7Context&)>> g_atexit;
std::mutex g_atexit_mutex;
std::string armv7_fmt(ARMv7Context& context, vm::psv::ptr<const char> fmt, u32 g_count, u32 f_count, u32 v_count)
{
std::string result;
@ -152,7 +154,7 @@ namespace sce_libc_func
{
sceLibc.Warning("__cxa_atexit(func=*0x%x, arg=*0x%x, dso=*0x%x)", func, arg, dso);
LV2_LOCK;
std::lock_guard<std::mutex> lock(g_atexit_mutex);
g_atexit.insert(g_atexit.begin(), [func, arg, dso](ARMv7Context& context)
{
@ -164,7 +166,7 @@ namespace sce_libc_func
{
sceLibc.Warning("__aeabi_atexit(arg=*0x%x, func=*0x%x, dso=*0x%x)", arg, func, dso);
LV2_LOCK;
std::lock_guard<std::mutex> lock(g_atexit_mutex);
g_atexit.insert(g_atexit.begin(), [func, arg, dso](ARMv7Context& context)
{
@ -176,19 +178,27 @@ namespace sce_libc_func
{
sceLibc.Warning("exit()");
for (auto func : g_atexit)
std::lock_guard<std::mutex> lock(g_atexit_mutex);
if (!Emu.IsStopped())
{
func(context);
for (auto func : decltype(g_atexit)(std::move(g_atexit)))
{
func(context);
}
sceLibc.Success("Process finished");
CallAfter([]()
{
Emu.Stop();
});
while (!Emu.IsStopped())
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
g_atexit.clear();
sceLibc.Success("Process finished");
CallAfter([]()
{
Emu.Stop();
});
}
void printf(ARMv7Context& context, vm::psv::ptr<const char> fmt) // va_args...

View file

@ -225,7 +225,7 @@ void ppu_interpreter::VCMPBFP(PPUThread& CPU, ppu_opcode_t op)
const auto b = CPU.VPR[op.vb].vf;
const auto sign = _mm_castsi128_ps(_mm_set1_epi32(0x80000000));
const auto bneg = _mm_xor_ps(b, sign);
CPU.VPR[op.vd].vf = _mm_or_ps(_mm_and_ps(_mm_cmple_ps(a, b), sign), _mm_and_ps(_mm_cmpge_ps(a, bneg), _mm_castsi128_ps(_mm_set1_epi32(0x40000000))));
CPU.VPR[op.vd].vf = _mm_or_ps(_mm_and_ps(_mm_cmpnle_ps(a, b), sign), _mm_and_ps(_mm_cmpnge_ps(a, bneg), _mm_castsi128_ps(_mm_set1_epi32(0x40000000))));
}
void ppu_interpreter::VCMPBFP_(PPUThread& CPU, ppu_opcode_t op)

View file

@ -230,7 +230,7 @@ s32 sys_lwmutex_lock(PPUThread& CPU, vm::ptr<sys_lwmutex_t> lwmutex, u64 timeout
// locking succeeded
auto old = lwmutex->owner.exchange(tid);
if (old.data() != se32(lwmutex_reserved))
if (old.data() != se32(lwmutex_reserved) && !Emu.IsStopped())
{
sysPrxForUser.Fatal("sys_lwmutex_lock(lwmutex=*0x%x): locking failed (owner=0x%x)", lwmutex, old);
}
@ -301,7 +301,7 @@ s32 sys_lwmutex_trylock(PPUThread& CPU, vm::ptr<sys_lwmutex_t> lwmutex)
// locking succeeded
auto old = lwmutex->owner.exchange(tid);
if (old.data() != se32(lwmutex_reserved))
if (old.data() != se32(lwmutex_reserved) && !Emu.IsStopped())
{
sysPrxForUser.Fatal("sys_lwmutex_trylock(lwmutex=*0x%x): locking failed (owner=0x%x)", lwmutex, old);
}
@ -592,7 +592,7 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
const auto old = lwmutex->owner.exchange(tid);
lwmutex->recursive_count = recursive_value;
if (old.data() != se32(lwmutex_reserved))
if (old.data() != se32(lwmutex_reserved) && !Emu.IsStopped())
{
sysPrxForUser.Fatal("sys_lwcond_wait(lwcond=*0x%x): locking failed (lwmutex->owner=0x%x)", lwcond, old);
}
@ -621,7 +621,7 @@ s32 sys_lwcond_wait(PPUThread& CPU, vm::ptr<sys_lwcond_t> lwcond, u64 timeout)
const auto old = lwmutex->owner.exchange(tid);
lwmutex->recursive_count = recursive_value;
if (old.data() != se32(lwmutex_reserved))
if (old.data() != se32(lwmutex_reserved) && !Emu.IsStopped())
{
sysPrxForUser.Fatal("sys_lwcond_wait(lwcond=*0x%x): locking failed after timeout (lwmutex->owner=0x%x)", lwcond, old);
}

View file

@ -30,15 +30,27 @@ s32 sys_process_getppid()
return 0;
}
s32 sys_process_exit(s32 errorcode)
s32 sys_process_exit(s32 status)
{
sys_process.Warning("sys_process_exit(%d)", errorcode);
Emu.Pause();
sys_process.Success("Process finished");
CallAfter([]()
sys_process.Warning("sys_process_exit(status=0x%x)", status);
LV2_LOCK;
if (!Emu.IsStopped())
{
Emu.Stop();
});
sys_process.Success("Process finished");
CallAfter([]()
{
Emu.Stop();
});
while (!Emu.IsStopped())
{
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
}
return CELL_OK;
}