Commit 8706cebc authored by Sylvain Henry's avatar Sylvain Henry Committed by Ben Gamari

Fix GCC warnings with __clear_cache builtin (#16867)

(cherry picked from commit 4ec233ec)
parent 6e255b62
......@@ -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
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment