Issue 26161: Use Py_uintptr_t instead of void* for atomic pointers (original) (raw)
Attached patch fixes compiler warnings on atomic pointers.
Python has 4 implementations of atomic types:
- <stdatomic.h>
- GCC 4.7+ builtin atomic operations
- GCC x86 and x86_64 assembler
- volatile
The type of atomic pointers changes depending on the implementation. Attached patch changes the _Py_atomic_address to use atomic_uintptr_t (<stdatomic.h>) or Py_uintptr_t type internally.
The patchs also adds GET_TSTATE(), SET_TSTATE() and GET_INTERP_STATE() macros in pystate.c to make the code more readable.
This issue is a follow up of the issue #22038 which added support for <stdatomic.h> in Python/pyatomic.h. See also issues #23644 (compilation issue with g++), #25150 (compilation issue with OpenMP) and #26154 (add _PyThreadState_UncheckedGet()).
I would be "nice" to backport this change to Python 3.5.2 to fix the compiler warning, but I'm not 100% confident that my patch works on all compilers and all platforms. Maybe it's better to "experiment" it only in Python 3.6.
Note: I copied the nosy list of the issue #22038 since this one is a follow up.