Skip to content

Commit

Permalink
[libc++][AIX] Use C++ overloads from libc++'s math.h
Browse files Browse the repository at this point in the history
AIX's system header provides these C++ overloads for compatibility with
older XL C++ implementations, but they can be disabled by defining
__LIBC_NO_CPP_MATH_OVERLOADS__ since AIX 7.2 TL 5 SP 3.

Since D109078 landed clang will define this macro when using libc++ on
AIX and we already run the lit tests with it too. This change will
enable the overloads in libc++'s math.h and we'll continue to require
the compiler to define the macro going forward.

Reviewed By: ldionne, jsji, EricWF

Differential Revision: https://reviews.llvm.org/D102172

co-authored-by: Jason Liu <jasonliu.development@gmail.com>
  • Loading branch information
daltenty and jasonliudev committed Mar 1, 2022
1 parent 70629d5 commit f642436
Show file tree
Hide file tree
Showing 21 changed files with 43 additions and 82 deletions.
86 changes: 43 additions & 43 deletions libcxx/include/math.h
Expand Up @@ -788,10 +788,10 @@ isunordered(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT

// acos

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float acos(float __lcpp_x) _NOEXCEPT {return ::acosf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double acos(long double __lcpp_x) _NOEXCEPT {return ::acosl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -800,10 +800,10 @@ acos(_A1 __lcpp_x) _NOEXCEPT {return ::acos((double)__lcpp_x);}

// asin

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float asin(float __lcpp_x) _NOEXCEPT {return ::asinf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double asin(long double __lcpp_x) _NOEXCEPT {return ::asinl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -812,10 +812,10 @@ asin(_A1 __lcpp_x) _NOEXCEPT {return ::asin((double)__lcpp_x);}

// atan

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float atan(float __lcpp_x) _NOEXCEPT {return ::atanf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double atan(long double __lcpp_x) _NOEXCEPT {return ::atanl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -824,10 +824,10 @@ atan(_A1 __lcpp_x) _NOEXCEPT {return ::atan((double)__lcpp_x);}

// atan2

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float atan2(float __lcpp_y, float __lcpp_x) _NOEXCEPT {return ::atan2f(__lcpp_y, __lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double atan2(long double __lcpp_y, long double __lcpp_x) _NOEXCEPT {return ::atan2l(__lcpp_y, __lcpp_x);}
#endif
# endif

template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -847,10 +847,10 @@ atan2(_A1 __lcpp_y, _A2 __lcpp_x) _NOEXCEPT

// ceil

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float ceil(float __lcpp_x) _NOEXCEPT {return ::ceilf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double ceil(long double __lcpp_x) _NOEXCEPT {return ::ceill(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -859,10 +859,10 @@ ceil(_A1 __lcpp_x) _NOEXCEPT {return ::ceil((double)__lcpp_x);}

// cos

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float cos(float __lcpp_x) _NOEXCEPT {return ::cosf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double cos(long double __lcpp_x) _NOEXCEPT {return ::cosl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -871,10 +871,10 @@ cos(_A1 __lcpp_x) _NOEXCEPT {return ::cos((double)__lcpp_x);}

// cosh

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float cosh(float __lcpp_x) _NOEXCEPT {return ::coshf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double cosh(long double __lcpp_x) _NOEXCEPT {return ::coshl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -883,10 +883,10 @@ cosh(_A1 __lcpp_x) _NOEXCEPT {return ::cosh((double)__lcpp_x);}

// exp

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float exp(float __lcpp_x) _NOEXCEPT {return ::expf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double exp(long double __lcpp_x) _NOEXCEPT {return ::expl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -895,10 +895,10 @@ exp(_A1 __lcpp_x) _NOEXCEPT {return ::exp((double)__lcpp_x);}

// fabs

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float fabs(float __lcpp_x) _NOEXCEPT {return ::fabsf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double fabs(long double __lcpp_x) _NOEXCEPT {return ::fabsl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -907,10 +907,10 @@ fabs(_A1 __lcpp_x) _NOEXCEPT {return ::fabs((double)__lcpp_x);}

// floor

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float floor(float __lcpp_x) _NOEXCEPT {return ::floorf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double floor(long double __lcpp_x) _NOEXCEPT {return ::floorl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -919,10 +919,10 @@ floor(_A1 __lcpp_x) _NOEXCEPT {return ::floor((double)__lcpp_x);}

// fmod

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float fmod(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::fmodf(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double fmod(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::fmodl(__lcpp_x, __lcpp_y);}
#endif
# endif

template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -942,10 +942,10 @@ fmod(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT

// frexp

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float frexp(float __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpf(__lcpp_x, __lcpp_e);}
inline _LIBCPP_INLINE_VISIBILITY long double frexp(long double __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexpl(__lcpp_x, __lcpp_e);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -954,10 +954,10 @@ frexp(_A1 __lcpp_x, int* __lcpp_e) _NOEXCEPT {return ::frexp((double)__lcpp_x, _

// ldexp

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float ldexp(float __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpf(__lcpp_x, __lcpp_e);}
inline _LIBCPP_INLINE_VISIBILITY long double ldexp(long double __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexpl(__lcpp_x, __lcpp_e);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -966,10 +966,10 @@ ldexp(_A1 __lcpp_x, int __lcpp_e) _NOEXCEPT {return ::ldexp((double)__lcpp_x, __

// log

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float log(float __lcpp_x) _NOEXCEPT {return ::logf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double log(long double __lcpp_x) _NOEXCEPT {return ::logl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -978,10 +978,10 @@ log(_A1 __lcpp_x) _NOEXCEPT {return ::log((double)__lcpp_x);}

// log10

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float log10(float __lcpp_x) _NOEXCEPT {return ::log10f(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double log10(long double __lcpp_x) _NOEXCEPT {return ::log10l(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -990,17 +990,17 @@ log10(_A1 __lcpp_x) _NOEXCEPT {return ::log10((double)__lcpp_x);}

// modf

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float modf(float __lcpp_x, float* __lcpp_y) _NOEXCEPT {return ::modff(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double modf(long double __lcpp_x, long double* __lcpp_y) _NOEXCEPT {return ::modfl(__lcpp_x, __lcpp_y);}
#endif
# endif

// pow

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float pow(float __lcpp_x, float __lcpp_y) _NOEXCEPT {return ::powf(__lcpp_x, __lcpp_y);}
inline _LIBCPP_INLINE_VISIBILITY long double pow(long double __lcpp_x, long double __lcpp_y) _NOEXCEPT {return ::powl(__lcpp_x, __lcpp_y);}
#endif
# endif

template <class _A1, class _A2>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -1020,7 +1020,7 @@ pow(_A1 __lcpp_x, _A2 __lcpp_y) _NOEXCEPT

// sin

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float sin(float __lcpp_x) _NOEXCEPT {return ::sinf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sin(long double __lcpp_x) _NOEXCEPT {return ::sinl(__lcpp_x);}
#endif
Expand All @@ -1032,10 +1032,10 @@ sin(_A1 __lcpp_x) _NOEXCEPT {return ::sin((double)__lcpp_x);}

// sinh

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float sinh(float __lcpp_x) _NOEXCEPT {return ::sinhf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sinh(long double __lcpp_x) _NOEXCEPT {return ::sinhl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -1044,10 +1044,10 @@ sinh(_A1 __lcpp_x) _NOEXCEPT {return ::sinh((double)__lcpp_x);}

// sqrt

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float sqrt(float __lcpp_x) _NOEXCEPT {return ::sqrtf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double sqrt(long double __lcpp_x) _NOEXCEPT {return ::sqrtl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -1056,10 +1056,10 @@ sqrt(_A1 __lcpp_x) _NOEXCEPT {return ::sqrt((double)__lcpp_x);}

// tan

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float tan(float __lcpp_x) _NOEXCEPT {return ::tanf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double tan(long double __lcpp_x) _NOEXCEPT {return ::tanl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand All @@ -1068,10 +1068,10 @@ tan(_A1 __lcpp_x) _NOEXCEPT {return ::tan((double)__lcpp_x);}

// tanh

#if !(defined(_AIX) || defined(__sun__))
# if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float tanh(float __lcpp_x) _NOEXCEPT {return ::tanhf(__lcpp_x);}
inline _LIBCPP_INLINE_VISIBILITY long double tanh(long double __lcpp_x) _NOEXCEPT {return ::tanhl(__lcpp_x);}
#endif
# endif

template <class _A1>
inline _LIBCPP_INLINE_VISIBILITY
Expand Down
1 change: 0 additions & 1 deletion libcxx/test/libcxx/fuzzing/random.pass.cpp
Expand Up @@ -7,7 +7,6 @@
//===----------------------------------------------------------------------===//

// UNSUPPORTED: c++03, c++11
// XFAIL: LIBCXX-AIX-FIXME

#include <cassert>
#include <cmath>
Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/std/depr/depr.c.headers/math_h.pass.cpp
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <math.h>

#include <math.h>
Expand Down
Expand Up @@ -9,8 +9,6 @@
// NetBSD does not support LC_TIME at the moment
// XFAIL: netbsd

// XFAIL: LIBCXX-AIX-FIXME

// REQUIRES: locale.en_US.UTF-8
// REQUIRES: locale.fr_FR.UTF-8

Expand Down
2 changes: 0 additions & 2 deletions libcxx/test/std/numerics/c.math/cmath.pass.cpp
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <cmath>

#include <cmath>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<Arithmetic T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<Arithmetic T, Arithmetic U>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down
Expand Up @@ -6,8 +6,6 @@
//
//===----------------------------------------------------------------------===//

// XFAIL: LIBCXX-AIX-FIXME

// <complex>

// template<class T>
Expand Down

0 comments on commit f642436

Please sign in to comment.