Compiling on RISC-V (without an explicit -latomic) fails with
/usr/riscv64-linux-gnu/include/c++/10/ostream:611:
undefined reference to __atomic_compare_exchange_1
Use std::atomic<uint8_t>::exchange() to detect whether -latomic
implements 1-byte compare-and-exchange API used by Squid.
Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
#include <atomic>
#include <cstdint>
int
- main(int, char **) {
- return std::atomic<uint64_t>{}.is_lock_free() ? 0 : 1;
+ main(int argc, char **) {
+ return (
+ std::atomic<uint8_t>(uint8_t(argc)).exchange(0) &&
+ std::atomic<uint64_t>{}.is_lock_free()
+ ) ? 0 : 1;
}
]])],[
AC_MSG_RESULT(yes)