Skip to content

Commit d050089

Browse files
colesburyaisk
authored andcommitted
pythongh-112779: Check 1-byte atomics in configure (pythongh-112819)
1 parent 5b66c3b commit d050089

File tree

2 files changed

+28
-8
lines changed

2 files changed

+28
-8
lines changed

configure

+14-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

configure.ac

+14-4
Original file line numberDiff line numberDiff line change
@@ -7023,6 +7023,9 @@ AC_SUBST([TEST_MODULES])
70237023
# libatomic __atomic_fetch_or_8(), or not, depending on the C compiler and the
70247024
# compiler flags.
70257025
#
7026+
# gh-112779: On RISC-V, GCC 12 and earlier require libatomic support for 1-byte
7027+
# and 2-byte operations, but not for 8-byte operations.
7028+
#
70267029
# Avoid #include <Python.h> or #include <pyport.h>. The <Python.h> header
70277030
# requires <pyconfig.h> header which is only written below by AC_OUTPUT below.
70287031
# If the check is done after AC_OUTPUT, modifying LIBS has no effect
@@ -7052,12 +7055,19 @@ typedef intptr_t Py_ssize_t;
70527055
70537056
int main()
70547057
{
7055-
uint64_t byte;
7056-
_Py_atomic_store_uint64(&byte, 2);
7057-
if (_Py_atomic_or_uint64(&byte, 8) != 2) {
7058+
uint64_t value;
7059+
_Py_atomic_store_uint64(&value, 2);
7060+
if (_Py_atomic_or_uint64(&value, 8) != 2) {
7061+
return 1; // error
7062+
}
7063+
if (_Py_atomic_load_uint64(&value) != 10) {
7064+
return 1; // error
7065+
}
7066+
uint8_t byte = 0xb8;
7067+
if (_Py_atomic_or_uint8(&byte, 0x2d) != 0xb8) {
70587068
return 1; // error
70597069
}
7060-
if (_Py_atomic_load_uint64(&byte) != 10) {
7070+
if (_Py_atomic_load_uint8(&byte) != 0xbd) {
70617071
return 1; // error
70627072
}
70637073
return 0; // all good

0 commit comments

Comments
 (0)