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/VectorType.cpp b/VectorType.cpp
index 6a0542e..237113e 100644
--- a/VectorType.cpp
+++ b/VectorType.cpp
@@ -18,6 +18,7 @@
#include "ArrayType.h"
#include "CompoundType.h"
+#include "HidlTypeAssertion.h"
#include <hidl-util/Formatter.h>
#include <android-base/logging.h>
@@ -740,9 +741,11 @@
return mElementType->containsPointer();
}
+// All hidl_vec<T> have the same size.
+static HidlTypeAssertion assertion("hidl_vec<char>", 16 /* size */);
void VectorType::getAlignmentAndSize(size_t *align, size_t *size) const {
*align = 8; // hidl_vec<T>
- *size = 16;
+ *size = assertion.size();
}
} // namespace android