6 /* As wrap4.c, but also throw in various calls to another redirected
7 function (malloc) to check that that doesn't screw anything up.
20 void addMoreLard ( void )
25 p
= malloc(sizeof(Lard
));
32 static int fact1 ( int n
);
33 static int fact2 ( int n
);
35 /* This is needed to stop gcc4 turning 'fact' into a loop */
36 __attribute__((noinline
))
37 int mul ( int x
, int y
) { return x
* y
; }
42 if (n
== 0) return 1; else return mul(n
, fact2(n
-1));
47 if (n
== 0) return 1; else return mul(n
, fact1(n
-1));
51 int I_WRAP_SONAME_FNNAME_ZU(NONE
,fact1
) ( int n
)
55 VALGRIND_GET_ORIG_FN(fn
);
56 printf("in wrapper1-pre: fact(%d)\n", n
);
58 CALL_FN_W_W(r
, fn
, n
);
60 printf("in wrapper1-post: fact(%d) = %d\n", n
, r
);
61 if (n
>= 3) r
+= fact2(2);
65 int I_WRAP_SONAME_FNNAME_ZU(NONE
,fact2
) ( int n
)
69 VALGRIND_GET_ORIG_FN(fn
);
70 printf("in wrapper2-pre: fact(%d)\n", n
);
72 CALL_FN_W_W(r
, fn
, n
);
74 printf("in wrapper2-post: fact(%d) = %d\n", n
, r
);
84 printf("computing fact1(7)\n");
86 printf("fact1(7) = %d\n", r
);
88 printf("allocated %d Lards\n", ctr
);
89 for (p
= lard
; p
; p
= p_next
) {