about summary refs log tree commit diff
path: root/scripts/bench.pl
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/bench.pl')
-rwxr-xr-xscripts/bench.pl25
1 files changed, 21 insertions, 4 deletions
diff --git a/scripts/bench.pl b/scripts/bench.pl
index 6ad93fa5ae..90441e1969 100755
--- a/scripts/bench.pl
+++ b/scripts/bench.pl
@@ -93,6 +93,13 @@ LINE:while (<INPUTS>) {
 
 my $bench_func = "#define CALL_BENCH_FUNC(v, i) $func (";
 
+# Output variables.  These include the return value as well as any pointers
+# that may get passed into the function, denoted by the <> around the type.
+my $outvars = "";
+
+if ($ret ne "void") {
+  $outvars = "static volatile $ret ret;\n";
+}
 
 # Print the definitions and macros.
 foreach $incl (@include_headers) {
@@ -124,8 +131,18 @@ if (@args > 0) {
       $bench_func = "$bench_func,";
     }
 
-    $arg_struct = "$arg_struct volatile $arg arg$num;";
-    $bench_func = "$bench_func variants[v].in[i].arg$num";
+    $_ = $arg;
+    if (/<(.*)\*>/) {
+      # Output variables.  These have to be pointers, so dereference once by
+      # dropping one *.
+      $outvars = $outvars . "static $1 out$num;\n";
+      $bench_func = "$bench_func &out$num";
+    }
+    else {
+      $arg_struct = "$arg_struct volatile $arg arg$num;";
+      $bench_func = "$bench_func variants[v].in[i].arg$num";
+    }
+
     $num = $num + 1;
   }
 
@@ -172,12 +189,12 @@ else {
   print "#define VARIANT(v) FUNCNAME \"()\"\n"
 }
 
-
+# Print the output variable definitions.
+print "$outvars\n";
 
 # In some cases not storing a return value seems to result in the function call
 # being optimized out.
 if ($ret ne "void") {
-  print "static volatile $ret ret;\n";
   $getret = "ret = ";
 }