#include #include // syscall can't have helprer due to variable number of arguments. // So we have to call it through pointer. int syscall(int,...); LSB_CHECKER(DEFAULT,syscall); // now pointer syscall_a is available. int syscall_gettid_available() { return syscall_available() && (syscall_gettid() != -1); } #ifndef SYS_gettid // i386: 224, ia64: 1105, amd64: 186, sparc 143 #ifdef __ia64__ #define SYS_gettid 1105 #elif __i386__ #define SYS_gettid 224 #elif __amd64__ #define SYS_gettid 186 #elif __sparc__ #define SYS_gettid 143 #else #error define gettid for the arch #endif #endif int syscall_gettid() { //To load address we must check availability syscall_available(); //now syscall return (*syscall_a)(SYS_gettid); }