about summary refs log tree commit diff
path: root/src/internal
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2020-07-05 13:49:55 -0400
committerRich Felker <dalias@aerifal.cx>2020-07-05 13:51:50 -0400
commit0a005f499cf39822166dd4db3d2d31f0639f1b1b (patch)
tree685e6646f2b13b18a45fab6e71dfc2a29fa9935d /src/internal
parenta62df9c9b7cad47e62b293abeddaf3fcdf09d8ae (diff)
downloadmusl-0a005f499cf39822166dd4db3d2d31f0639f1b1b.tar.gz
musl-0a005f499cf39822166dd4db3d2d31f0639f1b1b.tar.xz
musl-0a005f499cf39822166dd4db3d2d31f0639f1b1b.zip
fix C implementation of a_clz_32
this broke mallocng size_to_class on archs without a native
implementation of a_clz_32. the incorrect logic seems to have been
something i derived from a related but distinct log2-type operation.
with the change made here, it passes an exhaustive test.

as this function is new and presently only used by mallocng, no other
functionality was affected.
Diffstat (limited to 'src/internal')
-rw-r--r--src/internal/atomic.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/internal/atomic.h b/src/internal/atomic.h
index 99539cc0..96c1552d 100644
--- a/src/internal/atomic.h
+++ b/src/internal/atomic.h
@@ -319,7 +319,7 @@ static inline int a_clz_64(uint64_t x)
 #define a_clz_32 a_clz_32
 static inline int a_clz_32(uint32_t x)
 {
-	x--;
+	x >>= 1;
 	x |= x >> 1;
 	x |= x >> 2;
 	x |= x >> 4;