mirror of
https://github.com/RPCS3/rpcs3.git
synced 2026-06-03 21:25:04 -06:00
Add type-safe idm::last_id() overload
This commit is contained in:
parent
db474c292f
commit
ecf77ecef0
@ -2425,7 +2425,7 @@ ppu_thread::~ppu_thread()
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu_thread::ppu_thread(const ppu_thread_params& param, std::string_view name, u32 _prio, int detached)
|
ppu_thread::ppu_thread(const ppu_thread_params& param, std::string_view name, u32 _prio, int detached)
|
||||||
: cpu_thread(idm::last_id())
|
: cpu_thread(idm::last_id<ppu_thread>())
|
||||||
, stack_size(param.stack_size)
|
, stack_size(param.stack_size)
|
||||||
, stack_addr(param.stack_addr)
|
, stack_addr(param.stack_addr)
|
||||||
, joiner(detached != 0 ? ppu_join_status::detached : ppu_join_status::joinable)
|
, joiner(detached != 0 ? ppu_join_status::detached : ppu_join_status::joinable)
|
||||||
@ -2525,7 +2525,7 @@ struct save_lv2_tag
|
|||||||
};
|
};
|
||||||
|
|
||||||
ppu_thread::ppu_thread(utils::serial& ar)
|
ppu_thread::ppu_thread(utils::serial& ar)
|
||||||
: cpu_thread(idm::last_id()) // last_id() is showed to constructor on serialization
|
: cpu_thread(idm::last_id<ppu_thread>()) // last_id<>() is shown to constructor on serialization
|
||||||
, stack_size(ar)
|
, stack_size(ar)
|
||||||
, stack_addr(ar)
|
, stack_addr(ar)
|
||||||
, joiner(ar.pop<ppu_join_status>())
|
, joiner(ar.pop<ppu_join_status>())
|
||||||
|
|||||||
@ -1757,7 +1757,7 @@ void spu_thread::init_spu_decoder()
|
|||||||
}
|
}
|
||||||
|
|
||||||
spu_thread::spu_thread(lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated, u32 option)
|
spu_thread::spu_thread(lv2_spu_group* group, u32 index, std::string_view name, u32 lv2_id, bool is_isolated, u32 option)
|
||||||
: cpu_thread(idm::last_id())
|
: cpu_thread(idm::last_id<spu_thread>())
|
||||||
, group(group)
|
, group(group)
|
||||||
, index(index)
|
, index(index)
|
||||||
, thread_type(group ? spu_type::threaded : is_isolated ? spu_type::isolated : spu_type::raw)
|
, thread_type(group ? spu_type::threaded : is_isolated ? spu_type::isolated : spu_type::raw)
|
||||||
@ -1819,7 +1819,7 @@ void spu_thread::serialize_common(utils::serial& ar)
|
|||||||
}
|
}
|
||||||
|
|
||||||
spu_thread::spu_thread(utils::serial& ar, lv2_spu_group* group)
|
spu_thread::spu_thread(utils::serial& ar, lv2_spu_group* group)
|
||||||
: cpu_thread(idm::last_id())
|
: cpu_thread(idm::last_id<spu_thread>())
|
||||||
, group(group)
|
, group(group)
|
||||||
, index(ar)
|
, index(ar)
|
||||||
, thread_type(group ? spu_type::threaded : ar.pop<u8>() ? spu_type::isolated : spu_type::raw)
|
, thread_type(group ? spu_type::threaded : ar.pop<u8>() ? spu_type::isolated : spu_type::raw)
|
||||||
|
|||||||
@ -114,7 +114,7 @@ error_code sys_cond_create(ppu_thread& ppu, vm::ptr<u32> cond_id, u32 mutex_id,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*cond_id = idm::last_id();
|
*cond_id = idm::last_id<lv2_cond>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -319,7 +319,7 @@ error_code sys_config_open(u32 equeue_hdl, vm::ptr<u32> out_config_hdl)
|
|||||||
const auto config = lv2_config_handle::create(std::move(queue));
|
const auto config = lv2_config_handle::create(std::move(queue));
|
||||||
if (config)
|
if (config)
|
||||||
{
|
{
|
||||||
*out_config_hdl = idm::last_id();
|
*out_config_hdl = idm::last_id<lv2_config_handle>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -15,7 +15,7 @@
|
|||||||
LOG_CHANNEL(sys_event);
|
LOG_CHANNEL(sys_event);
|
||||||
|
|
||||||
lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept
|
lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64 ipc_key) noexcept
|
||||||
: id(idm::last_id())
|
: id(idm::last_id<lv2_event_queue>())
|
||||||
, protocol{static_cast<u8>(protocol)}
|
, protocol{static_cast<u8>(protocol)}
|
||||||
, type(static_cast<u8>(type))
|
, type(static_cast<u8>(type))
|
||||||
, size(static_cast<u8>(size))
|
, size(static_cast<u8>(size))
|
||||||
@ -25,7 +25,7 @@ lv2_event_queue::lv2_event_queue(u32 protocol, s32 type, s32 size, u64 name, u64
|
|||||||
}
|
}
|
||||||
|
|
||||||
lv2_event_queue::lv2_event_queue(utils::serial& ar) noexcept
|
lv2_event_queue::lv2_event_queue(utils::serial& ar) noexcept
|
||||||
: id(idm::last_id())
|
: id(idm::last_id<lv2_event_queue>())
|
||||||
, protocol(ar)
|
, protocol(ar)
|
||||||
, type(ar)
|
, type(ar)
|
||||||
, size(ar)
|
, size(ar)
|
||||||
@ -260,7 +260,7 @@ error_code sys_event_queue_create(cpu_thread& cpu, vm::ptr<u32> equeue_id, vm::p
|
|||||||
}
|
}
|
||||||
|
|
||||||
cpu.check_state();
|
cpu.check_state();
|
||||||
*equeue_id = idm::last_id();
|
*equeue_id = idm::last_id<lv2_event_queue>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -90,7 +90,7 @@ error_code sys_event_flag_create(ppu_thread& ppu, vm::ptr<u32> id, vm::ptr<sys_e
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*id = idm::last_id();
|
*id = idm::last_id<lv2_event_flag>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -13,13 +13,13 @@ LOG_CHANNEL(sys_interrupt);
|
|||||||
|
|
||||||
lv2_int_tag::lv2_int_tag() noexcept
|
lv2_int_tag::lv2_int_tag() noexcept
|
||||||
: lv2_obj(1)
|
: lv2_obj(1)
|
||||||
, id(idm::last_id())
|
, id(idm::last_id<lv2_int_tag>())
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
lv2_int_tag::lv2_int_tag(utils::serial& ar) noexcept
|
lv2_int_tag::lv2_int_tag(utils::serial& ar) noexcept
|
||||||
: lv2_obj(1)
|
: lv2_obj(1)
|
||||||
, id(idm::last_id())
|
, id(idm::last_id<lv2_int_tag>())
|
||||||
, handler([&]()
|
, handler([&]()
|
||||||
{
|
{
|
||||||
const u32 id{ar};
|
const u32 id{ar};
|
||||||
@ -46,7 +46,7 @@ void lv2_int_tag::save(utils::serial& ar)
|
|||||||
|
|
||||||
lv2_int_serv::lv2_int_serv(shared_ptr<named_thread<ppu_thread>> thread, u64 arg1, u64 arg2) noexcept
|
lv2_int_serv::lv2_int_serv(shared_ptr<named_thread<ppu_thread>> thread, u64 arg1, u64 arg2) noexcept
|
||||||
: lv2_obj(1)
|
: lv2_obj(1)
|
||||||
, id(idm::last_id())
|
, id(idm::last_id<lv2_int_serv>())
|
||||||
, thread(thread)
|
, thread(thread)
|
||||||
, arg1(arg1)
|
, arg1(arg1)
|
||||||
, arg2(arg2)
|
, arg2(arg2)
|
||||||
@ -55,7 +55,7 @@ lv2_int_serv::lv2_int_serv(shared_ptr<named_thread<ppu_thread>> thread, u64 arg1
|
|||||||
|
|
||||||
lv2_int_serv::lv2_int_serv(utils::serial& ar) noexcept
|
lv2_int_serv::lv2_int_serv(utils::serial& ar) noexcept
|
||||||
: lv2_obj(1)
|
: lv2_obj(1)
|
||||||
, id(idm::last_id())
|
, id(idm::last_id<lv2_int_serv>())
|
||||||
, thread(idm::get_unlocked<named_thread<ppu_thread>>(ar.pop<u32>()))
|
, thread(idm::get_unlocked<named_thread<ppu_thread>>(ar.pop<u32>()))
|
||||||
, arg1(ar)
|
, arg1(ar)
|
||||||
, arg2(ar)
|
, arg2(ar)
|
||||||
|
|||||||
@ -235,7 +235,7 @@ error_code sys_mmapper_allocate_shared_memory(ppu_thread& ppu, u64 ipc_key, u64
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*mem_id = idm::last_id();
|
*mem_id = idm::last_id<lv2_memory>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ error_code sys_mmapper_allocate_shared_memory_from_container(ppu_thread& ppu, u6
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*mem_id = idm::last_id();
|
*mem_id = idm::last_id<lv2_memory>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ error_code sys_mmapper_allocate_shared_memory_ext(ppu_thread& ppu, u64 ipc_key,
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*mem_id = idm::last_id();
|
*mem_id = idm::last_id<lv2_memory>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -493,7 +493,7 @@ error_code sys_mmapper_allocate_shared_memory_from_container_ext(ppu_thread& ppu
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*mem_id = idm::last_id();
|
*mem_id = idm::last_id<lv2_memory>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -99,7 +99,7 @@ error_code sys_mutex_create(ppu_thread& ppu, vm::ptr<u32> mutex_id, vm::ptr<sys_
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*mutex_id = idm::last_id();
|
*mutex_id = idm::last_id<lv2_mutex>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -257,7 +257,7 @@ lv2_socket::lv2_socket(utils::serial& ar, lv2_socket_type _type)
|
|||||||
|
|
||||||
ar(so_rcvtimeo, so_sendtimeo);
|
ar(so_rcvtimeo, so_sendtimeo);
|
||||||
|
|
||||||
lv2_id = idm::last_id();
|
lv2_id = idm::last_id<lv2_socket>();
|
||||||
|
|
||||||
ar(last_bound_addr);
|
ar(last_bound_addr);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -70,7 +70,7 @@ static error_code overlay_load_module(vm::ptr<u32> ovlmid, const std::string& vp
|
|||||||
|
|
||||||
sys_overlay.success("Loaded overlay: \"%s\" (id=0x%x)", vpath, idm::last_id());
|
sys_overlay.success("Loaded overlay: \"%s\" (id=0x%x)", vpath, idm::last_id());
|
||||||
|
|
||||||
*ovlmid = idm::last_id();
|
*ovlmid = idm::last_id<lv2_overlay>();
|
||||||
*entry = ovlm->entry;
|
*entry = ovlm->entry;
|
||||||
|
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
|
|||||||
@ -237,7 +237,7 @@ static error_code prx_load_module(const std::string& vpath, u64 flags, vm::ptr<s
|
|||||||
|
|
||||||
sys_prx.warning("Ignored module: \"%s\" (id=0x%x)", vpath, idm::last_id());
|
sys_prx.warning("Ignored module: \"%s\" (id=0x%x)", vpath, idm::last_id());
|
||||||
|
|
||||||
return not_an_error(idm::last_id());
|
return not_an_error(idm::last_id<lv2_prx>());
|
||||||
};
|
};
|
||||||
|
|
||||||
if (ignore)
|
if (ignore)
|
||||||
@ -300,7 +300,7 @@ static error_code prx_load_module(const std::string& vpath, u64 flags, vm::ptr<s
|
|||||||
|
|
||||||
sys_prx.success("Loaded module: \"%s\" (id=0x%x)", vpath, idm::last_id());
|
sys_prx.success("Loaded module: \"%s\" (id=0x%x)", vpath, idm::last_id());
|
||||||
|
|
||||||
return not_an_error(idm::last_id());
|
return not_an_error(idm::last_id<lv2_prx>());
|
||||||
}
|
}
|
||||||
|
|
||||||
fs::file make_file_view(fs::file&& file, u64 offset, u64 size);
|
fs::file make_file_view(fs::file&& file, u64 offset, u64 size);
|
||||||
|
|||||||
@ -61,7 +61,7 @@ error_code sys_rwlock_create(ppu_thread& ppu, vm::ptr<u32> rw_lock_id, vm::ptr<s
|
|||||||
}
|
}
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*rw_lock_id = idm::last_id();
|
*rw_lock_id = idm::last_id<lv2_rwlock>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -74,7 +74,7 @@ error_code sys_semaphore_create(ppu_thread& ppu, vm::ptr<u32> sem_id, vm::ptr<sy
|
|||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
|
|
||||||
*sem_id = idm::last_id();
|
*sem_id = idm::last_id<lv2_sema>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -833,7 +833,7 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr<u32> thread, u32 g
|
|||||||
if (auto state = +group->run_state; state != SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)
|
if (auto state = +group->run_state; state != SPU_THREAD_GROUP_STATUS_NOT_INITIALIZED)
|
||||||
{
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
idm::remove<named_thread<spu_thread>>(idm::last_id());
|
ensure(idm::remove<named_thread<spu_thread>>(idm::last_id<spu_thread>()));
|
||||||
|
|
||||||
if (state == SPU_THREAD_GROUP_STATUS_DESTROYED)
|
if (state == SPU_THREAD_GROUP_STATUS_DESTROYED)
|
||||||
{
|
{
|
||||||
@ -846,7 +846,7 @@ error_code sys_spu_thread_initialize(ppu_thread& ppu, vm::ptr<u32> thread, u32 g
|
|||||||
if (group->threads_map[spu_num] != -1)
|
if (group->threads_map[spu_num] != -1)
|
||||||
{
|
{
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
idm::remove<named_thread<spu_thread>>(idm::last_id());
|
ensure(idm::remove<named_thread<spu_thread>>(idm::last_id<spu_thread>()));
|
||||||
return CELL_EBUSY;
|
return CELL_EBUSY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1137,7 +1137,7 @@ error_code sys_spu_thread_group_create(ppu_thread& ppu, vm::ptr<u32> id, u32 num
|
|||||||
sys_spu.warning("sys_spu_thread_group_create(): Thread group \"%s\" created (id=0x%x)", group->name, idm::last_id());
|
sys_spu.warning("sys_spu_thread_group_create(): Thread group \"%s\" created (id=0x%x)", group->name, idm::last_id());
|
||||||
|
|
||||||
ppu.check_state();
|
ppu.check_state();
|
||||||
*id = idm::last_id();
|
*id = idm::last_id<lv2_spu_group>();
|
||||||
return CELL_OK;
|
return CELL_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -591,6 +591,20 @@ public:
|
|||||||
return id_manager::g_id;
|
return id_manager::g_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get last ID with type validation
|
||||||
|
template <typename T>
|
||||||
|
static inline u32 last_id(std::source_location src = std::source_location::current())
|
||||||
|
{
|
||||||
|
const u32 last = id_manager::g_id;
|
||||||
|
|
||||||
|
if (get_index<T>(last) >= T::id_count)
|
||||||
|
{
|
||||||
|
fmt::raw_range_error(src, last, T::id_base);
|
||||||
|
}
|
||||||
|
|
||||||
|
return last;
|
||||||
|
}
|
||||||
|
|
||||||
// Add a new ID of specified type with specified constructor arguments (returns object or null_ptr)
|
// Add a new ID of specified type with specified constructor arguments (returns object or null_ptr)
|
||||||
template <typename T, typename Make = T, typename... Args> requires (std::is_constructible_v<Make, Args&&...>)
|
template <typename T, typename Make = T, typename... Args> requires (std::is_constructible_v<Make, Args&&...>)
|
||||||
static inline stx::shared_ptr<Make> make_ptr(Args&&... args)
|
static inline stx::shared_ptr<Make> make_ptr(Args&&... args)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user