Add a macro GCC_VERSION and use it to control code paths.
Code paths that work on lower version of GCC are required because
Mac OS will never move beyond GCC 4.2. I added the code paths so
that Mac builds can pass.
Change-Id: I4a3340355133dff4a5107b94970bc809d9de264e
diff --git a/src/common_test.h b/src/common_test.h
index 396cda5..c89527c 100644
--- a/src/common_test.h
+++ b/src/common_test.h
@@ -173,8 +173,16 @@
uintptr_t limit = RoundUp(data + code_length, kPageSize);
uintptr_t len = limit - base;
int result = mprotect(reinterpret_cast<void*>(base), len, PROT_READ | PROT_WRITE | PROT_EXEC);
+
// Flush instruction cache
+ // Only uses __builtin___clear_cache if GCC >= 4.3.3
+#if GCC_VERSION >= 40303
__builtin___clear_cache(reinterpret_cast<void*>(base), reinterpret_cast<void*>(base + len));
+#else
+ // Currently, only Mac OS builds use GCC 4.2.*. Those host builds do not
+ // need to generate clear_cache on x86.
+#endif
+
CHECK_EQ(result, 0);
}