Mercurial > hg > CbC > old > device
annotate test/hoge.c @ 725:3f1f6c0610c1
goto with enviornment syntax changed.
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 20 Aug 2009 16:39:02 +0900 |
parents | 6b7372e17970 |
children | c2c709727221 |
rev | line source |
---|---|
658 | 1 #include <stdio.h> |
2 // #include "hoge.h" | |
3 // #include "task.h" | |
4 | |
720 | 5 struct task; |
6 | |
658 | 7 typedef |
8 struct pkt { | |
9 int val; | |
10 __code (*next)(struct pkt *,struct task *); | |
11 } Pkt, *PktPtr; | |
12 | |
13 | |
14 typedef | |
15 struct task { | |
16 int val; | |
17 __code (*next)(struct pkt *,struct task *); | |
18 } Task, *TaskPtr; | |
19 | |
20 int count = 5; | |
21 | |
22 void *env; | |
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
23 __code (*exit0)(int,void*); |
658 | 24 |
25 __code scheduler(PktPtr pkt, TaskPtr task) | |
26 { | |
27 if (count-->0) | |
28 goto pkt->next(pkt,task); | |
725
3f1f6c0610c1
goto with enviornment syntax changed.
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents:
720
diff
changeset
|
29 goto exit0(0,env); |
658 | 30 } |
31 | |
32 __code modulo(PktPtr pkt, TaskPtr current_task); | |
33 | |
34 __code increment(PktPtr pkt, TaskPtr current_task) | |
35 { | |
36 pkt->val++; | |
37 printf("inc: %d\n", pkt->val); | |
38 pkt->next = modulo; | |
39 goto scheduler(pkt, current_task); | |
40 } | |
41 | |
42 __code modulo(PktPtr pkt, TaskPtr current_task) | |
43 { | |
44 pkt->val %= 10; | |
45 pkt->val = pkt->val % 10; | |
46 printf("mod: %d\n", pkt->val); | |
47 pkt->next = increment; | |
48 goto scheduler(pkt, current_task); | |
49 } | |
50 | |
51 static Pkt pkt; | |
52 static Task task; | |
53 | |
54 int | |
55 main() | |
56 { | |
720 | 57 exit0 = __return; |
58 env = __environment; | |
658 | 59 goto increment(&pkt,&task); |
60 } |