riscv: Support $ in identifiers in extended asm.
[tinycc.git] / tests / asm-c-connect-1.c
blob90f59c83b39400cccbeb0ac01cfd8d2c6e616c85
1 #include <stdio.h>
3 #if (defined _WIN32 || defined __APPLE__) && (!defined __TINYC__ || defined __leading_underscore)
4 # define _ "_"
5 #else
6 # define _
7 #endif
9 #ifdef __clang__
10 /* clang needs some help tp not throw functions away even at -O0 */
11 #define __USED __attribute__((__used__))
12 #else
13 #define __USED
14 #endif
16 static int __USED x1_c (void)
18 printf(" x1");
19 return 1;
22 #if __i386__
23 asm(".text;"_"x1: call "_"x1_c; ret");
24 #else
25 /* Keep stack aligned */
26 asm(".text;"_"x1: sub $8,%rsp; call "_"x1_c; add $8,%rsp; ret");
27 #endif
29 void callx4(void);
30 void callx5_again(void);
32 void x6()
34 printf(" x6-1");
37 int main(int argc, char *argv[])
39 printf("*");
40 asm("call "_"x1");
41 asm("call "_"x2");
42 asm("call "_"x3");
43 callx4();
44 asm("call "_"x5");
45 callx5_again();
46 x6();
47 printf(" *\n");
48 return 0;
51 static
52 int __USED x2(void)
54 printf(" x2");
55 return 2;
58 extern int x3(void);
60 void x4(void)
62 printf(" x4");
65 void x5(void);
66 void x5(void)
68 printf(" x5");