Skip to content
Snippets Groups Projects
Commit 345c7f4e authored by Armin Luntzer's avatar Armin Luntzer
Browse files

add __clzsi2()

parent d5ce2874
Branches
No related tags found
No related merge requests found
......@@ -149,10 +149,9 @@ fpe_trap_handler:
hw_div0_trap_handler:
.global __interrupt_entry
__interrupt_entry:
.global __clzsi2
__clzsi2:
.global memset
memset:
ta 1
.global nmi_entry
nmi_entry:
.global reg_access_trap_handler
......@@ -165,8 +164,6 @@ strtol:
syscall_tbl:
.global syscall_trap
syscall_trap:
.global tag_overflow_trap_handler
tag_overflow_trap_handler:
.global .udiv
.udiv:
.global .umul
......
......@@ -9,3 +9,4 @@ lib-y += elf.o
lib-y += data_proc_tracker.o
lib-y += data_proc_task.o
lib-y += data_proc_net.o
lib-y += libc_bitops.o
// SPDX-License-Identifier: GPL-2.0
/**
* @file lib/libc_bitops.c
*
* @ingroup libc
* @defgroup functions expected by the compiler
*
* @note these can be overridden by linking architecture-specific implementation
*
* @note add as needed
*
* @see https://gcc.gnu.org/onlinedocs/gccint/Integer-library-routines.html
*
*/
#include <kernel/export.h>
/**
* @brief locates the most significant bit set in a word
* @note taken from linux: include/asm-generic/bitops/fls.h
*/
static int fls(int x)
{
int r = 32;
if (!x)
return 0;
if (!(x & 0xffff0000u)) {
x <<= 16;
r -= 16;
}
if (!(x & 0xff000000u)) {
x <<= 8;
r -= 8;
}
if (!(x & 0xf0000000u)) {
x <<= 4;
r -= 4;
}
if (!(x & 0xc0000000u)) {
x <<= 2;
r -= 2;
}
if (!(x & 0x80000000u)) {
x <<= 1;
r -= 1;
}
return r;
}
/**
* @brief returns the number of leading 0-bits in a,
* starting at the most significant bit position.
* If a is zero, the result is undefined.
*/
int __attribute__((weak)) __clzsi2(unsigned int a);
int __attribute__((weak)) __clzsi2(unsigned int a)
{
return 32 - fls(a);
}
EXPORT_SYMBOL(__clzsi2);
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment