summaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-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