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