summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDino Li <Dino.Li@ite.com.tw>2017-10-25 17:25:18 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-10-26 02:33:46 -0700
commit54034c0b8a6a96bc05d7d801b11b0fbc061cf037 (patch)
treed7ac4b638cd5e99b76c7492b27379ae1f9807dfb
parenta412a69bd2e91a4fa0981ffa61c06627e1cb9e0b (diff)
downloadchrome-ec-54034c0b8a6a96bc05d7d801b11b0fbc061cf037.tar.gz
nds32: add built-in function
A built-in function (__builtin_ffs) is missing after we sync down the source code to latest. Signed-off-by: Dino Li <dino.li@ite.com.tw> BRANCH=none BUG=none TEST=We use the CL:730246 to verify this change, and no error was received after running the test. Change-Id: I5210f85db05650545c9924940e8b24e350b82f71 Reviewed-on: https://chromium-review.googlesource.com/730245 Commit-Ready: Dino Li <Dino.Li@ite.com.tw> Tested-by: Dino Li <Dino.Li@ite.com.tw> Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r--core/nds32/__builtin.c16
-rw-r--r--core/nds32/build.mk2
2 files changed, 17 insertions, 1 deletions
diff --git a/core/nds32/__builtin.c b/core/nds32/__builtin.c
new file mode 100644
index 0000000000..45baa59aff
--- /dev/null
+++ b/core/nds32/__builtin.c
@@ -0,0 +1,16 @@
+/* Copyright 2017 The Chromium OS Authors. All rights reserved.
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+
+#include "common.h"
+
+/*
+ * __builtin_ffs:
+ * Returns one plus the index of the least significant 1-bit of x,
+ * or if x is zero, returns zero.
+ */
+int __ffssi2(int x)
+{
+ return 32 - __builtin_clz(x & -x);
+}
diff --git a/core/nds32/build.mk b/core/nds32/build.mk
index 5b87d85b15..523ac5300c 100644
--- a/core/nds32/build.mk
+++ b/core/nds32/build.mk
@@ -12,5 +12,5 @@ $(call set-option,CROSS_COMPILE,$(CROSS_COMPILE_nds32),nds32le-cros-elf-)
# CPU specific compilation flags
CFLAGS_CPU+=-march=v3m -Os
-core-y=cpu.o init.o panic.o task.o switch.o __muldi3.o math.o
+core-y=cpu.o init.o panic.o task.o switch.o __muldi3.o math.o __builtin.o
core-$(CONFIG_FPU)+=__libsoftfpu.o