Print this page
5261 libm should stop using synonyms.h


  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 /*
  26  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27  * Use is subject to license terms.
  28  */
  29 
  30 #pragma weak sinpil = __sinpil
  31 
  32 /* long double sinpil(long double x),
  33  * return long double precision sinl(pi*x).
  34  *
  35  * Algorithm, 10/17/2002, K.C. Ng
  36  * ------------------------------
  37  * Let y = |4x|, z = floor(y), and n = (int)(z mod 8.0) (displayed in binary).
  38  *      1. If y == z, then x is a multiple of pi/4. Return the following values:
  39  *             ---------------------------------------------------
  40  *               n  x mod 2    sin(x*pi)    cos(x*pi)   tan(x*pi)
  41  *             ---------------------------------------------------
  42  *              000  0.00       +0 ___       +1 ___      +0
  43  *              001  0.25       +\/0.5       +\/0.5      +1
  44  *              010  0.50       +1 ___       +0 ___      +inf
  45  *              011  0.75       +\/0.5       -\/0.5      -1
  46  *              100  1.00       -0 ___       -1 ___      +0
  47  *              101  1.25       -\/0.5       -\/0.5      +1
  48  *              110  1.50       -1 ___       -0 ___      +inf
  49  *              111  1.75       -\/0.5       +\/0.5      -1
  50  *             ---------------------------------------------------
  51  *      2. Otherwise,


  53  *               n     t        sin(x*pi)    cos(x*pi)   tan(x*pi)
  54  *             ---------------------------------------------------
  55  *              000  (y-z)/4     sinpi(t)     cospi(t)    tanpi(t)
  56  *              001  (z+1-y)/4   cospi(t)     sinpi(t)    1/tanpi(t)
  57  *              010  (y-z)/4     cospi(t)    -sinpi(t)   -1/tanpi(t)
  58  *              011  (z+1-y)/4   sinpi(t)    -cospi(t)   -tanpi(t)
  59  *              100  (y-z)/4    -sinpi(t)    -cospi(t)    tanpi(t)
  60  *              101  (z+1-y)/4  -cospi(t)    -sinpi(t)    1/tanpi(t)
  61  *              110  (y-z)/4    -cospi(t)     sinpi(t)   -1/tanpi(t)
  62  *              111  (z+1-y)/4  -sinpi(t)     cospi(t)   -tanpi(t)
  63  *             ---------------------------------------------------
  64  *
  65  * NOTE. This program compute sinpi/cospi(t<0.25) by __k_sin/cos(pi*t, 0.0).
  66  * This will return a result with error slightly more than one ulp (but less
  67  * than 2 ulp). If one wants accurate result,  one may break up pi*t in
  68  * high (tpi_h) and low (tpi_l) parts and call __k_sin/cos(tip_h, tip_lo)
  69  * instead.
  70  */
  71 
  72 #include "libm.h"
  73 #include "libm_synonyms.h"
  74 #include "longdouble.h"
  75 
  76 #include <sys/isa_defs.h>
  77 
  78 #define I(q, m) ((int *) &(q))[m]
  79 #define U(q, m) ((unsigned *) &(q))[m]
  80 #if defined(__i386) || defined(__amd64)
  81 #define LDBL_MOST_SIGNIF_I(ld)  ((I(ld, 2) << 16) | (0xffff & (I(ld, 1) >> 15)))
  82 #define LDBL_LEAST_SIGNIF_U(ld) U(ld, 0)
  83 #define PREC    64
  84 #define PRECM1  63
  85 #define PRECM2  62
  86 static const long double twoPRECM2 = 9.223372036854775808000000000000000e+18L;
  87 #else
  88 #define LDBL_MOST_SIGNIF_I(ld)  I(ld, 0)
  89 #define LDBL_LEAST_SIGNIF_U(ld) U(ld, sizeof(long double) / sizeof(int) - 1)
  90 #define PREC    113
  91 #define PRECM1  112
  92 #define PRECM2  111
  93 static const long double twoPRECM2 = 5.192296858534827628530496329220096e+33L;




  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  24  */
  25 /*
  26  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
  27  * Use is subject to license terms.
  28  */
  29 


  30 /* long double sinpil(long double x),
  31  * return long double precision sinl(pi*x).
  32  *
  33  * Algorithm, 10/17/2002, K.C. Ng
  34  * ------------------------------
  35  * Let y = |4x|, z = floor(y), and n = (int)(z mod 8.0) (displayed in binary).
  36  *      1. If y == z, then x is a multiple of pi/4. Return the following values:
  37  *             ---------------------------------------------------
  38  *               n  x mod 2    sin(x*pi)    cos(x*pi)   tan(x*pi)
  39  *             ---------------------------------------------------
  40  *              000  0.00       +0 ___       +1 ___      +0
  41  *              001  0.25       +\/0.5       +\/0.5      +1
  42  *              010  0.50       +1 ___       +0 ___      +inf
  43  *              011  0.75       +\/0.5       -\/0.5      -1
  44  *              100  1.00       -0 ___       -1 ___      +0
  45  *              101  1.25       -\/0.5       -\/0.5      +1
  46  *              110  1.50       -1 ___       -0 ___      +inf
  47  *              111  1.75       -\/0.5       +\/0.5      -1
  48  *             ---------------------------------------------------
  49  *      2. Otherwise,


  51  *               n     t        sin(x*pi)    cos(x*pi)   tan(x*pi)
  52  *             ---------------------------------------------------
  53  *              000  (y-z)/4     sinpi(t)     cospi(t)    tanpi(t)
  54  *              001  (z+1-y)/4   cospi(t)     sinpi(t)    1/tanpi(t)
  55  *              010  (y-z)/4     cospi(t)    -sinpi(t)   -1/tanpi(t)
  56  *              011  (z+1-y)/4   sinpi(t)    -cospi(t)   -tanpi(t)
  57  *              100  (y-z)/4    -sinpi(t)    -cospi(t)    tanpi(t)
  58  *              101  (z+1-y)/4  -cospi(t)    -sinpi(t)    1/tanpi(t)
  59  *              110  (y-z)/4    -cospi(t)     sinpi(t)   -1/tanpi(t)
  60  *              111  (z+1-y)/4  -sinpi(t)     cospi(t)   -tanpi(t)
  61  *             ---------------------------------------------------
  62  *
  63  * NOTE. This program compute sinpi/cospi(t<0.25) by __k_sin/cos(pi*t, 0.0).
  64  * This will return a result with error slightly more than one ulp (but less
  65  * than 2 ulp). If one wants accurate result,  one may break up pi*t in
  66  * high (tpi_h) and low (tpi_l) parts and call __k_sin/cos(tip_h, tip_lo)
  67  * instead.
  68  */
  69 
  70 #include "libm.h"

  71 #include "longdouble.h"
  72 
  73 #include <sys/isa_defs.h>
  74 
  75 #define I(q, m) ((int *) &(q))[m]
  76 #define U(q, m) ((unsigned *) &(q))[m]
  77 #if defined(__i386) || defined(__amd64)
  78 #define LDBL_MOST_SIGNIF_I(ld)  ((I(ld, 2) << 16) | (0xffff & (I(ld, 1) >> 15)))
  79 #define LDBL_LEAST_SIGNIF_U(ld) U(ld, 0)
  80 #define PREC    64
  81 #define PRECM1  63
  82 #define PRECM2  62
  83 static const long double twoPRECM2 = 9.223372036854775808000000000000000e+18L;
  84 #else
  85 #define LDBL_MOST_SIGNIF_I(ld)  I(ld, 0)
  86 #define LDBL_LEAST_SIGNIF_U(ld) U(ld, sizeof(long double) / sizeof(int) - 1)
  87 #define PREC    113
  88 #define PRECM1  112
  89 #define PRECM2  111
  90 static const long double twoPRECM2 = 5.192296858534827628530496329220096e+33L;