Mercurial > hg > CbC > old > device
view test/hoge.c @ 927:b491db049d74
Added tag current-release for changeset 4e73a22327a8
author | kono |
---|---|
date | Sun, 13 Apr 2014 10:20:02 +0900 |
parents | 5313ed059cee |
children |
line wrap: on
line source
#include <stdio.h> // #include "hoge.h" // #include "task.h" struct task; 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,void*); __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("#0036: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("#0045: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); }