Skip to content

Clean-up pyatomic headers #109693

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

Closed
colesbury opened this issue Sep 21, 2023 · 9 comments
Closed

Clean-up pyatomic headers #109693

colesbury opened this issue Sep 21, 2023 · 9 comments
Labels
3.13 bugs and security fixes type-feature A feature request or enhancement

Comments

@colesbury
Copy link
Contributor

colesbury commented Sep 21, 2023

@colesbury colesbury added type-feature A feature request or enhancement 3.13 bugs and security fixes labels Sep 21, 2023
colesbury added a commit to colesbury/cpython that referenced this issue Sep 21, 2023
Use functions from `pyatomic.h` instead.
vstinner pushed a commit that referenced this issue Sep 21, 2023
_PyUnicode_FromId() now uses pyatomic.h functions instead.
@colesbury
Copy link
Contributor Author

@vstinner, For pycore_atomic.h, I'm not sure whether to keep _Py_atomic_address and _Py_atomic_int or not.

@vstinner
Copy link
Member

I was fine to remove pycore_atomic_funcs.h at once since it's only used by _PyUnicode_FromId() which is... no longer used by Python itself!

To remove pycore_atomic.h, I would prefer to make baby steps: convert usage one by one. For example, you can start by converting signal handlers: get_handler() and set_handler() in Modules/signalmodule.c, and also the two "tripped" variables.

If someone goes wrong, it would be easier to revert changes if they have limited scope. Also, smaller PRs are easier to review :-)

csm10495 pushed a commit to csm10495/cpython that referenced this issue Sep 28, 2023
_PyUnicode_FromId() now uses pyatomic.h functions instead.
corona10 added a commit to corona10/cpython that referenced this issue Oct 6, 2023
corona10 added a commit to corona10/cpython that referenced this issue Oct 6, 2023
@corona10
Copy link
Member

corona10 commented Oct 10, 2023

@colesbury @vstinner
I am working on the following fields.

_Py_atomic_address last_holder;
/* Whether the GIL is already taken (-1 if uninitialized). This is
atomic because it can be read without any lock taken in ceval.c. */
_Py_atomic_int locked;

corona10 added a commit to corona10/cpython that referenced this issue Oct 10, 2023
@vstinner
Copy link
Member

The last part seems to be about annotations:

vstinner@mona$ git grep pycore_atomic.h

Makefile.pre.in:                $(srcdir)/Include/internal/pycore_atomic.h \
PCbuild/pythoncore.vcxproj:    <ClInclude Include="..\Include\internal\pycore_atomic.h" />
PCbuild/pythoncore.vcxproj.filters:    <ClInclude Include="..\Include\internal\pycore_atomic.h">

Python/ceval_gil.c:#include "pycore_atomic.h"        // _Py_ANNOTATE_RWLOCK_CREATE
Python/thread_pthread.h:#include "pycore_atomic.h"        // _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX

@vstinner
Copy link
Member

Python/ceval_gil.c:#include "pycore_atomic.h"        // _Py_ANNOTATE_RWLOCK_CREATE
Python/thread_pthread.h:#include "pycore_atomic.h"        // _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX

Hum, in fact, these symbols come from dynamic_annotations.h. It seems like pycore_pyatomic.h is no longer needed.

@corona10: Do you want to prepare a PR to remove it?

@corona10
Copy link
Member

@corona10: Do you want to prepare a PR to remove it?

Yeah, I am preparing the PR

corona10 added a commit to corona10/cpython that referenced this issue Oct 17, 2023
@corona10
Copy link
Member

@colesbury @vstinner I think that now we can close this issue.
Please let me know if you want to reopen this issue :)

@colesbury
Copy link
Contributor Author

Thanks @corona10!

@vstinner
Copy link
Member

Well done. One less legacy API in Python C API :-)

aisk pushed a commit to aisk/cpython that referenced this issue Feb 11, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
_PyUnicode_FromId() now uses pyatomic.h functions instead.
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Glyphack pushed a commit to Glyphack/cpython that referenced this issue Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

3 participants