changeset 466:831b7f6fd687

Fix warning pointer type
author Tatsuki IHA <innparusu@cr.ie.u-ryukyu.ac.jp>
date Thu, 21 Dec 2017 18:52:21 +0900
parents b6437feb04ee
children 4ec61e201c19
files src/parallel_execution/examples/calc/calc.cbc src/parallel_execution/generate_stub.pl src/parallel_execution/test/multiDimIterator_test.cbc src/parallel_execution/test/queue_test.cbc src/parallel_execution/test/rbTree_test.cbc src/parallel_execution/test/stack_test.cbc
diffstat 6 files changed, 24 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/src/parallel_execution/examples/calc/calc.cbc	Thu Dec 21 00:34:25 2017 +0900
+++ b/src/parallel_execution/examples/calc/calc.cbc	Thu Dec 21 18:52:21 2017 +0900
@@ -32,7 +32,7 @@
     goto initDataGears(context, loopCounter, taskManager);
 }
 
-__code code1(struct Time* time) {
+__code code1(struct Timer* timer) {
     printf("cpus:\t\t%d\n", cpu_num);
     printf("gpus:\t\t%d\n", gpu_num);
     printf("length:\t\t%d\n", length);
@@ -48,7 +48,7 @@
 }
 
 __code code1_stub(struct Context* context) {
-    goto code1(context, Gearef(context, Time));
+    goto code1(context, Gearef(context, Timer));
 }
 
 
--- a/src/parallel_execution/generate_stub.pl	Thu Dec 21 00:34:25 2017 +0900
+++ b/src/parallel_execution/generate_stub.pl	Thu Dec 21 18:52:21 2017 +0900
@@ -162,12 +162,13 @@
                         my $next = $2;
                         my @args = split(/,/,$3);
                         push(@{$code{$name}->{$method}},"\_\_code $next");
-                    } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\*)*+\s(\w+)//) {
+                    } elsif ($args =~ s/^(struct|union)?\s*(\w+)(\**)\s+(\w+)//) {
                         my $structType = $1;
                         my $typeName = $2;
+                        my $ptrType = $3;
                         my $varName = $4;
                         my $typeField = lcfirst($typeName);
-                        push(@{$code{$name}->{$method}},"$typeName $varName");
+                        push(@{$code{$name}->{$method}},"$typeName$ptrType $varName");
                     } elsif ($args =~ s/(.*,)//) {
                     } else {
                         last;
@@ -211,7 +212,7 @@
 }
 
 sub generateStubArgs {
-    my($codeGearName, $varName, $typeName, $typeField, $interface,$output) = @_;
+    my($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,$output) = @_;
     my $varname1 = $output?"O_$varName":$varName;
     for my $n ( @{$dataGearVar{$codeGearName}} ) {
         # we already have it
@@ -228,12 +229,12 @@
             if ($varName eq $ivar) {
                 if ($typeName eq $var{$interface}->{$ivar}) {
                     if ($output) {
-                        $dataGearName{$codeGearName} .= "\t$typeName** O_$varName = &Gearef(context, $interface)->$varName;\n";
-                        $outputVar{$codeGearName} .= "\t$typeName* $varName;\n";
+                        $dataGearName{$codeGearName} .= "\t$typeName$ptrType* O_$varName = &Gearef(context, $interface)->$varName;\n";
+                        $outputVar{$codeGearName} .= "\t$typeName$ptrType $varName;\n";
                         return 1;
                     }
 
-                    $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $interface)->$varName;\n";
+                    $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
                     return 1;
                 }
             }
@@ -247,10 +248,10 @@
         }
         # global or local variable case
         if ($typeName eq "Code") {
-            $dataGearName{$codeGearName} .= "\tenum $typeName $varName = Gearef(context, $interface)->$varName;\n";
+            $dataGearName{$codeGearName} .= "\tenum $typeName$ptrType $varName = Gearef(context, $interface)->$varName;\n";
             return 1;
         }
-        $dataGearName{$codeGearName} .= "\t$typeName* $varName = Gearef(context, $typeName);\n";
+        $dataGearName{$codeGearName} .= "\t$typeName$ptrType $varName = Gearef(context, $typeName);\n";
         return 1;
     }
 }
