changeset 658:cb3809f4ec97

*** empty log message ***
author kono
date Wed, 24 Jan 2007 13:48:28 +0900
parents bb3a11f3f31d
children 2a3b1cddd45f
files test/hoge.c
diffstat 1 files changed, 58 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/hoge.c	Wed Jan 24 13:48:28 2007 +0900
@@ -0,0 +1,58 @@
+#include <stdio.h>
+// #include "hoge.h"
+// #include "task.h"
+
+typedef
+struct pkt {
+    int val;
+    __code (*next)(struct pkt *,struct task *);
+} Pkt, *PktPtr;
+
+
+typedef
+struct task {
+    int val;
+    __code (*next)(struct pkt *,struct task *);
+} Task, *TaskPtr;
+
+int count = 5;
+
+void *env;
+__code (*exit0)(int);
+
+__code scheduler(PktPtr pkt, TaskPtr task)
+{
+    if (count-->0)
+	goto pkt->next(pkt,task);
+    goto exit0(0),env;
+}
+
+__code modulo(PktPtr pkt, TaskPtr current_task);
+
+__code increment(PktPtr pkt, TaskPtr current_task)
+{
+    pkt->val++;
+    printf("inc: %d\n", pkt->val);
+    pkt->next = modulo;
+    goto scheduler(pkt, current_task);
+}
+
+__code modulo(PktPtr pkt, TaskPtr current_task)
+{
+    pkt->val %= 10;
+    pkt->val = pkt->val % 10;
+    printf("mod: %d\n", pkt->val);
+    pkt->next = increment;
+    goto scheduler(pkt, current_task);
+}
+
+static Pkt pkt;
+static Task task;
+
+int
+main()
+{
+    exit0 = return;
+    env = environment;
+    goto increment(&pkt,&task);
+}