Skip to content

Commit

Permalink
Remove int128 experiment as it is currently cursed with msvc
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Apr 6, 2024
1 parent 1ba3088 commit 431eeb8
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 2,020 deletions.
6 changes: 2 additions & 4 deletions ccmath_headers.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ set(ccmath_internal_predef_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/predef/unlikely.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/predef/no_debug.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/predef/suppress.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/predef/has_builtin.hpp
)

set(ccmath_internal_support_headers
Expand All @@ -31,15 +32,12 @@ set(ccmath_internal_support_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/unreachable.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/ctz.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/type_identity.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/floating_point_bits.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/math_support.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/support/always_false.hpp
)

set(ccmath_internal_types_headers
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/types/fp_types.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/types/uint128.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/types/uint.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/types/number_pair.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/types/sign.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/ccmath/internal/types/float128.hpp
)
Expand Down
17 changes: 17 additions & 0 deletions include/ccmath/internal/predef/has_builtin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2024-Present Ian Pike
* Copyright (c) 2024-Present ccmath contributors
*
* This library is provided under the MIT License.
* See LICENSE for more information.
*/

#pragma once

#ifndef CCM_HAS_BUILTIN
# if defined(__has_builtin)
# define CCM_HAS_BUILTIN(x) __has_builtin(x)
# else
# define CCM_HAS_BUILTIN(x) 0
# endif
#endif // CCM_HAS_BUILTIN
19 changes: 10 additions & 9 deletions include/ccmath/internal/support/bits.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include "ccmath/internal/support/ctz.hpp"
#include "ccmath/internal/predef/has_builtin.hpp"

#include <cstdint>
#include <type_traits>
Expand Down Expand Up @@ -219,13 +220,13 @@ namespace ccm::support
return std::numeric_limits<T>::digits - countl_zero(value);
}

#if __has_builtin(__builtin_popcountg)
#if CCM_HAS_BUILTIN(__builtin_popcountg)
template <typename T>
[[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>, int> popcount(T value)
{
return __builtin_popcountg(value);
}
#else // !__has_builtin(__builtin_popcountg)
#else // !CCM_HAS_BUILTIN(__builtin_popcountg)
template <typename T>
[[nodiscard]] constexpr std::enable_if_t<std::is_unsigned_v<T>, int> popcount(T value)
{
Expand All @@ -236,10 +237,10 @@ namespace ccm::support
}
return count;
}
#endif // __has_builtin(__builtin_popcountg)
#endif // CCM_HAS_BUILTIN(__builtin_popcountg)

// If the compiler has builtin's for popcount, the create specializations that use the builtin.
#if __has_builtin(__builtin_popcount)
#if CCM_HAS_BUILTIN(__builtin_popcount)
template <>
[[nodiscard]] constexpr int popcount<unsigned char>(unsigned char value)
{
Expand All @@ -257,22 +258,22 @@ namespace ccm::support
{
return __builtin_popcount(value);
}
#endif // __has_builtin(__builtin_popcount)
#endif // CCM_HAS_BUILTIN(__builtin_popcount)

#if __has_builtin(__builtin_popcountl)
#if CCM_HAS_BUILTIN(__builtin_popcountl)
template <>
[[nodiscard]] constexpr int popcount<unsigned long>(unsigned long value)
{
return __builtin_popcountl(value);
}
#endif // __has_builtin(__builtin_popcountl)
#endif // CCM_HAS_BUILTIN(__builtin_popcountl)

#if __has_builtin(__builtin_popcountll)
#if CCM_HAS_BUILTIN(__builtin_popcountll)
template <>
[[nodiscard]] constexpr int popcount<unsigned long long>(unsigned long long value)
{
return __builtin_popcountll(value);
}
#endif // __has_builtin(__builtin_popcountll)
#endif // CCM_HAS_BUILTIN(__builtin_popcountll)

} // namespace ccm::support
10 changes: 6 additions & 4 deletions include/ccmath/internal/support/ctz.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

#pragma once

#include "ccmath/internal/predef/has_builtin.hpp"

#include <limits>
#include <type_traits>

Expand Down Expand Up @@ -47,7 +49,7 @@ namespace ccm::support
template <>
constexpr int ctz(unsigned short x) noexcept
{
#if __has_builtin(__builtin_ctzs)
#if CCM_HAS_BUILTIN(__builtin_ctzs)
return __builtin_ctzs(x);
#else
return internal::generic_ctz(x);
Expand All @@ -57,7 +59,7 @@ namespace ccm::support
template <>
constexpr int ctz(unsigned int x) noexcept
{
#if __has_builtin(__builtin_ctz)
#if CCM_HAS_BUILTIN(__builtin_ctz)
return __builtin_ctz(x);
#else
return internal::generic_ctz(x);
Expand All @@ -67,7 +69,7 @@ namespace ccm::support
template <>
constexpr int ctz(unsigned long x) noexcept
{
#if __has_builtin(__builtin_ctzl)
#if CCM_HAS_BUILTIN(__builtin_ctzl)
return __builtin_ctzl(x);
#else
return internal::generic_ctz(x);
Expand All @@ -77,7 +79,7 @@ namespace ccm::support
template <>
constexpr int ctz(unsigned long long x) noexcept
{
#if __has_builtin(__builtin_ctzll)
#if CCM_HAS_BUILTIN(__builtin_ctzll)
return __builtin_ctzll(x);
#else
return internal::generic_ctz(x);
Expand Down
Loading

0 comments on commit 431eeb8

Please sign in to comment.