The following implementation is based on the disassembly of pthread_self and works on my machine™.
1 2 3 4 5 6 | inline u32 GetThreadID(void) { u32 ThreadID; asm ("mov %%fs:0x10,%0" : "=r" (ThreadID)); return ThreadID; } |
Does anybody know how portable this code is, will it work on Mac OS X?
Oh, and please point out if I did something stupid. I obviously have no clue what I am doing.
/Kim