pthread_setname_np() can only set the name of the current thread on
macOS, so only pass a single name argument.
Fixes build break on macOS 12.2 with _GNU_SOURCE defined.
On Windows there is no way to distinguish callstack data coming from random
sampling and from context switches. Each callstack timestamp has to be matched
against the context switch data in order to decide its origin. This is
obviously non-trivial.
On some other platforms, the origin information may be available right away,
in which case the process of matching against the context switch data, which
possibly includes postponing callstacks for processing in the future, may be
completely omitted.
Both Windows and Linux use 32-bit thread identifiers. MacOS has a 64-bit
counter, but in practice it will never overflow during profiling and no false
aliasing will happen.
These changes are only done client-side and in the network protocol. The
server still uses 64-bit thread identifiers, to enable virtual threads, etc.
The C++11 spec states in [basic.stc.thread] thread storage duration:
2. A variable with thread storage duration shall be initialized before its
first odr-use (3.2) and, if constructed, shall be destroyed on thread exit.
Previously Tracy relied on the TLS data being initialized:
- During thread creation (MSVC).
- Or during first use in a thread, but the initialization was performed for
the whole TLS block.
It seems that new compilers are more granular with how they perform the
initialization, hence rpmalloc init has to be checked before each allocation,
as it cannot be "folded" into, for example, initialization of the profiler
itself.