mirror of
https://git.musl-libc.org/git/musl
synced 2025-01-24 15:12:04 +03:00
add fallback a_clz_32 implementation
some archs already have a_clz_32, used to provide a_ctz_32, but it hasn't been mandatory because it's not used anywhere yet. mallocng will need it, however, so add it now. it should probably be optimized better, but doesn't seem to make a difference at present.
This commit is contained in:
parent
1fc67fc117
commit
ca36573ecf
@ -315,4 +315,19 @@ static inline int a_clz_64(uint64_t x)
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef a_clz_32
|
||||
#define a_clz_32 a_clz_32
|
||||
static inline int a_clz_32(uint32_t x)
|
||||
{
|
||||
x--;
|
||||
x |= x >> 1;
|
||||
x |= x >> 2;
|
||||
x |= x >> 4;
|
||||
x |= x >> 8;
|
||||
x |= x >> 16;
|
||||
x++;
|
||||
return 31-a_ctz_32(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user