]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
include/intarith: drop ctz()
authorKefu Chai <tchaikov@gmail.com>
Sun, 21 Aug 2022 16:52:13 +0000 (00:52 +0800)
committerKefu Chai <tchaikov@gmail.com>
Wed, 24 Aug 2022 09:49:41 +0000 (17:49 +0800)
it is not used anymore

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

index ff626681704b2ab287bedc205739bded4515046f..86002c312ba6750305f051187dd73516310ae59a 100644 (file)
@@ -83,40 +83,6 @@ constexpr inline T p2roundup(T x, T align) {
   return -(-x & -align);
 }
 
-// count trailing 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 ctz(T v) {
-  if (v == 0)
-    return sizeof(v) * 8;
-  return __builtin_ctz(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 ctz(T v) {
-  if (v == 0)
-    return sizeof(v) * 8;
-  return __builtin_ctzl(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 ctz(T v) {
-  if (v == 0)
-    return sizeof(v) * 8;
-  return __builtin_ctzll(v);
-}
-
 // count bits (set + any 0's that follow)
 template<std::integral T>
 unsigned cbits(T v) {
index 11bfbc6d1564af1c9cf38ea03733444e48c953a4..4457b9399fd8cffd68caa29edcc20d1b870155c3 100644 (file)
@@ -23,26 +23,6 @@ TEST(intarith, cbits) {
   ASSERT_EQ(64u, cbits(0xffffffffffffffff));
 }
 
-TEST(intarith, ctz) {
-  ASSERT_EQ(32u, ctz(0));
-  ASSERT_EQ(0u, ctz(1));
-  ASSERT_EQ(1u, ctz(2));
-  ASSERT_EQ(0u, ctz(3));
-  ASSERT_EQ(2u, ctz(4));
-  ASSERT_EQ(64u, ctz(UINT64_C(0)));
-  ASSERT_EQ(0u, ctz(UINT64_C(1)));
-  ASSERT_EQ(1u, ctz(UINT64_C(2)));
-  ASSERT_EQ(0u, ctz(UINT64_C(3)));
-  ASSERT_EQ(2u, ctz(UINT64_C(4)));
-  ASSERT_EQ(8u, ctz(0x100));
-  ASSERT_EQ(8u, ctz(UINT64_C(0x100)));
-  ASSERT_EQ(0u, ctz(0xffffffff));
-  ASSERT_EQ(0u, ctz(UINT32_C(0xffffffff)));
-  ASSERT_EQ(0u, ctz(UINT64_C(0xffffffff)));
-  ASSERT_EQ(20u, ctz(UINT64_C(0xffffffff00000)));
-  ASSERT_EQ(48u, ctz(UINT64_C(0xff000000000000)));
-}
-
 TEST(intarith, p2family) {
   ASSERT_EQ(1024, p2align(1200, 1024));
   ASSERT_EQ(1024, p2align(1024, 1024));