1  /* { dg-do link } */
       2  /* { dg-options "-O2 -ffast-math" } */
       3  
       4  #include "builtins-config.h"
       5  
       6  void link_error (void);
       7  
       8  extern long lround(double);
       9  extern long lrint(double);
      10  
      11  extern long long llround(double);
      12  extern long long llrint(double);
      13  
      14  extern long lroundf(float);
      15  extern long lrintf(float);
      16  
      17  extern long long llroundf(float);
      18  extern long long llrintf(float);
      19  
      20  extern long lroundl(long double);
      21  extern long lrintl(long double);
      22  
      23  extern long long llroundl(long double);
      24  extern long long llrintl(long double);
      25  
      26  
      27  void test(double x)
      28  {
      29  #ifdef HAVE_C99_RUNTIME
      30    if (sizeof(long) != sizeof(long long))
      31      return;
      32  
      33    if (__builtin_lceil(x) != __builtin_llceil(x))
      34      link_error();
      35    if (__builtin_lfloor(x) != __builtin_llfloor(x))
      36      link_error();
      37    if (lround(x) != llround(x))
      38      link_error();
      39    if (lrint(x) != llrint(x))
      40      link_error();
      41  #endif
      42  }
      43  
      44  void testf(float x)
      45  {
      46  #ifdef HAVE_C99_RUNTIME
      47    if (sizeof(long) != sizeof(long long))
      48      return;
      49  
      50    if (__builtin_lceilf(x) != __builtin_llceilf(x))
      51      link_error();
      52    if (__builtin_lfloorf(x) != __builtin_llfloorf(x))
      53      link_error();
      54    if (lroundf(x) != llroundf(x))
      55      link_error();
      56    if (lrintf(x) != llrintf(x))
      57      link_error();
      58  #endif
      59  }
      60  
      61  void testl(long double x)
      62  {
      63  #ifdef HAVE_C99_RUNTIME
      64    if (sizeof(long) != sizeof(long long))
      65      return;
      66  
      67    if (__builtin_lceill(x) != __builtin_llceill(x))
      68      link_error();
      69    if (__builtin_lfloorl(x) != __builtin_llfloorl(x))
      70      link_error();
      71    if (lroundl(x) != llroundl(x))
      72      link_error();
      73    if (lrintl(x) != llrintl(x))
      74      link_error();
      75  #endif
      76  }
      77  
      78  int main()
      79  {
      80    test(0.0);
      81    testf(0.0);
      82    testl(0.0);
      83    return 0;
      84  }
      85