1 /*
2 * %CopyrightBegin%
3 *
4 * Copyright Ericsson AB and Kjell Winblad 2019. All Rights Reserved.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * %CopyrightEnd%
19 */
20
21 /*
22 * Description:
23 *
24 * Author: Kjell Winblad
25 *
26 */
27
28
29 #include <stdio.h>
30 #include <stdlib.h>
31
32 #define YCF_YIELD()
33
34
fun(char x,char * y,char ** z,unsigned long a,unsigned long * b,unsigned long ** c)35 unsigned long fun(char x, char* y, char **z, unsigned long a, unsigned long* b, unsigned long** c){
36 unsigned int f = 3 + 3;
37 x = x + 1;
38 y = y + 1;
39 z = z + 1;
40 a = a + 1;
41 b = b + 1;
42 c = c + 1;
43 YCF_YIELD();
44 f = f - 6;
45 x = x + 1;
46 y = y + 1;
47 z = z + 1;
48 a = a + 1;
49 b = b + 1;
50 c = c + 1;
51 return (unsigned long)((long)(x + y) + ((z + a) + ((long)b + (long)c))) + f;
52 }
53
allocator(size_t size,void * context)54 void* allocator(size_t size, void* context){
55 (void)context;
56 return malloc(size);
57 }
58
freer(void * data,void * context)59 void freer(void* data, void* context){
60 (void)context;
61 free(data);
62 }
63
main(int argc,const char * argv[])64 int main( int argc, const char* argv[] )
65 {
66 #ifdef YCF_YIELD_CODE_GENERATED
67 void* wb = NULL;
68 #endif
69 int ret = 0;
70 long nr_of_reductions = 1;
71 #ifdef YCF_YIELD_CODE_GENERATED
72 do{
73 ret = fun_ycf_gen_yielding(&nr_of_reductions,&wb,NULL,allocator,freer,NULL,0,NULL,1,(void*)1,(void*)1,1,(void*)1,(void*)1);
74 if(wb != NULL){
75 printf("TRAPPED\n");
76 }
77 }while(wb != NULL);
78 if(wb != NULL){
79 free(wb);
80 }
81 #else
82 ret = fun(1,(void*)1,(void*)1,1,(void*)1,(void*)1);
83 #endif
84 printf("RETURNED %d\n", ret);
85 if(ret != fun(1,(void*)1,(void*)1,1,(void*)1,(void*)1)){
86 return 1;
87 }else{
88 return 0;
89 }
90 }
91
92