]> gcc.gnu.org Git - gcc.git/blame - gcc/libgcc1-test.c
* cppinit.c: Fix thinko in previous patch.
[gcc.git] / gcc / libgcc1-test.c
CommitLineData
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
8int foo ();
9double dfoo ();
820f6e3a
MM
10void discard (int);
11void 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 16int
0d5b1231 17main_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 73void
2117d0f5 74discard (x)
820f6e3a 75 int x __attribute__((__unused__));
2117d0f5
DE
76{}
77
820f6e3a 78void
2117d0f5 79ddiscard (x)
820f6e3a 80 double x __attribute__((__unused__));
2117d0f5
DE
81{}
82
820f6e3a 83int
2117d0f5
DE
84foo ()
85{
86 static int table[] = {20, 69, 4, 12};
87 static int idx;
88
89 return table[idx++];
90}
91
92double
93dfoo ()
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. */
104extern void start() __asm__("start");
105extern void _start() __asm__("_start");
979721f8 106extern void __start() __asm__("__start");
2aa82cbe 107
42b82dd3 108/* Provide functions that might be needed by soft-float emulation routines. */
820f6e3a
MM
109void *memcpy(void *to,
110 const void *from __attribute__((__unused__)),
111 size_t len __attribute__((__unused__)))
112{
113 return to;
114}
42b82dd3 115
2aa82cbe
MM
116void start() {}
117void _start() {}
979721f8
MM
118void __start() {}
119void mainCRTStartup() {}
This page took 0.75341 seconds and 5 git commands to generate.