aboutsummaryrefslogtreecommitdiff
path: root/types.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-09-11 12:01:17 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-09-11 12:01:17 -0400
commitdee3742b48e27ef36637d004163286d3352b0763 (patch)
tree881a9a25b4cfeb6ff632a3fa48ccd3abd7f642ae /types.c
parentbba9f1b141fba5ffc366ef9377fb3089c0c5a1a3 (diff)
Optional structs
Diffstat (limited to 'types.c')
-rw-r--r--types.c7
1 files changed, 5 insertions, 2 deletions
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 <gc/cord.h>
-#include <stdint.h>
-#include <signal.h>
#include <limits.h>
#include <math.h>
+#include <signal.h>
+#include <stdint.h>
+#include <sys/param.h>
#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);
}
}