]> git.saurik.com Git - apple/ld64.git/blob - unit-tests/test-cases/data-in-code/main.c
811449a764ca065cfdb4f91f3f40708ad8006f81
[apple/ld64.git] / unit-tests / test-cases / data-in-code / main.c
1
2 #include <stdio.h>
3
4 #define DTRACE_STRINGIFY(s) #s
5 #define DTRACE_TOSTRING(s) DTRACE_STRINGIFY(s)
6
7 #define DTRACE_NOPS \
8 "nop" "\n\t" \
9 "nop" "\n\t" \
10 "nop" "\n\t"
11
12
13 #define DTRACE_LAB(p, n) \
14 "__dtrace_probe$" DTRACE_TOSTRING(%=__LINE__) DTRACE_STRINGIFY(_##p##___##n)
15
16 #define DTRACE_LABEL(p, n) \
17 ".section __DATA, __data\n\t" \
18 ".globl " DTRACE_LAB(p, n) "\n\t" \
19 DTRACE_LAB(p, n) ":\n\t" ".long 1f""\n\t" \
20 ".text" "\n\t" \
21 "1:"
22
23 #define DTRACE_CALL(p,n) \
24 DTRACE_LABEL(p,n) \
25 DTRACE_NOPS
26
27 #define DTRACE_CALL0ARGS(provider, name) \
28 __asm volatile ( \
29 DTRACE_CALL(provider, name) \
30 : \
31 : \
32 );
33
34 int deadwood()
35 {
36 DTRACE_CALL0ARGS(__foo__, test2)
37 return 0;
38 }
39
40
41 int main() {
42 int a = 1;
43
44 while(a) {
45 DTRACE_CALL0ARGS(__foo__, test1)
46 }
47
48 return 0;
49 }