mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-01-11 03:00:16 +01:00
[orbis-kernel] Implement umtx_wait_uint within umtx_wait
Remove separate functions: * umtx_wait_uint * umtx_wait_uint_private
This commit is contained in:
parent
eda542561c
commit
4020bc1108
|
|
@ -67,7 +67,8 @@ struct Thread;
|
|||
ErrorCode umtx_lock_umtx(Thread *thread, ptr<umtx> umtx, ulong id,
|
||||
std::uint64_t ut);
|
||||
ErrorCode umtx_unlock_umtx(Thread *thread, ptr<umtx> umtx, ulong id);
|
||||
ErrorCode umtx_wait(Thread *thread, ptr<void> addr, ulong id, std::uint64_t ut);
|
||||
ErrorCode umtx_wait(Thread *thread, ptr<void> addr, ulong id, std::uint64_t ut,
|
||||
bool is32);
|
||||
ErrorCode umtx_wake(Thread *thread, ptr<void> addr, sint n_wake);
|
||||
ErrorCode umtx_trylock_umutex(Thread *thread, ptr<umutex> m);
|
||||
ErrorCode umtx_lock_umutex(Thread *thread, ptr<umutex> m, std::uint64_t ut);
|
||||
|
|
@ -78,16 +79,12 @@ ErrorCode umtx_cv_wait(Thread *thread, ptr<ucond> cv, ptr<umutex> m,
|
|||
std::uint64_t ut, ulong wflags);
|
||||
ErrorCode umtx_cv_signal(Thread *thread, ptr<ucond> cv);
|
||||
ErrorCode umtx_cv_broadcast(Thread *thread, ptr<ucond> cv);
|
||||
ErrorCode umtx_wait_uint(Thread *thread, ptr<void> addr, ulong id,
|
||||
std::uint64_t ut);
|
||||
ErrorCode umtx_rw_rdlock(Thread *thread, ptr<void> obj, std::int64_t val,
|
||||
ptr<void> uaddr1, ptr<void> uaddr2);
|
||||
ErrorCode umtx_rw_wrlock(Thread *thread, ptr<void> obj, std::int64_t val,
|
||||
ptr<void> uaddr1, ptr<void> uaddr2);
|
||||
ErrorCode umtx_rw_unlock(Thread *thread, ptr<void> obj, std::int64_t val,
|
||||
ptr<void> uaddr1, ptr<void> uaddr2);
|
||||
ErrorCode umtx_wait_uint_private(Thread *thread, ptr<void> addr, ulong id,
|
||||
std::uint64_t ut);
|
||||
ErrorCode umtx_wake_private(Thread *thread, ptr<void> uaddr, sint n_wake);
|
||||
ErrorCode umtx_wait_umutex(Thread *thread, ptr<umutex> m, std::uint64_t ut);
|
||||
ErrorCode umtx_wake_umutex(Thread *thread, ptr<umutex> m);
|
||||
|
|
|
|||
|
|
@ -81,7 +81,9 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr<void> obj, sint op,
|
|||
return umtx_unlock_umtx(thread, (ptr<umtx>)obj, val);
|
||||
case 2: {
|
||||
return with_timeout(
|
||||
[&](std::uint64_t ut) { return umtx_wait(thread, obj, val, ut); },
|
||||
[&](std::uint64_t ut) {
|
||||
return umtx_wait(thread, obj, val, ut, false);
|
||||
},
|
||||
false);
|
||||
}
|
||||
case 3:
|
||||
|
|
@ -112,7 +114,8 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr<void> obj, sint op,
|
|||
return umtx_cv_broadcast(thread, (ptr<ucond>)obj);
|
||||
case 11: {
|
||||
return with_timeout(
|
||||
[&](std::uint64_t ut) { return umtx_wait_uint(thread, obj, val, ut); });
|
||||
[&](std::uint64_t ut) { return umtx_wait(thread, obj, val, ut, true); },
|
||||
false);
|
||||
}
|
||||
case 12:
|
||||
return umtx_rw_rdlock(thread, obj, val, uaddr1, uaddr2);
|
||||
|
|
@ -121,9 +124,9 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr<void> obj, sint op,
|
|||
case 14:
|
||||
return umtx_rw_unlock(thread, obj, val, uaddr1, uaddr2);
|
||||
case 15: {
|
||||
return with_timeout([&](std::uint64_t ut) {
|
||||
return umtx_wait_uint_private(thread, obj, val, ut);
|
||||
});
|
||||
return with_timeout(
|
||||
[&](std::uint64_t ut) { return umtx_wait(thread, obj, val, ut, true); },
|
||||
false);
|
||||
}
|
||||
case 16:
|
||||
return umtx_wake_private(thread, obj, val);
|
||||
|
|
|
|||
|
|
@ -59,12 +59,17 @@ orbis::ErrorCode orbis::umtx_unlock_umtx(Thread *thread, ptr<umtx> umtx,
|
|||
}
|
||||
|
||||
orbis::ErrorCode orbis::umtx_wait(Thread *thread, ptr<void> addr, ulong id,
|
||||
std::uint64_t ut) {
|
||||
std::uint64_t ut, bool is32) {
|
||||
ORBIS_LOG_NOTICE(__FUNCTION__, addr, id, ut);
|
||||
auto [chain, key, lock] = g_context.getUmtxChain0(thread->tproc->pid, addr);
|
||||
auto node = chain.enqueue(key, thread);
|
||||
ErrorCode result = {};
|
||||
if (reinterpret_cast<ptr<std::atomic<ulong>>>(addr)->load() == id) {
|
||||
ulong val = 0;
|
||||
if (is32)
|
||||
val = reinterpret_cast<ptr<std::atomic<uint>>>(addr)->load();
|
||||
else
|
||||
val = reinterpret_cast<ptr<std::atomic<ulong>>>(addr)->load();
|
||||
if (val == id) {
|
||||
if (ut + 1 == 0) {
|
||||
node->second.cv.wait(chain.mtx);
|
||||
} else {
|
||||
|
|
@ -326,12 +331,6 @@ orbis::ErrorCode orbis::umtx_cv_broadcast(Thread *thread, ptr<ucond> cv) {
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::ErrorCode orbis::umtx_wait_uint(Thread *thread, ptr<void> addr, ulong id,
|
||||
std::uint64_t ut) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, addr, id, ut);
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::ErrorCode orbis::umtx_rw_rdlock(Thread *thread, ptr<void> obj,
|
||||
std::int64_t val, ptr<void> uaddr1,
|
||||
ptr<void> uaddr2) {
|
||||
|
|
@ -353,12 +352,6 @@ orbis::ErrorCode orbis::umtx_rw_unlock(Thread *thread, ptr<void> obj,
|
|||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::ErrorCode orbis::umtx_wait_uint_private(Thread *thread, ptr<void> addr,
|
||||
ulong id, std::uint64_t ut) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, addr, id, ut);
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
||||
orbis::ErrorCode orbis::umtx_wake_private(Thread *thread, ptr<void> uaddr,
|
||||
sint n_wake) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, uaddr, n_wake);
|
||||
|
|
|
|||
Loading…
Reference in a new issue