aboutsummaryrefslogtreecommitdiff
path: root/contrib/libc++/include/math.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-08-22 19:49:51 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-08-22 19:49:51 +0000
commit2f1cb2a6c9c3a63d61ea267fb9d81773616ea83b (patch)
treedfafd26b02c2aba8ba71862335377d6c0ccfb0ed /contrib/libc++/include/math.h
parent14a0b2859e9d76204ca897de961b36344ce1e775 (diff)
parent1147845301c03308e3419b89c28c77bb6917fe04 (diff)
Notes
Diffstat (limited to 'contrib/libc++/include/math.h')
-rw-r--r--contrib/libc++/include/math.h143
1 files changed, 93 insertions, 50 deletions
diff --git a/contrib/libc++/include/math.h b/contrib/libc++/include/math.h
index 3cc72aa2791e..194df2077bb1 100644
--- a/contrib/libc++/include/math.h
+++ b/contrib/libc++/include/math.h
@@ -1,10 +1,9 @@
// -*- C++ -*-
//===---------------------------- math.h ----------------------------------===//
//
-// The LLVM Compiler Infrastructure
-//
-// This file is dual licensed under the MIT and the University of Illinois Open
-// Source Licenses. See LICENSE.TXT for details.
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
@@ -298,6 +297,9 @@ long double truncl(long double x);
#pragma GCC system_header
#endif
+#define _LIBCPP_STDLIB_INCLUDE_NEXT
+#include <stdlib.h>
+
#include_next <math.h>
#ifdef __cplusplus
@@ -755,20 +757,61 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
// abs
+#undef abs
+#undef labs
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+#undef llabs
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
+ return ::labs(__x);
+}
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
+ return ::llabs(__x);
+}
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+
+
#if !(defined(_AIX) || defined(__sun__))
-inline _LIBCPP_INLINE_VISIBILITY
-float
-abs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
+ return ::fabsf(__lcpp_x);
+}
-inline _LIBCPP_INLINE_VISIBILITY
-double
-abs(double __lcpp_x) _NOEXCEPT {return ::fabs(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY double abs(double __lcpp_x) _NOEXCEPT {
+ return ::fabs(__lcpp_x);
+}
-inline _LIBCPP_INLINE_VISIBILITY
-long double
-abs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
+inline _LIBCPP_INLINE_VISIBILITY long double
+abs(long double __lcpp_x) _NOEXCEPT {
+ return ::fabsl(__lcpp_x);
+}
#endif // !(defined(_AIX) || defined(__sun__))
+// div
+
+#undef div
+#undef ldiv
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+#undef lldiv
+#endif
+
+// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
+ return ::ldiv(__x, __y);
+}
+#ifndef _LIBCPP_HAS_NO_LONG_LONG
+inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
+ long long __y) _NOEXCEPT {
+ return ::lldiv(__x, __y);
+}
+#endif // _LIBCPP_HAS_NO_LONG_LONG
+#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
+
// acos
#if !(defined(_AIX) || defined(__sun__))
@@ -814,7 +857,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long do
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -823,8 +866,8 @@ typename std::__lazy_enable_if
atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::atan2((__result_type)__lcpp_y, (__result_type)__lcpp_x);
}
@@ -909,7 +952,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -918,8 +961,8 @@ typename std::__lazy_enable_if
fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fmod((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -987,7 +1030,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long doub
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -996,8 +1039,8 @@ typename std::__lazy_enable_if
pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::pow((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1114,7 +1157,7 @@ copysign(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1123,8 +1166,8 @@ typename std::__lazy_enable_if
copysign(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::copysign((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1175,7 +1218,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fdim(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1184,8 +1227,8 @@ typename std::__lazy_enable_if
fdim(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fdim((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1196,7 +1239,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fma(long double __lcpp_x, long doub
template <class _A1, class _A2, class _A3>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value &&
@@ -1206,9 +1249,9 @@ typename std::__lazy_enable_if
fma(_A1 __lcpp_x, _A2 __lcpp_y, _A3 __lcpp_z) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2, _A3>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value &&
- std::is_same<_A3, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value &&
+ std::_IsSame<_A3, __result_type>::value)), "");
return ::fma((__result_type)__lcpp_x, (__result_type)__lcpp_y, (__result_type)__lcpp_z);
}
@@ -1219,7 +1262,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmax(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1228,8 +1271,8 @@ typename std::__lazy_enable_if
fmax(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fmax((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1240,7 +1283,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double fmin(long double __lcpp_x, long dou
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1249,8 +1292,8 @@ typename std::__lazy_enable_if
fmin(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::fmin((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1261,7 +1304,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double hypot(long double __lcpp_x, long do
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1270,8 +1313,8 @@ typename std::__lazy_enable_if
hypot(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::hypot((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1384,7 +1427,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double nextafter(long double __lcpp_x, lon
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1393,8 +1436,8 @@ typename std::__lazy_enable_if
nextafter(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::nextafter((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1415,7 +1458,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double remainder(long double __lcpp_x, lon
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1424,8 +1467,8 @@ typename std::__lazy_enable_if
remainder(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::remainder((__result_type)__lcpp_x, (__result_type)__lcpp_y);
}
@@ -1436,7 +1479,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double remquo(long double __lcpp_x, long d
template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
-typename std::__lazy_enable_if
+typename std::_EnableIf
<
std::is_arithmetic<_A1>::value &&
std::is_arithmetic<_A2>::value,
@@ -1445,8 +1488,8 @@ typename std::__lazy_enable_if
remquo(_A1 __lcpp_x, _A2 __lcpp_y, int* __lcpp_z) _NOEXCEPT
{
typedef typename std::__promote<_A1, _A2>::type __result_type;
- static_assert((!(std::is_same<_A1, __result_type>::value &&
- std::is_same<_A2, __result_type>::value)), "");
+ static_assert((!(std::_IsSame<_A1, __result_type>::value &&
+ std::_IsSame<_A2, __result_type>::value)), "");
return ::remquo((__result_type)__lcpp_x, (__result_type)__lcpp_y, __lcpp_z);
}