File: inlinedvars.c

package info (click to toggle)
systemtap 5.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 47,556 kB
  • sloc: cpp: 81,117; ansic: 54,933; xml: 49,795; exp: 43,595; sh: 11,526; python: 5,003; perl: 2,252; tcl: 1,312; makefile: 1,006; javascript: 149; lisp: 105; awk: 101; asm: 91; java: 70; sed: 16
file content (46 lines) | stat: -rw-r--r-- 1,115 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
static inline int
m(char *name, int i, long j)
{
  // Random syntactical block to be inlined.
  // Mimics what STAP_PROBE macro does a bit.
  do {
    // Dummy (volatile) counter to trick gcc into thinking we are actually
    // using the label. If not it will partially optimize the label away,
    // but still emits a somewhat bogus DW_AT_low_pc for it...
    volatile int c = 0;
    volatile __typeof__(name) p_name = name;
    volatile __typeof__(i) p_i = i;
    volatile __typeof__(j) p_j = j;
    // empty asm to force locals into regs.
    inlined_label: asm volatile ("" : "=g"(c) : "g"(p_name), "g"(p_i), "g"(p_j));
    if (c != 0) goto inlined_label;
  } while (0);
  return i + 32;
}

static inline int
call(int pi, long pj)
{
  volatile int ic = pi - 42;
  volatile long jc = pj + 42;
  return m("call", ic, jc);
}

static inline int
call2(int pi2, long pj2)
{
  volatile int ic2 = pi2 + 64;
  volatile long jc2 = pj2 - 64;
  return m("call2", ic2, jc2);
}

int
main (int argc, char **argv)
{
  volatile int i = 64;
  volatile long j = 42;
  call(i, j);
  call2(i, j);
  m("main", i, j);
  return 0;
}