Home | History | Annotate | Download | only in fdlibm
      1 
      2 /* @(#)fdlibm.h 1.5 04/04/22 */
      3 /*
      4  * ====================================================
      5  * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
      6  *
      7  * Permission to use, copy, modify, and distribute this
      8  * software is freely granted, provided that this notice
      9  * is preserved.
     10  * ====================================================
     11  */
     12 
     13 /* Sometimes it's necessary to define __LITTLE_ENDIAN explicitly
     14    but these catch some common cases. */
     15 
     16 #if defined(i386) || defined(i486) || \
     17 	defined(intel) || defined(x86) || defined(i86pc) || \
     18 	defined(__alpha) || defined(__osf__)
     19 #define __LITTLE_ENDIAN
     20 #endif
     21 
     22 #ifdef __LITTLE_ENDIAN
     23 #define __HI(x) *(1+(int*)&x)
     24 #define __LO(x) *(int*)&x
     25 #define __HIp(x) *(1+(int*)x)
     26 #define __LOp(x) *(int*)x
     27 #else
     28 #define __HI(x) *(int*)&x
     29 #define __LO(x) *(1+(int*)&x)
     30 #define __HIp(x) *(int*)x
     31 #define __LOp(x) *(1+(int*)x)
     32 #endif
     33 
     34 #ifdef __STDC__
     35 #define	__P(p)	p
     36 #else
     37 #define	__P(p)	()
     38 #endif
     39 
     40 /*
     41  * ANSI/POSIX
     42  */
     43 
     44 extern int signgam;
     45 
     46 #define	MAXFLOAT	((float)3.40282346638528860e+38)
     47 
     48 enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
     49 
     50 #define _LIB_VERSION_TYPE enum fdversion
     51 #define _LIB_VERSION _fdlib_version
     52 
     53 /* if global variable _LIB_VERSION is not desirable, one may
     54  * change the following to be a constant by:
     55  *	#define _LIB_VERSION_TYPE const enum version
     56  * In that case, after one initializes the value _LIB_VERSION (see
     57  * s_lib_version.c) during compile time, it cannot be modified
     58  * in the middle of a program
     59  */
     60 extern  _LIB_VERSION_TYPE  _LIB_VERSION;
     61 
     62 #define _IEEE_  fdlibm_ieee
     63 #define _SVID_  fdlibm_svid
     64 #define _XOPEN_ fdlibm_xopen
     65 #define _POSIX_ fdlibm_posix
     66 
     67 struct exception {
     68 	int type;
     69 	char *name;
     70 	double arg1;
     71 	double arg2;
     72 	double retval;
     73 };
     74 
     75 #define	HUGE		MAXFLOAT
     76 
     77 /*
     78  * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
     79  * (one may replace the following line by "#include <values.h>")
     80  */
     81 
     82 #define X_TLOSS		1.41484755040568800000e+16
     83 
     84 #define	DOMAIN		1
     85 #define	SING		2
     86 #define	OVERFLOW	3
     87 #define	UNDERFLOW	4
     88 #define	TLOSS		5
     89 #define	PLOSS		6
     90 
     91 /*
     92  * ANSI/POSIX
     93  */
     94 extern double ieee_acos __P((double));
     95 extern double ieee_asin __P((double));
     96 extern double ieee_atan __P((double));
     97 extern double ieee_atan2 __P((double, double));
     98 extern double ieee_cos __P((double));
     99 extern double ieee_sin __P((double));
    100 extern double ieee_tan __P((double));
    101 
    102 extern double ieee_cosh __P((double));
    103 extern double ieee_sinh __P((double));
    104 extern double ieee_tanh __P((double));
    105 
    106 extern double ieee_exp __P((double));
    107 extern double ieee_frexp __P((double, int *));
    108 extern double ieee_ldexp __P((double, int));
    109 extern double ieee_log __P((double));
    110 extern double ieee_log10 __P((double));
    111 extern double ieee_modf __P((double, double *));
    112 
    113 extern double ieee_pow __P((double, double));
    114 extern double ieee_sqrt __P((double));
    115 
    116 extern double ieee_ceil __P((double));
    117 extern double ieee_fabs __P((double));
    118 extern double ieee_floor __P((double));
    119 extern double ieee_fmod __P((double, double));
    120 
    121 extern double ieee_erf __P((double));
    122 extern double ieee_erfc __P((double));
    123 extern double ieee_gamma __P((double));
    124 extern double ieee_hypot __P((double, double));
    125 extern int ieee_isnan __P((double));
    126 extern int ieee_finite __P((double));
    127 extern double ieee_j0 __P((double));
    128 extern double ieee_j1 __P((double));
    129 extern double ieee_jn __P((int, double));
    130 extern double ieee_lgamma __P((double));
    131 extern double ieee_y0 __P((double));
    132 extern double ieee_y1 __P((double));
    133 extern double ieee_yn __P((int, double));
    134 
    135 extern double acosh __P((double));
    136 extern double asinh __P((double));
    137 extern double atanh __P((double));
    138 extern double ieee_cbrt __P((double));
    139 extern double ieee_logb __P((double));
    140 extern double ieee_nextafter __P((double, double));
    141 extern double ieee_remainder __P((double, double));
    142 #ifdef _SCALB_INT
    143 extern double ieee_scalb __P((double, int));
    144 #else
    145 extern double ieee_scalb __P((double, double));
    146 #endif
    147 
    148 extern int ieee_matherr __P((struct exception *));
    149 
    150 /*
    151  * IEEE Test Vector
    152  */
    153 extern double ieee_significand __P((double));
    154 
    155 /*
    156  * Functions callable from C, intended to support IEEE arithmetic.
    157  */
    158 extern double ieee_copysign __P((double, double));
    159 extern int ieee_ilogb __P((double));
    160 extern double ieee_rint __P((double));
    161 extern double ieee_scalbn __P((double, int));
    162 
    163 /*
    164  * BSD math library entry points
    165  */
    166 extern double ieee_expm1 __P((double));
    167 extern double ieee_log1p __P((double));
    168 
    169 /*
    170  * Reentrant version of gamma & lgamma; passes signgam back by reference
    171  * as the second argument; user must allocate space for signgam.
    172  */
    173 #ifdef _REENTRANT
    174 extern double ieee_gamma_r __P((double, int *));
    175 extern double ieee_lgamma_r __P((double, int *));
    176 #endif	/* _REENTRANT */
    177 
    178 /* ieee style elementary functions */
    179 extern double __ieee754_sqrt __P((double));
    180 extern double __ieee754_acos __P((double));
    181 extern double __ieee754_acosh __P((double));
    182 extern double __ieee754_log __P((double));
    183 extern double __ieee754_atanh __P((double));
    184 extern double __ieee754_asin __P((double));
    185 extern double __ieee754_atan2 __P((double,double));
    186 extern double __ieee754_exp __P((double));
    187 extern double __ieee754_cosh __P((double));
    188 extern double __ieee754_fmod __P((double,double));
    189 extern double __ieee754_pow __P((double,double));
    190 extern double __ieee754_lgamma_r __P((double,int *));
    191 extern double __ieee754_gamma_r __P((double,int *));
    192 extern double __ieee754_lgamma __P((double));
    193 extern double __ieee754_gamma __P((double));
    194 extern double __ieee754_log10 __P((double));
    195 extern double __ieee754_sinh __P((double));
    196 extern double __ieee754_hypot __P((double,double));
    197 extern double __ieee754_j0 __P((double));
    198 extern double __ieee754_j1 __P((double));
    199 extern double __ieee754_y0 __P((double));
    200 extern double __ieee754_y1 __P((double));
    201 extern double __ieee754_jn __P((int,double));
    202 extern double __ieee754_yn __P((int,double));
    203 extern double __ieee754_remainder __P((double,double));
    204 extern int    __ieee754_rem_pio2 __P((double,double*));
    205 #ifdef _SCALB_INT
    206 extern double __ieee754_scalb __P((double,int));
    207 #else
    208 extern double __ieee754_scalb __P((double,double));
    209 #endif
    210 
    211 /* fdlibm kernel function */
    212 extern double __kernel_standard __P((double,double,int));
    213 extern double __kernel_sin __P((double,double,int));
    214 extern double __kernel_cos __P((double,double));
    215 extern double __kernel_tan __P((double,double,int));
    216 extern int    __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));
    217