Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@google.com>2015-11-18 02:25:00 +0300
committerAdam Langley <agl@google.com>2015-11-19 03:15:11 +0300
commit9e65d487b8b907a3ddb84f736b89e0a8f95abce3 (patch)
tree5dcbac1da33487eab26516278213d721db32c5cc /include/openssl/cpu.h
parent3ac32b1eda0da7a99d9c2b6c605fe50af80ccd90 (diff)
Allow |CRYPTO_is_NEON_capable| to be known at compile time, if possible.
If -mfpu=neon is passed then we don't need to worry about checking for NEON support at run time. This change allows |CRYPTO_is_NEON_capable| to statically return 1 in this case. This then allows the compiler to discard generic code in several cases. Change-Id: I3b229740ea3d5cb0a304f365c400a0996d0c66ef Reviewed-on: https://boringssl-review.googlesource.com/6523 Reviewed-by: David Benjamin <davidben@chromium.org> Reviewed-by: Adam Langley <agl@google.com>
Diffstat (limited to 'include/openssl/cpu.h')
-rw-r--r--include/openssl/cpu.h18
1 files changed, 14 insertions, 4 deletions
diff --git a/include/openssl/cpu.h b/include/openssl/cpu.h
index 19e11d04..e946304a 100644
--- a/include/openssl/cpu.h
+++ b/include/openssl/cpu.h
@@ -102,10 +102,20 @@ extern uint32_t OPENSSL_ia32cap_P[4];
#if !defined(OPENSSL_STATIC_ARMCAP)
-/* CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. Note
- * that |OPENSSL_armcap_P| also exists and contains the same information in a
- * form that's easier for assembly to use. */
-OPENSSL_EXPORT char CRYPTO_is_NEON_capable(void);
+/* CRYPTO_is_NEON_capable_at_runtime returns true if the current CPU has a NEON
+ * unit. Note that |OPENSSL_armcap_P| also exists and contains the same
+ * information in a form that's easier for assembly to use. */
+OPENSSL_EXPORT char CRYPTO_is_NEON_capable_at_runtime(void);
+
+/* CRYPTO_is_NEON_capable returns true if the current CPU has a NEON unit. If
+ * this is known statically then it returns one immediately. */
+static inline int CRYPTO_is_NEON_capable(void) {
+#if defined(__ARM_NEON__)
+ return 1;
+#else
+ return CRYPTO_is_NEON_capable_at_runtime();
+#endif
+}
/* CRYPTO_set_NEON_capable sets the return value of |CRYPTO_is_NEON_capable|.
* By default, unless the code was compiled with |-mfpu=neon|, NEON is assumed