uc-sdk
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
fdlibm.h
Go to the documentation of this file.
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 #include <stddef.h>
17 
18 #if defined(i386) || defined(i486) || \
19  defined(intel) || defined(x86) || defined(i86pc) || \
20  defined(__alpha) || defined(__osf__)
21 #define __LITTLE_ENDIAN
22 #endif
23 
24 #ifdef __LITTLE_ENDIAN
25 #define __HI(x) *(1+(int*)&x)
26 #define __LO(x) *(int*)&x
27 #define __HIp(x) *(1+(int*)x)
28 #define __LOp(x) *(int*)x
29 #else
30 #define __HI(x) *(int*)&x
31 #define __LO(x) *(1+(int*)&x)
32 #define __HIp(x) *(int*)x
33 #define __LOp(x) *(1+(int*)x)
34 #endif
35 
36 #ifdef __STDC__
37 #define __P(p) p
38 #else
39 #define __P(p) ()
40 #endif
41 
42 /*
43  * ANSI/POSIX
44  */
45 
46 extern int signgam;
47 
48 #define MAXFLOAT ((float)3.40282346638528860e+38)
49 
51 
52 #define _LIB_VERSION_TYPE enum fdversion
53 #define _LIB_VERSION _fdlib_version
54 
55 /* if global variable _LIB_VERSION is not desirable, one may
56  * change the following to be a constant by:
57  * #define _LIB_VERSION_TYPE const enum version
58  * In that case, after one initializes the value _LIB_VERSION (see
59  * s_lib_version.c) during compile time, it cannot be modified
60  * in the middle of a program
61  */
63 
64 #define _IEEE_ fdlibm_ieee
65 #define _SVID_ fdlibm_svid
66 #define _XOPEN_ fdlibm_xopen
67 #define _POSIX_ fdlibm_posix
68 
69 struct exception {
70  int type;
71  char *name;
72  double arg1;
73  double arg2;
74  double retval;
75 };
76 
77 #define HUGE MAXFLOAT
78 
79 /*
80  * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
81  * (one may replace the following line by "#include <values.h>")
82  */
83 
84 #define X_TLOSS 1.41484755040568800000e+16
85 
86 #define DOMAIN 1
87 #define SING 2
88 #define OVERFLOW 3
89 #define UNDERFLOW 4
90 #define TLOSS 5
91 #define PLOSS 6
92 
93 /*
94  * ANSI/POSIX
95  */
96 extern double acos __P((double));
97 extern double asin __P((double));
98 extern double atan __P((double));
99 extern double atan2 __P((double, double));
100 extern double cos __P((double));
101 extern double sin __P((double));
102 extern double tan __P((double));
103 
104 extern double cosh __P((double));
105 extern double sinh __P((double));
106 extern double tanh __P((double));
107 
108 extern double exp __P((double));
109 extern double frexp __P((double, int *));
110 extern double ldexp __P((double, int));
111 extern double log __P((double));
112 extern double log10 __P((double));
113 extern double modf __P((double, double *));
114 
115 extern double pow __P((double, double));
116 extern double sqrt __P((double));
117 
118 extern double ceil __P((double));
119 extern double fabs __P((double));
120 extern double floor __P((double));
121 extern double fmod __P((double, double));
122 
123 extern double erf __P((double));
124 extern double erfc __P((double));
125 extern double gamma __P((double));
126 extern double hypot __P((double, double));
127 extern int isnan __P((double));
128 extern int finite __P((double));
129 extern double j0 __P((double));
130 extern double j1 __P((double));
131 extern double jn __P((int, double));
132 extern double lgamma __P((double));
133 extern double y0 __P((double));
134 extern double y1 __P((double));
135 extern double yn __P((int, double));
136 
137 extern double acosh __P((double));
138 extern double asinh __P((double));
139 extern double atanh __P((double));
140 extern double cbrt __P((double));
141 extern double logb __P((double));
142 extern double nextafter __P((double, double));
143 extern double remainder __P((double, double));
144 #ifdef _SCALB_INT
145 extern double scalb __P((double, int));
146 #else
147 extern double scalb __P((double, double));
148 #endif
149 
150 extern int matherr __P((struct exception *));
151 
152 /*
153  * IEEE Test Vector
154  */
155 extern double significand __P((double));
156 
157 /*
158  * Functions callable from C, intended to support IEEE arithmetic.
159  */
160 extern double copysign __P((double, double));
161 extern int ilogb __P((double));
162 extern double rint __P((double));
163 extern double scalbn __P((double, int));
164 
165 /*
166  * BSD math library entry points
167  */
168 extern double expm1 __P((double));
169 extern double log1p __P((double));
170 
171 /*
172  * Reentrant version of gamma & lgamma; passes signgam back by reference
173  * as the second argument; user must allocate space for signgam.
174  */
175 #ifdef _REENTRANT
176 extern double gamma_r __P((double, int *));
177 extern double lgamma_r __P((double, int *));
178 #endif /* _REENTRANT */
179 
180 /* ieee style elementary functions */
181 extern double __ieee754_sqrt __P((double));
182 extern double __ieee754_acos __P((double));
183 extern double __ieee754_acosh __P((double));
184 extern double __ieee754_log __P((double));
185 extern double __ieee754_atanh __P((double));
186 extern double __ieee754_asin __P((double));
187 extern double __ieee754_atan2 __P((double,double));
188 extern double __ieee754_exp __P((double));
189 extern double __ieee754_cosh __P((double));
190 extern double __ieee754_fmod __P((double,double));
191 extern double __ieee754_pow __P((double,double));
192 extern double __ieee754_lgamma_r __P((double,int *));
193 extern double __ieee754_gamma_r __P((double,int *));
194 extern double __ieee754_lgamma __P((double));
195 extern double __ieee754_gamma __P((double));
196 extern double __ieee754_log10 __P((double));
197 extern double __ieee754_sinh __P((double));
198 extern double __ieee754_hypot __P((double,double));
199 extern double __ieee754_j0 __P((double));
200 extern double __ieee754_j1 __P((double));
201 extern double __ieee754_y0 __P((double));
202 extern double __ieee754_y1 __P((double));
203 extern double __ieee754_jn __P((int,double));
204 extern double __ieee754_yn __P((int,double));
205 extern double __ieee754_remainder __P((double,double));
206 extern int __ieee754_rem_pio2 __P((double,double*));
207 #ifdef _SCALB_INT
208 extern double __ieee754_scalb __P((double,int));
209 #else
210 extern double __ieee754_scalb __P((double,double));
211 #endif
212 
213 /* fdlibm kernel function */
214 extern double __kernel_standard __P((double,double,int));
215 extern double __kernel_sin __P((double,double,int));
216 extern double __kernel_cos __P((double,double));
217 extern double __kernel_tan __P((double,double,int));
218 extern int __kernel_rem_pio2 __P((double*,double*,int,int,int,const int*));