#pragma once #include "sys_sync.h" struct sys_mutex_attribute_t { be_t protocol; // SYS_SYNC_FIFO, SYS_SYNC_PRIORITY or SYS_SYNC_PRIORITY_INHERIT be_t recursive; // SYS_SYNC_RECURSIVE or SYS_SYNC_NOT_RECURSIVE be_t pshared; be_t adaptive; be_t ipc_key; be_t flags; be_t pad; union { char name[8]; u64 name_u64; }; }; struct lv2_mutex_t { static const u32 id_base = 0x85000000; static const u32 id_step = 0x100; static const u32 id_count = 8192; const bool recursive; const u32 protocol; const u64 name; atomic_t cond_count{ 0 }; // count of condition variables associated atomic_t recursive_count{ 0 }; // count of recursive locks std::shared_ptr owner; // current mutex owner sleep_queue sq; lv2_mutex_t(bool recursive, u32 protocol, u64 name) : recursive(recursive) , protocol(protocol) , name(name) { } void unlock(lv2_lock_t); }; class ppu_thread; // SysCalls s32 sys_mutex_create(vm::ps3::ptr mutex_id, vm::ps3::ptr attr); s32 sys_mutex_destroy(u32 mutex_id); s32 sys_mutex_lock(ppu_thread& ppu, u32 mutex_id, u64 timeout); s32 sys_mutex_trylock(ppu_thread& ppu, u32 mutex_id); s32 sys_mutex_unlock(ppu_thread& ppu, u32 mutex_id);