]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Make regtests build on arm-linux -- all changes are to do with
authorJulian Seward <jseward@acm.org>
Sat, 2 Jan 2010 10:43:23 +0000 (10:43 +0000)
committerJulian Seward <jseward@acm.org>
Sat, 2 Jan 2010 10:43:23 +0000 (10:43 +0000)
assembly code for atomic memory modifications.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@10991

helgrind/tests/Makefile.am
helgrind/tests/annotate_hbefore.c
helgrind/tests/tc07_hbl1.c
helgrind/tests/tc08_hbl2.c
helgrind/tests/tc11_XCHG.c

index a56bc3c0c8f68ef470b7188dcf45a792b82e258c..ff8bcb3e31fbbca0c8c1ecfcc3fcfc864a2c4c20 100644 (file)
@@ -129,6 +129,16 @@ if ! VGCONF_PLATFORMS_INCLUDE_X86_DARWIN
        tc22_exit_w_lock
 endif
 
+if VGCONF_PLATFORMS_INCLUDE_ARM_LINUX
+annotate_hbefore_CFLAGS = $(AM_CFLAGS) -mcpu=cortex-a8
+tc07_hbl1_CFLAGS        = $(AM_CFLAGS) -mcpu=cortex-a8
+tc08_hbl2_CFLAGS        = $(AM_CFLAGS) -mcpu=cortex-a8
+else
+annotate_hbefore_CFLAGS = $(AM_CFLAGS)
+tc07_hbl1_CFLAGS        = $(AM_CFLAGS)
+tc08_hbl2_CFLAGS        = $(AM_CFLAGS)
+endif
+
 if HAVE_PTHREAD_BARRIER
 check_PROGRAMS += bar_bad bar_trivial
 endif
index 2df2982315807ef7730510d2ba4656c1317eac2e..33aa67cc29dcd8483c97740fc85a0770d41f1c83 100644 (file)
@@ -132,6 +132,39 @@ UWord do_acasW ( UWord* addr, UWord expected, UWord nyu )
    return block[3] & 1;
 }
 
+#elif defined(VGA_arm)
+
+// arm
+/* return 1 if success, 0 if failure */
+UWord do_acasW ( UWord* addr, UWord expected, UWord nyu )
+{
+  UWord old, success;
+  UWord block[2] = { (UWord)addr, nyu };
+
+  /* Fetch the old value, and set the reservation */
+  __asm__ __volatile__ (
+     "ldrex  %0, [%1]"    "\n"
+      : /*out*/   "=r"(old)
+      : /*in*/    "r"(addr)
+   );
+
+   /* If the old value isn't as expected, we've had it */
+   if (old != expected) return 0;
+
+   /* otherwise try to stuff the new value in */
+   __asm__ __volatile__(
+      "ldr    r4, [%1, #0]"      "\n\t"
+      "ldr    r5, [%1, #4]"      "\n\t"
+      "strex  r6, r5, [r4, #0]"  "\n\t"
+      "eor    %0, r6, #1"        "\n\t"
+      : /*out*/ "=r"(success)
+      : /*in*/ "r"(&block[0])
+      : /*trash*/ "r4","r5","r6","memory"
+   );
+   assert(success == 0 || success == 1);
+   return success;
+}
+
 #endif
 
 void atomic_incW ( UWord* w )
index 12253aa21a29fb68ad10a635e2bb7787aecd60df..2dc9b444b7b6ef907c5f2997d517c679670236fd 100644 (file)
@@ -6,25 +6,34 @@
 /* Simple test program, no race.  Parent and child both modify x and
    use the hardware bus lock. */
 
+#undef PLAT_ppc64_aix5
+#undef PLAT_ppc32_aix5
+#undef PLAT_x86_darwin
+#undef PLAT_amd64_darwin
 #undef PLAT_x86_linux
 #undef PLAT_amd64_linux
 #undef PLAT_ppc32_linux
 #undef PLAT_ppc64_linux
-#undef PLAT_ppc32_aix5
-#undef PLAT_ppc64_aix5
+#undef PLAT_arm_linux
 
