Mercurial > hg > Members > kono > Cerium
annotate example/word_count/spe/Exec.cc @ 467:44c0bce54dcf
fix all examples. test_render is not working now.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 01 Oct 2009 19:25:25 +0900 |
parents | e08d0aa94367 |
children | ab866bc8a624 |
rev | line source |
---|---|
393 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Exec.h" | |
4 #include "Func.h" | |
5 | |
6 /* これは必須 */ | |
7 SchedDefineTask(Exec); | |
8 | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
9 static int |
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
10 run(SchedTask *s, void *rbuf, void *wbuf) |
393 | 11 { |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
12 char *i_data = (char*)s->get_input(rbuf, 0); |
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); |
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
14 int length = s->get_param(0); |
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
15 int word_flag = s->get_param(1); |
393 | 16 int word_num = 0; |
17 int line_num = 0; | |
18 int i; | |
19 | |
20 /*先頭の文字まで、飛ぶルーチン*/ | |
21 for(i = 0; i < length; i++) { | |
22 if ((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
23 //s->printf("[SPE%d] break[%d] %d\n",id,i,i_data[i]); |
393 | 24 break; |
25 } | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
26 //s->printf("[SPE%d]%c",id,i_data[start_num]); |
393 | 27 word_num += word_flag; |
28 word_flag = 0; | |
29 line_num += (i_data[i] == 0x0A); | |
30 } | |
31 | |
32 word_flag = 0; | |
33 | |
34 for (; i < length; i++) { | |
35 | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
36 //s->printf("[SPE%d]%c",id,i_data[i]); |
393 | 37 |
38 | |
39 if (i_data[i] == 0x20) { | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
40 //s->printf("スペース\n"); |
393 | 41 word_flag = 1; |
42 } | |
43 | |
44 else if (i_data[i] == 0x0A) { | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
45 //s->printf("改行\n"); |
393 | 46 line_num += 1; |
47 word_flag = 1; | |
48 } | |
49 | |
50 else { | |
51 word_num += word_flag; | |
52 word_flag = 0; | |
53 } | |
54 | |
55 } | |
56 | |
57 word_num += word_flag; | |
58 | |
467
44c0bce54dcf
fix all examples. test_render is not working now.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
394
diff
changeset
|
59 //s->printf("%d %d\n",word_num,line_num); |
393 | 60 |
61 o_data[0] = (unsigned long long)word_num; | |
62 o_data[1] = (unsigned long long)line_num; | |
63 | |
64 return 0; | |
65 } |