summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-06-25 18:53:22 +0200
committerMarge Bot <ben+marge-bot@smart-cactus.org>2019-06-27 23:58:37 -0400
commit4ec233ecfc7f061c19d0c5ef98ad05719b1161e7 (patch)
treed1cd86a4564768f0c13df4e5631284c1785f6a11
parent217258d0dfef5f0d9844055e5c62077f3a4eb340 (diff)
downloadhaskell-4ec233ecfc7f061c19d0c5ef98ad05719b1161e7.tar.gz
Fix GCC warnings with __clear_cache builtin (#16867)
-rw-r--r--rts/sm/Storage.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/rts/sm/Storage.c b/rts/sm/Storage.c
index f889e2262b..2e03b77695 100644
--- a/rts/sm/Storage.c
+++ b/rts/sm/Storage.c
@@ -1363,13 +1363,18 @@ StgWord calcTotalCompactW (void)
#include <libkern/OSCacheControl.h>
#endif
+/* __builtin___clear_cache is supported since GNU C 4.3.6.
+ * We pick 4.4 to simplify condition a bit.
+ */
+#define GCC_HAS_BUILTIN_CLEAR_CACHE (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4))
+
#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__)
+#elif defined(__GNUC__) && !GCC_HAS_BUILTIN_CLEAR_CACHE
/* __clear_cache is a libgcc function.
* It existed before __builtin___clear_cache was introduced.
* See #8562.
@@ -1397,15 +1402,12 @@ void flushExec (W_ len, AdjustorExecutable exec_addr)
__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.
- */
-# if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)
+# if GCC_HAS_BUILTIN_CLEAR_CACHE
__builtin___clear_cache((void*)begin, (void*)end);
# else
+ /* For all other platforms, fall back to a libgcc builtin. */
__clear_cache((void*)begin, (void*)end);
# endif
#else