]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Work around lameness in older ppc assemblers.
authorJulian Seward <jseward@acm.org>
Sun, 12 Mar 2006 16:47:10 +0000 (16:47 +0000)
committerJulian Seward <jseward@acm.org>
Sun, 12 Mar 2006 16:47:10 +0000 (16:47 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@5757

configure.in
none/tests/ppc32/mftocrf.c

index 318f9e4eaed535fa41690412066a41f57a9e80de..e1dfab894ee5de60ea6a21a99556349e07216358 100644 (file)
@@ -545,6 +545,7 @@ if test x$declaration_after_statement = xyes; then
   CFLAGS="$CFLAGS -Wdeclaration-after-statement"
 fi
 
+
 # does this compiler support __builtin_expect?
 AC_MSG_CHECKING([if gcc supports __builtin_expect])
  
@@ -563,6 +564,25 @@ if test x$ac_have_builtin_expect = xyes ; then
 fi
 
 
+# does the ppc assembler support "mtocrf" et al?
+AC_MSG_CHECKING([if ppc32/64 as supports mtocrf/mfocrf])
+
+AC_TRY_COMPILE(, [
+__asm__ __volatile__("mtocrf 0,0");
+__asm__ __volatile__("mfocrf 0,0");
+],
+[
+ac_have_as_ppc_mftocrf=yes
+AC_MSG_RESULT([yes])
+], [
+ac_have_as_ppc_mftocrf=no
+AC_MSG_RESULT([no])
+])
+if test x$ac_have_as_ppc_mftocrf = xyes ; then
+  AC_DEFINE(HAVE_AS_PPC_MFTOCRF, 1, [Define to 1 if as supports mtocrf/mfocrf.])
+fi
+
+
 # Check for TLS support in the compiler and linker
 AC_CACHE_CHECK([for TLS support], vg_cv_tls,
               [AC_ARG_ENABLE(tls, [  --enable-tls            platform supports TLS],
index 099fbdfdbdb0281f3b84a5cd13552b41f97f798f..916b9ada7354a1ab4e7a4023509c17f71e8076d0 100644 (file)
@@ -1,12 +1,13 @@
 
 #include <stdio.h>
+#include <config.h>
 
 static
 int try_mtocrf ( int x )
 {
   int base = 0x31415927;
   int res;
-
+#ifdef HAVE_AS_PPC_MFTOCRF
   /* pre-set CR */
   __asm__ __volatile__(
      "mtcr %0"
@@ -21,7 +22,9 @@ int try_mtocrf ( int x )
   __asm__ __volatile__(
      "mfcr %0"
      : /*w*/"=b"(res) : /*r*/ );
-
+#else
+  res = 42;
+#endif
   return res;
 }
 
@@ -29,6 +32,7 @@ static
 int try_mfocrf ( int x ) 
 {
    int res;
+#ifdef HAVE_AS_PPC_MFTOCRF
    /* CR = x */
    __asm__ __volatile__(
      "mtcr %0"
@@ -39,7 +43,9 @@ int try_mfocrf ( int x )
      "li %0,0\n\t"
      "mfocrf %0,64"
      : /*w*/"=b"(res) : /*r*/ );
-
+#else
+  res = 42;
+#endif
   return res;
 }