# Backport NVIDIA CUDA crt glibc-2.43 (rsqrt/rsqrtf, abs) exception-specifier fixes
# from cuda_crt 13.2.78 onto 13.1.80, matching the fix NVIDIA shipped in CUDA 13.2.1.
--- a/targets/x86_64-linux/include/crt/math_functions.h
+++ b/targets/x86_64-linux/include/crt/math_functions.h
@@ -125,10 +125,19 @@
 #  else
 #    define __NV_GLIBC_PROVIDES_IEC_60559_FUNCS 0
 #  endif
+# if __GLIBC_PREREQ(2,42)
+#    define _NV_GLIBC_VERSION_GE_2_42 1
+# endif
 #else
 #  define __NV_GLIBC_PROVIDES_IEC_60559_FUNCS 0
 #endif
 
+#if defined(_NV_GLIBC_VERSION_GE_2_42)
+# define _NV_RSQRT_SPECIFIER noexcept(true)
+#else
+# define _NV_RSQRT_SPECIFIER
+#endif
+
 /*******************************************************************************
 *                                                                              *
 *                                                                              *
@@ -604,6 +613,7 @@
 #if defined(__QNX__) && !defined(_LIBCPP_VERSION)
 } /* std */
 #endif
+
 /**
  * \ingroup CUDA_MATH_DOUBLE
  * \brief Calculate the reciprocal of the square root of the input argument.
@@ -626,7 +636,7 @@
  *
  * \note_accuracy_double
  */
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ double                 rsqrt(double x) _NV_RSQRT_SPECIFIER;
 
 /**
  * \ingroup CUDA_MATH_SINGLE
@@ -650,7 +660,7 @@
  *
  * \note_accuracy_single
  */
-extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x);
+extern __DEVICE_FUNCTIONS_DECL__ __device_builtin__ float                  rsqrtf(float x) _NV_RSQRT_SPECIFIER;
 
 #if defined(__QNX__) && !defined(_LIBCPP_VERSION)
 namespace std {
@@ -5360,12 +5370,24 @@
 #else /* __CUDACC_RTC__ ||
          (!defined(_MSC_VER) || _MSC_VER < 1800) &&
          (!defined(_LIBCPP_VERSION) || (_LIBCPP_VERSION < 1101)) */
+#if defined(_LIBCPP_VERSION) && (_LIBCPP_VERSION > 210000)
+NV_MATH_BEGIN_NAMESPACE_STD
+extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ float       __cdecl abs(float __x) NV_MATH_NOEXCEPT_OR_THROW;
+extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ double      __cdecl abs(double __x) NV_MATH_NOEXCEPT_OR_THROW;
+extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ long double __cdecl abs(long double __x) NV_MATH_NOEXCEPT_OR_THROW;
+ 
+template <class> extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ int       __cdecl abs(int __x) NV_MATH_NOEXCEPT_OR_THROW;
+template <class> extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ long      __cdecl abs(long __x) NV_MATH_NOEXCEPT_OR_THROW;
+template <class> extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ long long __cdecl abs(long long __x) NV_MATH_NOEXCEPT_OR_THROW;
+NV_MATH_END_NAMESPACE_STD
+#else
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ long int __cdecl abs(long int) NV_MATH_NOEXCEPT_OR_THROW;
 #if defined(_LIBCPP_VERSION)
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ long long int __cdecl abs(long long int) NV_MATH_NOEXCEPT_OR_THROW;
 #endif /* defined(_LIBCPP_VERSION) */
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ float    __cdecl abs(float) NV_MATH_NOEXCEPT_OR_THROW;
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ double   __cdecl abs(double) NV_MATH_NOEXCEPT_OR_THROW;
+#endif
 NV_MATH_BEGIN_NAMESPACE_STD
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ float    __cdecl fabs(float) NV_MATH_NOEXCEPT_OR_THROW;
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ float    __cdecl ceil(float) NV_MATH_NOEXCEPT_OR_THROW;
@@ -5374,7 +5396,12 @@
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__ float    __cdecl pow(float, float) NV_MATH_NOEXCEPT_OR_THROW;
 #if defined(_LIBCPP_VERSION)
 #if (defined (__ANDROID__) || defined(__HORIZON__)) && (_LIBCPP_VERSION >= 9000)
-#if _LIBCPP_VERSION >= 180000
+#if _LIBCPP_VERSION >= 210000
+template <class _A1, class _A2,
+	  std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int>>
+extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__
+std::__promote_t<_A1, _A2> pow(_A1 __lcpp_x, _A2 __lcpp_y) __NV_NOEXCEPT;
+#elif _LIBCPP_VERSION >= 180000
 template <class _A1, class _A2,
 	  std::__enable_if_t<std::is_arithmetic<_A1>::value && std::is_arithmetic<_A2>::value, int>>
 extern __DEVICE_FUNCTIONS_DECL__ __cudart_builtin__
@@ -6043,7 +6070,7 @@
 
 #endif /* _WIN32 */
 
-__func__(double rsqrt(double a));
+__func__(double rsqrt(double a) _NV_RSQRT_SPECIFIER);
 
 __func__(double rcbrt(double a));
 
@@ -6069,7 +6096,7 @@
 
 __func__(double erfcx(double a));
 
-__func__(float rsqrtf(float a));
+__func__(float rsqrtf(float a) _NV_RSQRT_SPECIFIER);
 
 __func__(float rcbrtf(float a));
 
--- a/targets/x86_64-linux/include/crt/math_functions.hpp
+++ b/targets/x86_64-linux/include/crt/math_functions.hpp
@@ -2984,7 +2984,7 @@
 *                                                                              *
 *******************************************************************************/
 
-__func__(double rsqrt(const double a))
+__func__(double rsqrt(const double a)) _NV_RSQRT_SPECIFIER
 {
   return 1.0 / sqrt(a);
 }
@@ -3377,7 +3377,7 @@
   return t1;
 }
 
-__func__(float rsqrtf(const float a))
+__func__(float rsqrtf(const float a) _NV_RSQRT_SPECIFIER) 
 {
   return static_cast<float>(rsqrt(static_cast<double>(a)));
 }
