From: Kefu Chai Date: Sun, 21 Aug 2022 16:42:58 +0000 (+0800) Subject: include/intarith: drop clz() X-Git-Tag: v18.0.0~196^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f4706f95e6e4e0c92610def09eb7b78b726be293;p=ceph.git include/intarith: drop clz() it is not used anymore Signed-off-by: Kefu Chai --- diff --git a/src/include/intarith.h b/src/include/intarith.h index b3d76ecd5305..bb50d79f73a1 100644 --- a/src/include/intarith.h +++ b/src/include/intarith.h @@ -117,40 +117,6 @@ template return __builtin_ctzll(v); } -// count leading zeros -// NOTE: the builtin is nondeterministic on 0 input -template - inline typename std::enable_if< - (std::is_integral::value && - sizeof(T) <= sizeof(unsigned)), - unsigned>::type clz(T v) { - if (v == 0) - return sizeof(v) * 8; - return __builtin_clz(v); -} - -template - inline typename std::enable_if< - (std::is_integral::value && - sizeof(T) > sizeof(unsigned int) && - sizeof(T) <= sizeof(unsigned long)), - unsigned>::type clz(T v) { - if (v == 0) - return sizeof(v) * 8; - return __builtin_clzl(v); -} - -template - inline typename std::enable_if< - (std::is_integral::value && - sizeof(T) > sizeof(unsigned long) && - sizeof(T) <= sizeof(unsigned long long)), - unsigned>::type clz(T v) { - if (v == 0) - return sizeof(v) * 8; - return __builtin_clzll(v); -} - // count bits (set + any 0's that follow) template unsigned cbits(T v) { diff --git a/src/test/test_intarith.cc b/src/test/test_intarith.cc index bb01343d4d17..d8943caf3905 100644 --- a/src/test/test_intarith.cc +++ b/src/test/test_intarith.cc @@ -23,24 +23,6 @@ TEST(intarith, cbits) { ASSERT_EQ(64u, cbits(0xffffffffffffffff)); } -TEST(intarith, clz) { - ASSERT_EQ(32u, clz(UINT32_C(0))); - ASSERT_EQ(31u, clz(UINT32_C(1))); - ASSERT_EQ(30u, clz(UINT32_C(2))); - ASSERT_EQ(30u, clz(UINT32_C(3))); - ASSERT_EQ(29u, clz(UINT32_C(4))); - ASSERT_EQ(64u, clz(UINT64_C(0))); - ASSERT_EQ(63u, clz(UINT64_C(1))); - ASSERT_EQ(62u, clz(UINT64_C(2))); - ASSERT_EQ(62u, clz(UINT64_C(3))); - ASSERT_EQ(61u, clz(UINT64_C(4))); - ASSERT_EQ(23u, clz(UINT32_C(0x100))); - ASSERT_EQ(55u, clz(UINT64_C(0x100))); - ASSERT_EQ(0u, clz(0xffffffff)); - ASSERT_EQ(32u, clz(UINT64_C(0xffffffff))); - ASSERT_EQ(0u, clz(UINT64_C(0xffffffffffffffff))); -} - TEST(intarith, ctz) { ASSERT_EQ(32u, ctz(0)); ASSERT_EQ(0u, ctz(1));