/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "quad.h"
#ifdef __sparcv9
/*
* _Qp_add(pz, ox, oy) sets *pz = *ox + *oy.
*/
void
const union longdouble *oy)
#else
/*
* _Q_add(ox, oy) returns *ox + *oy.
*/
union longdouble
#endif /* __sparcv9 */
{
union longdouble z;
const union longdouble *x, *y;
/* sort so |x| >= |y| */
y = ox;
x = oy;
} else {
x = ox;
y = oy;
}
/* get the fsr */
/* handle nan and inf cases */
if (xm >= 0x7fff0000) {
/* x is nan or inf */
if (ym >= 0x7fff0000) {
/* y is nan or inf */
y->l.frac4) {
/* y is nan; x must be nan too */
/* the following logic implements V9 app. B */
if (!(ym & 0x8000)) {
/* y is snan, signal invalid */
} else {
Z.l.msw |= 0x8000;
}
QUAD_RETURN(Z);
}
/* x and y are both qnan */
Z = *oy;
QUAD_RETURN(Z);
}
x->l.frac4)) {
/* x and y are both inf */
/* inf - inf, signal invalid */
} else {
Z.l.msw = 0x7fffffff;
Z.l.frac4 = 0xffffffff;
}
QUAD_RETURN(Z);
}
/* inf + inf, return inf */
Z = *x;
QUAD_RETURN(Z);
}
}
/* x is nan */
if (!(xm & 0x8000)) {
/* snan, signal invalid */
} else {
Z = *x;
Z.l.msw |= 0x8000;
}
QUAD_RETURN(Z);
}
Z = *x;
QUAD_RETURN(Z);
}
/* x is inf */
Z = *x;
QUAD_RETURN(Z);
}
/* now x and y are finite and |x| >= |y| */
__quad_mag_sub(x, y, &z, &fsr);
else
__quad_mag_add(x, y, &z, &fsr);
} else {
Z = z;
}
QUAD_RETURN(Z);
}