From dee3742b48e27ef36637d004163286d3352b0763 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 11 Sep 2024 12:01:17 -0400 Subject: Optional structs --- types.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'types.c') diff --git a/types.c b/types.c index daa1026f..6a1459c4 100644 --- a/types.c +++ b/types.c @@ -1,9 +1,10 @@ // Logic for handling type_t types #include -#include -#include #include #include +#include +#include +#include #include "builtins/integers.h" #include "builtins/table.h" @@ -418,6 +419,7 @@ PUREFUNC size_t type_size(type_t *t) case TYPE_IBITS8: return sizeof(OptionalInt8_t); default: errx(1, "Invalid integer bit size"); } + case StructType: return padded_type_size(nonnull) + 1; default: return type_size(nonnull); } } @@ -495,6 +497,7 @@ PUREFUNC size_t type_align(type_t *t) case TYPE_IBITS8: return __alignof__(OptionalInt8_t); default: errx(1, "Invalid integer bit size"); } + case StructType: return MAX(1, type_align(nonnull)); default: return type_align(nonnull); } } -- cgit v1.2.3