-#if !defined(_AIX) && defined(__i386__)
+#if defined(_AIX) && defined(__64BIT__)
+#  define PLAT_ppc64_aix5 1
+#elif defined(_AIX) && !defined(__64BIT__)
+#  define PLAT_ppc32_aix5 1
+#elif defined(__APPLE__) && defined(__i386__)
+#  define PLAT_x86_darwin 1
+#elif defined(__APPLE__) && defined(__x86_64__)
+#  define PLAT_amd64_darwin 1
+#elif defined(__linux__) && defined(__i386__)
 #  define PLAT_x86_linux 1
-#elif !defined(_AIX) && defined(__x86_64__)
+#elif defined(__linux__) && defined(__x86_64__)
 #  define PLAT_amd64_linux 1
-#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__)
+#elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
 #  define PLAT_ppc32_linux 1
-#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__)
+#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__)
 #  define PLAT_ppc64_linux 1
-#elif defined(_AIX) && defined(__64BIT__)
-#  define PLAT_ppc64_aix5 1
-#elif defined(_AIX) && !defined(__64BIT__)
-#  define PLAT_ppc32_aix5 1
+#elif defined(__linux__) && defined(__arm__)
+#  define PLAT_arm_linux 1
 #endif
 
 #if defined(PLAT_amd64_linux) || defined(PLAT_x86_linux)
       : /*out*/ : /*in*/ "b"(&(_lval))    \
       : /*trash*/ "r15", "cr0", "memory"  \
    )
+#elif defined(PLAT_arm_linux)
+#  define INC(_lval,_lqual) \
+  __asm__ __volatile__( \
+      "L1xyzzy1" _lqual ":\n"                \
+      "        ldrex r8, [%0, #0]\n"         \
+      "        add   r8, r8, #1\n"           \
+      "        strex r9, r8, [%0, #0]\n"     \
+      "        cmp   r9, #0\n"               \
+      "        bne L1xyzzy1" _lqual          \
+      : /*out*/ : /*in*/ "r"(&(_lval))       \
+      : /*trash*/ "r8", "r9", "cc", "memory" \
+  );
 #else
 #  error "Fix Me for this platform"
 #endif
index d67435ab5f69c5e0b505630983f296c4af341069..e6741670035c9b2a47f2fbdd0fdbcd8f1bc46ee0 100644 (file)
    child joins back to parent.  Parent (writer) uses hardware bus lock;
    child is only reading and so does not need to use a bus lock. */
 
-
+#undef PLAT_ppc64_aix5
+#undef PLAT_ppc32_aix5
+#undef PLAT_x86_darwin
+#undef PLAT_amd64_darwin
 #undef PLAT_x86_linux
 #undef PLAT_amd64_linux
 #undef PLAT_ppc32_linux
 #undef PLAT_ppc64_linux
-#undef PLAT_ppc32_aix5
-#undef PLAT_ppc64_aix5
+#undef PLAT_arm_linux
 
-#if !defined(_AIX) && defined(__i386__)
+#if defined(_AIX) && defined(__64BIT__)
+#  define PLAT_ppc64_aix5 1
+#elif defined(_AIX) && !defined(__64BIT__)
+#  define PLAT_ppc32_aix5 1
+#elif defined(__APPLE__) && defined(__i386__)
+#  define PLAT_x86_darwin 1
+#elif defined(__APPLE__) && defined(__x86_64__)
+#  define PLAT_amd64_darwin 1
+#elif defined(__linux__) && defined(__i386__)
 #  define PLAT_x86_linux 1
-#elif !defined(_AIX) && defined(__x86_64__)
+#elif defined(__linux__) && defined(__x86_64__)
 #  define PLAT_amd64_linux 1
-#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__)
+#elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
 #  define PLAT_ppc32_linux 1
-#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__)
+#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__)
 #  define PLAT_ppc64_linux 1
-#elif defined(_AIX) && defined(__64BIT__)
-#  define PLAT_ppc64_aix5 1
-#elif defined(_AIX) && !defined(__64BIT__)
-#  define PLAT_ppc32_aix5 1
+#elif defined(__linux__) && defined(__arm__)
+#  define PLAT_arm_linux 1
 #endif
 
