summaryrefslogtreecommitdiff
path: root/rts/sm
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2017-07-05 08:36:08 +0100
committerSergei Trofimovich <slyfox@gentoo.org>2017-07-05 08:46:00 +0100
commit9492703a5862ee8623455209e50344cf8c4de077 (patch)
treee111f10720040e72f8f3ec03256fc1e745a11f02 /rts/sm
parentfd7a7a6363d8dde1813bc23cb4ef00ebb70a49c0 (diff)
downloadhaskell-9492703a5862ee8623455209e50344cf8c4de077.tar.gz
rts/sm/Storage.c: tweak __clear_cache proto for clang
clang defines '__clear_cache' slightly differently from gcc: rts/sm/Storage.c:1349:13: error: error: conflicting types for '__clear_cache' | 1349 | extern void __clear_cache(char * begin, char * end); | ^ extern void __clear_cache(char * begin, char * end); ^ note: '__clear_cache' is a builtin with type 'void (void *, void *)' Reported by Moritz Angermann. While at it used '__builtin___clear_cache' if advertised by clang. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org>
Diffstat (limited to 'rts/sm')
-rw-r--r--rts/sm/Storage.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index e2435173c1..f518856842 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -1341,7 +1341,13 @@ StgWord calcTotalCompactW (void)
#include <libkern/OSCacheControl.h>
#endif
-#if defined(__GNUC__)
+#if defined(__CLANG__)
+/* clang defines __clear_cache as a builtin on some platforms.
+ * For example on armv7-linux-androideabi. The type slightly
+ * differs from gcc.
+ */
+extern void __clear_cache(void * begin, void * end);
+#elif defined(__GNUC__)
/* __clear_cache is a libgcc function.
* It existed before __builtin___clear_cache was introduced.
* See Trac #8562.
@@ -1360,11 +1366,16 @@ void flushExec (W_ len, AdjustorExecutable exec_addr)
#elif (defined(arm_HOST_ARCH) || defined(aarch64_HOST_ARCH)) && defined(ios_HOST_OS)
/* On iOS we need to use the special 'sys_icache_invalidate' call. */
sys_icache_invalidate(exec_addr, len);
+#elif defined(__CLANG__)
+# if __has_builtin(__builtin___clear_cache)
+ __builtin___clear_cache((void*)begin, (void*)end);
+# else
+ __clear_cache((void*)begin, (void*)end);
+# endif
#elif defined(__GNUC__)
/* For all other platforms, fall back to a libgcc builtin. */
unsigned char* begin = (unsigned char*)exec_addr;
unsigned char* end = begin + len;
-
/* __builtin___clear_cache is supported since GNU C 4.3.6.
* We pick 4.4 to simplify condition a bit.
*/