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/MemoryType.cpp b/MemoryType.cpp
index 614f368..f685cfc 100644
--- a/MemoryType.cpp
+++ b/MemoryType.cpp
@@ -16,6 +16,8 @@
#include "MemoryType.h"
+#include "HidlTypeAssertion.h"
+
#include <hidl-util/Formatter.h>
#include <android-base/logging.h>
@@ -140,9 +142,10 @@
return false;
}
+static HidlTypeAssertion assertion("hidl_memory", 40 /* size */);
void MemoryType::getAlignmentAndSize(size_t *align, size_t *size) const {
*align = 8; // hidl_memory
- *size = 40;
+ *size = assertion.size();
}
status_t MemoryType::emitVtsTypeDeclarations(Formatter &out) const {