OSDN Git Service

* Makefile.in (start.encap): Do not depend on LIBGCC1.
[pf3gnuchains/gcc-fork.git] / gcc / libgcc1-test.c
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
6 #include <stddef.h>
7
8 int foo ();
9 double dfoo ();
10 void discard (int);
11 void ddiscard (double);
12
13 /* We don't want __main here because that can drag in atexit (among other
14    things) which won't necessarily exist yet.  */
15
16 int
17 main_without__main ()
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
73 void
74 discard (x)
75      int x __attribute__((__unused__));
76 {}
77
78 void
79 ddiscard (x)
80      double x __attribute__((__unused__));
81 {}
82
83 int
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
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");
106 extern void __start() __asm__("__start");
107
108 /* Provide functions that might be needed by soft-float emulation routines.  */
109 void *memcpy(void *to,
110              const void *from __attribute__((__unused__)),
111              size_t len __attribute__((__unused__)))
112 {
113   return to;
114 }
115
116 void start() {}
117 void _start() {}
118 void __start() {}
119 void mainCRTStartup() {}