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