1 #define FOR_EACH_SCALAR(F) \
2 F(sc, signed char) \
3 F(uc, unsigned char) \
4 F(ss, short) \
5 F(us, unsigned short) \
6 F(si, int) \
7 F(ui, unsigned int) \
8 F(sl, long) \
9 F(ul, unsigned long) \
10 F(sll, long long) \
11 F(ull, unsigned long long) \
12 F(f, float) \
13 F(d, double) \
14 F(ld, long double) \
15 F(ptr, void *)
16
17 #define EXTERN(SUFFIX, TYPE) extern TYPE x##SUFFIX;
18 #define STATIC(SUFFIX, TYPE) static TYPE s##SUFFIX;
19 #define COMMON(SUFFIX, TYPE) TYPE c##SUFFIX;
20
21 #define GETADDR(SUFFIX, TYPE) \
22 TYPE *get##SUFFIX (int which) \
23 { \
24 return (which == 0 ? &c##SUFFIX \
25 : which == 1 ? &s##SUFFIX \
26 : &x##SUFFIX); \
27 }
28
29 #define COPY(SUFFIX, TYPE) c##SUFFIX = s##SUFFIX; s##SUFFIX = x##SUFFIX;
30
31 FOR_EACH_SCALAR (EXTERN)
FOR_EACH_SCALAR(STATIC)32 FOR_EACH_SCALAR (STATIC)
33 FOR_EACH_SCALAR (COMMON)
34
35 FOR_EACH_SCALAR (GETADDR)
36
37 void
38 copy (void)
39 {
40 FOR_EACH_SCALAR (COPY);
41 }
42
43 extern void foo (int);
44
45 void
sibcall1(void)46 sibcall1 (void)
47 {
48 foo (1);
49 }
50
51 void
sibcall2(void)52 sibcall2 (void)
53 {
54 foo (csi + ssi + xsi);
55 }
56
57 static void
sibcall3(void)58 sibcall3 (void)
59 {
60 foo (1);
61 foo (2);
62 foo (3);
63 }
64
65 extern void bar (void (*) (void));
66
67 int
nested(int x)68 nested (int x)
69 {
70 void sub (void) { foo (x); }
71 bar (sub);
72 bar (sibcall3);
73 return 1;
74 }
75