Bug 1590676 - Fix build if arm doesn't support NEON r=kjacobs
authorGiulio Benetti <giulio.benetti@benettiengineering.com>
Wed, 30 Oct 2019 08:23:07 -0700
changeset 15364 58f2471ace3b33d8a055b9e37921da8b960136e3
parent 15363 6e5f69781137312510b83507b1bfc546f20de55e
child 15365 dbba7db4b79d43ff5e2e655f7a978eb5e43d6458
push id3559
push userjjones@mozilla.com
push dateWed, 30 Oct 2019 21:03:23 +0000
reviewerskjacobs
bugs1590676
Bug 1590676 - Fix build if arm doesn't support NEON r=kjacobs At the moment NSS assumes that ARM supports NEON extension but this is not true and leads to build failure on ARM without NEON extension. Add check to assure USE_HW_AES is not defined if ARM without NEON extension is used.
lib/freebl/aes-armv8.c
lib/freebl/rijndael.c
--- a/lib/freebl/aes-armv8.c
+++ b/lib/freebl/aes-armv8.c
@@ -1,18 +1,19 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "secerr.h"
 #include "rijndael.h"
 
-#if (defined(__clang__) ||                            \
-     (defined(__GNUC__) && defined(__GNUC_MINOR__) && \
-      (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8))))
+#if ((defined(__clang__) ||                                         \
+      (defined(__GNUC__) && defined(__GNUC_MINOR__) &&              \
+       (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 8)))) && \
+     (defined(__ARM_NEON) || defined(__ARM_NEON__)))
 
 #ifndef __ARM_FEATURE_CRYPTO
 #error "Compiler option is invalid"
 #endif
 
 #include <arm_neon.h>
 
 SECStatus
--- a/lib/freebl/rijndael.c
+++ b/lib/freebl/rijndael.c
@@ -15,17 +15,18 @@
 #include "blapi.h"
 #include "rijndael.h"
 
 #include "cts.h"
 #include "ctr.h"
 #include "gcm.h"
 #include "mpi.h"
 
-#if !defined(IS_LITTLE_ENDIAN) && !defined(NSS_X86_OR_X64)
+#if (!defined(IS_LITTLE_ENDIAN) && !defined(NSS_X86_OR_X64)) || \
+    (defined(__arm__) && !defined(__ARM_NEON) && !defined(__ARM_NEON__))
 // not test yet on big endian platform of arm
 #undef USE_HW_AES
 #endif
 
 #ifdef USE_HW_AES
 #ifdef NSS_X86_OR_X64
 #include "intel-aes.h"
 #else