Home | History | Annotate | Download | only in Unit
      1 //===--------------- fixtfsi_test.c - Test __fixtfsi ----------------------===//
      2 //
      3 //                     The LLVM Compiler Infrastructure
      4 //
      5 // This file is dual licensed under the MIT and the University of Illinois Open
      6 // Source Licenses. See LICENSE.TXT for details.
      7 //
      8 //===----------------------------------------------------------------------===//
      9 //
     10 // This file tests __fixtfsi for the compiler_rt library.
     11 //
     12 //===----------------------------------------------------------------------===//
     13 
     14 #include <stdio.h>
     15 
     16 #if __LDBL_MANT_DIG__ == 113
     17 
     18 #include "fp_test.h"
     19 
     20 int __fixtfsi(long double a);
     21 
     22 int test__fixtfsi(long double a, int expected)
     23 {
     24     int x = __fixtfsi(a);
     25     int ret = (x != expected);
     26 
     27     if (ret){
     28         printf("error in test__fixtfsi(%.20Lf) = %d, "
     29                "expected %d\n", a, x, expected);
     30     }
     31     return ret;
     32 }
     33 
     34 char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
     35 
     36 #endif
     37 
     38 int main()
     39 {
     40 #if __LDBL_MANT_DIG__ == 113
     41     if (test__fixtfsi(makeInf128(), 0x7fffffff))
     42         return 1;
     43     if (test__fixtfsi(0, 0x0))
     44         return 1;
     45     if (test__fixtfsi(0x1.23456789abcdefp+5, 0x24))
     46         return 1;
     47     if (test__fixtfsi(0x1.23456789abcdefp-3, 0x0))
     48         return 1;
     49     if (test__fixtfsi(0x1.23456789abcdefp+20, 0x123456))
     50         return 1;
     51     if (test__fixtfsi(0x1.23456789abcdefp+40, 0x7fffffff))
     52         return 1;
     53     if (test__fixtfsi(0x1.23456789abcdefp+256, 0x7fffffff))
     54         return 1;
     55     if (test__fixtfsi(-0x1.23456789abcdefp+20, 0xffedcbaa))
     56         return 1;
     57     if (test__fixtfsi(-0x1.23456789abcdefp+40, 0x80000000))
     58         return 1;
     59 
     60 #else
     61     printf("skipped\n");
     62 
     63 #endif
     64     return 0;
     65 }
     66