mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-20 20:55:56 +00:00
Merge branch 'task/tidcache' into dev
This commit is contained in:
commit
bf7c507e4c
1 file changed
+8
-1
@@ -1172,7 +1172,14 @@ size_t plat_getenv(const char *name, char *out, size_t cap) {
|
||||
return n;
|
||||
}
|
||||
|
||||
uint32_t plat_thread_id(void) { return (uint32_t)syscall(SYS_gettid); }
|
||||
// Cached per thread: plat_rmutex_lock asks on every acquire, hundreds of thousands of times a second in play, and
|
||||
// gettid is a full syscall on Linux (Windows reads GetCurrentThreadId from the TEB). A thread's id never changes, and
|
||||
// the runtime starts child processes with posix_spawn only, so no forked copy inherits a stale id.
|
||||
uint32_t plat_thread_id(void) {
|
||||
static __thread uint32_t tid;
|
||||
if (!tid) tid = (uint32_t)syscall(SYS_gettid);
|
||||
return tid;
|
||||
}
|
||||
|
||||
// The first set variable of names ("ru_RU.UTF-8") as a BCP-47 tag ("ru-RU") into tag; "" for C and POSIX.
|
||||
static void locale_tag(const char *const *names, int n, char *tag, size_t cap) {
|
||||
|
||||
Reference in new issue
Block a user