view test_func2code.c @ 11:6d45489b5dcb

forget file
author Kaito Tokumori <e105711@ie.u-ryukyu.ac.jp>
date Thu, 16 Apr 2015 19:40:07 +0900
parents 35d6eabeadb0
children 586096c45873
line wrap: on
line source

#include<stdio.h>
#include<stdlib.h>

#define DEBUG 1
#ifdef DEBUG
#define log(f, args...)                                 \
  fprintf(stderr, "in %s: "f, __FUNCTION__, ## args)
#else
#define log(f, args...) ;
#endif

__code
exitter(int a)
{
  exit(0);
}

__code
cs0(int x, int y)
{
  log("x = %d, y = %d.\n", x, y);
  log("will exit with code %d.\n", x*y);
  goto exitter(x*y);
}

void
continuation(int a)
{
  log("go code segment cs0\n");
  goto cs0(a, a*20);
  log("Error: continuation reachs bad region.\n");
}

int
main(int argc, char **argv)
{
  int a;
  if (argc>2) {
    a = atoi(argv[1]);
  }
  
  continuation(20);
}