Remove building with NOCRYPTO option
[minix.git] / sys / external / bsd / compiler_rt / dist / lib / builtins / ppc / multc3.c
blob738b65a83b03a28c21c8df0c3f51960388e1ad0c
1 /* This file is distributed under the University of Illinois Open Source
2 * License. See LICENSE.TXT for details.
3 */
5 #include "DD.h"
6 #include "../int_math.h"
8 #define makeFinite(x) { \
9 (x).s.hi = crt_copysign(crt_isinf((x).s.hi) ? 1.0 : 0.0, (x).s.hi); \
10 (x).s.lo = 0.0; \
13 #define zeroNaN(x) { \
14 if (crt_isnan((x).s.hi)) { \
15 (x).s.hi = crt_copysign(0.0, (x).s.hi); \
16 (x).s.lo = 0.0; \
17 } \
20 long double __gcc_qadd(long double, long double);
21 long double __gcc_qsub(long double, long double);
22 long double __gcc_qmul(long double, long double);
24 long double _Complex
25 __multc3(long double a, long double b, long double c, long double d)
27 long double ac = __gcc_qmul(a,c);
28 long double bd = __gcc_qmul(b,d);
29 long double ad = __gcc_qmul(a,d);
30 long double bc = __gcc_qmul(b,c);
32 DD real = { .ld = __gcc_qsub(ac,bd) };
33 DD imag = { .ld = __gcc_qadd(ad,bc) };
35 if (crt_isnan(real.s.hi) && crt_isnan(imag.s.hi))
37 int recalc = 0;
39 DD aDD = { .ld = a };
40 DD bDD = { .ld = b };
41 DD cDD = { .ld = c };
42 DD dDD = { .ld = d };
44 if (crt_isinf(aDD.s.hi) || crt_isinf(bDD.s.hi))
46 makeFinite(aDD);
47 makeFinite(bDD);
48 zeroNaN(cDD);
49 zeroNaN(dDD);
50 recalc = 1;
53 if (crt_isinf(cDD.s.hi) || crt_isinf(dDD.s.hi))
55 makeFinite(cDD);
56 makeFinite(dDD);
57 zeroNaN(aDD);
58 zeroNaN(bDD);
59 recalc = 1;
62 if (!recalc)
64 DD acDD = { .ld = ac };
65 DD bdDD = { .ld = bd };
66 DD adDD = { .ld = ad };
67 DD bcDD = { .ld = bc };
69 if (crt_isinf(acDD.s.hi) || crt_isinf(bdDD.s.hi) ||
70 crt_isinf(adDD.s.hi) || crt_isinf(bcDD.s.hi))
72 zeroNaN(aDD);
73 zeroNaN(bDD);
74 zeroNaN(cDD);
75 zeroNaN(dDD);
76 recalc = 1;
80 if (recalc)
82 real.s.hi = CRT_INFINITY * (aDD.s.hi*cDD.s.hi - bDD.s.hi*dDD.s.hi);
83 real.s.lo = 0.0;
84 imag.s.hi = CRT_INFINITY * (aDD.s.hi*dDD.s.hi + bDD.s.hi*cDD.s.hi);
85 imag.s.lo = 0.0;
89 long double _Complex z;
90 __real__ z = real.ld;
91 __imag__ z = imag.ld;
93 return z;