]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
include/intarith: drop clz()
authorKefu Chai <tchaikov@gmail.com>
Sun, 21 Aug 2022 16:42:58 +0000 (00:42 +0800)
committerKefu Chai <tchaikov@gmail.com>
Mon, 22 Aug 2022 10:03:59 +0000 (18:03 +0800)
it is not used anymore

Signed-off-by: Kefu Chai <tchaikov@gmail.com>
src/include/intarith.h
src/test/test_intarith.cc

index b3d76ecd5305db8d17b8e8ebd71b11e5850ef448..bb50d79f73a16b7a23823a6202cc6565f9b5f3c3 100644 (file)
@@ -117,40 +117,6 @@ template<class T>
   return __builtin_ctzll(v);
 }
 
-// count leading zeros
-// NOTE: the builtin is nondeterministic on 0 input
-template<class T>
-  inline typename std::enable_if<
-  (std::is_integral<T>::value &&
-   sizeof(T) <= sizeof(unsigned)),
-  unsigned>::type clz(T v) {
-  if (v == 0)
-    return sizeof(v) * 8;
-  return __builtin_clz(v);
-}
-
-template<class T>
-  inline typename std::enable_if<
-  (std::is_integral<T>::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<class T>
-  inline typename std::enable_if<
-  (std::is_integral<T>::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<std::integral T>
 unsigned cbits(T v) {
index bb01343d4d17a239e8bb5e5ef44ec41b12266f11..d8943caf39053d9d4d9215b674a3914cfdb59b1c 100644 (file)
@@ -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));