-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[libc][signal] clean up usage of sighandler_t #125745
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
Merged
Merged
Changes from 1 commit
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
62e8a9c
[libc][signal] clean up sighandler_t declarations
nickdesaulniers c84b8f2
clean up our usage of sighandler_t
nickdesaulniers 669bb96
only include __sighandler_t.h on linux
nickdesaulniers 19e518a
update signal.h hdrgen
nickdesaulniers d486708
reformat
nickdesaulniers 5864bf7
add dependency so include/llvm-libc-types/__sighandler_t.h gets copied
nickdesaulniers 3730708
remove any typedef for __sighandler_t, rename files
nickdesaulniers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| //===-- Definition of sighandler_t ----------------------------------------===// | ||
| // | ||
| // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | ||
| // See https://llvm.org/LICENSE.txt for license information. | ||
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| // | ||
| //===----------------------------------------------------------------------===// | ||
|
|
||
| #ifndef LLVM_LIBC_TYPES_SIGHANDLER_T_H | ||
| #define LLVM_LIBC_TYPES_SIGHANDLER_T_H | ||
|
|
||
| #ifdef __linux__ | ||
| // For compatibility with glibc. | ||
| typedef void (*sighandler_t)(int); | ||
| #endif | ||
|
|
||
| #endif // LLVM_LIBC_TYPES_SIGHANDLER_T_H | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
sure you don't want a
_GNU_SOURCEor whatever your internal equivalent is? (both glibc and bionic have__USE_GNUas the post-<features.h>-inclusion internal equivalent.)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.
No, we don't currently hold folk's code hostage based on them defining
_GNU_SOURCEor not, and I don't plan to add 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 flirted with that myself for bionic, but it's a bit more complicated in practice --- "what when the GNU variant conflicts with the POSIX one?", say, or "what when people are trying to build code that's incompatible with GNU extensions [because they use some of the names themselves, say]"...
(the weird one for Android is
_BSD_SOURCEwhere by historical accident that's always on. but_GNU_SOURCEis something developers are used to turning on/off either via-std=gnu23vs-std=c23or-D/#define.)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 was thinking more about this last night, and
qsort_rcame to mind.So I guess I should change my stance slightly from "never" to "perhaps when there is a conflict."
Is there a conflict here? Well,
sig_tandsighandler_tdon't conflict with each other, and the issue isn't as severe asqsort_r. But Bionic provides both without requiring users to pledge allegiance; if bionic doesn't llvm-libc should not either (IMO).But I will keep that in mind that
_GNU_SOURCEand_BSD_SOURCEdo exist more for than just pledges of allegiance and holding user code hostage, and that we may need to deploy those in llvm-libc in the future. I still don't think we need to here (yet; famous last words).Wait...what?!
uh...so perhaps not a bug in clang as the first two statements made me think...but WTF!?
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.
yeah, as you can probably tell, i do think "provide all the things until/unless proven problematic" is a developer-friendly option.
the only real counterargument i've heard is "it's bad for source portability in the other direction". but i've always cared more that people's stuff "just works" when ported to the libc i have control over rather than what might happen when ported away (in part because that's probably less common anyway; any library that's first developed on Android seems likely to be Android-specific in some way, or you'd probably make it cross-platform from the beginning).
oh, yeah, that's it ... i never do this myself, so i can never remember which combinations imply
_GNU_SOURCE, just that there are dragons in that area.madness indeed. (especially because
gnuvscdoes let you opt in/out of language extensions. if you were going to do anything here, consistency would have been nice. i assume there was a historical accident somewhere -- like bionic's always-on_BSD_SOURCEand they just couldn't fix it by the time they realized.)