Some pthread implementations, e.g. Android 21+, provide
pid_t pthread_gettid_np(pthread_t);
The implementation may use the internal structure of struct pthread_t to retrieve the native thread id, same as the one returned by gettid() or syscall(SYS_gettid) when called in the context of that thread.