aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorнаб <[email protected]>2021-04-19 07:13:24 +0200
committerGitHub <[email protected]>2021-04-18 22:13:24 -0700
commitfef8bd41fc178d7212957b611c9bc81fe10cb63e (patch)
tree3b3b31ae3fd5f1408f09bf547cb6d99767d6708b /config
parent50d9ff93dfdb5052e0466729d1d2e1e627a56080 (diff)
libspl: implement atomics in terms of atomics
This replaces the generic libspl atomic.c atomics implementation with one based on builtin gcc atomics. This functionality was added as an experimental feature in gcc 4.4. Today even CentOS 7 ships with gcc 4.8 as the default compiler we can make this the default. Furthermore, the builtin atomics are as good or better than our hand-rolled implementation so it's reasonable to drop that custom code. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ahelenia Ziemiańska <[email protected]> Closes #11904
Diffstat (limited to 'config')
-rw-r--r--config/user-libatomic.m434
-rw-r--r--config/user.m41
2 files changed, 35 insertions, 0 deletions
diff --git a/config/user-libatomic.m4 b/config/user-libatomic.m4
new file mode 100644
index 000000000..14a60bbea
--- /dev/null
+++ b/config/user-libatomic.m4
@@ -0,0 +1,34 @@
+dnl #
+dnl # If -latomic exists, it's needed for __atomic intrinsics.
+dnl #
+dnl # Some systems (like FreeBSD 13) don't have a libatomic at all because
+dnl # their toolchain doesn't ship it – they obviously don't need it.
+dnl #
+dnl # Others (like sufficiently ancient CentOS) have one,
+dnl # but terminally broken or unlinkable (e.g. it's a dangling symlink,
+dnl # or a linker script that points to a nonexistent file) –
+dnl # most arches affected by this don't actually need -latomic (and if they do,
+dnl # then they should have libatomic that actually exists and links,
+dnl # so don't fall into this category).
+dnl #
+dnl # Technically, we could check if the platform *actually* needs -latomic,
+dnl # or if it has native support for all the intrinsics we use,
+dnl # but it /really/ doesn't matter, and C11 recommends to always link it.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_USER_LIBATOMIC], [
+ AC_MSG_CHECKING([whether -latomic is present])
+
+ saved_libs="$LIBS"
+ LIBS="$LIBS -latomic"
+
+ AC_LINK_IFELSE([AC_LANG_PROGRAM([], [])], [
+ LIBATOMIC_LIBS="-latomic"
+ AC_MSG_RESULT([yes])
+ ], [
+ LIBATOMIC_LIBS=""
+ AC_MSG_RESULT([no])
+ ])
+
+ LIBS="$saved_libs"
+ AC_SUBST([LIBATOMIC_LIBS])
+])
diff --git a/config/user.m4 b/config/user.m4
index c22067551..e799faffb 100644
--- a/config/user.m4
+++ b/config/user.m4
@@ -21,6 +21,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
ZFS_AC_CONFIG_USER_LIBUDEV
ZFS_AC_CONFIG_USER_LIBCRYPTO
ZFS_AC_CONFIG_USER_LIBAIO
+ ZFS_AC_CONFIG_USER_LIBATOMIC
ZFS_AC_CONFIG_USER_CLOCK_GETTIME
ZFS_AC_CONFIG_USER_PAM
ZFS_AC_CONFIG_USER_RUNSTATEDIR