diff dyncall/dyncall_aggregate.c @ 546:ba70fb631bea

x64: * support for non-standard aggr-by-value packing (#pragma pack, etc.) * callbacks: handling callconv prefixes in signature
author Tassilo Philipp
date Tue, 31 May 2022 19:29:34 +0200
parents 71c884e610f0
children eef302b7a58d
line wrap: on
line diff
--- a/dyncall/dyncall_aggregate.c	Tue May 31 18:35:06 2022 +0200
+++ b/dyncall/dyncall_aggregate.c	Tue May 31 19:29:34 2022 +0200
@@ -48,6 +48,7 @@
 	DCaggr* ag = (DCaggr*)dcAllocMem(sizeof(DCaggr) + maxFieldCount * sizeof(DCfield));
 	ag->n_fields = 0;
 	ag->size = size;
+	ag->alignment = 0;
 	return ag;
 }
 
@@ -83,11 +84,19 @@
 			va_end(ap);
 
 			f->size = f->sub_aggr->size;
+			f->alignment = f->sub_aggr->alignment;
 			break;
 		}
 		default:
 			assert(0);
 	}
+
+	if(type != DC_SIGCHAR_AGGREGATE)
+		f->alignment = f->size;
+
+	/* aggr's field alignment is relative largest field size */
+	if(ag->alignment < f->alignment)
+		ag->alignment = f->alignment;
 }