mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 05:21:25 +12:00
Hotfix (#1705)
This commit is contained in:
parent
cdefb969ec
commit
edc92843a7
5 changed files with 36 additions and 26 deletions
|
@ -1169,7 +1169,7 @@ const std::string& fs::get_executable_dir()
|
||||||
wchar_t buf[2048];
|
wchar_t buf[2048];
|
||||||
if (GetModuleFileName(NULL, buf, ::size32(buf)) - 1 >= ::size32(buf) - 1)
|
if (GetModuleFileName(NULL, buf, ::size32(buf)) - 1 >= ::size32(buf) - 1)
|
||||||
{
|
{
|
||||||
MessageBoxA(0, fmt::format("GetModuleFileName() failed: error %u.", GetLastError()).c_str(), "fs::get_config_dir()", MB_ICONERROR);
|
MessageBoxA(0, fmt::format("GetModuleFileName() failed: error %u.", GetLastError()).c_str(), "fs::get_executable_dir()", MB_ICONERROR);
|
||||||
return dir; // empty
|
return dir; // empty
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -38,38 +38,35 @@ namespace util
|
||||||
{
|
{
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
NtWaitForKeyedEvent(NULL, &key, FALSE, NULL);
|
|
||||||
|
|
||||||
u32 read = key.load();
|
u32 read = key.load();
|
||||||
u32 copy = read;
|
u32 copy = read;
|
||||||
|
|
||||||
while (pred(read), read != copy)
|
while (func(read), read != copy)
|
||||||
{
|
{
|
||||||
read = key.compare_and_swap(copy, read);
|
read = key.compare_and_swap(copy, read);
|
||||||
|
|
||||||
if (copy == read)
|
if (copy == read)
|
||||||
{
|
{
|
||||||
break;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
copy = read;
|
copy = read;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NtWaitForKeyedEvent(NULL, &key, FALSE, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Try to wake up a thread.
|
// Try to wake up a thread.
|
||||||
inline bool keyed_post(atomic_t<u32>& key, u32 acknowledged_value)
|
inline bool keyed_post(atomic_t<u32>& key, u32 acknowledged_value)
|
||||||
{
|
{
|
||||||
LARGE_INTEGER zero;
|
LARGE_INTEGER timeout;
|
||||||
zero.QuadPart = 0;
|
timeout.QuadPart = -50;
|
||||||
|
|
||||||
while (UNLIKELY(NtReleaseKeyedEvent(NULL, &key, FALSE, &zero) == WAIT_TIMEOUT))
|
while (UNLIKELY(NtReleaseKeyedEvent(NULL, &key, FALSE, &timeout) != ERROR_SUCCESS))
|
||||||
{
|
{
|
||||||
if (key.load() != acknowledged_value)
|
if (key.load() != acknowledged_value)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
//NtReleaseKeyedEvent(NULL, &key, FALSE, NULL);
|
|
||||||
//return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -22,13 +22,34 @@ namespace vm
|
||||||
this->mask = ~(size - 1);
|
this->mask = ~(size - 1);
|
||||||
this->thread = thread_ctrl::get_current();
|
this->thread = thread_ctrl::get_current();
|
||||||
|
|
||||||
|
struct waiter final
|
||||||
{
|
{
|
||||||
writer_lock lock(s_mutex);
|
waiter_base* m_ptr;
|
||||||
s_waiters.emplace(this);
|
thread_ctrl* m_thread;
|
||||||
}
|
|
||||||
|
waiter(waiter_base* ptr)
|
||||||
|
: m_ptr(ptr)
|
||||||
|
, m_thread(ptr->thread)
|
||||||
|
{
|
||||||
|
// Initialize waiter
|
||||||
|
writer_lock{s_mutex}, s_waiters.emplace(m_ptr);
|
||||||
|
|
||||||
|
m_thread->lock();
|
||||||
|
}
|
||||||
|
|
||||||
|
~waiter()
|
||||||
|
{
|
||||||
|
// Reset thread
|
||||||
|
atomic_storage<thread_ctrl*>::store(m_ptr->thread, nullptr);
|
||||||
|
m_thread->unlock();
|
||||||
|
|
||||||
|
// Remove waiter
|
||||||
|
writer_lock{s_mutex}, s_waiters.erase(m_ptr);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
// Wait until thread == nullptr
|
// Wait until thread == nullptr
|
||||||
thread_lock(), thread_ctrl::wait(WRAP_EXPR(!thread || test()));
|
waiter{this}, thread_ctrl::wait(WRAP_EXPR(!thread || test()));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool waiter_base::try_notify()
|
bool waiter_base::try_notify()
|
||||||
|
@ -66,12 +87,6 @@ namespace vm
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
waiter_base::~waiter_base()
|
|
||||||
{
|
|
||||||
writer_lock lock(s_mutex);
|
|
||||||
s_waiters.erase(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
void notify_at(u32 addr, u32 size)
|
void notify_at(u32 addr, u32 size)
|
||||||
{
|
{
|
||||||
reader_lock lock(s_mutex);
|
reader_lock lock(s_mutex);
|
||||||
|
@ -111,7 +126,7 @@ namespace vm
|
||||||
while (!Emu.IsStopped())
|
while (!Emu.IsStopped())
|
||||||
{
|
{
|
||||||
// Poll waiters periodically (TODO)
|
// Poll waiters periodically (TODO)
|
||||||
while (notify_all() && !Emu.IsPaused())
|
while (notify_all() && !Emu.IsPaused() && !Emu.IsStopped())
|
||||||
{
|
{
|
||||||
thread_ctrl::sleep(50);
|
thread_ctrl::sleep(50);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,8 +17,6 @@ namespace vm
|
||||||
bool try_notify();
|
bool try_notify();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
~waiter_base();
|
|
||||||
|
|
||||||
virtual bool test() = 0;
|
virtual bool test() = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -216,7 +216,7 @@ namespace psf
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip padding
|
// Skip padding
|
||||||
stream.seek(header.off_data_table);
|
stream.trunc(stream.seek(header.off_data_table));
|
||||||
|
|
||||||
// Save data
|
// Save data
|
||||||
for (const auto& entry : psf)
|
for (const auto& entry : psf)
|
||||||
|
@ -241,7 +241,7 @@ namespace psf
|
||||||
}
|
}
|
||||||
|
|
||||||
stream.write(value);
|
stream.write(value);
|
||||||
stream.seek(max - size, fs::seek_cur); // Skip up to max_size
|
stream.trunc(stream.seek(max - size, fs::seek_cur)); // Skip up to max_size
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue