Only #define __builtin_prefetch if it doesn't exist. aom's check for conditionally defining __builtin_prefetch is broken, since clang-cl defines __builtin_prefetch on Win ARM64: in addition, it supports up to 3 arguments, with the latter 2 being optional. This causes build breaks when paired with other libraries, like Abseil, which do perform the conditional test correctly. The real fix here is to define something like AOM_PREFETCH rather than trying to #define an implementation-reserved name, which is undefined behavior. Bug: chromium:328105513 Change-Id: I77711d758fde058eef4e4b09dca73b6d19e4a88f
diff --git a/aom_ports/mem.h b/aom_ports/mem.h index a70ce82..7718006 100644 --- a/aom_ports/mem.h +++ b/aom_ports/mem.h
@@ -24,7 +24,13 @@ #define DECLARE_ALIGNED(n, typ, val) typ val #endif -#if HAVE_NEON && defined(_MSC_VER) +#if defined(__has_builtin) +#define AOM_HAS_BUILTIN(x) __has_builtin(x) +#else +#define AOM_HAS_BUILTIN(x) 0 +#endif + +#if !AOM_HAS_BUILTIN(__builtin_prefetch) && !defined(__GNUC__) #define __builtin_prefetch(x) #endif