mirror of
https://github.com/RPCS3/rpcs3.git
synced 2024-11-22 02:32:36 +01:00
Remove thread_ctrl::atexit
It was only a workaround for poor C++11 thread_local support
This commit is contained in:
parent
f2229a5f53
commit
c5676e5649
@ -1654,9 +1654,8 @@ void thread_ctrl::initialize()
|
||||
|
||||
void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
|
||||
{
|
||||
// Run atexit functions
|
||||
m_task.invoke();
|
||||
m_task.reset();
|
||||
// Report pending errors
|
||||
error_code::error_report(0, 0, 0, 0);
|
||||
|
||||
#ifdef _WIN32
|
||||
ULONG64 cycles{};
|
||||
@ -1695,11 +1694,6 @@ void thread_ctrl::finalize(std::exception_ptr eptr) noexcept
|
||||
m_jcv.notify_all();
|
||||
}
|
||||
|
||||
void thread_ctrl::_push(task_stack task)
|
||||
{
|
||||
g_tls_this_thread->m_task.push(std::move(task));
|
||||
}
|
||||
|
||||
bool thread_ctrl::_wait_for(u64 usec)
|
||||
{
|
||||
auto _this = g_tls_this_thread;
|
||||
|
@ -132,7 +132,7 @@ class thread_ctrl final
|
||||
// Remotely set or caught exception
|
||||
std::exception_ptr m_exception;
|
||||
|
||||
// Thread initial task or atexit task
|
||||
// Thread initial task
|
||||
task_stack m_task;
|
||||
|
||||
// Fixed name
|
||||
@ -150,9 +150,6 @@ class thread_ctrl final
|
||||
// Called at the thread end
|
||||
void finalize(std::exception_ptr) noexcept;
|
||||
|
||||
// Add task (atexit)
|
||||
static void _push(task_stack);
|
||||
|
||||
// Internal waiting function, may throw. Infinite value is -1.
|
||||
static bool _wait_for(u64 usec);
|
||||
|
||||
@ -241,13 +238,6 @@ public:
|
||||
return g_tls_this_thread;
|
||||
}
|
||||
|
||||
// Register function at thread exit (for the current thread)
|
||||
template<typename F>
|
||||
static inline void atexit(F&& func)
|
||||
{
|
||||
_push(std::forward<F>(func));
|
||||
}
|
||||
|
||||
// Create detached named thread
|
||||
template<typename N, typename F>
|
||||
static inline void spawn(N&& name, F&& func)
|
||||
|
@ -4,39 +4,8 @@
|
||||
|
||||
#include "sys_net_.h"
|
||||
|
||||
|
||||
|
||||
LOG_CHANNEL(libnet);
|
||||
|
||||
struct sys_net_tls_data
|
||||
{
|
||||
be_t<s32> _errno;
|
||||
be_t<s32> _h_errno;
|
||||
char addr[16];
|
||||
};
|
||||
|
||||
// TODO
|
||||
thread_local vm::ptr<sys_net_tls_data> g_tls_net_data{};
|
||||
|
||||
static NEVER_INLINE vm::ptr<sys_net_tls_data> get_tls()
|
||||
{
|
||||
// Allocate if not initialized
|
||||
if (!g_tls_net_data)
|
||||
{
|
||||
g_tls_net_data.set(vm::alloc(sizeof(decltype(g_tls_net_data)::type), vm::main));
|
||||
|
||||
// Initial values
|
||||
g_tls_net_data->_errno = SYS_NET_EBUSY;
|
||||
|
||||
thread_ctrl::atexit([addr = g_tls_net_data.addr()]
|
||||
{
|
||||
vm::dealloc_verbose_nothrow(addr, vm::main);
|
||||
});
|
||||
}
|
||||
|
||||
return g_tls_net_data;
|
||||
}
|
||||
|
||||
s32 sys_net_accept(s32 s, vm::ptr<sys_net_sockaddr> addr, vm::ptr<u32> paddrlen)
|
||||
{
|
||||
libnet.todo("accept(s=%d, addr=*0x%x, paddrlen=*0x%x)", s, addr, paddrlen);
|
||||
@ -314,11 +283,12 @@ s32 sys_net_show_nameserver()
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
vm::ptr<s32> _sys_net_errno_loc()
|
||||
vm::ptr<s32> _sys_net_errno_loc(ppu_thread& ppu)
|
||||
{
|
||||
libnet.warning("_sys_net_errno_loc()");
|
||||
|
||||
return get_tls().ptr(&sys_net_tls_data::_errno);
|
||||
// Return fake location from system TLS area
|
||||
return vm::cast(ppu.gpr[13] - 0x7030 + 0x2c);
|
||||
}
|
||||
|
||||
s32 sys_net_set_resolver_configurations()
|
||||
@ -388,11 +358,12 @@ s32 sys_net_finalize_network()
|
||||
return CELL_OK;
|
||||
}
|
||||
|
||||
vm::ptr<s32> _sys_net_h_errno_loc()
|
||||
vm::ptr<s32> _sys_net_h_errno_loc(ppu_thread& ppu)
|
||||
{
|
||||
libnet.warning("_sys_net_h_errno_loc()");
|
||||
|
||||
return get_tls().ptr(&sys_net_tls_data::_h_errno);
|
||||
// Return fake location from system TLS area
|
||||
return vm::cast(ppu.gpr[13] - 0x7030 + 0x28);
|
||||
}
|
||||
|
||||
s32 sys_net_set_netemu_test_param()
|
||||
|
@ -1446,10 +1446,11 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i
|
||||
static thread_local std::unordered_map<std::string, std::size_t> g_tls_error_stats;
|
||||
static thread_local std::string g_tls_error_str;
|
||||
|
||||
if (g_tls_error_stats.empty())
|
||||
if (!sup)
|
||||
{
|
||||
thread_ctrl::atexit([]
|
||||
if (!sup2)
|
||||
{
|
||||
// Report and clean error state
|
||||
for (auto&& pair : g_tls_error_stats)
|
||||
{
|
||||
if (pair.second > 3)
|
||||
@ -1457,7 +1458,10 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i
|
||||
LOG_ERROR(GENERAL, "Stat: %s [x%u]", pair.first, pair.second);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
g_tls_error_stats.clear();
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
logs::channel* channel = &logs::GENERAL;
|
||||
|
Loading…
Reference in New Issue
Block a user