libks
libks copied to clipboard
MacOS build libks error
This is another duplicated issue of https://github.com/signalwire/homebrew-signalwire/issues/21
Root Cause
The POSIX pthread_self returns the pthread_t, which is a struct, not a unsigned long int alias. And gettid(), which return the current thread id, is not available in mac os.
Solution https://elliotth.blogspot.com/2012/04/gettid-on-mac-os.html
uint64_t tid;
pthread_threadid_np(NULL, &tid);
or
syscall(SYS_thread_selfid)
But syscall is deprecated in macOS 10.12, there will be a warning. I suggest use pthread_threadid_np.
'syscall' is deprecated: first deprecated in macOS 10.12 - syscall(2) is unsupported;
Both the v1 & v2 release has same problem in mac os. So I guess this PR need to merge to both v1 and v2 release branch.