Fix alignment of structs containing real

This commit is contained in:
Alexey Prokhin
2011-02-25 22:29:43 +03:00
parent 1653abbbc9
commit 3bb91c7513
2 changed files with 11 additions and 8 deletions

View File

@@ -322,24 +322,24 @@ void Type::init()
#endif #endif
Tsize_t = Tuns32; Tsize_t = Tuns32;
Tptrdiff_t = Tint32; Tptrdiff_t = Tint32;
PTRSIZE = 4; PTRSIZE = 4;
} }
// set real size and padding // set real size and padding
if (global.params.cpu == ARCHx86) if (global.params.cpu == ARCHx86)
{ {
REALSIZE = 12; REALSIZE = 12;
REALPAD = 2; REALPAD = 2;
} }
else if (global.params.cpu == ARCHx86_64) else if (global.params.cpu == ARCHx86_64)
{ {
REALSIZE = 16; REALSIZE = 16;
REALPAD = 6; REALPAD = 6;
} }
else else
{ {
REALSIZE = 8; REALSIZE = 8;
REALPAD = 0; REALPAD = 0;
} }
} }

View File

@@ -226,10 +226,13 @@ void AggregateDeclaration::addField(Scope *sc, VarDeclaration *v)
if (!isUnionDeclaration()) if (!isUnionDeclaration())
sc->offset = ofs; sc->offset = ofs;
#endif #endif
#if !IN_LLVM
if (global.params.is64bit && sc->structalign == 8 && memalignsize == 16) if (global.params.is64bit && sc->structalign == 8 && memalignsize == 16)
/* Not sure how to handle this */ /* Not sure how to handle this */
; ;
else if (sc->structalign < memalignsize) else
#endif
if (sc->structalign < memalignsize)
memalignsize = sc->structalign; memalignsize = sc->structalign;
if (alignsize < memalignsize) if (alignsize < memalignsize)
alignsize = memalignsize; alignsize = memalignsize;