Merge "Force alignment for GrantorDescriptor struct."
diff --git a/base/include/hidl/MQDescriptor.h b/base/include/hidl/MQDescriptor.h
index ec063f4..869917c 100644
--- a/base/include/hidl/MQDescriptor.h
+++ b/base/include/hidl/MQDescriptor.h
@@ -29,12 +29,19 @@
typedef uint64_t RingBufferPosition;
struct GrantorDescriptor {
- uint32_t flags;
- uint32_t fdIndex;
- uint32_t offset;
- size_t extent;
+ uint32_t flags __attribute__ ((aligned(4)));
+ uint32_t fdIndex __attribute__ ((aligned(4)));
+ uint32_t offset __attribute__ ((aligned(4)));
+ uint64_t extent __attribute__ ((aligned(8)));
};
+static_assert(offsetof(GrantorDescriptor, flags) == 0, "wrong offset");
+static_assert(offsetof(GrantorDescriptor, fdIndex) == 4, "wrong offset");
+static_assert(offsetof(GrantorDescriptor, offset) == 8, "wrong offset");
+static_assert(offsetof(GrantorDescriptor, extent) == 16, "wrong offset");
+static_assert(sizeof(GrantorDescriptor) == 24, "wrong size");
+static_assert(__alignof(GrantorDescriptor) == 8, "wrong alignment");
+
enum MQFlavor : uint32_t {
/*
* kSynchronizedReadWrite represents the wait-free synchronized flavor of the