From 6cc8eab6452b40cfbd5f24c4c225e9216a57f72f Mon Sep 17 00:00:00 2001
From: pleroy <pascal.h.leroy@gmail.com>
Date: Tue, 23 Apr 2024 18:20:47 +0200
Subject: [PATCH 1/2] Conditional compilation of core-math for Clang.

---
 functions/cos.cc | 5 +++++
 functions/sin.cc | 5 +++++
 2 files changed, 10 insertions(+)

diff --git a/functions/cos.cc b/functions/cos.cc
index 0b290584ab..3f6f8a01d0 100644
--- a/functions/cos.cc
+++ b/functions/cos.cc
@@ -36,6 +36,7 @@ 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__
@@ -43,7 +44,9 @@ SOFTWARE.
 #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)
@@ -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
diff --git a/functions/sin.cc b/functions/sin.cc
index 52fca4b4b9..3e90e360a5 100644
--- a/functions/sin.cc
+++ b/functions/sin.cc
@@ -36,6 +36,7 @@ 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__
@@ -43,7 +44,9 @@ SOFTWARE.
 #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)
@@ -2050,8 +2053,10 @@ cr_sin (double x)
 }  // namespace functions
 }  // namespace principia
 
+#if PRINCIPIA_COMPILER_MSVC
 #undef __builtin_clzl
 #undef __builtin_expect
 #undef __builtin_fabs
 #undef __builtin_floor
+#endif
 #undef __builtin_fma

From 945507cdbb201caf0177c705014f29428c9af4f9 Mon Sep 17 00:00:00 2001
From: pleroy <pascal.h.leroy@gmail.com>
Date: Tue, 23 Apr 2024 18:21:57 +0200
Subject: [PATCH 2/2] #undef

---
 functions/sin.cc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/functions/sin.cc b/functions/sin.cc
index 3e90e360a5..87423bf4ae 100644
--- a/functions/sin.cc
+++ b/functions/sin.cc
@@ -2055,8 +2055,8 @@ cr_sin (double x)
 
 #if PRINCIPIA_COMPILER_MSVC
 #undef __builtin_clzl
+#endif
 #undef __builtin_expect
 #undef __builtin_fabs
 #undef __builtin_floor
-#endif
 #undef __builtin_fma