-
Notifications
You must be signed in to change notification settings - Fork 401
Get the thread id on macOS 10.12 Sierra without using the now deprecated syscall(2) #39
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Hi Bob, Thanks for contributing! I'm wondering whether we can completely remove |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this changeset has no sense (Restrict the scope of tid64. 2c03086)
Hi, Thanks for plog! I don't know. I have access to a mac still running 10.11, but not until tomorrow at the earliest. I can check then. It looks as though it's been around since at least 2013 based on one thread I found. Another thread says it was introduced with OSX 10.6 -- actually several. If this is true, then you're probably right. |
Why does it have no sense? You mean the curly braces? Possibly not, but it does localise the variable. |
Yes, curly braces. Removing all macro stuff will produce the following: inline unsigned int gettid()
{
{
uint64_t tid64;
pthread_threadid_np(NULL, &tid64);
return static_cast<unsigned int>(tid64);
}
} Looks redundant. |
True. Maybe it's just a coding practice from my history. The idea is to try to keep everything as local as possible to minimise the necessity of mentally trying to figure out what the function looks like. Your call, takes 30s to change. I can do that when I check OS X 10.11 tomorrow, or manage to confirm that pthread_threadid_np does date back to OS X 10.6 |
Found some code released with OS X 10.7 (and it says pthread_threadid_np was added in 10.6). This puts it as having been introduced in 2009. |
10.6 (2009). Don't need to support that far back.
Looks good. I wish macOS had better documentation. |
On macOS 10.12 (Sierra) syscall(2) has been deprecated. The result is that using plog as-is produces a deprecation warning for every source file including plog.
This pull request deals with that.