xref: /aosp_15_r20/external/compiler-rt/test/builtins/Unit/letf2_test.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot //===------------ letf2_test.c - Test __letf2------------------------------===//
2*7c3d14c8STreehugger Robot //
3*7c3d14c8STreehugger Robot //                     The LLVM Compiler Infrastructure
4*7c3d14c8STreehugger Robot //
5*7c3d14c8STreehugger Robot // This file is dual licensed under the MIT and the University of Illinois Open
6*7c3d14c8STreehugger Robot // Source Licenses. See LICENSE.TXT for details.
7*7c3d14c8STreehugger Robot //
8*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
9*7c3d14c8STreehugger Robot //
10*7c3d14c8STreehugger Robot // This file tests __letf2 for the compiler_rt library.
11*7c3d14c8STreehugger Robot //
12*7c3d14c8STreehugger Robot //===----------------------------------------------------------------------===//
13*7c3d14c8STreehugger Robot 
14*7c3d14c8STreehugger Robot #include <stdio.h>
15*7c3d14c8STreehugger Robot 
16*7c3d14c8STreehugger Robot #if __LP64__ && __LDBL_MANT_DIG__ == 113
17*7c3d14c8STreehugger Robot 
18*7c3d14c8STreehugger Robot #include "fp_test.h"
19*7c3d14c8STreehugger Robot 
20*7c3d14c8STreehugger Robot int __letf2(long double a, long double b);
21*7c3d14c8STreehugger Robot 
test__letf2(long double a,long double b,enum EXPECTED_RESULT expected)22*7c3d14c8STreehugger Robot int test__letf2(long double a, long double b, enum EXPECTED_RESULT expected)
23*7c3d14c8STreehugger Robot {
24*7c3d14c8STreehugger Robot     int x = __letf2(a, b);
25*7c3d14c8STreehugger Robot     int ret = compareResultCMP(x, expected);
26*7c3d14c8STreehugger Robot 
27*7c3d14c8STreehugger Robot     if (ret){
28*7c3d14c8STreehugger Robot         printf("error in test__letf2(%.20Lf, %.20Lf) = %d, "
29*7c3d14c8STreehugger Robot                "expected %s\n", a, b, x, expectedStr(expected));
30*7c3d14c8STreehugger Robot     }
31*7c3d14c8STreehugger Robot     return ret;
32*7c3d14c8STreehugger Robot }
33*7c3d14c8STreehugger Robot 
34*7c3d14c8STreehugger Robot char assumption_1[sizeof(long double) * CHAR_BIT == 128] = {0};
35*7c3d14c8STreehugger Robot 
36*7c3d14c8STreehugger Robot #endif
37*7c3d14c8STreehugger Robot 
main()38*7c3d14c8STreehugger Robot int main()
39*7c3d14c8STreehugger Robot {
40*7c3d14c8STreehugger Robot #if __LP64__ && __LDBL_MANT_DIG__ == 113
41*7c3d14c8STreehugger Robot     // NaN
42*7c3d14c8STreehugger Robot     if (test__letf2(makeQNaN128(),
43*7c3d14c8STreehugger Robot                     0x1.234567890abcdef1234567890abcp+3L,
44*7c3d14c8STreehugger Robot                     GREATER_0))
45*7c3d14c8STreehugger Robot         return 1;
46*7c3d14c8STreehugger Robot     // <
47*7c3d14c8STreehugger Robot     // exp
48*7c3d14c8STreehugger Robot     if (test__letf2(0x1.234567890abcdef1234567890abcp-3L,
49*7c3d14c8STreehugger Robot                     0x1.234567890abcdef1234567890abcp+3L,
50*7c3d14c8STreehugger Robot                     LESS_EQUAL_0))
51*7c3d14c8STreehugger Robot         return 1;
52*7c3d14c8STreehugger Robot     // mantissa
53*7c3d14c8STreehugger Robot     if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
54*7c3d14c8STreehugger Robot                     0x1.334567890abcdef1234567890abcp+3L,
55*7c3d14c8STreehugger Robot                     LESS_EQUAL_0))
56*7c3d14c8STreehugger Robot         return 1;
57*7c3d14c8STreehugger Robot     // sign
58*7c3d14c8STreehugger Robot     if (test__letf2(-0x1.234567890abcdef1234567890abcp+3L,
59*7c3d14c8STreehugger Robot                     0x1.234567890abcdef1234567890abcp+3L,
60*7c3d14c8STreehugger Robot                     LESS_EQUAL_0))
61*7c3d14c8STreehugger Robot         return 1;
62*7c3d14c8STreehugger Robot     // ==
63*7c3d14c8STreehugger Robot     if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
64*7c3d14c8STreehugger Robot                     0x1.234567890abcdef1234567890abcp+3L,
65*7c3d14c8STreehugger Robot                     LESS_EQUAL_0))
66*7c3d14c8STreehugger Robot         return 1;
67*7c3d14c8STreehugger Robot     // >
68*7c3d14c8STreehugger Robot     // exp
69*7c3d14c8STreehugger Robot     if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
70*7c3d14c8STreehugger Robot                     0x1.234567890abcdef1234567890abcp-3L,
71*7c3d14c8STreehugger Robot                     GREATER_0))
72*7c3d14c8STreehugger Robot         return 1;
73*7c3d14c8STreehugger Robot     // mantissa
74*7c3d14c8STreehugger Robot     if (test__letf2(0x1.334567890abcdef1234567890abcp+3L,
75*7c3d14c8STreehugger Robot                     0x1.234567890abcdef1234567890abcp+3L,
76*7c3d14c8STreehugger Robot                     GREATER_0))
77*7c3d14c8STreehugger Robot         return 1;
78*7c3d14c8STreehugger Robot     // sign
79*7c3d14c8STreehugger Robot     if (test__letf2(0x1.234567890abcdef1234567890abcp+3L,
80*7c3d14c8STreehugger Robot                     -0x1.234567890abcdef1234567890abcp+3L,
81*7c3d14c8STreehugger Robot                     GREATER_0))
82*7c3d14c8STreehugger Robot         return 1;
83*7c3d14c8STreehugger Robot 
84*7c3d14c8STreehugger Robot #else
85*7c3d14c8STreehugger Robot     printf("skipped\n");
86*7c3d14c8STreehugger Robot 
87*7c3d14c8STreehugger Robot #endif
88*7c3d14c8STreehugger Robot     return 0;
89*7c3d14c8STreehugger Robot }
90