1 /* This test case tests that when static allocation for value 2 * profiler is on, no malloc/calloc calls will be invoked by 3 * profile runtime library. */ 4 #include <stdlib.h> foo()5__attribute__((noinline)) void foo() {} foo2()6__attribute__((noinline)) void foo2() {} 7 void (*FP)(); 8 int MainEntered = 0; 9 int CallocCalled = 0; 10 int MallocCalled = 0; 11 12 extern void *__real_calloc(size_t s, size_t n); 13 extern void *__real_malloc(size_t s); 14 __wrap_calloc(size_t s,size_t n)15void *__wrap_calloc(size_t s, size_t n) { 16 if (MainEntered) 17 CallocCalled = 1; 18 return __real_calloc(s, n); 19 } __wrap_malloc(size_t s)20void *__wrap_malloc(size_t s) { 21 if (MainEntered) 22 MallocCalled = 1; 23 return __real_malloc(s); 24 } 25 getFP(int i)26void getFP(int i) { 27 if (i % 2) 28 FP = foo; 29 else 30 FP = foo2; 31 } 32 main()33int main() { 34 int i; 35 MainEntered = 1; 36 for (i = 0; i < 100; i++) { 37 getFP(i); 38 FP(); 39 } 40 return CallocCalled + MallocCalled; 41 } 42