@@ -340,7 +341,7 @@
                     if ($args =~ s/^(\s)*\_\_code\s+(\w+)\(([^)]*)\)//) {
                         my $next = $2;
                         my @args = split(/,/,$3);
-                        if (&generateStubArgs($codeGearName, $next, "Code", $next, $interface,0) ) {
+                        if (&generateStubArgs($codeGearName, $next, "Code", "", $next, $interface,0) ) {
                             $newArgs .= "enum Code $next";
                         }
                         # analyze continuation arguments
@@ -349,23 +350,25 @@
                         for my $arg (@args) {
                             $arg =~ s/^\s*//;
                             last if ($arg =~ /\.\.\./);
-                            $arg =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//;
+                            $arg =~ s/^(struct|union)? (\w+)(\**)\s(\w+)//;
                             my $structType = $1;
                             my $typeName = $2;
+                            my $ptrType = $3;
                             my $varName = $4;
                             my $typeField = lcfirst($typeName);
                             push(@{$outputArgs{$codeGearName}->{$next}}, $varName);
-                            if (&generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface,1)) {
+                            if (&generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,1)) {
                                 $newArgs .= ",$structType $typeName **O_$varName";
                             }
                         }
-                    } elsif ($args =~ s/^(struct|union) (\w+)(\*)+\s(\w+)//) {
+                    } elsif ($args =~ s/^(struct|union)? (\w+)(\**)\s(\w+)//) {
                         my $structType = $1;
                         my $typeName = $2;
+                        my $ptrType = $3;
                         my $varName = $4;
                         my $typeField = lcfirst($typeName);
                         $newArgs .= $&;    # assuming no duplicate
-                        &generateStubArgs($codeGearName, $varName, $typeName, $typeField, $interface,0);
+                        &generateStubArgs($codeGearName, $varName, $typeName, $ptrType, $typeField, $interface,0);
                     } elsif ($args =~ s/(.*,)//) {
                         $newArgs .= $1;
                     } else {
@@ -427,8 +430,8 @@
                         } else {
                             print $fd "\tGearef(context, $ntype)->$pName = C_$arg;\n";
                         }
-                    } elsif ($pType =~ s/Data$//){
-                        print $fd "\tGearef(context, $ntype)->$pName = (union Data*) $arg;\n";
+                    } elsif ($pType =~ /Data\**$/){
+                        print $fd "\tGearef(context, $ntype)->$pName = (union $pType) $arg;\n";
                     } else {
                         print $fd "\tGearef(context, $ntype)->$pName = $arg;\n";
                     }
--- a/src/parallel_execution/test/multiDimIterator_test.cbc	Thu Dec 21 00:34:25 2017 +0900
+++ b/src/parallel_execution/test/multiDimIterator_test.cbc	Thu Dec 21 18:52:21 2017 +0900
@@ -2,6 +2,7 @@
 #include <string.h>
 #include <stdlib.h>
 #include <unistd.h>
+#include "Iterator.h"
 
 #include "../../context.h"
 
--- a/src/parallel_execution/test/queue_test.cbc	Thu Dec 21 00:34:25 2017 +0900
+++ b/src/parallel_execution/test/queue_test.cbc	Thu Dec 21 18:52:21 2017 +0900
@@ -1,4 +1,5 @@
 #include "../../context.h"
+#include "Queue.h"
 #include <assert.h>
 
 __code queueTest1(struct Queue* queue) {
--- a/src/parallel_execution/test/rbTree_test.cbc	Thu Dec 21 00:34:25 2017 +0900
+++ b/src/parallel_execution/test/rbTree_test.cbc	Thu Dec 21 18:52:21 2017 +0900
@@ -1,4 +1,5 @@
 #include "../../context.h"
+#include "Tree.h"
 /* #include <assert.h> */
 
 __code rbTreeTest1(struct Tree* tree) {
--- a/src/parallel_execution/test/stack_test.cbc	Thu Dec 21 00:34:25 2017 +0900
+++ b/src/parallel_execution/test/stack_test.cbc	Thu Dec 21 18:52:21 2017 +0900
@@ -1,4 +1,5 @@
 #include "../../context.h"
+#include "Stack.h"
 #include <assert.h>
 
 __code stackTest1(struct Stack* stack) {