+
 #if defined(PLAT_amd64_linux) || defined(PLAT_x86_linux)
 #  define INC(_lval,_lqual)         \
       __asm__ __volatile__ ( \
       : /*out*/ : /*in*/ "b"(&(_lval))    \
       : /*trash*/ "r15", "cr0", "memory"  \
    )
+#elif defined(PLAT_arm_linux)
+#  define INC(_lval,_lqual) \
+  __asm__ __volatile__( \
+      "L1xyzzy1" _lqual ":\n"                \
+      "        ldrex r8, [%0, #0]\n"         \
+      "        add   r8, r8, #1\n"           \
+      "        strex r9, r8, [%0, #0]\n"     \
+      "        cmp   r9, #0\n"               \
+      "        bne L1xyzzy1" _lqual          \
+      : /*out*/ : /*in*/ "r"(&(_lval))       \
+      : /*trash*/ "r8", "r9", "cc", "memory" \
+  );
 #else
 #  error "Fix Me for this platform"
 #endif
index 22c6baf355ae934c1777acbecaee10319a3bdb8f..0f60259d9126046ae02a3e74226d49afb7770002 100644 (file)
@@ -9,25 +9,34 @@
    use the hardware bus lock (implicitly, since XCHG r,m on x86/amd64
    does not require an explicit LOCK prefix.). */
 
+#undef PLAT_ppc64_aix5
+#undef PLAT_ppc32_aix5
+#undef PLAT_x86_darwin
+#undef PLAT_amd64_darwin
 #undef PLAT_x86_linux
 #undef PLAT_amd64_linux
 #undef PLAT_ppc32_linux
 #undef PLAT_ppc64_linux
-#undef PLAT_ppc32_aix5
-#undef PLAT_ppc64_aix5
+#undef PLAT_arm_linux
 
-#if !defined(_AIX) && defined(__i386__)
+#if defined(_AIX) && defined(__64BIT__)
+#  define PLAT_ppc64_aix5 1
+#elif defined(_AIX) && !defined(__64BIT__)
+#  define PLAT_ppc32_aix5 1
+#elif defined(__APPLE__) && defined(__i386__)
+#  define PLAT_x86_darwin 1
+#elif defined(__APPLE__) && defined(__x86_64__)
+#  define PLAT_amd64_darwin 1
+#elif defined(__linux__) && defined(__i386__)
 #  define PLAT_x86_linux 1
-#elif !defined(_AIX) && defined(__x86_64__)
+#elif defined(__linux__) && defined(__x86_64__)
 #  define PLAT_amd64_linux 1
-#elif !defined(_AIX) && defined(__powerpc__) && !defined(__powerpc64__)
+#elif defined(__linux__) && defined(__powerpc__) && !defined(__powerpc64__)
 #  define PLAT_ppc32_linux 1
-#elif !defined(_AIX) && defined(__powerpc__) && defined(__powerpc64__)
+#elif defined(__linux__) && defined(__powerpc__) && defined(__powerpc64__)
 #  define PLAT_ppc64_linux 1
-#elif defined(_AIX) && defined(__64BIT__)
-#  define PLAT_ppc64_aix5 1
-#elif defined(_AIX) && !defined(__64BIT__)
-#  define PLAT_ppc32_aix5 1
+#elif defined(__linux__) && defined(__arm__)
+#  define PLAT_arm_linux 1
 #endif
 
 
@@ -48,7 +57,8 @@
      )
 
 #elif defined(PLAT_ppc32_linux) || defined(PLAT_ppc64_linux) \
-      || defined(PLAT_ppc32_aix5) || defined(PLAT_ppc64_aix5)
+      || defined(PLAT_ppc32_aix5) || defined(PLAT_ppc64_aix5) \
+      || defined(PLAT_arm_linux)
 #  if defined(HAVE_BUILTIN_ATOMIC)
 #    define XCHG_M_R(_addr,_lval)                                           \
         do {                                                                \