1//===--------------- extendsftf2_test.c - Test __extendsftf2 --------------===// 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 __extendsftf2 for the compiler_rt library. 11// 12//===----------------------------------------------------------------------===// 13 14#include "int_lib.h" 15#include <stdio.h> 16 17#if __LDBL_MANT_DIG__ == 113 18 19#include "fp_test.h" 20 21COMPILER_RT_ABI long double __extendsftf2(float a); 22 23int test__extendsftf2(float a, uint64_t expectedHi, uint64_t expectedLo) 24{ 25 long double x = __extendsftf2(a); 26 int ret = compareResultLD(x, expectedHi, expectedLo); 27 28 if (ret) 29 { 30 printf("error in test__extendsftf2(%f) = %.20Lf, " 31 "expected %.20Lf\n", a, x, fromRep128(expectedHi, expectedLo)); 32 } 33 return ret; 34} 35 36char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0}; 37 38#endif 39 40int main() 41{ 42#if __LDBL_MANT_DIG__ == 113 43 // qNaN 44 if (test__extendsftf2(makeQNaN32(), 45 UINT64_C(0x7fff800000000000), 46 UINT64_C(0x0))) 47 return 1; 48 // NaN 49 if (test__extendsftf2(makeNaN32(UINT32_C(0x410000)), 50 UINT64_C(0x7fff820000000000), 51 UINT64_C(0x0))) 52 return 1; 53 // inf 54 if (test__extendsftf2(makeInf32(), 55 UINT64_C(0x7fff000000000000), 56 UINT64_C(0x0))) 57 return 1; 58 // zero 59 if (test__extendsftf2(0.0f, UINT64_C(0x0), UINT64_C(0x0))) 60 return 1; 61 62 if (test__extendsftf2(0x1.23456p+5f, 63 UINT64_C(0x4004234560000000), 64 UINT64_C(0x0))) 65 return 1; 66 if (test__extendsftf2(0x1.edcbap-9f, 67 UINT64_C(0x3ff6edcba0000000), 68 UINT64_C(0x0))) 69 return 1; 70 if (test__extendsftf2(0x1.23456p+45f, 71 UINT64_C(0x402c234560000000), 72 UINT64_C(0x0))) 73 return 1; 74 if (test__extendsftf2(0x1.edcbap-45f, 75 UINT64_C(0x3fd2edcba0000000), 76 UINT64_C(0x0))) 77 return 1; 78 79#else 80 printf("skipped\n"); 81 82#endif 83 return 0; 84} 85