summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSylvain Henry <sylvain@haskus.fr>2019-06-25 18:53:22 +0200
committerBen Gamari <ben@smart-cactus.org>2019-06-30 07:40:34 -0400
commit8706cebc4b97a161c2005af788174e26f7881a73 (patch)
treea88e6b7e0dff7281bdb822c8f5fe491e58ad0aae
parent6e255b62a998632f83cd1ae73b6673b9088694c2 (diff)
downloadhaskell-8706cebc4b97a161c2005af788174e26f7881a73.tar.gz
Fix GCC warnings with __clear_cache builtin (#16867)
(cherry picked from commit 4ec233ecfc7f061c19d0c5ef98ad05719b1161e7)
-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 dcc5b3a3c7..6783818171 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 Trac #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