Mercurial > projects > ldc
comparison dmd2/struct.c @ 1003:de97188378bc
Fix struct field alignment on x86-64 (for align > 8, like real.alignof)
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Fri, 27 Feb 2009 12:35:31 +0100 |
parents | 356e65836fb5 |
children | 638d16625da2 |
comparison
equal
deleted
inserted
replaced
1002:c749648ed2b8 | 1003:de97188378bc |
---|---|
132 * Align sizes of 0, as we may not know array sizes yet. | 132 * Align sizes of 0, as we may not know array sizes yet. |
133 */ | 133 */ |
134 | 134 |
135 void AggregateDeclaration::alignmember(unsigned salign, unsigned size, unsigned *poffset) | 135 void AggregateDeclaration::alignmember(unsigned salign, unsigned size, unsigned *poffset) |
136 { | 136 { |
137 //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); | 137 //printf("salign = %d, size = %d, offset = %d\n",salign,size,*poffset); |
138 if (salign > 1) | 138 if (salign > 1) |
139 { int sa; | 139 { int sa; |
140 | 140 |
141 switch (size) | 141 switch (size) |
142 { case 1: | 142 { case 1: |
150 if (salign == 2) | 150 if (salign == 2) |
151 goto case_2; | 151 goto case_2; |
152 *poffset = (*poffset + 3) & ~3; // align to dword | 152 *poffset = (*poffset + 3) & ~3; // align to dword |
153 break; | 153 break; |
154 default: | 154 default: |
155 *poffset = (*poffset + salign - 1) & ~(salign - 1); | 155 *poffset = (*poffset + size - 1) & ~(size - 1); |
156 break; | 156 break; |
157 } | 157 } |
158 } | 158 } |
159 //printf("result = %d\n",offset); | 159 //printf("result = %d\n",*poffset); |
160 } | 160 } |
161 | 161 |
162 | 162 |
163 void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v) | 163 void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v) |
164 { | 164 { |