]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
mips: flush the cache in perf/bigcode.c
authorPetar Jovanovic <mips32r2@gmail.com>
Sun, 15 Sep 2013 22:16:38 +0000 (22:16 +0000)
committerPetar Jovanovic <mips32r2@gmail.com>
Sun, 15 Sep 2013 22:16:38 +0000 (22:16 +0000)
MIPS needs to flush the cache after memcpy in perf/bigcode.c.
Otherwise, the executed code will likely be wrong.

This fixes issues with bigcode test on some MIPS platforms.

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

perf/bigcode.c

index c36879858be196590ef8333e02eb71574d142757..628cd01dd45f2aa34ce79ac611723b8c43acfbd6 100644 (file)
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
+#if defined(__mips__)
+#include <asm/cachectl.h>
+#include <sys/syscall.h>
+#endif
 #include "tests/sys_mman.h"
 
 #define FN_SIZE   996      // Must be big enough to hold the compiled f()
@@ -58,7 +62,11 @@ int main(int argc, char* argv[])
    for (i = 0; i < n_fns; i++) {
       memcpy(&a[FN_SIZE*i], f, FN_SIZE);
    }
-   
+
+#if defined(__mips__)
+   syscall(__NR_cacheflush, a, FN_SIZE * n_fns, ICACHE);
+#endif
+
    for (h = 0; h < n_reps; h += 1) {
       for (i = 0; i < n_fns; i += 4) {
          int(*f1)(int,int) = (void*)&a[FN_SIZE*(i+0)];