summary refs log tree commit diff
path: root/sysdeps/sparc/sparc32/configure
diff options
context:
space:
mode:
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-11-12 19:11:10 +0000
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2019-11-27 10:31:13 -0300
commit3b5ebe85aabfa44583a18a7ef51bc4d387e362c1 (patch)
tree8853a1bcbe48f93c1e696ae89e503922845c6e8c /sysdeps/sparc/sparc32/configure
parent5d9b7b9fa734c5381e0295c85c0e40520d9f6063 (diff)
downloadglibc-3b5ebe85aabfa44583a18a7ef51bc4d387e362c1.tar.gz
glibc-3b5ebe85aabfa44583a18a7ef51bc4d387e362c1.tar.xz
glibc-3b5ebe85aabfa44583a18a7ef51bc4d387e362c1.zip
sparc: Use atomic compiler builtins on sparc
This patch removes the arch-specific atomic instruction, relying on
compiler builtins.  The __sparc32_atomic_locks support is removed
and a configure check is added to check if compiler uses libatomic
to implement CAS.

It also removes the sparc specific sem_* and pthread_barrier_*
implementations.  It in turn allows buidling against a LEON3/LEON4
sparcv8 target, although it will still be incompatible with generic
sparcv9.

Checked on sparcv9-linux-gnu and sparc64-linux-gnu.  I also checked
with build against sparcv8-linux-gnu with -mcpu=leon3.

Tested-by: Andreas Larsson <andreas@gaisler.com>
Diffstat (limited to 'sysdeps/sparc/sparc32/configure')
-rw-r--r--sysdeps/sparc/sparc32/configure35
1 files changed, 35 insertions, 0 deletions
diff --git a/sysdeps/sparc/sparc32/configure b/sysdeps/sparc/sparc32/configure
index d7f16b1de0..b6ec0e7d8f 100644
--- a/sysdeps/sparc/sparc32/configure
+++ b/sysdeps/sparc/sparc32/configure
@@ -160,3 +160,38 @@ $as_echo "$libc_cv_sparcv8" >&6; }
 if test $libc_cv_sparcv8 = no; then
   as_fn_error $? "no support for pre-v8 sparc" "$LINENO" 5
 fi
+
+# Test if compiler generates external calls to libatomic for CAS operation.
+# It is suffice to check for int only and the test is similar of C11
+# atomic_compare_exchange_strong using GCC builtins.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for external libatomic calls" >&5
+$as_echo_n "checking for external libatomic calls... " >&6; }
+if ${libc_cv_cas_uses_libatomic+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+	       _Bool foo (int *ptr, int *expected, int desired)
+	       {
+		 return __atomic_compare_exchange_n (ptr, expected, desired, 0,
+						     __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST);
+	       }
+EOF
+	       libc_cv_cas_uses_libatomic=no
+	       if { ac_try='${CC-cc} -S conftest.c -o conftest.s 1>&5'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+		 if grep '__atomic_compare_exchange_4' conftest.s >/dev/null; then
+		   libc_cv_cas_uses_libatomic=yes
+		 fi
+	       fi
+	       rm -f conftest.c conftest.s
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cas_uses_libatomic" >&5
+$as_echo "$libc_cv_cas_uses_libatomic" >&6; }
+if test $libc_cv_cas_uses_libatomic = yes; then
+  as_fn_error $? "external dependency of libatomic is not supported" "$LINENO" 5
+fi