diff options
-rw-r--r-- | core/cortex-m0/__builtin.c | 16 | ||||
-rw-r--r-- | core/cortex-m0/build.mk | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/core/cortex-m0/__builtin.c b/core/cortex-m0/__builtin.c new file mode 100644 index 0000000000..4bf495a011 --- /dev/null +++ b/core/cortex-m0/__builtin.c @@ -0,0 +1,16 @@ +/* Copyright 2019 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 __keep __ffssi2(int x) +{ + return 32 - __builtin_clz(x & -x); +} diff --git a/core/cortex-m0/build.mk b/core/cortex-m0/build.mk index f199b09361..a314976bce 100644 --- a/core/cortex-m0/build.mk +++ b/core/cortex-m0/build.mk @@ -21,7 +21,7 @@ LDFLAGS_EXTRA+=-flto endif core-y=cpu.o init.o thumb_case.o div.o lmul.o ldivmod.o mula.o uldivmod.o -core-y+=vecttable.o +core-y+=vecttable.o __builtin.o core-$(CONFIG_COMMON_PANIC_OUTPUT)+=panic.o core-$(CONFIG_COMMON_RUNTIME)+=switch.o task.o |