Mercurial > hg > Game > Cerium
annotate example/Prime/spe/PrintTask.cc @ 1233:247da1f5e625 draft
fix
author | Daichi Toma <amothic@gmail.com> |
---|---|
date | Tue, 18 Oct 2011 12:25:08 +0900 |
parents | 2dfac651288e |
children | 9df036b11eae |
rev | line source |
---|---|
1171 | 1 #include <stdio.h> |
2 #include "SchedTask.h" | |
3 #include "PrintTask.h" | |
4 #include "Func.h" | |
5 | |
6 SchedDefineTask1(PrintTask, print); | |
7 | |
8 static int | |
9 print(SchedTask *smanager, void *rbuf, void *wbuf) | |
10 { | |
1232 | 11 long print_flag = (long)smanager->get_param(1); //プリントするかどうか |
1194
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1171
diff
changeset
|
12 |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1171
diff
changeset
|
13 if (print_flag < 0) { |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1171
diff
changeset
|
14 return 0; |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1171
diff
changeset
|
15 } |
7909536bf611
fix Prime/PrintTask
Daichi TOMA <e085740@ie.u-ryukyu.ac.jp>
parents:
1171
diff
changeset
|
16 |
1232 | 17 long length = (long)smanager->get_param(0); /* 出力する範囲 */ |
18 bool *input = (bool*)smanager->get_input(rbuf, 0); /* 出力する配列 */ | |
1171 | 19 |
20 /* 素数の判定結果が1ならば出力する */ | |
1232 | 21 for (long i = 0; i < length; i++) { |
22 if ( input[i] == true ) { | |
1233 | 23 printf("%ld ",i); |
1171 | 24 } |
25 } | |
26 printf("\n"); | |
27 return 0; | |
28 } |