SHA256
1
0
forked from pool/libvirt
libvirt/7e5f6a51-rpc-generator.patch

74 lines
3.2 KiB
Diff

commit 7e5f6a516c1b0066206364655be31276056da147
Author: Jim Fehlig <jfehlig@novell.com>
Date: Fri Aug 26 11:46:41 2011 -0600
Fix generator to cope with call-by-ref long types
From: Matthias Bolte <matthias.bolte@googlemail.com>
Tested-by: Jim Fehlig <jfehlig@novell.com>
Matthias provided this patch to fix an issue I encountered in the
generator with APIs containing call-by-ref long type, e.g.
int virDomainMigrateGetMaxSpeed(virDomainPtr domain,
unsigned long *bandwidth,
unsigned int flags);
diff --git a/src/rpc/gendispatch.pl b/src/rpc/gendispatch.pl
index 0d344e8..f671ff0 100755
--- a/src/rpc/gendispatch.pl
+++ b/src/rpc/gendispatch.pl
@@ -640,10 +640,11 @@ elsif ($opt_b) {
} elsif ($ret_member =~ m/^(?:unsigned )?hyper (\S+)<\S+>;/) {
# error out on unannotated arrays
die "hyper array without insert@<offset> annotation: $ret_member";
- } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);/) {
+ } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);(?:\s*\/\*\s*insert@(\d+)\s*\*\/)?/) {
my $type_name = $1;
my $ret_name = $2;
my $ret_assign;
+ my $insert = $3;
if (hyper_to_long($call->{ProcName}, "ret", $ret_name)) {
my $sign = ""; $sign = "U" if ($1);
@@ -657,7 +658,13 @@ elsif ($opt_b) {
push(@vars_list, "$type_name $ret_name");
push(@ret_list, $ret_assign);
- $single_ret_var = $ret_name;
+
+ if ($insert) {
+ splice(@args_list, int($insert), 0, "&$ret_name");
+ $single_ret_var = undef;
+ } else {
+ $single_ret_var = $ret_name;
+ }
if ($call->{ProcName} eq "DomainGetMaxMemory" or
$call->{ProcName} eq "NodeGetFreeMemory") {
@@ -1285,6 +1292,24 @@ elsif ($opt_k) {
$single_ret_var = "int rv = -1";
$single_ret_type = "int";
+ } elsif ($ret_member =~ m/^(unsigned )?hyper (\S+);\s*\/\*\s*insert@(\d+)\s*\*\//) {
+ my $type_name = $1;
+ my $sign = ""; $sign = "U" if ($1);
+ my $ret_name = $2;
+ my $insert = $3;
+
+ if (hyper_to_long($call->{ProcName}, "ret", $ret_name)) {
+ $type_name .= "long";
+ push(@ret_list, "if ($ret_name) HYPER_TO_${sign}LONG(*$ret_name, ret.$ret_name);");
+ } else {
+ $type_name .= "long long";
+ push(@ret_list, "if ($ret_name) *$ret_name = ret.$ret_name;");
+ }
+
+ splice(@args_list, int($insert), 0, ("$type_name *$ret_name"));
+ push(@ret_list, "rv = 0;");
+ $single_ret_var = "int rv = -1";
+ $single_ret_type = "int";
} elsif ($ret_member =~ m/^unsigned hyper (\S+);/) {
my $ret_name = $1;