mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Release Cosmopolitan v3.6.0
This release is an atomic upgrade to GCC 14.1.0 with C23 and C++23
This commit is contained in:
parent
62ace3623a
commit
5660ec4741
1585 changed files with 117353 additions and 271644 deletions
24
third_party/libcxx/__bit/popcount.h
vendored
24
third_party/libcxx/__bit/popcount.h
vendored
|
@ -6,6 +6,9 @@
|
|||
//
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// TODO: __builtin_popcountg is available since Clang 19 and GCC 14. When support for older versions is dropped, we can
|
||||
// refactor this code to exclusively use __builtin_popcountg.
|
||||
|
||||
#ifndef _LIBCPP___BIT_POPCOUNT_H
|
||||
#define _LIBCPP___BIT_POPCOUNT_H
|
||||
|
||||
|
@ -23,19 +26,25 @@ _LIBCPP_PUSH_MACROS
|
|||
|
||||
_LIBCPP_BEGIN_NAMESPACE_STD
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
int __libcpp_popcount(unsigned __x) _NOEXCEPT { return __builtin_popcount(__x); }
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned __x) _NOEXCEPT {
|
||||
return __builtin_popcount(__x);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
int __libcpp_popcount(unsigned long __x) _NOEXCEPT { return __builtin_popcountl(__x); }
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned long __x) _NOEXCEPT {
|
||||
return __builtin_popcountl(__x);
|
||||
}
|
||||
|
||||
inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR
|
||||
int __libcpp_popcount(unsigned long long __x) _NOEXCEPT { return __builtin_popcountll(__x); }
|
||||
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR int __libcpp_popcount(unsigned long long __x) _NOEXCEPT {
|
||||
return __builtin_popcountll(__x);
|
||||
}
|
||||
|
||||
#if _LIBCPP_STD_VER >= 20
|
||||
|
||||
template <__libcpp_unsigned_integer _Tp>
|
||||
_LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
|
||||
[[nodiscard]] _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
|
||||
# if __has_builtin(__builtin_popcountg)
|
||||
return __builtin_popcountg(__t);
|
||||
# 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))
|
||||
|
@ -50,6 +59,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr int popcount(_Tp __t) noexcept {
|
|||
}
|
||||
return __ret;
|
||||
}
|
||||
# endif // __has_builtin(__builtin_popcountg)
|
||||
}
|
||||
|
||||
#endif // _LIBCPP_STD_VER >= 20
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue