From 1040a210f53cc8a96f4e2c0bfc2b7ea53479955a Mon Sep 17 00:00:00 2001
Date: Mon, 17 May 2021 17:21:47 -0700
Subject: [PATCH 11/24] Fix missing long long math prototypes when using the
 Snow Leopard SDK

---
 libcxx/include/math.h | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/libcxx/include/math.h b/libcxx/include/math.h
index 1603d5748e2d..d64e6a52ccd3 100644
--- a/libcxx/include/math.h
+++ b/libcxx/include/math.h
@@ -299,6 +299,32 @@ long double    truncl(long double x);
 
 #include_next <math.h>
 
+#ifdef __APPLE__
+# if __has_include(<Availability.h>)
+#  include <Availability.h>
+#  if __MAC_OS_X_VERSION_MAX_ALLOWED < 1070
+#    define __APPLE_BAD_MATH_H 1
+#  else
+#    define __APPLE_BAD_MATH_H 0
+#  endif
+# else
+#  define __APPLE_BAD_MATH_H 1
+# endif
+
+# if __APPLE_BAD_MATH_H
+/* These prototypes are incorrectly omitted from <math.h> on Snow Leopard despite being available */
+extern "C" {
+    extern long long int llrintl(long double);
+    extern long long int llrint(double);
+    extern long long int llrintf(float);
+
+    extern long long int llroundl(long double);
+    extern long long int llround(double);
+    extern long long int llroundf(float);
+}
+# endif
+#endif // __APPLE__
+
 #ifdef __cplusplus
 
 // We support including .h headers inside 'extern "C"' contexts, so switch
-- 
2.21.1 (Apple Git-122.3)

