diff options
author | Michal Klocek <michal.klocek@qt.io> | 2022-07-08 11:26:18 +0200 |
---|---|---|
committer | Michal Klocek <michal.klocek@qt.io> | 2022-07-25 07:37:06 +0000 |
commit | bb8a10a90551248e5da3d569a6f3731a5a47a968 (patch) | |
tree | ab3ae3a6aa12e4e9a4c6ae63b1e9e9c4557c8449 | |
parent | 5f9753749b6c138c1d5bc390006396e9a65b19a1 (diff) | |
download | qtwebengine-chromium-bb8a10a90551248e5da3d569a6f3731a5a47a968.tar.gz |
Rewrite array for token/unguessable token
Use union to wrap array as with neon intrinsics this gets
miss-compiled and ends up triggering alignment trap on arm32.
Note the same code without neon support works just fine.
Pick-to: 98-based 102-based
Fixes: QTBUG-104477
Fixes: QTBUG-103149
Change-Id: I9dd183c16874021e62135c5dcfa6865ab9783fcf
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
-rw-r--r-- | chromium/base/token.cc | 2 | ||||
-rw-r--r-- | chromium/base/token.h | 23 |
2 files changed, 15 insertions, 10 deletions
diff --git a/chromium/base/token.cc b/chromium/base/token.cc index 6b9f3f9b72a..b09fe32fd6f 100644 --- a/chromium/base/token.cc +++ b/chromium/base/token.cc @@ -24,7 +24,7 @@ Token Token::CreateRandom() { } std::string Token::ToString() const { - return base::StringPrintf("%016" PRIX64 "%016" PRIX64, words_[0], words_[1]); + return base::StringPrintf("%016" PRIX64 "%016" PRIX64, words_.w0, words_.w1); } void WriteTokenToPickle(Pickle* pickle, const Token& token) { diff --git a/chromium/base/token.h b/chromium/base/token.h index 2490abaa0b4..ccec44155bf 100644 --- a/chromium/base/token.h +++ b/chromium/base/token.h @@ -41,17 +41,17 @@ class BASE_EXPORT Token { static Token CreateRandom(); // The high and low 64 bits of this Token. - constexpr uint64_t high() const { return words_[0]; } - constexpr uint64_t low() const { return words_[1]; } + constexpr uint64_t high() const { return words_.w0; } + constexpr uint64_t low() const { return words_.w1; } - constexpr bool is_zero() const { return words_[0] == 0 && words_[1] == 0; } + constexpr bool is_zero() const { return words_.w0 == 0 && words_.w1 == 0; } span<const uint8_t, 16> AsBytes() const { - return as_bytes(make_span(words_)); + return as_bytes(make_span(words_.arr)); } constexpr bool operator==(const Token& other) const { - return words_[0] == other.words_[0] && words_[1] == other.words_[1]; + return words_.w0 == other.words_.w0 && words_.w1 == other.words_.w1; } constexpr bool operator!=(const Token& other) const { @@ -59,8 +59,8 @@ class BASE_EXPORT Token { } constexpr bool operator<(const Token& other) const { - return std::tie(words_[0], words_[1]) < - std::tie(other.words_[0], other.words_[1]); + return std::tie(words_.w0, words_.w1) < + std::tie(other.words_.w0, other.words_.w1); } // Generates a string representation of this Token useful for e.g. logging. @@ -70,8 +70,13 @@ class BASE_EXPORT Token { // Note: Two uint64_t are used instead of uint8_t[16] in order to have a // simpler implementation, paricularly for |ToString()|, |is_zero()|, and // constexpr value construction. - - uint64_t words_[2] = {0, 0}; + union { + uint64_t arr[2]; + struct { + uint64_t w0; + uint64_t w1; + }; + } words_ = {{0,0}}; }; // For use in std::unordered_map. |