commit 8d0efe4 Author: Martin Husemann Date: Wed Jun 18 18:12:22 2014 +0200 Bug 1026499 - Use MOZ_ALIGNED_DECL to declare union members in ipdl value declarations. r=bsmedberg --- ipc/ipdl/ipdl/cxx/ast.py | 7 ++++--- ipc/ipdl/ipdl/cxx/cgen.py | 5 ++++- ipc/ipdl/ipdl/lower.py | 2 +- 4 files changed, 10 insertions(+), 5 deletions(-) diff --git ipc/ipdl/ipdl/cxx/ast.py ipc/ipdl/ipdl/cxx/ast.py index 3180a65..c2d945b 100644 --- ipc/ipdl/ipdl/cxx/ast.py +++ ipc/ipdl/ipdl/cxx/ast.py @@ -336,12 +336,13 @@ Type.VOID = Type('void') Type.VOIDPTR = Type('void', ptr=1) class TypeArray(Node): - def __init__(self, basetype, nmemb): - '''the type |basetype DECLNAME[nmemb]|. |nmemb| is an Expr''' + def __init__(self, basetype, nmemb, alignType): + '''the type |basetype DECLNAME[nmemb]|. |nmemb| is an Expr, |alignType| is a type''' self.basetype = basetype self.nmemb = nmemb + self.alignType = alignType def __deepcopy__(self, memo): - return TypeArray(deepcopy(self.basetype, memo), nmemb) + return TypeArray(deepcopy(self.basetype, memo), nmemb, alignType) class TypeEnum(Node): def __init__(self, name=None): diff --git ipc/ipdl/ipdl/cxx/cgen.py ipc/ipdl/ipdl/cxx/cgen.py index 48b0988..bc914cf 100644 --- ipc/ipdl/ipdl/cxx/cgen.py +++ ipc/ipdl/ipdl/cxx/cgen.py @@ -101,6 +101,7 @@ class CxxCodeGen(CodePrinter, Visitor): def visitDecl(self, d): # C-syntax arrays make code generation much more annoying if isinstance(d.type, TypeArray): + self.write('MOZ_ALIGNED_DECL(') d.type.basetype.accept(self) else: d.type.accept(self) @@ -111,7 +112,9 @@ class CxxCodeGen(CodePrinter, Visitor): if isinstance(d.type, TypeArray): self.write('[') d.type.nmemb.accept(self) - self.write(']') + self.write('], MOZ_ALIGNOF(') + d.type.alignType.accept(self) + self.write('))') def visitParam(self, p): self.visitDecl(p) diff --git ipc/ipdl/ipdl/lower.py ipc/ipdl/ipdl/lower.py index e97a34c..9360f3c 100644 --- ipc/ipdl/ipdl/lower.py +++ ipc/ipdl/ipdl/lower.py @@ -768,7 +768,7 @@ IPDL union type.""" if self.recursive: return self.ptrToType() else: - return TypeArray(Type('char'), ExprSizeof(self.internalType())) + return TypeArray(Type('char'), ExprSizeof(self.internalType()), self.internalType()) def unionValue(self): # NB: knows that Union's storage C union is named |mValue|