Skip to content

Commit

Permalink
Avoid duplicate signatures
Browse files Browse the repository at this point in the history
  • Loading branch information
marcauberer committed Mar 28, 2024
1 parent a529487 commit 16a8c1d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 37 deletions.
17 changes: 3 additions & 14 deletions libcxx/include/__bit/countl.h
Expand Up @@ -59,25 +59,15 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_clz(__uint128_t __x)
}
#endif // _LIBCPP_HAS_NO_INT128

#if __has_builtin(__builtin_clzg)

template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
if (__t == 0)
return numeric_limits<_Tp>::digits;

#if __has_builtin(__builtin_clzg)
return __builtin_clzg(__t);
}

#else // __has_builtin(__builtin_clzg)

template <class _Tp>
_LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _NOEXCEPT {
static_assert(__libcpp_is_unsigned_integer<_Tp>::value, "__countl_zero requires an unsigned integer type");
if (__t == 0)
return numeric_limits<_Tp>::digits;

#else // __has_builtin(__builtin_clzg)
if (sizeof(_Tp) <= sizeof(unsigned int))
return std::__libcpp_clz(static_cast<unsigned int>(__t)) -
(numeric_limits<unsigned int>::digits - numeric_limits<_Tp>::digits);
Expand All @@ -99,9 +89,8 @@ _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countl_zero(_Tp __t) _
}
return __ret + __iter;
}
}

#endif // __has_builtin(__builtin_clzg)
}

#if _LIBCPP_STD_VER >= 20

Expand Down
16 changes: 3 additions & 13 deletions libcxx/include/__bit/countr.h
Expand Up @@ -38,23 +38,14 @@ _LIBCPP_NODISCARD inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_ct
return __builtin_ctzll(__x);
}

#if __has_builtin(__builtin_ctzg)

template <class _Tp>
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT {
if (__t == 0)
return numeric_limits<_Tp>::digits;

#if __has_builtin(__builtin_ctzg)
return __builtin_ctzg(__t);
}

#else // __has_builtin(__builtin_ctzg)

template <class _Tp>
_LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __countr_zero(_Tp __t) _NOEXCEPT {
if (__t == 0)
return numeric_limits<_Tp>::digits;

#else // __has_builtin(__builtin_ctzg)
if (sizeof(_Tp) <= sizeof(unsigned int))
return std::__libcpp_ctz(static_cast<unsigned int>(__t));
else if (sizeof(_Tp) <= sizeof(unsigned long))
Expand All @@ -70,9 +61,8 @@ _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 int __coun
}
return __ret + std::__libcpp_ctz(static_cast<unsigned long long>(__t));
}
}

#endif // __has_builtin(__builtin_ctzg)
}

#if _LIBCPP_STD_VER >= 20

Expand Down
13 changes: 3 additions & 10 deletions libcxx/include/__bit/popcount.h
Expand Up @@ -40,17 +40,11 @@ inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned lo

#if _LIBCPP_STD_VER >= 20

# if __has_builtin(__builtin_popcountg)

template <__libcpp_unsigned_integer _Tp>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
# if __has_builtin(__builtin_popcountg)
return __builtin_popcountg(__t);
}

# else // __has_builtin(__builtin_popcountg)

template <__libcpp_unsigned_integer _Tp>
_LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
# else // __has_builtin(__builtin_popcountg)
if (sizeof(_Tp) <= sizeof(unsigned int))
return std::__libcpp_popcount(static_cast<unsigned int>(__t));
else if (sizeof(_Tp) <= sizeof(unsigned long))
Expand All @@ -65,9 +59,8 @@ _LIBCPP_NODISCARD_EXT _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noex
}
return __ret;
}
}

# endif // __has_builtin(__builtin_popcountg)
}

#endif // _LIBCPP_STD_VER >= 20

Expand Down

0 comments on commit 16a8c1d

Please sign in to comment.