mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-01-31 20:41:45 +01:00
Reenable thread_local for all platforms
This commit is contained in:
parent
025a09ed87
commit
c1450ad616
@ -246,7 +246,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Get text
|
// Get text
|
||||||
std::string text;
|
thread_local std::string text; text.clear();
|
||||||
fmt::raw_append(text, fmt, sup, args);
|
fmt::raw_append(text, fmt, sup, args);
|
||||||
std::string prefix = g_tls_log_prefix();
|
std::string prefix = g_tls_log_prefix();
|
||||||
|
|
||||||
@ -266,7 +266,7 @@ void logs::message::broadcast(const char* fmt, const fmt_type_info* sup, const u
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Store message additionally
|
// Store message additionally
|
||||||
g_messages.emplace_back(stored_message{*this, stamp, std::move(prefix), std::move(text)});
|
g_messages.emplace_back(stored_message{*this, stamp, std::move(prefix), text});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -347,7 +347,7 @@ logs::file_listener::file_listener(const std::string& name)
|
|||||||
|
|
||||||
void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::string& prefix, const std::string& _text)
|
void logs::file_listener::log(u64 stamp, const logs::message& msg, const std::string& prefix, const std::string& _text)
|
||||||
{
|
{
|
||||||
std::string text; text.reserve(prefix.size() + _text.size() + 200);
|
thread_local std::string text;
|
||||||
|
|
||||||
// Used character: U+00B7 (Middle Dot)
|
// Used character: U+00B7 (Middle Dot)
|
||||||
switch (msg.sev)
|
switch (msg.sev)
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
#define SAFE_BUFFERS
|
#define SAFE_BUFFERS
|
||||||
#define NEVER_INLINE __attribute__((noinline))
|
#define NEVER_INLINE __attribute__((noinline))
|
||||||
#define FORCE_INLINE __attribute__((always_inline)) inline
|
#define FORCE_INLINE __attribute__((always_inline)) inline
|
||||||
#define thread_local __thread
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#define CHECK_SIZE(type, size) static_assert(sizeof(type) == size, "Invalid " #type " type size")
|
#define CHECK_SIZE(type, size) static_assert(sizeof(type) == size, "Invalid " #type " type size")
|
||||||
|
@ -793,26 +793,20 @@ void Emulator::Stop()
|
|||||||
|
|
||||||
s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_info* sup2, u64 arg2)
|
s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_info* sup2, u64 arg2)
|
||||||
{
|
{
|
||||||
static thread_local std::unordered_map<std::string, std::size_t>* g_tls_error_stats{};
|
static thread_local std::unordered_map<std::string, std::size_t> g_tls_error_stats;
|
||||||
static thread_local std::string* g_tls_error_str{};
|
static thread_local std::string g_tls_error_str;
|
||||||
|
|
||||||
if (!g_tls_error_stats)
|
if (g_tls_error_stats.empty())
|
||||||
{
|
{
|
||||||
g_tls_error_stats = new std::unordered_map<std::string, std::size_t>;
|
|
||||||
g_tls_error_str = new std::string;
|
|
||||||
|
|
||||||
thread_ctrl::atexit([]
|
thread_ctrl::atexit([]
|
||||||
{
|
{
|
||||||
for (auto&& pair : *g_tls_error_stats)
|
for (auto&& pair : g_tls_error_stats)
|
||||||
{
|
{
|
||||||
if (pair.second > 3)
|
if (pair.second > 3)
|
||||||
{
|
{
|
||||||
LOG_ERROR(GENERAL, "Stat: %s [x%u]", pair.first, pair.second);
|
LOG_ERROR(GENERAL, "Stat: %s [x%u]", pair.first, pair.second);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delete g_tls_error_stats;
|
|
||||||
delete g_tls_error_str;
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -842,15 +836,15 @@ s32 error_code::error_report(const fmt_type_info* sup, u64 arg, const fmt_type_i
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Format log message (use preallocated buffer)
|
// Format log message (use preallocated buffer)
|
||||||
g_tls_error_str->clear();
|
g_tls_error_str.clear();
|
||||||
fmt::append(*g_tls_error_str, "'%s' failed with 0x%08x%s%s%s%s", func, arg, sup ? " : " : "", std::make_pair(sup, arg), sup2 ? ", " : "", std::make_pair(sup2, arg2));
|
fmt::append(g_tls_error_str, "'%s' failed with 0x%08x%s%s%s%s", func, arg, sup ? " : " : "", std::make_pair(sup, arg), sup2 ? ", " : "", std::make_pair(sup2, arg2));
|
||||||
|
|
||||||
// Update stats and check log threshold
|
// Update stats and check log threshold
|
||||||
const auto stat = ++(*g_tls_error_stats)[*g_tls_error_str];
|
const auto stat = ++g_tls_error_stats[g_tls_error_str];
|
||||||
|
|
||||||
if (stat <= 3)
|
if (stat <= 3)
|
||||||
{
|
{
|
||||||
channel->format(level, "%s [%u]", *g_tls_error_str, stat);
|
channel->format(level, "%s [%u]", g_tls_error_str, stat);
|
||||||
}
|
}
|
||||||
|
|
||||||
return static_cast<s32>(arg);
|
return static_cast<s32>(arg);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user