diff options
| author | Ginger Bill <bill@gingerbill.org> | 2017-02-05 15:19:30 +0000 |
|---|---|---|
| committer | Ginger Bill <bill@gingerbill.org> | 2017-02-05 15:19:30 +0000 |
| commit | 2a5b674d33e4f483964da119f76038457cd9f1f2 (patch) | |
| tree | 1e094b9e6ed3fa435dc5c76cdf7f4a7e740781f7 /src/types.c | |
| parent | 7944b7714f5478b9a89e3fc1e331e8090652e49e (diff) | |
Custom struct alignment
Diffstat (limited to 'src/types.c')
| -rw-r--r-- | src/types.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/types.c b/src/types.c index 52a8c4d08..5443f85f1 100644 --- a/src/types.c +++ b/src/types.c @@ -87,6 +87,8 @@ typedef struct TypeRecord { bool struct_is_ordered; Entity **fields_in_src_order; // Entity_Variable + i64 custom_align; // NOTE(bill): Only used in structs at the moment + Type * enum_base_type; Entity * enum_count; Entity * enum_min_value; @@ -1459,6 +1461,9 @@ i64 type_align_of_internal(BaseTypeSizes s, gbAllocator allocator, Type *t, Type case Type_Record: { switch (t->Record.kind) { case TypeRecord_Struct: + if (t->Record.custom_align > 0) { + return gb_clamp(t->Record.custom_align, 1, s.max_align); + } if (t->Record.field_count > 0) { // TODO(bill): What is this supposed to be? if (t->Record.struct_is_packed) { |