harec

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 9a9199ee9d8fac4e82ecd3337d1286b1d83c7a0f
parent 3fdbcbb3c04f151e3878e73494f455f8a68f540d
Author: Drew DeVault <sir@cmpwn.com>
Date:   Sun, 31 Jan 2021 12:47:00 -0500

gen: fix gen_copy alignment issues

Diffstat:
Msrc/gen.c | 9++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/gen.c b/src/gen.c @@ -197,6 +197,7 @@ gen_copy(struct gen_context *ctx, } } + size_t offset = 0; while (field) { temp.type = field->type; if (temp.type->stype == Q_HALF || temp.type->stype == Q_BYTE) { @@ -232,7 +233,13 @@ gen_copy(struct gen_context *ctx, if (!dest->type->is_union) { assert(field->type->size != 0); - constl(&size, field->type->size); + size_t add = field->type->size; + offset += add; + if (field->next && offset % field->next->type->size != 0) { + add += offset % field->next->type->size; + offset += offset % field->next->type->size; + } + constl(&size, add); pushi(ctx->current, &destp, Q_ADD, &destp, &size, NULL); pushi(ctx->current, &srcp, Q_ADD, &srcp, &size, NULL); }