summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2023-06-16 22:45:08 -0700
committerGravatar Copybara-Service <copybara-worker@google.com>2023-06-16 22:46:16 -0700
commit76548f868453259834c6b96a3c2e434200d9d289 (patch)
treefbd636ce64b9d0a93a41bfa23cf45e0c3c0821d1
parent049aa40e7ec9e37ed47c4dd2452affb13cd62ebe (diff)
Ensure arrays are 16-byte aligned before casting to uint128
PiperOrigin-RevId: 541111597 Change-Id: I88165130e30e548a03d8d6173dadab33dc18b21e
-rw-r--r--absl/random/internal/randen_benchmarks.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/absl/random/internal/randen_benchmarks.cc b/absl/random/internal/randen_benchmarks.cc
index f589172c..ec086cea 100644
--- a/absl/random/internal/randen_benchmarks.cc
+++ b/absl/random/internal/randen_benchmarks.cc
@@ -47,8 +47,10 @@ static constexpr size_t kSeedSizeT = Randen::kSeedBytes / sizeof(uint32_t);
// Randen implementation benchmarks.
template <typename T>
struct AbsorbFn : public T {
- mutable uint64_t state[kStateSizeT] = {};
- mutable uint32_t seed[kSeedSizeT] = {};
+ // These are both cast to uint128* in the RandenHwAes implementation, so
+ // ensure they are 16 byte aligned.
+ alignas(16) mutable uint64_t state[kStateSizeT] = {};
+ alignas(16) mutable uint32_t seed[kSeedSizeT] = {};
static constexpr size_t bytes() { return sizeof(seed); }