Enforce Treble "wire" ABI by emitting static_asserts for the sizes of
hidl types, such as hidl_handle, hidl_memory, hidl_string and friends.
Bug: 33846034
Test: make
Change-Id: I859b5a7185e2c3e59ef5665e8f8c1f5bb34bced3
diff --git a/FmqType.cpp b/FmqType.cpp
index 989f613..e3a8ae6 100644
--- a/FmqType.cpp
+++ b/FmqType.cpp
@@ -16,6 +16,8 @@
#include "FmqType.h"
+#include "HidlTypeAssertion.h"
+
#include <hidl-util/Formatter.h>
#include <android-base/logging.h>
@@ -137,10 +139,14 @@
return false;
}
+// All MQDescriptor<T, flavor> have the same size.
+static HidlTypeAssertion assertion(
+ "MQDescriptor<char, ::android::hardware::kSynchronizedReadWrite>", 32);
+
void FmqType::getAlignmentAndSize(
size_t *align, size_t *size) const {
*align = 8; // MQDescriptor<>
- *size = 32;
+ *size = assertion.size();
}
bool FmqType::needsEmbeddedReadWrite() const {