blob: 906bcf94916e81bfb500a59fbdce990026d30cdc [file] [log] [blame]
J. Duke319a3b92007-12-01 00:00:00 +00001
2/*
3 * Copyright 1998-2002 Sun Microsystems, Inc. All Rights Reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation. Sun designates this
9 * particular file as subject to the "Classpath" exception as provided
10 * by Sun in the LICENSE file that accompanied this code.
11 *
12 * This code is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
15 * version 2 for more details (a copy is included in the LICENSE file that
16 * accompanied this code).
17 *
18 * You should have received a copy of the GNU General Public License version
19 * 2 along with this work; if not, write to the Free Software Foundation,
20 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
21 *
22 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
23 * CA 95054 USA or visit www.sun.com if you need additional information or
24 * have any questions.
25 */
26
27#include "jfdlibm.h"
28
29#ifdef __NEWVALID /* special setup for Sun test regime */
30#if defined(i386) || defined(i486) || \
31 defined(intel) || defined(x86) || \
32 defined(i86pc) || defined(_M_IA64)
33#define _LITTLE_ENDIAN
34#endif
35#endif
36
37#ifdef _LITTLE_ENDIAN
38#define __HI(x) *(1+(int*)&x)
39#define __LO(x) *(int*)&x
40#define __HIp(x) *(1+(int*)x)
41#define __LOp(x) *(int*)x
42#else
43#define __HI(x) *(int*)&x
44#define __LO(x) *(1+(int*)&x)
45#define __HIp(x) *(int*)x
46#define __LOp(x) *(1+(int*)x)
47#endif
48
49#ifdef __STDC__
50#define __P(p) p
51#else
52#define __P(p) ()
53#endif
54
55/*
56 * ANSI/POSIX
57 */
58
59extern int signgam;
60
61#define MAXFLOAT ((float)3.40282346638528860e+38)
62
63enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
64
65#define _LIB_VERSION_TYPE enum fdversion
66#define _LIB_VERSION _fdlib_version
67
68/* if global variable _LIB_VERSION is not desirable, one may
69 * change the following to be a constant by:
70 * #define _LIB_VERSION_TYPE const enum version
71 * In that case, after one initializes the value _LIB_VERSION (see
72 * s_lib_version.c) during compile time, it cannot be modified
73 * in the middle of a program
74 */
75extern _LIB_VERSION_TYPE _LIB_VERSION;
76
77#define _IEEE_ fdlibm_ieee
78#define _SVID_ fdlibm_svid
79#define _XOPEN_ fdlibm_xopen
80#define _POSIX_ fdlibm_posix
81
82struct exception {
83 int type;
84 char *name;
85 double arg1;
86 double arg2;
87 double retval;
88};
89
90#define HUGE MAXFLOAT
91
92/*
93 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
94 * (one may replace the following line by "#include <values.h>")
95 */
96
97#define X_TLOSS 1.41484755040568800000e+16
98
99#define DOMAIN 1
100#define SING 2
101#define OVERFLOW 3
102#define UNDERFLOW 4
103#define TLOSS 5
104#define PLOSS 6
105
106/*
107 * ANSI/POSIX
108 */
109extern double acos __P((double));
110extern double asin __P((double));
111extern double atan __P((double));
112extern double atan2 __P((double, double));
113extern double cos __P((double));
114extern double sin __P((double));
115extern double tan __P((double));
116
117extern double cosh __P((double));
118extern double sinh __P((double));
119extern double tanh __P((double));
120
121extern double exp __P((double));
122extern double frexp __P((double, int *));
123extern double ldexp __P((double, int));
124extern double log __P((double));
125extern double log10 __P((double));
126extern double modf __P((double, double *));
127
128extern double pow __P((double, double));
129extern double sqrt __P((double));
130
131extern double ceil __P((double));
132extern double fabs __P((double));
133extern double floor __P((double));
134extern double fmod __P((double, double));
135
136extern double erf __P((double));
137extern double erfc __P((double));
138extern double gamma __P((double));
139extern double hypot __P((double, double));
140extern int isnan __P((double));
141extern int finite __P((double));
142extern double j0 __P((double));
143extern double j1 __P((double));
144extern double jn __P((int, double));
145extern double lgamma __P((double));
146extern double y0 __P((double));
147extern double y1 __P((double));
148extern double yn __P((int, double));
149
150extern double acosh __P((double));
151extern double asinh __P((double));
152extern double atanh __P((double));
153extern double cbrt __P((double));
154extern double logb __P((double));
155extern double nextafter __P((double, double));
156extern double remainder __P((double, double));
157#ifdef _SCALB_INT
158extern double scalb __P((double, int));
159#else
160extern double scalb __P((double, double));
161#endif
162
163extern int matherr __P((struct exception *));
164
165/*
166 * IEEE Test Vector
167 */
168extern double significand __P((double));
169
170/*
171 * Functions callable from C, intended to support IEEE arithmetic.
172 */
173extern double copysign __P((double, double));
174extern int ilogb __P((double));
175extern double rint __P((double));
176extern double scalbn __P((double, int));
177
178/*
179 * BSD math library entry points
180 */
181extern double expm1 __P((double));
182extern double log1p __P((double));
183
184/*
185 * Reentrant version of gamma & lgamma; passes signgam back by reference
186 * as the second argument; user must allocate space for signgam.
187 */
188#ifdef _REENTRANT
189extern double gamma_r __P((double, int *));
190extern double lgamma_r __P((double, int *));
191#endif /* _REENTRANT */
192
193/* ieee style elementary functions */
194extern double __ieee754_sqrt __P((double));
195extern double __ieee754_acos __P((double));
196extern double __ieee754_acosh __P((double));
197extern double __ieee754_log __P((double));
198extern double __ieee754_atanh __P((double));
199extern double __ieee754_asin __P((double));
200extern double __ieee754_atan2 __P((double,double));
201extern double __ieee754_exp __P((double));
202extern double __ieee754_cosh __P((double));
203extern double __ieee754_fmod __P((double,double));
204extern double __ieee754_pow __P((double,double));
205extern double __ieee754_lgamma_r __P((double,int *));
206extern double __ieee754_gamma_r __P((double,int *));
207extern double __ieee754_lgamma __P((double));
208extern double __ieee754_gamma __P((double));
209extern double __ieee754_log10 __P((double));
210extern double __ieee754_sinh __P((double));
211extern double __ieee754_hypot __P((double,double));
212extern double __ieee754_j0 __P((double));
213extern double __ieee754_j1 __P((double));
214extern double __ieee754_y0 __P((double));
215extern double __ieee754_y1 __P((double));
216extern double __ieee754_jn __P((int,double));
217extern double __ieee754_yn __P((int,double));
218extern double __ieee754_remainder __P((double,double));
219extern int __ieee754_rem_pio2 __P((double,double*));
220#ifdef _SCALB_INT
221extern double __ieee754_scalb __P((double,int));
222#else
223extern double __ieee754_scalb __P((double,double));
224#endif
225
226/* fdlibm kernel function */
227extern double __kernel_standard __P((double,double,int));
228extern double __kernel_sin __P((double,double,int));
229extern double __kernel_cos __P((double,double));
230extern double __kernel_tan __P((double,double,int));
231extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));