Make the SysV gates for fiat assembly more consistent

__GNUC__ is not a great proxy for SysV because that's about the compiler
features. E.g. someone might be building on MinGW. (MinGW is not
currently tested or supported.) The assembly files all use __APPLE__ ||
__ELF__, so match that.

Also use our OPENSSL_X86_64 abstraction since that's what the assembly
uses.

Change-Id: Id8606791a2c316a6af40641c7028167fb6ad4452
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/97047
Commit-Queue: Adam Langley <agl@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
Reviewed-by: Adam Langley <agl@google.com>
diff --git a/crypto/curve25519/internal.h b/crypto/curve25519/internal.h
index c3bc6fe..ecaecb9 100644
--- a/crypto/curve25519/internal.h
+++ b/crypto/curve25519/internal.h
@@ -30,7 +30,7 @@
 #endif
 
 #if !defined(OPENSSL_NO_ASM) && !defined(OPENSSL_SMALL) && \
-    defined(__GNUC__) && defined(__x86_64__) && !defined(OPENSSL_WINDOWS)
+    (defined(__APPLE__) || defined(__ELF__)) && defined(OPENSSL_X86_64)
 #define BORINGSSL_FE25519_ADX
 
 // fiat_curve25519_adx_mul is defined in
diff --git a/crypto/fipsmodule/ec/p256_internal.h b/crypto/fipsmodule/ec/p256_internal.h
index 91fb28a..336931f 100644
--- a/crypto/fipsmodule/ec/p256_internal.h
+++ b/crypto/fipsmodule/ec/p256_internal.h
@@ -49,12 +49,12 @@
 #endif
 
 extern "C" {
-#if !defined(OPENSSL_NO_ASM) && defined(__GNUC__) && \
+#if !defined(OPENSSL_NO_ASM) && (defined(__ELF__) || defined(__APPLE__)) && \
     defined(OPENSSL_X86_64) && !defined(OPENSSL_NANOLIBC)
-// These functions are only available with gas and SysV ABI, so limit to
-// __GNUC__. Unlike most of our SysV assembly, they currently rely on the SysV
-// redzone. This trips one target which looks like it targets SysV but has no
-// redzone. This happens to define `OPENSSL_NANOLIBC`, so gate on that.
+// These functions are only available with gas and SysV ABI, used by Apple and
+// ELF-based platforms. Unlike most of our SysV assembly, they currently rely on
+// the SysV redzone. This trips one target which looks like it targets SysV but
+// has no redzone. This happens to define `OPENSSL_NANOLIBC`, so gate on that.
 //
 // TODO(crbug.com/522255483): Come up with a clearer story for the redzone
 // situation.