[libcxx] Implement P1956 rename low-level bit functions

Implements P1956: On the names of low-level bit manipulation functions.

Users may use older versions of libc++ or other standard libraries with the old names. In order to keep compatibility the old functions are kept, but marked as deprecated.

The patch also adds a new config macro `_LIBCPP_DEPRECATED_MSG`. Do you prefer a this is a separate patch?

Reviewed By: ldionne, #libc

Differential Revision: https://reviews.llvm.org/D90551

GitOrigin-RevId: 1a036e9cc82a7f6d6f4675d631fa5eecd8748784
diff --git a/include/bit b/include/bit
index ae4605b..a720b2e 100644
--- a/include/bit
+++ b/include/bit
@@ -17,13 +17,13 @@
 
   // [bit.pow.two], integral powers of 2
   template <class T>
-    constexpr bool ispow2(T x) noexcept; // C++20
+    constexpr bool has_single_bit(T x) noexcept; // C++20
   template <class T>
-    constexpr T ceil2(T x);              // C++20
+    constexpr T bit_ceil(T x);                   // C++20
   template <class T>
-    constexpr T floor2(T x) noexcept;    // C++20
+    constexpr T bit_floor(T x) noexcept;         // C++20
   template <class T>
-    constexpr T log2p1(T x) noexcept;    // C++20
+    constexpr T bit_width(T x) noexcept;         // C++20
 
   // [bit.rotate], rotating
   template<class T>
@@ -348,9 +348,9 @@
 
 template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
-bool __ispow2(_Tp __t) _NOEXCEPT
+bool __has_single_bit(_Tp __t) _NOEXCEPT
 {
-    static_assert(__bitop_unsigned_integer<_Tp>::value, "__ispow2 requires unsigned");
+    static_assert(__bitop_unsigned_integer<_Tp>::value, "__has_single_bit requires unsigned");
     return __t != 0 && (((__t & (__t - 1)) == 0));
 }
 
@@ -399,7 +399,7 @@
 enable_if_t<__bitop_unsigned_integer<_Tp>::value, int>
 countr_zero(_Tp __t) noexcept
 {
-	return __countr_zero(__t);
+    return __countr_zero(__t);
 }
 
 
@@ -424,15 +424,15 @@
 template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<__bitop_unsigned_integer<_Tp>::value, bool>
-ispow2(_Tp __t) noexcept
+has_single_bit(_Tp __t) noexcept
 {
-    return __ispow2(__t);
+    return __has_single_bit(__t);
 }
 
 template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
-floor2(_Tp __t) noexcept
+bit_floor(_Tp __t) noexcept
 {
     return __t == 0 ? 0 : _Tp{1} << __bit_log2(__t);
 }
@@ -440,11 +440,11 @@
 template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
-ceil2(_Tp __t) noexcept
+bit_ceil(_Tp __t) noexcept
 {
     if (__t < 2) return 1;
     const unsigned __n = numeric_limits<_Tp>::digits - countl_zero((_Tp)(__t - 1u));
-    _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to ceil2");
+    _LIBCPP_DEBUG_ASSERT(__libcpp_is_constant_evaluated() || __n != numeric_limits<_Tp>::digits, "Bad input to bit_ceil");
 
     if constexpr (sizeof(_Tp) >= sizeof(unsigned))
         return _Tp{1} << __n;
@@ -459,12 +459,11 @@
 template <class _Tp>
 _LIBCPP_INLINE_VISIBILITY constexpr
 enable_if_t<__bitop_unsigned_integer<_Tp>::value, _Tp>
-log2p1(_Tp __t) noexcept
+bit_width(_Tp __t) noexcept
 {
     return __t == 0 ? 0 : __bit_log2(__t) + 1;
 }
 
-
 enum class endian
 {
     little = 0xDEAD,