I am working in glibc and I need to get the id of the current thread. For this i use
syscall(SYS_gettid);
Issue is, i am forced to include bits/syscall.h
gettid() is a system call. As for as I know there is no glibc wrapper for gettid. You need to invoke gettid() using syscall(). The following code works for me.
#include <sys/syscall.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
int main()
{
long tid;
tid = syscall(SYS_gettid);
printf("%ld\n", tid);
return EXIT_SUCCESS;
}