fixed_typemap.hpp: return reference

This commit is contained in:
Nekotekina 2021-03-02 14:59:19 +03:00
parent bbf52f3cea
commit ea5e837bd6
87 changed files with 3028 additions and 2997 deletions

View file

@ -1,6 +1,7 @@
#include "stdafx.h"
#include "sys_ppu_thread.h"
#include "Emu/System.h"
#include "Emu/IdManager.h"
#include "Emu/perf_meter.hpp"
@ -48,13 +49,13 @@ struct ppu_thread_cleaner
bool ppu_thread_exit(ppu_thread& ppu)
{
ppu.state += cpu_flag::exit + cpu_flag::wait;
// Deallocate Stack Area
ensure(vm::dealloc(ppu.stack_addr, vm::stack) == ppu.stack_size);
if (const auto dct = g_fxo->get<lv2_memory_container>())
if (auto& dct = g_fxo->get<lv2_memory_container>(); !Emu.IsStopped())
{
dct->used -= ppu.stack_size;
dct.used -= ppu.stack_size;
}
return false;
@ -99,7 +100,7 @@ void _sys_ppu_thread_exit(ppu_thread& ppu, u64 errorcode)
ppu.state -= cpu_flag::suspend;
}
g_fxo->get<ppu_thread_cleaner>()->clean(old_status == ppu_join_status::detached ? ppu.id : 0);
g_fxo->get<ppu_thread_cleaner>().clean(old_status == ppu_join_status::detached ? ppu.id : 0);
while (ppu.joiner == ppu_join_status::zombie && !ppu.is_stopped())
{
@ -127,7 +128,7 @@ error_code sys_ppu_thread_join(ppu_thread& ppu, u32 thread_id, vm::ptr<u64> vptr
sys_ppu_thread.trace("sys_ppu_thread_join(thread_id=0x%x, vptr=*0x%x)", thread_id, vptr);
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
auto thread = idm::get<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread) -> CellError
{
@ -210,7 +211,7 @@ error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id)
sys_ppu_thread.trace("sys_ppu_thread_detach(thread_id=0x%x)", thread_id);
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
const auto thread = idm::check<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread) -> CellError
{
@ -261,8 +262,8 @@ error_code sys_ppu_thread_detach(ppu_thread& ppu, u32 thread_id)
if (thread.ret == CELL_EAGAIN)
{
g_fxo->get<ppu_thread_cleaner>()->clean(thread_id);
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(thread_id);
g_fxo->get<ppu_thread_cleaner>().clean(0);
}
return CELL_OK;
@ -293,7 +294,7 @@ error_code sys_ppu_thread_set_priority(ppu_thread& ppu, u32 thread_id, s32 prio)
}
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
const auto thread = idm::check<named_thread<ppu_thread>>(thread_id, [&](ppu_thread& thread)
{
@ -325,7 +326,7 @@ error_code sys_ppu_thread_get_priority(ppu_thread& ppu, u32 thread_id, vm::ptr<s
sys_ppu_thread.trace("sys_ppu_thread_get_priority(thread_id=0x%x, priop=*0x%x)", thread_id, priop);
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
u32 prio;
@ -426,15 +427,15 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr<u64> thread_id, vm::p
const u32 tls = param->tls;
// Clean some detached thread (hack)
g_fxo->get<ppu_thread_cleaner>()->clean(0);
g_fxo->get<ppu_thread_cleaner>().clean(0);
// Compute actual stack size and allocate
const u32 stack_size = utils::align<u32>(std::max<u32>(_stacksz, 4096), 4096);
const auto dct = g_fxo->get<lv2_memory_container>();
auto& dct = g_fxo->get<lv2_memory_container>();
// Try to obtain "physical memory" from the default container
if (!dct->take(stack_size))
if (!dct.take(stack_size))
{
return CELL_ENOMEM;
}
@ -443,7 +444,7 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr<u64> thread_id, vm::p
if (!stack_base)
{
dct->used -= stack_size;
dct.used -= stack_size;
return CELL_ENOMEM;
}
@ -484,7 +485,7 @@ error_code _sys_ppu_thread_create(ppu_thread& ppu, vm::ptr<u64> thread_id, vm::p
if (!tid)
{
vm::dealloc(stack_base);
dct->used -= stack_size;
dct.used -= stack_size;
return CELL_EAGAIN;
}
@ -634,11 +635,11 @@ error_code sys_ppu_thread_get_page_fault_context(ppu_thread& ppu, u32 thread_id,
}
// We can only get a context if the thread is being suspended for a page fault.
auto pf_events = g_fxo->get<page_fault_event_entries>();
reader_lock lock(pf_events->pf_mutex);
auto& pf_events = g_fxo->get<page_fault_event_entries>();
reader_lock lock(pf_events.pf_mutex);
const auto evt = pf_events->events.find(thread.ptr.get());
if (evt == pf_events->events.end())
const auto evt = pf_events.events.find(thread.ptr.get());
if (evt == pf_events.events.end())
{
return CELL_EINVAL;
}