summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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