include <sys/syscall.h> pid_t tid = (pid_t) syscall (SYS_gettid); static pid_t my_gettid() { return (pid_t)syscall(SYS_gettid); }