If you are OK with including platform specific headers (pthread.h) in game dll layer, then sure, that would work.
Casey was not OK to do that. He didn't want to include windows.h in game dll to be able to use GetCurrentThreadId. And he put code in #ifdef. You can do the same:
1
2
3
4
5
6
7
8
9
10
11
12
13
14 | inline u32 GetThreadID(void)
{
#elif HANDMADE_OSX
u32 ThreadID;
asm("mov %%gs:0x0,%0" : "=r"(ThreadID));
return ThreadID;
#elif HANDMADE_LINUX
...
#elif HANDMADE_WIN32
...
#else
#error How to get current thread id for this OS?
#endif
}
|