25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * CDDL HEADER START
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * The contents of this file are subject to the terms of the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Common Development and Distribution License (the "License").
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * You may not use this file except in compliance with the License.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * or http://www.opensolaris.org/os/licensing.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * See the License for the specific language governing permissions
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * and limitations under the License.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * When distributing Covered Code, include this CDDL HEADER in each
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * If applicable, add the following below this CDDL HEADER, with the
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * fields enclosed by brackets "[]" replaced with your own identifying
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * information: Portions Copyright [yyyy] [name of copyright owner]
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * CDDL HEADER END
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Copyright 2005 Sun Microsystems, Inc. All rights reserved.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis * Use is subject to license terms.
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisextern const int _TBL_ipio2_inf[];
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisextern int __rem_pio2m(double *, double *, int, int, int, const int *);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisextern int __swapRP(int);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtisstatic const double C[] = {
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 4.46066928428959230679140546271810308098793029785e-0003,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 4.92165316309189027066395283327437937259674072266e+0000,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis -7.11410648161473480044492134766187518835067749023e-0001,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 4.08549808374053391446523164631798863410949707031e+0000,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 2.50411070398050927821032018982805311679840087891e+0000,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 1.11492064560251158411574579076841473579406738281e+0001,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis -1.50565540968422650891511693771462887525558471680e+0000,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis -1.81484378878349295050043110677506774663925170898e+0000,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 3.333335997532835641297409611782510896641e-0001,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 2.999997598248363761541668282006867229939e+00,
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 0.636619772367581343075535, /* 2^ -1 * 1.45F306DC9C883 */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 1.570796326734125614166, /* 2^ 0 * 1.921FB54400000 */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis 6.077100506506192601475e-11, /* 2^-34 * 1.0B4611A626331 */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis double y, z, w;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis volatile int i;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis hx = *((int *)&x);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis y = (double)x;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis if (ix <= 0x4016cbe4) { /* |x| < 3*pi/4 */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis if (ix <= 0x39800000) { /* |x| < 2**-12 */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis return ((float)((y * T0) * (T1 + y * y)));
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis return ((float)(((P0 * y) * (P1 + z * (P2 + z)) *
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis return ((float)(-one / z));
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis w = ((P0 * y) * (P1 + z * (P2 + z)) * (P3 + z * (P4 + z))) *
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis return ((float)(-one / w));
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis if (ix <= 0x49c90fdb) { /* |x| < 2^19*pi */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis n = (int)(w - half);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis n = (int)(w + half);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis return (x / x); /* sin(Inf or NaN) is NaN */
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis ((int *)&w)[HIWORD] = (hy & 0xfffff) | 0x41600000;
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis ((int *)&w)[LOWORD] = ((int *)&y)[LOWORD];
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis n = __rem_pio2m(&w, &y, n, 1, 0, _TBL_ipio2_inf);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis f = ((n & 1) == 0)? (float)z : (float)(-one / z);
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis w = ((P0 * y) * (P1 + z * (P2 + z)) * (P3 + z * (P4 + z))) *
25c28e83beb90e7c80452a7c818c5e6f73a07dc8Piotr Jasiukajtis f = ((n & 1) == 0)? (float)w : (float)(-one / w);