Skip to content

Commit

Permalink
push work up
Browse files Browse the repository at this point in the history
  • Loading branch information
Rinzii committed Mar 1, 2024
1 parent 796b2f7 commit 0b2bdfe
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
12 changes: 11 additions & 1 deletion include/ccmath/detail/compare/signbit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@

#include "ccmath/internal/type_traits/floating_point_traits.hpp"

// If we have C++23, we can use std::signbit as it is constexpr
#if (defined(__cpp_lib_constexpr_cmath) && __cpp_lib_constexpr_cmath >= 202202L)
#include <cmath>
#ifndef CCMATH_HAS_CONSTEXPR_SIGNBIT
#define CCMATH_HAS_CONSTEXPR_SIGNBIT
#endif
#endif

// We only implement this for MSVC as that is the only manner to get constexpr signbit that is also static_assert-able
#ifndef CCMATH_HAS_BUILTIN_BIT_CAST
#if (defined(_MSC_VER) && _MSC_VER >= 1927)
Expand Down Expand Up @@ -82,7 +90,9 @@ namespace ccm
template <typename T, std::enable_if_t<std::is_floating_point<T>::value, int> = 0>
[[nodiscard]] inline constexpr bool signbit(T x) noexcept
{
#if defined(CCMATH_HAS_CONSTEXPR_BUILTIN_SIGNBIT)
#if defined(CCMATH_HAS_CONSTEXPR_SIGNBIT)
return std::signbit(x);
#elif defined(CCMATH_HAS_CONSTEXPR_BUILTIN_SIGNBIT)
return __builtin_signbit(x);
#elif defined(CCMATH_HAS_BUILTIN_BIT_CAST)
// Check for the sign of +0.0 and -0.0 with __builtin_bit_cast
Expand Down
3 changes: 2 additions & 1 deletion include/ccmath/internal/helpers/fpclassify_helper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,12 @@ namespace ccm::helpers
eFP_ZERO,
eFP_SUBNORMAL,
eFP_NORMAL
// TODO: What the fuck? Why is this assertion being hit before the preprocessor has defined the compiler?
static_assert(false, "FP_* macros are extremely implementation specific and are not defined for this compiler. Please add support for this compiler.")
#endif
};
}

// Clean up the global namespace
#include "ccmath/internal/setup/compiler_undef.hpp"
//#include "ccmath/internal/setup/compiler_undef.hpp"

2 changes: 0 additions & 2 deletions include/ccmath/internal/setup/compiler_def.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

/// ATTENTION: If you add a new compiler remember to add it to compiler_undef.hpp also!

#pragma once

#if defined(__GNUC__) && !defined(CCMATH_COMPILER_GCC)
#define CCMATH_COMPILER_GCC
#define CCMATH_COMPILER_GCC_VER ((__GNUC__ * 10000) + (__GNUC_MINOR__ * 100) + __GNUC_PATCHLEVEL__)
Expand Down
2 changes: 0 additions & 2 deletions include/ccmath/internal/setup/compiler_undef.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
* See LICENSE for more information.
*/

#pragma once

// Undefine all the compiler macros to clean up the global namespace

// GCC
Expand Down

0 comments on commit 0b2bdfe

Please sign in to comment.