Merge "Move renderscript over to __clear_cache (compiler-rt)."
diff --git a/cpu_ref/linkloader/utils/flush_cpu_cache.h b/cpu_ref/linkloader/utils/flush_cpu_cache.h
index 7a269ed..51dd8e5 100644
--- a/cpu_ref/linkloader/utils/flush_cpu_cache.h
+++ b/cpu_ref/linkloader/utils/flush_cpu_cache.h
@@ -17,36 +17,10 @@
 #ifndef FLUSH_CPU_CACHE_H
 #define FLUSH_CPU_CACHE_H
 
-#if defined(__arm__) || defined(__mips__)
-
-// Note: Though we wish to use the gcc builtin function __clear_cache to
-// invalidate the instruction cache; however, the toolchain of Android
-// has not supported it properly.  We are going to use cacheflush system
-// call to invalidate the instruction cache.
-//
-// As a side note, Dalvik VM use the same system call to invalidate the
-// instruction as well.
-
-#include <unistd.h>
-
-#define FLUSH_CPU_CACHE(BEGIN, END) \
-  cacheflush(((long)(BEGIN)), ((long)(END)), 0)
-
-#if 0 && defined(__mips__)
-
-// Note: Following code does not work with Android Toolchain, though they
-// works while using standalone mips-linux-gnu-gcc.
-
-#include <sys/cachectl.h>
-#define FLUSH_CPU_CACHE(BEGIN, END) \
-  _flush_cache(reinterpret_cast<char*>(BEGIN), END-BEGIN+1, BCACHE);
-
-#endif
-
+#if defined(__arm__) || defined(__aarch64__) || defined(__mips__)
+#define FLUSH_CPU_CACHE(BEGIN, END) __clear_cache((BEGIN), (END))
 #else
-
 #define FLUSH_CPU_CACHE(BEGIN, END) do { } while (0)
-
 #endif
 
 #endif // FLUSH_CPU_CACHE_H
diff --git a/cpu_ref/rsCpuIntrinsicColorMatrix.cpp b/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
index 06bc222..87db9ba 100644
--- a/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
+++ b/cpu_ref/rsCpuIntrinsicColorMatrix.cpp
@@ -20,6 +20,7 @@
 #include "rsCpuIntrinsic.h"
 #include "rsCpuIntrinsicInlines.h"
 #include "linkloader/include/MemChunk.h"
+#include "linkloader/utils/flush_cpu_cache.h"
 
 #include <sys/mman.h>
 #include <stddef.h>
@@ -658,7 +659,7 @@
         return false;
     }
 
-    cacheflush((long)mBuf, (long)mBuf + mBufSize, 0);
+    FLUSH_CPU_CACHE(mBuf, (char*) mBuf + mBufSize);
     return true;
 #else
     return false;