Probably some artifact left from older Windows or Visual Studio versions.
As Casey told on stream MSVC TLS uses gs register. So it is perfectly valid to access it. Here's example:
| __declspec(thread) int ThreadLocalVariable;
int main()
{
ThreadLocalVariable = 1;
}
|
Compile it with:
And look at assembly file tls.asm:
| mov ecx, DWORD PTR _tls_index
mov rax, QWORD PTR gs:88
mov edx, OFFSET FLAT:ThreadLocalVariable
mov rax, QWORD PTR [rax+rcx*8]
mov DWORD PTR [rdx+rax], 1
|
It accesses memory location using gs register.
That's for 64-bit code.
For 32-bit code it will use fs register:
| mov ecx, DWORD PTR __tls_index
mov eax, DWORD PTR fs:__tls_array
mov eax, DWORD PTR [eax+ecx*4]
mov DWORD PTR _ThreadLocalVariable[eax], 1
|
You might want to figure out GetCurrentThreadId works for 32-bit code and wrap our GetThreadID function in #ifdef macro depending on 32-bit/64-bit mode.