]>
Commit | Line | Data |
---|---|---|
2117d0f5 DE |
1 | /* This small function uses all the arithmetic operators that |
2 | libgcc1.c can handle. If you can link it, then | |
3 | you have provided replacements for all the libgcc1.c functions that | |
4 | your target machine needs. */ | |
5 | ||
820f6e3a MM |
6 | #include <stddef.h> |
7 | ||
2117d0f5 DE |
8 | int foo (); |
9 | double dfoo (); | |
820f6e3a MM |
10 | void discard (int); |
11 | void ddiscard (double); | |
2117d0f5 | 12 | |
0d5b1231 DE |
13 | /* We don't want __main here because that can drag in atexit (among other |
14 | things) which won't necessarily exist yet. */ | |
15 | ||
820f6e3a | 16 | int |
0d5b1231 | 17 | main_without__main () |
2117d0f5 DE |
18 | { |
19 | int a = foo (), b = foo (); | |
20 | unsigned int au = foo (), bu = foo (); | |
21 | float af = dfoo (), bf = dfoo (); | |
22 | double ad = dfoo (), bd = dfoo (); | |
23 | ||
24 | discard (a * b); | |
25 | discard (a / b); | |
26 | discard (a % b); | |
27 | ||
28 | discard (au / bu); | |
29 | discard (au % bu); | |
30 | ||
31 | discard (a >> b); | |
32 | discard (a << b); | |
33 | ||
34 | discard (au >> bu); | |
35 | discard (au << bu); | |
36 | ||
37 | ddiscard (ad + bd); | |
38 | ddiscard (ad - bd); | |
39 | ddiscard (ad * bd); | |
40 | ddiscard (ad / bd); | |
41 | ddiscard (-ad); | |
42 | ||
43 | ddiscard (af + bf); | |
44 | ddiscard (af - bf); | |
45 | ddiscard (af * bf); | |
46 | ddiscard (af / bf); | |
47 | ddiscard (-af); | |
48 | ||
49 | discard ((int) ad); | |
50 | discard ((int) af); | |
51 | ||
52 | ddiscard ((double) a); | |
53 | ddiscard ((float) a); | |
54 | ddiscard ((float) ad); | |
55 | ||
56 | discard (ad == bd); | |
57 | discard (ad < bd); | |
58 | discard (ad > bd); | |
59 | discard (ad != bd); | |
60 | discard (ad <= bd); | |
61 | discard (ad >= bd); | |
62 | ||
63 | discard (af == bf); | |
64 | discard (af < bf); | |
65 | discard (af > bf); | |
66 | discard (af != bf); | |
67 | discard (af <= bf); | |
68 | discard (af >= bf); | |
69 | ||
70 | return 0; | |
71 | } | |
72 | ||
820f6e3a | 73 | void |
2117d0f5 | 74 | discard (x) |
820f6e3a | 75 | int x __attribute__((__unused__)); |
2117d0f5 DE |
76 | {} |
77 | ||
820f6e3a | 78 | void |
2117d0f5 | 79 | ddiscard (x) |
820f6e3a | 80 | double x __attribute__((__unused__)); |
2117d0f5 DE |
81 | {} |
82 | ||
820f6e3a | 83 | int |
2117d0f5 DE |
84 | foo () |
85 | { | |
86 | static int table[] = {20, 69, 4, 12}; | |
87 | static int idx; | |
88 | ||
89 | return table[idx++]; | |
90 | } | |
91 | ||
92 | double | |
93 | dfoo () | |
94 | { | |
95 | static double table[] = {20.4, 69.96, 4.4, 202.202}; | |
96 | static int idx; | |
97 | ||
98 | return table[idx++]; | |
99 | } | |
100 | ||
2aa82cbe MM |
101 | /* Provide functions that some versions of the linker use to default |
102 | the start address if -e symbol is not used, to avoid the warning | |
103 | message saying the start address is defaulted. */ | |
104 | extern void start() __asm__("start"); | |
105 | extern void _start() __asm__("_start"); | |
979721f8 | 106 | extern void __start() __asm__("__start"); |
2aa82cbe | 107 | |
42b82dd3 | 108 | /* Provide functions that might be needed by soft-float emulation routines. */ |
820f6e3a MM |
109 | void *memcpy(void *to, |
110 | const void *from __attribute__((__unused__)), | |
111 | size_t len __attribute__((__unused__))) | |
112 | { | |
113 | return to; | |
114 | } | |
42b82dd3 | 115 | |
2aa82cbe MM |
116 | void start() {} |
117 | void _start() {} | |
979721f8 MM |
118 | void __start() {} |
119 | void mainCRTStartup() {} |