mirror of
https://github.com/reactos/wine.git
synced 2024-11-25 04:39:45 +00:00
server: Generate padding in request structures from make_requests.
Add compile-time asserts to check that the structures have the expected layout.
This commit is contained in:
parent
317ad64985
commit
7f1dc355ec
File diff suppressed because it is too large
Load Diff
@ -680,7 +680,6 @@ typedef union
|
||||
|
||||
/* Notify the server that a dll is being unloaded */
|
||||
@REQ(unload_dll)
|
||||
int __pad;
|
||||
mod_handle_t base; /* base address */
|
||||
@END
|
||||
|
||||
|
1294
server/request.h
1294
server/request.h
File diff suppressed because it is too large
Load Diff
@ -53,6 +53,7 @@ my %formats =
|
||||
|
||||
my @requests = ();
|
||||
my %replies = ();
|
||||
my @asserts = ();
|
||||
|
||||
my @trace_lines = ();
|
||||
|
||||
@ -167,11 +168,18 @@ sub PARSE_REQUESTS()
|
||||
if (/^\@END/)
|
||||
{
|
||||
die "Misplaced \@END" unless ($state == 2 || $state == 3);
|
||||
print SERVER_PROT "};\n";
|
||||
|
||||
if ($offset & 7) # all requests should be 8-byte aligned
|
||||
{
|
||||
my $count = 8 - ($offset & 7);
|
||||
print SERVER_PROT " char __pad_$offset\[$count\];\n";
|
||||
$offset += $count;
|
||||
}
|
||||
print SERVER_PROT "};\n";
|
||||
if ($state == 2) # build dummy reply struct
|
||||
{
|
||||
die "request $name too large ($offset)" if ($offset > $max_req_size);
|
||||
push @asserts, "C_ASSERT( sizeof(struct ${name}_request) == $offset );\n";
|
||||
print SERVER_PROT "struct ${name}_reply\n{\n";
|
||||
print SERVER_PROT " struct reply_header __header;\n";
|
||||
print SERVER_PROT "};\n";
|
||||
@ -179,6 +187,7 @@ sub PARSE_REQUESTS()
|
||||
else
|
||||
{
|
||||
die "reply $name too large ($offset)" if ($offset > $max_req_size);
|
||||
push @asserts, "C_ASSERT( sizeof(struct ${name}_reply) == $offset );\n";
|
||||
}
|
||||
# got a complete request
|
||||
push @requests, $name;
|
||||
@ -221,9 +230,19 @@ sub PARSE_REQUESTS()
|
||||
my @fmt = @{$formats{$type}};
|
||||
if ($offset & ($fmt[1] - 1))
|
||||
{
|
||||
my $count = $fmt[1] - ($offset & ($fmt[1] - 1));
|
||||
print "protocol.def:$.: warning: $name $offset $type $var needs padding\n" if $warnings;
|
||||
print SERVER_PROT " char __pad_$offset\[$count\];\n";
|
||||
$offset += $count;
|
||||
}
|
||||
if ($state == 2)
|
||||
{
|
||||
push @asserts, "C_ASSERT( FIELD_OFFSET(struct ${name}_request, $var) == $offset );\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
push @asserts, "C_ASSERT( FIELD_OFFSET(struct ${name}_reply, $var) == $offset );\n";
|
||||
}
|
||||
$offset = ($offset + $fmt[1] - 1) & ~($fmt[1] - 1);
|
||||
$offset += $fmt[0];
|
||||
}
|
||||
else
|
||||
@ -428,7 +447,15 @@ foreach my $req (@requests)
|
||||
{
|
||||
push @request_lines, " (req_handler)req_$req,\n";
|
||||
}
|
||||
push @request_lines, "};\n#endif /* WANT_REQUEST_HANDLERS */\n";
|
||||
push @request_lines, "};\n\n";
|
||||
|
||||
foreach my $type (sort keys %formats)
|
||||
{
|
||||
my $size = ${$formats{$type}}[0];
|
||||
push @request_lines, "C_ASSERT( sizeof($type) == $size );\n";
|
||||
}
|
||||
push @request_lines, @asserts;
|
||||
push @request_lines, "\n#endif /* WANT_REQUEST_HANDLERS */\n";
|
||||
|
||||
replace_in_file( "server/request.h",
|
||||
"### make_requests begin ###",
|
||||
|
Loading…
Reference in New Issue
Block a user