1 #include <stdio.h>
2 #include <stdlib.h>
3
4 #define YCF_YIELD()
5
empty_fun()6 int empty_fun(){
7 return 1;
8 }
9
fun(char x)10 int fun(char x){
11 x = x + 1; /* x == 2*/
12 YCF_YIELD();
13 x = x + 1; /* x == 3*/
14 {
15 int hej = !!empty_fun();
16 (void)hej;
17 }
18 return x;
19 }
20
allocator(size_t size,void * context)21 void* allocator(size_t size, void* context){
22 (void)context;
23 return malloc(size);
24 }
25
freer(void * data,void * context)26 void freer(void* data, void* context){
27 (void)context;
28 free(data);
29 }
30
main(int argc,const char * argv[])31 int main( int argc, const char* argv[] )
32 {
33 #ifdef YCF_YIELD_CODE_GENERATED
34 void* wb = NULL;
35 long nr_of_reductions = 1;
36 #endif
37 int ret = 0;
38 #ifdef YCF_YIELD_CODE_GENERATED
39 do{
40 ret = fun_ycf_gen_yielding(&nr_of_reductions,&wb,NULL,allocator,freer,NULL,0,NULL,1);
41 if(wb != NULL){
42 printf("TRAPPED\n");
43 }
44 }while(wb != NULL);
45 if(wb != NULL){
46 free(wb);
47 }
48 #else
49 fun(1);
50 #endif
51 printf("RETURNED %d\n", ret);
52 if(ret != 3){
53 return 1;
54 }else{
55 return 0;
56 }
57 }
58
59