Mercurial > hg > CbC > CbC_examples
view test2.c @ 17:a4f44624a253
asm longjmp (can return correct address but return value is wrong)
author | Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp> |
---|---|
date | Sun, 24 Jan 2016 06:01:43 +0900 |
parents | e1e9a4eac42d |
children | 586096c45873 |
line wrap: on
line source
#ifdef GCC #define __environment _CbC_environment #define __return _CbC_return #endif #include <stdio.h> int sender_bit; __code (*ret)(int,void *); void *env; struct packet { int bit; char *msg; __code (*next)(); }; __code print_struct(struct packet pkt) { printf("#0017:bit: %d\n", pkt.bit); printf("#0018:message: %s\n", pkt.msg); goto ret(0, env); } __code initSender(int init_bit, struct packet pkt) { sender_bit = init_bit; pkt.next = print_struct; printf("#0026:initSender bit: %d\n", pkt.bit); printf("#0027:initSender message: %s\n", pkt.msg); printf("#0028:sender_bit: %d\n", sender_bit); goto print_struct(pkt); } int main(void) { struct packet pkt; pkt.bit = 1; pkt.msg = "hogehoge"; pkt.next = initSender; ret = __return; env = __environment; printf("#0040:main bit: %d\n", pkt.bit); printf("#0041:main message: %s\n", pkt.msg); goto initSender(0, pkt); }