summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Sukhomlinov <sukhomlinov@google.com>2021-09-07 16:28:26 -0700
committerCommit Bot <commit-bot@chromium.org>2021-09-08 01:46:55 +0000
commit961fed4862bc8acc55530ef11e4da55dcd792738 (patch)
treedb41003013de781b407dfa7d9cbc3ce15be9fa63
parent1c3b00c3f7c0c819c330ddd98812d9085c578230 (diff)
downloadchrome-ec-961fed4862bc8acc55530ef11e4da55dcd792738.tar.gz
cr50: fix make buildall builds
When both https://crrev.com/c/3125994 and https://crrev.com/c/3119223 landed it resulted in broken host build as function attribute optimize("") is not supported by clang. This is happened due as both CLs are relatively independent by nature, but the first one added one of the sources to host build. BUG=none TEST=make buildall -j Signed-off-by: Vadim Sukhomlinov <sukhomlinov@google.com> Change-Id: If1b8425cea418ae42179bef46f6f5998ded3dc1f Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/ec/+/3146223 Reviewed-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Reviewed-by: Vadim Bendebury <vbendeb@chromium.org> Tested-by: Vadim Sukhomlinov <sukhomlinov@chromium.org> Commit-Queue: Vadim Sukhomlinov <sukhomlinov@chromium.org>
-rw-r--r--board/cr50/dcrypto/app_cipher.c4
-rw-r--r--board/cr50/dcrypto/compare.c2
-rw-r--r--board/cr50/dcrypto/internal.h13
3 files changed, 16 insertions, 3 deletions
diff --git a/board/cr50/dcrypto/app_cipher.c b/board/cr50/dcrypto/app_cipher.c
index 811d6feda1..9b7961f209 100644
--- a/board/cr50/dcrypto/app_cipher.c
+++ b/board/cr50/dcrypto/app_cipher.c
@@ -11,8 +11,8 @@
* compiler to optimize for speed here. Incidentally -O produces
* faster code than -O2!
*/
-static int __attribute__((optimize("O")))
-inner_loop(uint32_t **out, const uint32_t **in, size_t len)
+static int __optimize("O") inner_loop(uint32_t **out, const uint32_t **in,
+ size_t len)
{
uint32_t *outw = *out;
const uint32_t *inw = *in;
diff --git a/board/cr50/dcrypto/compare.c b/board/cr50/dcrypto/compare.c
index 09bbd36fd1..494e26617e 100644
--- a/board/cr50/dcrypto/compare.c
+++ b/board/cr50/dcrypto/compare.c
@@ -12,7 +12,7 @@
#define CRYPTO_FAST_COMPARE 0
/* Constant time, hardened comparator. */
-enum dcrypto_result __attribute__((optimize("-O1"))) DCRYPTO_equals(
+enum dcrypto_result __optimize("O1") DCRYPTO_equals(
const void *a, const void *b, size_t len)
{
uintptr_t a_addr = (uintptr_t)a;
diff --git a/board/cr50/dcrypto/internal.h b/board/cr50/dcrypto/internal.h
index fd4fa62f43..6df2df3ef9 100644
--- a/board/cr50/dcrypto/internal.h
+++ b/board/cr50/dcrypto/internal.h
@@ -265,6 +265,19 @@ void *always_memset(void *s, int c, size_t n);
#define __alias(func) __attribute__((alias(#func)))
#endif
+/**
+ * Macro to control optimization at function level. Typically used in
+ * very tight and critical loops to override -Os and get a better code.
+ * Only supported by gcc, so ignore it for clang.
+ */
+#ifndef __optimize
+#ifndef __clang__
+#define __optimize(a) __attribute__((optimize(a)))
+#else
+#define __optimize(a)
+#endif
+#endif
+
/* rotate 32-bit value right */
static inline uint32_t ror(uint32_t value, int bits)
{