gettid() and threading...
Edited to add:
C++, GCC 3.4.1, MDK 10.1.
------------------------------------------
I have created a function like:
#include <sys/types.h>
#include <linux/unistd.h>
_syscall0( pid_t, gettid )
int myGetTID( void )
{
return gettid();
}
This won't work correctly because where ever the _syscall0( pid_t, gettid) is called, it appears to create a static function gettid() that returns the pid_t of the "thread" it was called in. So, if I statically declare this in a header file, inlined, it will always return the PID of the parent process/first thread.
I can probably make a macro, and inline it all, but I was wondering if there is any "magic" I could use to put this in one area (besides a macro) and have it return the correct result.
Last edited by mrshadow76; 10-12-2005 at 08:57 AM.
|