We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ec4f375 commit 78f318aCopy full SHA for 78f318a
include/rtthread.h
@@ -794,6 +794,7 @@ rt_device_t rt_console_get_device(void);
794
795
int __rt_ffs(int value);
796
unsigned long __rt_ffsl(unsigned long value);
797
+unsigned long __rt_clz(unsigned long value);
798
799
void rt_show_version(void);
800
libcpu/aarch64/common/cpuport.c
@@ -56,4 +56,19 @@ unsigned long __rt_ffsl(unsigned long value)
56
#endif
57
}
58
59
+unsigned long __rt_clz(unsigned long value)
60
+{
61
+#ifdef __GNUC__
62
+ return __builtin_clz(value);
63
+#else
64
+ unsigned long val;
65
+
66
+ __asm__ volatile ("clz %0, %1"
67
+ :"=r"(val)
68
+ :"r"(value));
69
70
+ return val;
71
+#endif
72
+}
73
74
#endif /* RT_USING_CPU_FFS */
0 commit comments