summaryrefslogtreecommitdiff
path: root/mojo/public/c/system/buffer.h
diff options
context:
space:
mode:
authorChih-Hung Hsieh <chh@google.com>2018-11-16 09:07:02 +0900
committerQijiang Fan <fqj@google.com>2020-06-06 03:55:08 +0900
commit7fdaccd7985435112365df9a8931638f31d99bee (patch)
treec08ab96942e6d32761c8738cc73ee8795d630458 /mojo/public/c/system/buffer.h
parenta3f0ea1b5747b2bdc0fe4df8685162d6174fe362 (diff)
downloadlibchrome-7fdaccd7985435112365df9a8931638f31d99bee.tar.gz
Update asserts in mojo about int64_t's alignment
The purpose of these asserts is to check that the options structs are aligned sufficiently that an int64_t (or similar) could be added to them. The asserts were added in https://codereview.chromium.org/295383012 However, the alignment of int64_t on 32-bit x86 is actually 4 bytes, not 8. So how did this ever work? Before Clang r345419, the alignof() operator (which is what MOJO_ALIGNOF maps to) would return the *preferred alignment* of a type, not the *ABI alignment*. That's not what the C and C++ standards specify, so the bug was fixed and the asserts started firing. (See also https://llvm.org/pr26547) To fix the build, change the asserts to check that int64_t requires 8 bytes alignment *or less*. Bug: 900406 Bug: 119634736 Test: make checkbuild Change-Id: Icf80cea80ac31082423faab8c192420d0b98d515 Reviewed-on: https://chromium-review.googlesource.com/c/1318971 Commit-Queue: Ken Rockot <rockot@google.com> Reviewed-by: Ken Rockot <rockot@google.com> Cr-Commit-Position: refs/heads/master@{#605699} (Reconstructed from 9525530ea4ee4d70b55b5b376ad96ecdd587bd39)
Diffstat (limited to 'mojo/public/c/system/buffer.h')
-rw-r--r--mojo/public/c/system/buffer.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/mojo/public/c/system/buffer.h b/mojo/public/c/system/buffer.h
index 2cc54270ad..83b198b2a8 100644
--- a/mojo/public/c/system/buffer.h
+++ b/mojo/public/c/system/buffer.h
@@ -30,7 +30,7 @@ struct MOJO_ALIGNAS(8) MojoCreateSharedBufferOptions {
// See |MojoCreateSharedBufferFlags|.
MojoCreateSharedBufferFlags flags;
};
-MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) == 8, "int64_t has weird alignment");
+MOJO_STATIC_ASSERT(MOJO_ALIGNOF(int64_t) <= 8, "int64_t has weird alignment");
MOJO_STATIC_ASSERT(sizeof(MojoCreateSharedBufferOptions) == 8,
"MojoCreateSharedBufferOptions has wrong size");