Skip to content

Commit

Permalink
[FIXUP] __rt_clz loss in aarch64
Browse files Browse the repository at this point in the history
Signed-off-by: GuEe-GUI <[email protected]>
  • Loading branch information
GuEe-GUI committed Dec 12, 2024
1 parent 6541c98 commit 4456beb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
1 change: 1 addition & 0 deletions include/rtthread.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,6 +794,7 @@ rt_device_t rt_console_get_device(void);

int __rt_ffs(int value);
unsigned long __rt_ffsl(unsigned long value);
unsigned long __rt_clz(unsigned long value);

void rt_show_version(void);

Expand Down
15 changes: 15 additions & 0 deletions libcpu/aarch64/common/cpuport.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,19 @@ unsigned long __rt_ffsl(unsigned long value)
#endif
}

unsigned long __rt_clz(unsigned long value)
{
#ifdef __GNUC__
return __builtin_clz(value);
#else
unsigned long val;

__asm__ volatile ("clz %0, %1"
:"=r"(val)
:"r"(value));

return val;
#endif
}

#endif /* RT_USING_CPU_FFS */

0 comments on commit 4456beb

Please sign in to comment.