diff options
| author | GuEe-GUI <[email protected]> | 2024-05-30 17:30:03 +0800 |
|---|---|---|
| committer | Meco Man <[email protected]> | 2024-09-06 17:45:03 -0400 |
| commit | 802a6ed2caff69a4f881f109462931de4f4f2d40 (patch) | |
| tree | 83ce05609bc81f52076dc68684c83ad05c935761 /libcpu | |
| parent | 9631f04abefdea2341abe8cfe96cbabbdf432ab7 (diff) | |
[DM] Extended drivers MISC interface
1. RT_FIELD_PREP: prepare a bitfield element.
2. RT_FIELD_GET: extract a bitfield element.
3. rt_offsetof: member offset of a struct
4. rt_upper_32_bits: high 32 bits of value.
5. rt_lower_32_bits: lower 32 bits of value.
6. rt_upper_16_bits: high 16 bits of value.
7. rt_lower_16_bits: lower 16 bits of value.
8. rt_max_t: fix type of max(...).
9. rt_ilog2: integer logarithm base 2.
Signed-off-by: GuEe-GUI <[email protected]>
Diffstat (limited to 'libcpu')
| -rw-r--r-- | libcpu/aarch64/common/cpuport.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/libcpu/aarch64/common/cpuport.c b/libcpu/aarch64/common/cpuport.c index 4c1bf01cf3..b2592c854d 100644 --- a/libcpu/aarch64/common/cpuport.c +++ b/libcpu/aarch64/common/cpuport.c @@ -40,4 +40,20 @@ int __rt_ffs(int value) #endif } -#endif /* RT_USING_CPU_FFS */
\ No newline at end of file +unsigned long __rt_ffsl(unsigned long value) +{ +#ifdef __GNUC__ + return __builtin_ffsl(value); +#else + if (!value) + { + return 0; + } + + __asm__ volatile ("rbit %0, %0" : "+r" (value)); + + return __rt_clz(value); +#endif +} + +#endif /* RT_USING_CPU_FFS */ |
