Mercurial > hg > CbC > old > device
view test/hoge.c @ 658:cb3809f4ec97
*** empty log message ***
author | kono |
---|---|
date | Wed, 24 Jan 2007 13:48:28 +0900 |
parents | |
children | 6b7372e17970 |
line wrap: on
line source
#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); }