OSDN Git Service

PR testsuite/30179
[pf3gnuchains/gcc-fork.git] / gcc / testsuite / gcc.dg / builtins-55.c
1 /* { dg-do link } */
2 /* { dg-options "-O2 -ffast-math" } */
3 /* { dg-options "-ffast-math -mmacosx-version-min=10.3" { target powerpc-*-darwin* } } */
4 /* { dg-options "-O2 -ffast-math -std=c99" { target *-*-solaris2* } } */
5
6 #include "builtins-config.h"
7
8 void link_error (void);
9
10 extern long lround(double);
11 extern long lrint(double);
12
13 extern long long llround(double);
14 extern long long llrint(double);
15
16 extern long lroundf(float);
17 extern long lrintf(float);
18
19 extern long long llroundf(float);
20 extern long long llrintf(float);
21
22 extern long lroundl(long double);
23 extern long lrintl(long double);
24
25 extern long long llroundl(long double);
26 extern long long llrintl(long double);
27
28
29 void test(double x)
30 {
31 #ifdef HAVE_C99_RUNTIME
32   if (sizeof(long) != sizeof(long long))
33     return;
34
35   if (lround(x) != llround(x))
36     link_error();
37   if (lrint(x) != llrint(x))
38     link_error();
39 #endif
40 }
41
42 void testf(float x)
43 {
44 #ifdef HAVE_C99_RUNTIME
45   if (sizeof(long) != sizeof(long long))
46     return;
47
48   if (lroundf(x) != llroundf(x))
49     link_error();
50   if (lrintf(x) != llrintf(x))
51     link_error();
52 #endif
53 }
54
55 void testl(long double x)
56 {
57 #ifdef HAVE_C99_RUNTIME
58   if (sizeof(long) != sizeof(long long))
59     return;
60
61   if (lroundl(x) != llroundl(x))
62     link_error();
63   if (lrintl(x) != llrintl(x))
64     link_error();
65 #endif
66 }
67
68 int main()
69 {
70   test(0.0);
71   testf(0.0);
72   testl(0.0);
73   return 0;
74 }
75