fastcommon

fastcommon

简介

build error

  • Fixes deprecated syscall issue on macOS 10.12 gettid
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
#include <pthread.h>

pid_t GetCurrentThreadId(){
    pid_t tid = 0;
#if defined(__linux__)
    tid = syscall(SYS_gettid);
#elif defined(__APPLE__) && defined(__MACH__)
    tid = syscall(SYS_thread_selfid);
    uint64_t tid64;
    pthread_threadid_np(NULL, &tid64);
    tid = (pid_t)tid64;
#endif
    return tid;
}
updatedupdated2024-08-252024-08-25