gettid根据man手册
The gettid() system call first appeared on Linux in kernel 2.4.11. Library support was added in glibc 2.30. (Earlier glibc versions did not provide a wrapper for this system call, necessitating the use of syscall(2).)
我查的glibc版本为:
ldd --version
ldd (GNU libc) 2.12
或者rpm -qi glibc
版本低于2.30,要使用的话得这样来:
#include <unistd.h>
#include <sys/syscall.h>
#define gettid() syscall(SYS_gettid)