4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright (c) 1994-1997, by Sun Microsystems, Inc.
24 * All rights reserved.
27 #pragma ident "%Z%%M% %I% %E% SMI"
32 #define _Q_cmp _Qp_cmp
36 * _Q_cmp(x, y) returns the condition code that would result from
37 * fcmpq *x, *y (and raises the same exceptions).
40 _Q_cmp(const union longdouble
*x
, const union longdouble
*y
)
42 unsigned int xm
, ym
, fsr
;
44 if (QUAD_ISNAN(*x
) || QUAD_ISNAN(*y
)) {
45 if ((QUAD_ISNAN(*x
) && !(x
->l
.msw
& 0x8000)) ||
46 (QUAD_ISNAN(*y
) && !(y
->l
.msw
& 0x8000))) {
47 /* snan, signal invalid */
50 __quad_fcmpq(x
, y
, &fsr
);
51 return ((fsr
>> 10) & 3);
53 fsr
= (fsr
& ~FSR_CEXC
) | FSR_NVA
| FSR_NVC
;
57 return (fcc_unordered
);
60 /* ignore sign of zero */
68 if ((xm
^ ym
) & 0x80000000) /* x and y have opposite signs */
69 return ((ym
& 0x80000000)? fcc_greater
: fcc_less
);
71 if (xm
& 0x80000000) {
76 if (x
->l
.frac2
> y
->l
.frac2
)
78 if (x
->l
.frac2
< y
->l
.frac2
)
80 if (x
->l
.frac3
> y
->l
.frac3
)
82 if (x
->l
.frac3
< y
->l
.frac3
)
84 if (x
->l
.frac4
> y
->l
.frac4
)
86 if (x
->l
.frac4
< y
->l
.frac4
)
94 if (x
->l
.frac2
< y
->l
.frac2
)
96 if (x
->l
.frac2
> y
->l
.frac2
)
98 if (x
->l
.frac3
< y
->l
.frac3
)
100 if (x
->l
.frac3
> y
->l
.frac3
)
101 return (fcc_greater
);
102 if (x
->l
.frac4
< y
->l
.frac4
)
104 if (x
->l
.frac4
> y
->l
.frac4
)
105 return (fcc_greater
);