2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License, Version 1.0 only
2N/A * (the "License"). You may not use this file except in compliance
2N/A * with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A/*
2N/A * Copyright (c) 1994-1997, by Sun Microsystems, Inc.
2N/A * All rights reserved.
2N/A */
2N/A
2N/A#pragma ident "%Z%%M% %I% %E% SMI"
2N/A
2N/A#include "quad.h"
2N/A
2N/A#ifdef __sparcv9
2N/A#define _Q_cmpe _Qp_cmpe
2N/A#endif
2N/A
2N/A/*
2N/A * _Q_cmpe(x, y) returns the condition code that would result from
2N/A * fcmpeq *x, *y (and raises the same exceptions).
2N/A */
2N/Aenum fcc_type
2N/A_Q_cmpe(const union longdouble *x, const union longdouble *y)
2N/A{
2N/A unsigned int xm, ym, fsr;
2N/A
2N/A if (QUAD_ISNAN(*x) || QUAD_ISNAN(*y)) {
2N/A /* nan, signal invalid */
2N/A __quad_getfsrp(&fsr);
2N/A if (fsr & FSR_NVM) {
2N/A __quad_fcmpeq(x, y, &fsr);
2N/A return ((fsr >> 10) & 3);
2N/A } else {
2N/A fsr = (fsr & ~FSR_CEXC) | FSR_NVA | FSR_NVC;
2N/A __quad_setfsrp(&fsr);
2N/A }
2N/A return (fcc_unordered);
2N/A }
2N/A
2N/A /* ignore sign of zero */
2N/A xm = x->l.msw;
2N/A if (QUAD_ISZERO(*x))
2N/A xm &= 0x7fffffff;
2N/A ym = y->l.msw;
2N/A if (QUAD_ISZERO(*y))
2N/A ym &= 0x7fffffff;
2N/A
2N/A if ((xm ^ ym) & 0x80000000) /* x and y have opposite signs */
2N/A return ((ym & 0x80000000)? fcc_greater : fcc_less);
2N/A
2N/A if (xm & 0x80000000) {
2N/A if (xm > ym)
2N/A return (fcc_less);
2N/A if (xm < ym)
2N/A return (fcc_greater);
2N/A if (x->l.frac2 > y->l.frac2)
2N/A return (fcc_less);
2N/A if (x->l.frac2 < y->l.frac2)
2N/A return (fcc_greater);
2N/A if (x->l.frac3 > y->l.frac3)
2N/A return (fcc_less);
2N/A if (x->l.frac3 < y->l.frac3)
2N/A return (fcc_greater);
2N/A if (x->l.frac4 > y->l.frac4)
2N/A return (fcc_less);
2N/A if (x->l.frac4 < y->l.frac4)
2N/A return (fcc_greater);
2N/A return (fcc_equal);
2N/A }
2N/A if (xm < ym)
2N/A return (fcc_less);
2N/A if (xm > ym)
2N/A return (fcc_greater);
2N/A if (x->l.frac2 < y->l.frac2)
2N/A return (fcc_less);
2N/A if (x->l.frac2 > y->l.frac2)
2N/A return (fcc_greater);
2N/A if (x->l.frac3 < y->l.frac3)
2N/A return (fcc_less);
2N/A if (x->l.frac3 > y->l.frac3)
2N/A return (fcc_greater);
2N/A if (x->l.frac4 < y->l.frac4)
2N/A return (fcc_less);
2N/A if (x->l.frac4 > y->l.frac4)
2N/A return (fcc_greater);
2N/A return (fcc_equal);
2N/A}