about summary refs log tree commit diff
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-02-22T16·36-0800
committerDerek Mauro <dmauro@google.com>2018-02-23T16·27-0500
commit0d40cb771eec8741f44e5979cfccf1eeeedb012a (patch)
tree658d7db6ba497b0d3b6dc738ccead5c297b6e8a4
parentdca2eb50f9f5ee378395ee020953dc20a2a84c97 (diff)
Changes imported from Abseil "staging" branch:
  - 5d9197f54029dd26e144365738e99a1d3582cc18 Change alignment requirement for uint128. by Alex Strelnikov <strel@google.com>

GitOrigin-RevId: 5d9197f54029dd26e144365738e99a1d3582cc18
Change-Id: Ibac0689c5d95a019441be9d4479b65c5aba1c286
-rw-r--r--absl/numeric/int128.h13
1 files changed, 10 insertions, 3 deletions
diff --git a/absl/numeric/int128.h b/absl/numeric/int128.h
index 2eded2f3b549..803f0ff23ab8 100644
--- a/absl/numeric/int128.h
+++ b/absl/numeric/int128.h
@@ -45,8 +45,8 @@ namespace absl {
 // as closely as is practical, including exhibiting undefined behavior in
 // analogous cases (e.g. division by zero). This type is intended to be a
 // drop-in replacement once C++ supports an intrinsic `uint128_t` type; when
-// that occurs, existing uses of `uint128` will continue to work using that new
-// type.
+// that occurs, existing well-behaved uses of `uint128` will continue to work
+// using that new type.
 //
 // Note: code written with this type will continue to compile once `uint128_t`
 // is introduced, provided the replacement helper functions
@@ -70,6 +70,9 @@ namespace absl {
 //     types.
 //   * Conversion to integral types requires an explicit static_cast() to
 //     mimic use of the `-Wnarrowing` compiler flag.
+//   * The alignment requirement of `uint128` may differ from that of an
+//     intrinsic 128-bit integer type depending on platform and build
+//     configuration.
 //
 // Example:
 //
@@ -80,7 +83,11 @@ namespace absl {
 //     absl::uint64_t i = v;                         // Error
 //     absl::uint64_t i = static_cast<uint64_t>(v);  // OK
 //
-class alignas(16) uint128 {
+class
+#if defined(ABSL_HAVE_INTRINSIC_INT128)
+    alignas(unsigned __int128)
+#endif  // ABSL_HAVE_INTRINSIC_INT128
+        uint128 {
  public:
   uint128() = default;