Mercurial > hg > Members > kono > Cerium
annotate example/word_count3/ppe/Exec.cc @ 625:60aa3f241b10
64bit mode worked on Mac OS X.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 16 Nov 2009 10:59:55 +0900 |
parents | 7d9d209bdc82 |
children |
rev | line source |
---|---|
527 | 1 #include <stdio.h> |
2 #include <string.h> | |
3 #include "Exec.h" | |
4 #include "Func.h" | |
5 | |
6 /* これは必須 */ | |
7 SchedDefineTask(Exec); | |
8 | |
9 static int | |
10 run(SchedTask *s, void *rbuf, void *wbuf) | |
11 { | |
12 char *i_data = (char*)s->get_input(rbuf, 0); | |
13 unsigned long long *o_data = (unsigned long long*)s->get_output(wbuf, 0); | |
625
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
527
diff
changeset
|
14 long length = (long)s->get_param(0); |
60aa3f241b10
64bit mode worked on Mac OS X.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
527
diff
changeset
|
15 long word_flag = (long)s->get_param(1); |
527 | 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)) { | |
23 //s->printf("[SPE%d] break[%d] %d\n",id,i,i_data[i]); | |
24 break; | |
25 } | |
26 //s->printf("[SPE%d]%c",id,i_data[start_num]); | |
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 | |
36 //s->printf("[SPE%d]%c",id,i_data[i]); | |
37 | |
38 if((i_data[i] != 0x20) && (i_data[i] != 0x0A)) { | |
39 //s->printf("文字 数 = %d\n", word_num + word_flag); | |
40 word_num += word_flag; | |
41 word_flag = 0; | |
42 } | |
43 | |
44 if (i_data[i] == 0x20) { | |
45 //printf("スペース\n"); | |
46 word_flag = 1; | |
47 } | |
48 | |
49 if (i_data[i] == 0x0A) { | |
50 //printf("改行\n"); | |
51 line_num += 1; | |
52 word_flag = 1; | |
53 } | |
54 | |
55 } | |
56 | |
57 word_num += word_flag; | |
58 | |
59 //printf("%d %d\n",word_num,line_num); | |
60 | |
61 o_data[0] = (unsigned long long)word_num; | |
62 o_data[1] = (unsigned long long)line_num; | |
63 | |
64 return 0; | |
65 } |