diff --git a/orbis-kernel/include/orbis/umtx.hpp b/orbis-kernel/include/orbis/umtx.hpp index d99d5dccd..c02422177 100644 --- a/orbis-kernel/include/orbis/umtx.hpp +++ b/orbis-kernel/include/orbis/umtx.hpp @@ -67,7 +67,8 @@ struct Thread; ErrorCode umtx_lock_umtx(Thread *thread, ptr umtx, ulong id, std::uint64_t ut); ErrorCode umtx_unlock_umtx(Thread *thread, ptr umtx, ulong id); -ErrorCode umtx_wait(Thread *thread, ptr addr, ulong id, std::uint64_t ut); +ErrorCode umtx_wait(Thread *thread, ptr addr, ulong id, std::uint64_t ut, + bool is32); ErrorCode umtx_wake(Thread *thread, ptr addr, sint n_wake); ErrorCode umtx_trylock_umutex(Thread *thread, ptr m); ErrorCode umtx_lock_umutex(Thread *thread, ptr m, std::uint64_t ut); @@ -78,16 +79,12 @@ ErrorCode umtx_cv_wait(Thread *thread, ptr cv, ptr m, std::uint64_t ut, ulong wflags); ErrorCode umtx_cv_signal(Thread *thread, ptr cv); ErrorCode umtx_cv_broadcast(Thread *thread, ptr cv); -ErrorCode umtx_wait_uint(Thread *thread, ptr addr, ulong id, - std::uint64_t ut); ErrorCode umtx_rw_rdlock(Thread *thread, ptr obj, std::int64_t val, ptr uaddr1, ptr uaddr2); ErrorCode umtx_rw_wrlock(Thread *thread, ptr obj, std::int64_t val, ptr uaddr1, ptr uaddr2); ErrorCode umtx_rw_unlock(Thread *thread, ptr obj, std::int64_t val, ptr uaddr1, ptr uaddr2); -ErrorCode umtx_wait_uint_private(Thread *thread, ptr addr, ulong id, - std::uint64_t ut); ErrorCode umtx_wake_private(Thread *thread, ptr uaddr, sint n_wake); ErrorCode umtx_wait_umutex(Thread *thread, ptr m, std::uint64_t ut); ErrorCode umtx_wake_umutex(Thread *thread, ptr m); diff --git a/orbis-kernel/src/sys/sys_umtx.cpp b/orbis-kernel/src/sys/sys_umtx.cpp index 4a7895596..9993c9b0f 100644 --- a/orbis-kernel/src/sys/sys_umtx.cpp +++ b/orbis-kernel/src/sys/sys_umtx.cpp @@ -81,7 +81,9 @@ orbis::SysResult orbis::sys__umtx_op(Thread *thread, ptr obj, sint op, return umtx_unlock_umtx(thread, (ptr)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 obj, sint op, return umtx_cv_broadcast(thread, (ptr)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 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); diff --git a/orbis-kernel/src/umtx.cpp b/orbis-kernel/src/umtx.cpp index d56871527..0bfb73156 100644 --- a/orbis-kernel/src/umtx.cpp +++ b/orbis-kernel/src/umtx.cpp @@ -59,12 +59,17 @@ orbis::ErrorCode orbis::umtx_unlock_umtx(Thread *thread, ptr umtx, } orbis::ErrorCode orbis::umtx_wait(Thread *thread, ptr 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>>(addr)->load() == id) { + ulong val = 0; + if (is32) + val = reinterpret_cast>>(addr)->load(); + else + val = reinterpret_cast>>(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 cv) { return ErrorCode::NOSYS; } -orbis::ErrorCode orbis::umtx_wait_uint(Thread *thread, ptr 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 obj, std::int64_t val, ptr uaddr1, ptr uaddr2) { @@ -353,12 +352,6 @@ orbis::ErrorCode orbis::umtx_rw_unlock(Thread *thread, ptr obj, return ErrorCode::NOSYS; } -orbis::ErrorCode orbis::umtx_wait_uint_private(Thread *thread, ptr 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 uaddr, sint n_wake) { ORBIS_LOG_TODO(__FUNCTION__, uaddr, n_wake);