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 #ifdef YCF_YIELD_CODE_GENERATED
29 #include "tmp_dir/tmp.h"
30 #endif
31
32 #include <stdio.h>
33 #include <stdlib.h>
34
35 int A(int depth);
36 int B(int depth);
37
allocator(size_t size,void * context)38 void* allocator(size_t size, void* context){
39 (void)context;
40 return malloc(size);
41 }
42
freer(void * data,void * context)43 void freer(void* data, void* context){
44 (void)context;
45 free(data);
46 }
47
main(int argc,const char * argv[])48 int main( int argc, const char* argv[] )
49 {
50 #ifdef YCF_YIELD_CODE_GENERATED
51 void* wb = NULL;
52 #endif
53 int ret = 0;
54 long nr_of_reductions = 1;
55 #ifdef YCF_YIELD_CODE_GENERATED
56 do{
57 ret = A_ycf_gen_yielding(&nr_of_reductions,&wb,NULL,allocator,freer,NULL,0,NULL,0);
58 if(wb != NULL){
59 printf("TRAPPED\n");
60 }
61 }while(wb != NULL);
62 #else
63 ret = A(0);
64 #endif
65 printf("RETURNED %d\n", ret);
66 if(ret != A(0)){
67 return 1;
68 }else{
69 return 0;
70 }
71 }
72