summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLonnie Abelbeck <lonnie@abelbeck.com>2022-05-08 14:05:56 -0500
committerTormod Volden <debian.tormod@gmail.com>2022-06-26 17:09:14 +0200
commit95e601ce116dd46ea7915c171976b85ea0905d58 (patch)
tree76fb50434456b0b2d15ac01495882e7d4e57866d
parent0c09ba6dafd4da2f803743c5b344b195b1338077 (diff)
downloadlibusb-95e601ce116dd46ea7915c171976b85ea0905d58.tar.gz
configure.ac: Link with -latomic only if no atomic builtins
Follow-up to 561dbda, a check of GCC atomic builtins needs to be done first. I'm no autoconf guru, but using this: https://github.com/mesa3d/mesa/blob/0df485c285b73c34ba9062f0c27e55c3c702930d/configure.ac#L469 as inspiration, I created a pre-check before calling AC_SEARCH_LIBS(...) Fixes #1135 Closes #1139
-rw-r--r--configure.ac16
-rw-r--r--libusb/version_nano.h2
2 files changed, 16 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 968cdb7..bf423d1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -153,7 +153,21 @@ if test "x$platform" = xposix; then
AC_SEARCH_LIBS([pthread_create], [pthread],
[test "x$ac_cv_search_pthread_create" != "xnone required" && AC_SUBST(THREAD_LIBS, [-lpthread])],
[], [])
- AC_SEARCH_LIBS([__atomic_fetch_add_4], [atomic])
+ dnl Check for new-style atomic builtins. We first check without linking to -latomic.
+ AC_MSG_CHECKING(whether __atomic_load_n is supported)
+ AC_LINK_IFELSE([AC_LANG_SOURCE([[
+ #include <stdint.h>
+ int main() {
+ struct {
+ uint64_t *v;
+ } x;
+ return (int)__atomic_load_n(x.v, __ATOMIC_ACQUIRE) &
+ (int)__atomic_add_fetch(x.v, (uint64_t)1, __ATOMIC_ACQ_REL);
+ }]])], GCC_ATOMIC_BUILTINS_SUPPORTED=yes, GCC_ATOMIC_BUILTINS_SUPPORTED=no)
+ AC_MSG_RESULT($GCC_ATOMIC_BUILTINS_SUPPORTED)
+ if test "x$GCC_ATOMIC_BUILTINS_SUPPORTED" != xyes; then
+ AC_SEARCH_LIBS([__atomic_fetch_add_4], [atomic])
+ fi
elif test "x$platform" = xwindows; then
AC_DEFINE([PLATFORM_WINDOWS], [1], [Define to 1 if compiling for a Windows platform.])
else
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 80f51e2..f5bc7d1 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11733
+#define LIBUSB_NANO 11734