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
8void link_error (void);
9
10extern long lround(double);
11extern long lrint(double);
12
13extern long long llround(double);
14extern long long llrint(double);
15
16extern long lroundf(float);
17extern long lrintf(float);
18
19extern long long llroundf(float);
20extern long long llrintf(float);
21
22extern long lroundl(long double);
23extern long lrintl(long double);
24
25extern long long llroundl(long double);
26extern long long llrintl(long double);
27
28
29void 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
42void 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
55void 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
68int main()
69{
70  test(0.0);
71  testf(0.0);
72  testl(0.0);
73  return 0;
74}
75
76