mirror of https://github.com/python/cpython
gh-112779: Check 1-byte atomics in configure (gh-112819)
This commit is contained in:
parent
c744dbe9ac
commit
4d1eea59bd
|
@ -27885,6 +27885,9 @@ printf "%s\n" "$TEST_MODULES" >&6; }
|
||||||
# libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
|
# libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
|
||||||
# compiler flags.
|
# compiler flags.
|
||||||
#
|
#
|
||||||
|
# gh-112779: On RISC-V, GCC 12 and earlier require libatomic support for 1-byte
|
||||||
|
# and 2-byte operations, but not for 8-byte operations.
|
||||||
|
#
|
||||||
# Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
|
# Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
|
||||||
# requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
|
# requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
|
||||||
# If the check is done after AC_OUTPUT, modifying LIBS has no effect
|
# If the check is done after AC_OUTPUT, modifying LIBS has no effect
|
||||||
|
@ -27924,12 +27927,19 @@ typedef intptr_t Py_ssize_t;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
uint64_t byte;
|
uint64_t value;
|
||||||
_Py_atomic_store_uint64(&byte, 2);
|
_Py_atomic_store_uint64(&value, 2);
|
||||||
if (_Py_atomic_or_uint64(&byte, 8) != 2) {
|
if (_Py_atomic_or_uint64(&value, 8) != 2) {
|
||||||
return 1; // error
|
return 1; // error
|
||||||
}
|
}
|
||||||
if (_Py_atomic_load_uint64(&byte) != 10) {
|
if (_Py_atomic_load_uint64(&value) != 10) {
|
||||||
|
return 1; // error
|
||||||
|
}
|
||||||
|
uint8_t byte = 0xb8;
|
||||||
|
if (_Py_atomic_or_uint8(&byte, 0x2d) != 0xb8) {
|
||||||
|
return 1; // error
|
||||||
|
}
|
||||||
|
if (_Py_atomic_load_uint8(&byte) != 0xbd) {
|
||||||
return 1; // error
|
return 1; // error
|
||||||
}
|
}
|
||||||
return 0; // all good
|
return 0; // all good
|
||||||
|
|
18
configure.ac
18
configure.ac
|
@ -7023,6 +7023,9 @@ AC_SUBST([TEST_MODULES])
|
||||||
# libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
|
# libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
|
||||||
# compiler flags.
|
# compiler flags.
|
||||||
#
|
#
|
||||||
|
# gh-112779: On RISC-V, GCC 12 and earlier require libatomic support for 1-byte
|
||||||
|
# and 2-byte operations, but not for 8-byte operations.
|
||||||
|
#
|
||||||
# Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
|
# Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
|
||||||
# requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
|
# requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
|
||||||
# If the check is done after AC_OUTPUT, modifying LIBS has no effect
|
# If the check is done after AC_OUTPUT, modifying LIBS has no effect
|
||||||
|
@ -7052,12 +7055,19 @@ typedef intptr_t Py_ssize_t;
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
uint64_t byte;
|
uint64_t value;
|
||||||
_Py_atomic_store_uint64(&byte, 2);
|
_Py_atomic_store_uint64(&value, 2);
|
||||||
if (_Py_atomic_or_uint64(&byte, 8) != 2) {
|
if (_Py_atomic_or_uint64(&value, 8) != 2) {
|
||||||
return 1; // error
|
return 1; // error
|
||||||
}
|
}
|
||||||
if (_Py_atomic_load_uint64(&byte) != 10) {
|
if (_Py_atomic_load_uint64(&value) != 10) {
|
||||||
|
return 1; // error
|
||||||
|
}
|
||||||
|
uint8_t byte = 0xb8;
|
||||||
|
if (_Py_atomic_or_uint8(&byte, 0x2d) != 0xb8) {
|
||||||
|
return 1; // error
|
||||||
|
}
|
||||||
|
if (_Py_atomic_load_uint8(&byte) != 0xbd) {
|
||||||
return 1; // error
|
return 1; // error
|
||||||
}
|
}
|
||||||
return 0; // all good
|
return 0; // all good
|
||||||
|
|
Loading…
Reference in New Issue