-
Notifications
You must be signed in to change notification settings - Fork 5.5k
android: fix pthread compiler conditionals #12081
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -248,19 +248,12 @@ struct mmsghdr { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif // __ANDROID_API__ < 24 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif // ifdef __ANDROID_API__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef __linux__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #define SUPPORTS_PTHREAD_GETNAME_NP 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // https://android.googlesource.com/platform/bionic/+/master/docs/status.md | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // ``pthread_getname_np`` is introduced in API 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifdef __ANDROID_API__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if __ANDROID_API__ > 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #define SUPPORTS_PTHREAD_GETNAME_NP 1 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif // __ANDROID_API__ > 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif // ifdef __ANDROID_API__ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| // Ensure `SUPPORTS_PTHREAD_GETNAME_NP` is set | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #ifndef SUPPORTS_PTHREAD_GETNAME_NP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #define SUPPORTS_PTHREAD_GETNAME_NP 0 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if defined(__ANDROID_API__) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #if __ANDROID_API__ >= 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #define SUPPORTS_PTHREAD_GETNAME_NP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif // __ANDROID_API__ >= 26 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #elif defined(__linux__) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #define SUPPORTS_PTHREAD_GETNAME_NP | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #endif // defined(__ANDROID_API__) | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+253
to
+262
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we do this the compiler will complain that we're redefining
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, we're being strict with I would still suggest simplifying and renaming.
Comment on lines
+254
to
+262
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
How about this? The renaming suggestion to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We're currently only guarding against the one method right now I believe
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Right, Also, your suggestion is not equivalent to what I have on this branch @goaway. I'm not requiring
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm aware that
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We use the guard to generally disable the logic around pthread naming - both set and get. The boolean logic I posted above is equivalent to what you have, it just reduces the number of conditionals.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't have that strong of an opinion here. Renamed to what you requested. |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
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.
@jmarantz requested on the other PR that these be set to numerical values for (potential) boolean logic comparisons.
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.
I opted for basic
#defines here to keep the logic in this block simple. Using numeric-backed definitions would make this significantly more complicated and less readable. If people feel strongly I can change it.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.
I don't think that would change the logic at all; you'd just be adding a
1to the end of a couple of lines.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.
We would also need to either add 2
#elsecases to define it as zero in all branches, or add a separate block with an#ifndef, right?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.
i see. just define it to 0 at the start and undef/redefine it to 1 as needed?
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.
Updated.