Home | History | Annotate | Download | only in solaris
      1 /* Taken from memcheck/tests/inlinfo.c almost verbatim;
      2  * only main() renamed to main_nested().
      3  */
      4 
      5 #include "../../memcheck.h"
      6 #define INLINE    inline __attribute__((always_inline))
      7 
      8 INLINE int fun_d(int argd) {
      9    static int locd = 0;
     10    if (argd > 0)
     11       locd += argd;
     12    return locd;
     13 }
     14 
     15 INLINE int fun_c(int argc) {
     16    static int locc = 0;
     17    locc += argc;
     18    return fun_d(locc);
     19 }
     20 
     21 INLINE int fun_b(int argb) {
     22    static int locb = 0;
     23    locb += argb;
     24    return fun_c(locb);
     25 }
     26 
     27 INLINE int fun_a(int arga) {
     28    static int loca = 0;
     29    loca += arga;
     30    return fun_b(loca);
     31 }
     32 
     33 __attribute__((noinline))
     34 static int fun_noninline_m(int argm)
     35 {
     36    return fun_d(argm);
     37 }
     38 
     39 __attribute__((noinline))
     40 static int fun_noninline_o(int argo)
     41 {
     42    static int loco = 0;
     43    if (argo > 0)
     44       loco += argo;
     45    return loco;
     46 }
     47 
     48 INLINE int fun_f(int argf) {
     49    static int locf = 0;
     50    locf += argf;
     51    return fun_noninline_o(locf);
     52 }
     53 
     54 INLINE int fun_e(int arge) {
     55    static int loce = 0;
     56    loce += arge;
     57    return fun_f(loce);
     58 }
     59 
     60 __attribute__((noinline))
     61 static int fun_noninline_n(int argn)
     62 {
     63    return fun_e(argn);
     64 }
     65 
     66 
     67 int main_nested(void) {
     68    int result;
     69    result = fun_a(result);
     70    VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
     71    result += fun_noninline_m(result);
     72    VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
     73    result += fun_d(result);
     74    VALGRIND_MAKE_MEM_UNDEFINED(&result, sizeof(result));
     75    result += fun_noninline_n(result);
     76    return 0;
     77 }
     78 
     79