aom: Only #define __builtin_prefetch if it doesn't exist.

From 86ba8b684ef53a8bf11e320c2271aaa63108be36 Mon Sep 17 00:00:00 2001
From: Daniel Cheng <[EMAIL REDACTED]>
Date: Mon, 4 Mar 2024 18:06:30 -0800
Subject: [PATCH] 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
---
 aom_ports/mem.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/aom_ports/mem.h b/aom_ports/mem.h
index a70ce825b1..77180068ae 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