summaryrefslogtreecommitdiff
path: root/absl/numeric
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2018-03-06 12:30:19 -0800
committerGravatar Shaindel Schwartz <shaindel@google.com>2018-03-06 17:21:05 -0500
commit94f0f79ecd2d9e5271a21bc4ededea9b58c60674 (patch)
tree7e1fd953b35cd6961e0d5717e5f465d1931fd1d4 /absl/numeric
parent5337d2d0e312ce6bce0140b5f1da5548a0b3fed5 (diff)
Changes imported from Abseil "staging" branch:
- aba727a5943a014392e3873349cee9dd5efc634e Avoid using 128-bit intrinsics for Clang on Windows. by Abseil Team <absl-team@google.com> - cdd19f1eda562af8906bff8feff827eb8e8e9797 Utilize the rtems TID infrastructure on myriad2 platforms. by Abseil Team <absl-team@google.com> - 52f7f55daa84ea25fa210d1b9d2bd64d128e1d81 Use intrinsic 128 bit integer when available for division... by Alex Strelnikov <strel@google.com> - 51f881b1152c0c861cf7fcac53f30d3c7ce12902 Merge GitHub #95: Fix compiler version check for clang-cl... by Derek Mauro <dmauro@google.com> GitOrigin-RevId: aba727a5943a014392e3873349cee9dd5efc634e Change-Id: I9b52d84095537acbbc96d3f74917f78da9a51156
Diffstat (limited to 'absl/numeric')
-rw-r--r--absl/numeric/int128.cc10
1 files changed, 10 insertions, 0 deletions
diff --git a/absl/numeric/int128.cc b/absl/numeric/int128.cc
index f24b785c..3688e5ef 100644
--- a/absl/numeric/int128.cc
+++ b/absl/numeric/int128.cc
@@ -130,16 +130,26 @@ uint128::uint128(double v) : uint128(MakeUint128FromFloat(v)) {}
uint128::uint128(long double v) : uint128(MakeUint128FromFloat(v)) {}
uint128 operator/(uint128 lhs, uint128 rhs) {
+#if defined(ABSL_HAVE_INTRINSIC_INT128)
+ return static_cast<unsigned __int128>(lhs) /
+ static_cast<unsigned __int128>(rhs);
+#else // ABSL_HAVE_INTRINSIC_INT128
uint128 quotient = 0;
uint128 remainder = 0;
DivModImpl(lhs, rhs, &quotient, &remainder);
return quotient;
+#endif // ABSL_HAVE_INTRINSIC_INT128
}
uint128 operator%(uint128 lhs, uint128 rhs) {
+#if defined(ABSL_HAVE_INTRINSIC_INT128)
+ return static_cast<unsigned __int128>(lhs) %
+ static_cast<unsigned __int128>(rhs);
+#else // ABSL_HAVE_INTRINSIC_INT128
uint128 quotient = 0;
uint128 remainder = 0;
DivModImpl(lhs, rhs, &quotient, &remainder);
return remainder;
+#endif // ABSL_HAVE_INTRINSIC_INT128
}
namespace {