Mercurial > projects > ldc
comparison dmd/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 | aaade6ded589 |
children | b30fe7e1dbb9 |
comparison
equal
deleted
inserted
replaced
1002:c749648ed2b8 | 1003:de97188378bc |
---|---|
128 * Align sizes of 0, as we may not know array sizes yet. | 128 * Align sizes of 0, as we may not know array sizes yet. |
129 */ | 129 */ |
130 | 130 |
131 void AggregateDeclaration::alignmember(unsigned salign, unsigned size, unsigned *poffset) | 131 void AggregateDeclaration::alignmember(unsigned salign, unsigned size, unsigned *poffset) |
132 { | 132 { |
133 //printf("salign = %d, size = %d, offset = %d\n",salign,size,offset); | 133 //printf("salign = %d, size = %d, offset = %d\n",salign,size,*poffset); |
134 if (salign > 1) | 134 if (salign > 1) |
135 { int sa; | 135 { int sa; |
136 | 136 |
137 switch (size) | 137 switch (size) |
138 { case 1: | 138 { case 1: |
146 if (salign == 2) | 146 if (salign == 2) |
147 goto case_2; | 147 goto case_2; |
148 *poffset = (*poffset + 3) & ~3; // align to dword | 148 *poffset = (*poffset + 3) & ~3; // align to dword |
149 break; | 149 break; |
150 default: | 150 default: |
151 *poffset = (*poffset + salign - 1) & ~(salign - 1); | 151 *poffset = (*poffset + size - 1) & ~(size - 1); |
152 break; | 152 break; |
153 } | 153 } |
154 } | 154 } |
155 //printf("result = %d\n",offset); | 155 //printf("result = %d\n",*poffset); |
156 } | 156 } |
157 | 157 |
158 | 158 |
159 void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v) | 159 void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v) |
160 { | 160 { |