comparison 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
comparison
equal deleted inserted replaced
545:ca28e9e3c644 546:ba70fb631bea
46 DCaggr* dcNewAggr(DCsize maxFieldCount, DCsize size) 46 DCaggr* dcNewAggr(DCsize maxFieldCount, DCsize size)
47 { 47 {
48 DCaggr* ag = (DCaggr*)dcAllocMem(sizeof(DCaggr) + maxFieldCount * sizeof(DCfield)); 48 DCaggr* ag = (DCaggr*)dcAllocMem(sizeof(DCaggr) + maxFieldCount * sizeof(DCfield));
49 ag->n_fields = 0; 49 ag->n_fields = 0;
50 ag->size = size; 50 ag->size = size;
51 ag->alignment = 0;
51 return ag; 52 return ag;
52 } 53 }
53 54
54 55
55 void dcAggrField(DCaggr* ag, DCsigchar type, DCint offset, DCsize array_len, ...) 56 void dcAggrField(DCaggr* ag, DCsigchar type, DCint offset, DCsize array_len, ...)
81 va_start(ap, array_len); 82 va_start(ap, array_len);
82 f->sub_aggr = va_arg(ap, const DCaggr*); 83 f->sub_aggr = va_arg(ap, const DCaggr*);
83 va_end(ap); 84 va_end(ap);
84 85
85 f->size = f->sub_aggr->size; 86 f->size = f->sub_aggr->size;
87 f->alignment = f->sub_aggr->alignment;
86 break; 88 break;
87 } 89 }
88 default: 90 default:
89 assert(0); 91 assert(0);
90 } 92 }
93
94 if(type != DC_SIGCHAR_AGGREGATE)
95 f->alignment = f->size;
96
97 /* aggr's field alignment is relative largest field size */
98 if(ag->alignment < f->alignment)
99 ag->alignment = f->alignment;
91 } 100 }
92 101
93 102
94 void dcCloseAggr(DCaggr* ag) 103 void dcCloseAggr(DCaggr* ag)
95 { 104 {