+/*
+ * Handles the declaration
+ * type new = struct { type1 a1; type2 a2; ... };
+ */
+ipc_type_t *
+itStructDecl(u_int min_type_size_in_bytes, u_int required_alignment_in_bytes)
+{
+ int final_struct_bytes = min_type_size_in_bytes;
+ if (final_struct_bytes % required_alignment_in_bytes) {
+ final_struct_bytes += required_alignment_in_bytes -
(final_struct_bytes % required_alignment_in_bytes);
+ }
+ ipc_type_t *element_type = NULL;
+ int number_elements = 0;
+ // If the struct is short or int aligned, use that as the base type.
+ switch (required_alignment_in_bytes) {
+ case 2:
+ element_type = itShortType;
+ assert(final_struct_bytes % 2 == 0);
+ number_elements = final_struct_bytes / 2;
+ break;
+ case 4:
+ element_type = itIntType;
+ assert(final_struct_bytes % 4 == 0);
+ number_elements = final_struct_bytes / 4;
+ break;
+ case 1:
+ default:
+ element_type = itByteType;
+ number_elements = final_struct_bytes;
+ break;
+ }