[libcxx-commits] [libcxx] f3d7536 - [libc++] Fix abs and div overload issue for compilers on AIX
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Apr 9 07:47:51 PDT 2021
Author: jasonliu
Date: 2021-04-09T14:47:13Z
New Revision: f3d7536b24f1d65c09de4899a51d9fdda83c3b1d
URL: https://github.com/llvm/llvm-project/commit/f3d7536b24f1d65c09de4899a51d9fdda83c3b1d
DIFF: https://github.com/llvm/llvm-project/commit/f3d7536b24f1d65c09de4899a51d9fdda83c3b1d.diff
LOG: [libc++] Fix abs and div overload issue for compilers on AIX
Summary:
AIX system's stdlib.h provide different overload of abs and div
depending on compiler versions.
For example, std::div(long, long) and std::abs(long) are not available
from OS's stdlib.h when building with clang, but they are available
when building with xlclang compiler.
Therefore, we need to provide those extra overloads in libc++'s stdlib.h
when OS's stdlib.h does not.
Differential Revision: https://reviews.llvm.org/D99767
Added:
Modified:
libcxx/include/cmath
libcxx/include/stdlib.h
Removed:
################################################################################
diff --git a/libcxx/include/cmath b/libcxx/include/cmath
index 138ae6f99aad0..9c493ce38a538 100644
--- a/libcxx/include/cmath
+++ b/libcxx/include/cmath
@@ -335,9 +335,7 @@ using ::isunordered;
using ::float_t;
using ::double_t;
-#ifndef _AIX
using ::abs;
-#endif
using ::acos;
using ::acosf;
diff --git a/libcxx/include/stdlib.h b/libcxx/include/stdlib.h
index 812ea1024edf8..9ce0485c14a9f 100644
--- a/libcxx/include/stdlib.h
+++ b/libcxx/include/stdlib.h
@@ -103,7 +103,7 @@ extern "C++" {
#endif
// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY long abs(long __x) _NOEXCEPT {
return __builtin_labs(__x);
}
@@ -112,9 +112,9 @@ inline _LIBCPP_INLINE_VISIBILITY long long abs(long long __x) _NOEXCEPT {
return __builtin_llabs(__x);
}
#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+#endif // !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
-#if !(defined(_AIX) || defined(__sun__))
+#if !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY float abs(float __lcpp_x) _NOEXCEPT {
return __builtin_fabsf(__lcpp_x); // Use builtins to prevent needing math.h
}
@@ -127,7 +127,7 @@ inline _LIBCPP_INLINE_VISIBILITY long double
abs(long double __lcpp_x) _NOEXCEPT {
return __builtin_fabsl(__lcpp_x);
}
-#endif // !(defined(_AIX) || defined(__sun__))
+#endif // !defined(__sun__)
// div
@@ -138,7 +138,7 @@ abs(long double __lcpp_x) _NOEXCEPT {
#endif
// MSVCRT already has the correct prototype in <stdlib.h> if __cplusplus is defined
-#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__) && !defined(_AIX)
+#if !defined(_LIBCPP_MSVCRT) && !defined(__sun__)
inline _LIBCPP_INLINE_VISIBILITY ldiv_t div(long __x, long __y) _NOEXCEPT {
return ::ldiv(__x, __y);
}
@@ -148,7 +148,7 @@ inline _LIBCPP_INLINE_VISIBILITY lldiv_t div(long long __x,
return ::lldiv(__x, __y);
}
#endif // _LIBCPP_HAS_NO_LONG_LONG
-#endif // _LIBCPP_MSVCRT / __sun__ / _AIX
+#endif // _LIBCPP_MSVCRT / __sun__
} // extern "C++"
#endif // __cplusplus
More information about the libcxx-commits
mailing list