diff options
Diffstat (limited to 'source4/build/pidl/parser.pm')
-rw-r--r-- | source4/build/pidl/parser.pm | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/source4/build/pidl/parser.pm b/source4/build/pidl/parser.pm index 14314886dc..90a1998a50 100644 --- a/source4/build/pidl/parser.pm +++ b/source4/build/pidl/parser.pm @@ -56,6 +56,20 @@ sub find_size_var($$) ##################################################################### +# work out the correct alignment for a structure +sub struct_alignment($) +{ + my $s = shift; + my $align = 1; + for my $e (@{$s->{ELEMENTS}}) { + if ($align < util::type_align($e)) { + $align = util::type_align($e); + } + } + return $align; +} + +##################################################################### # parse an array - push side sub ParseArrayPush($$) { @@ -312,11 +326,14 @@ sub ParseStructPush($) $res .= "\tndr_push_save(ndr, &_save1);\n"; } + my $align = struct_alignment($struct); + $res .= "\tNDR_CHECK(ndr_push_align(ndr, $align));\n"; + $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; foreach my $e (@{$struct->{ELEMENTS}}) { if (defined($struct_len) && $e == $struct_len) { - $res .= "\tNDR_CHECK(ndr_push_align_$e->{TYPE}(ndr));\n"; + $res .= "\tNDR_CHECK(ndr_push_align(ndr, sizeof($e->{TYPE})));\n"; $res .= "\tndr_push_save(ndr, &_save2);\n"; } ParseElementPushScalar($e, "r->", "NDR_SCALARS"); @@ -394,6 +411,9 @@ sub ParseStructPull($) $res .= "\tndr_pull_save(ndr, &_save);\n"; } + my $align = struct_alignment($struct); + $res .= "\tNDR_CHECK(ndr_pull_align(ndr, $align));\n"; + $res .= "\tif (!(ndr_flags & NDR_SCALARS)) goto buffers;\n"; foreach my $e (@{$struct->{ELEMENTS}}) { ParseElementPullScalar($e, "r->", "NDR_SCALARS"); |