+static inline int validate_struct(PSI_Validator *V, decl_struct *s) {
+ size_t i;
+
+ if (!validate_decl_args(V, s->args)) {
+ return 0;
+ }
+
+ s->layout = calloc(s->args->count, sizeof(*s->layout));
+ for (i = 0; i < s->args->count; ++i) {
+ decl_arg *darg = s->args->args[i];
+ token_t t;
+
+ if (!validate_decl_arg(V, darg)) {
+ return 0;
+ }
+
+ t = darg->var->pointer_level
+ ? PSI_T_POINTER
+ : real_decl_type(darg->type)->type;
+
+ if (i) {
+ decl_struct_layout *l = &s->layout[i-1];
+ s->layout[i].pos = psi_t_align(t, l->pos + l->len);
+ } else {
+ s->layout[i].pos = 0;
+ }
+ s->layout[i].len = psi_t_size(t);
+ }
+ return 1;
+}
+static inline int validate_structs(PSI_Validator *V) {
+ size_t i;
+
+ for (i = 0; i < V->structs->count; ++i) {
+ if (!validate_struct(V, V->structs->list[i])) {
+ return 0;
+ }
+ }
+ return 1;
+}