Skip to content

Commit

Permalink
Merge pull request #3991 from pleroy/Make
Browse files Browse the repository at this point in the history
Conditional compilation of core-math for Clang
  • Loading branch information
pleroy authored Apr 23, 2024
2 parents 2bb1565 + 945507c commit 4da273b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
5 changes: 5 additions & 0 deletions functions/cos.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ SOFTWARE.
#include <fenv.h>

#include "absl/numeric/int128.h"
#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_MSVC.
#include "numerics/fma.hpp"

// Warning: clang also defines __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#endif

#if PRINCIPIA_COMPILER_MSVC
#define __builtin_clzl(x) __lzcnt64(x)
#endif
#define __builtin_expect(x, y) x
#define __builtin_fabs(x) std::abs(x)
#define __builtin_floor(x) std::floor(x)
Expand Down Expand Up @@ -2054,7 +2057,9 @@ cr_cos (double x)
} // namespace functions
} // namespace principia

#if PRINCIPIA_COMPILER_MSVC
#undef __builtin_clzl
#endif
#undef __builtin_expect
#undef __builtin_fabs
#undef __builtin_floor
Expand Down
5 changes: 5 additions & 0 deletions functions/sin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,17 @@ SOFTWARE.
#include <fenv.h>

#include "absl/numeric/int128.h"
#include "base/macros.hpp" // 🧙 For PRINCIPIA_COMPILER_MSVC.
#include "numerics/fma.hpp"

// Warning: clang also defines __GNUC__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic ignored "-Wunknown-pragmas"
#endif

#if PRINCIPIA_COMPILER_MSVC
#define __builtin_clzl(x) __lzcnt64(x)
#endif
#define __builtin_expect(x, y) x
#define __builtin_fabs(x) std::abs(x)
#define __builtin_floor(x) std::floor(x)
Expand Down Expand Up @@ -2050,7 +2053,9 @@ cr_sin (double x)
} // namespace functions
} // namespace principia

#if PRINCIPIA_COMPILER_MSVC
#undef __builtin_clzl
#endif
#undef __builtin_expect
#undef __builtin_fabs
#undef __builtin_floor
Expand Down

0 comments on commit 4da273b

Please sign in to comment.