-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
gh-109693: Use pyatomic.h for signal module #110480
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 all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
a747442
gh-109693: Use pyatomic.h for signal module
corona10 544fe84
Remove pycore_atomic.h from pycore_signal.h too
corona10 86b97a5
Address code review
corona10 4a8c0b3
nit
corona10 3696f01
Add comment
corona10 e19a437
Revert "Add comment"
corona10 bb3dae2
Use sequentially consistent for handlers tripped
corona10 0750bbb
Address code review
corona10 4d6e5ea
Add comment
corona10 3610ae6
Apply suggestions from code review
corona10 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ extern "C" { | |
# error "this header requires Py_BUILD_CORE define" | ||
#endif | ||
|
||
#include "pycore_atomic.h" // _Py_atomic_address | ||
#include <signal.h> // NSIG | ||
|
||
|
||
|
@@ -38,12 +37,10 @@ PyAPI_FUNC(void) _Py_RestoreSignals(void); | |
#define INVALID_FD (-1) | ||
|
||
struct _signals_runtime_state { | ||
volatile struct { | ||
_Py_atomic_int tripped; | ||
/* func is atomic to ensure that PyErr_SetInterrupt is async-signal-safe | ||
* (even though it would probably be otherwise, anyway). | ||
*/ | ||
_Py_atomic_address func; | ||
struct { | ||
// tripped and func should be accessed using atomic ops. | ||
int tripped; | ||
PyObject* func; | ||
} handlers[Py_NSIG]; | ||
|
||
volatile struct { | ||
|
@@ -63,8 +60,9 @@ struct _signals_runtime_state { | |
#endif | ||
} wakeup; | ||
|
||
/* Speed up sigcheck() when none tripped */ | ||
_Py_atomic_int is_tripped; | ||
/* Speed up sigcheck() when none tripped. | ||
is_tripped should be accessed using atomic ops. */ | ||
int is_tripped; | ||
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. Since the 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. Done! |
||
|
||
/* These objects necessarily belong to the main interpreter. */ | ||
PyObject *default_handler; | ||
|
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.
Uh oh!
There was an error while loading. Please reload this page.