modfl.c revision 1ec68d336ba97cd53f46053ac10401d16014d075
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * CDDL HEADER START
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * The contents of this file are subject to the terms of the
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Common Development and Distribution License (the "License").
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * You may not use this file except in compliance with the License.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * See the License for the specific language governing permissions
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * and limitations under the License.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * When distributing Covered Code, include this CDDL HEADER in each
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * If applicable, add the following below this CDDL HEADER, with the
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * fields enclosed by brackets "[]" replaced with your own identifying
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * information: Portions Copyright [yyyy] [name of copyright owner]
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * CDDL HEADER END
44ed9dbbfa620821ecf59a131462082f628dd0f3Stephen Hanson * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * Use is subject to license terms.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi#if defined(__sparc)
908f1e1388f616898b4e515d343c0414f2a6472esd unsigned i[4];
14ea4bb737263733ad80a36b4f73f681c30a6b45sd long double q;
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi unsigned hx, s;
e3d60c9bd991a9826cbfa63b10595d44e123b9c4Adrian Frost if (hx >= 0x406f0000) { /* x is NaN, infinite, or integral */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (xx.q);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi return (x);
908f1e1388f616898b4e515d343c0414f2a6472esd /* split x at the binary point */
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi yy.i[0] = xx.i[0] & ~((1 << (0x400f - (hx >> 16))) - 1);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi yy.i[1] = xx.i[1] & ~((1 << (0x402f - (hx >> 16))) - 1);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi yy.i[2] = xx.i[2] & ~((1 << (0x404f - (hx >> 16))) - 1);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi yy.i[3] = xx.i[3] & ~((1 << (0x406f - (hx >> 16))) - 1);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * we could implement the following more efficiently than by using
940d71d237794874e18a0eb72f6564821a823517eschrock * software emulation of fsubq, but we'll do it this way for now
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim * (and hope hardware support becomes commonplace)
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi xx.i[0] = (xx.i[0] & ~0x80000000) | s; /* keep sign of x */
14ea4bb737263733ad80a36b4f73f681c30a6b45sd return (xx.q);
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi unsigned i[3];
9dd0f810214fdc8e1af881a9a5c4b6927629ff9ecindi long double e;
602ca9ea8f9ce0933f0944601cc5d230e91a950dcth unsigned hx, s;
602ca9ea8f9ce0933f0944601cc5d230e91a950dcth * It might be faster to use one of the x86 fpops instead of
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi * the following.
0eb822a1c0c2bea495647510b75f77f0e57633ebcindi if (hx >= 0x403e) { /* x is NaN, infinite, or integral */
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim return (x);
ac88567a7a5bb7f01cf22cf366bc9d6203e24d7aHyon Kim /* split x at the binary point */
e58a33b62cd4c9a6815fd752ce58b5f389289da1Stephen Hanson xx.i[2] = (xx.i[2] & ~0x8000) | s; /* keep sign of x */