|
0
|
1 #ifndef CYGONCE_LIBM_MATHINCL_FDLIBM_H |
|
|
2 #define CYGONCE_LIBM_MATHINCL_FDLIBM_H |
|
|
3 //=========================================================================== |
|
|
4 // |
|
|
5 // fdlibm.h |
|
|
6 // |
|
|
7 // Internal definitions for math library implementation based on fdlibm |
|
|
8 // |
|
|
9 //=========================================================================== |
|
|
10 //####COPYRIGHTBEGIN#### |
|
|
11 // |
|
|
12 // ------------------------------------------- |
|
|
13 // The contents of this file are subject to the Cygnus eCos Public License |
|
|
14 // Version 1.0 (the "License"); you may not use this file except in |
|
|
15 // compliance with the License. You may obtain a copy of the License at |
|
|
16 // http://sourceware.cygnus.com/ecos |
|
|
17 // |
|
|
18 // Software distributed under the License is distributed on an "AS IS" |
|
|
19 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the |
|
|
20 // License for the specific language governing rights and limitations under |
|
|
21 // the License. |
|
|
22 // |
|
|
23 // The Original Code is eCos - Embedded Cygnus Operating System, released |
|
|
24 // September 30, 1998. |
|
|
25 // |
|
|
26 // The Initial Developer of the Original Code is Cygnus. Portions created |
|
2
|
27 // by Cygnus are Copyright (C) 1998,1999 Cygnus Solutions. All Rights Reserved. |
|
0
|
28 // ------------------------------------------- |
|
|
29 // |
|
|
30 //####COPYRIGHTEND#### |
|
|
31 //=========================================================================== |
|
|
32 //#####DESCRIPTIONBEGIN#### |
|
|
33 // |
|
2
|
34 // Author(s): jlarmour |
|
|
35 // Contributors: jlarmour |
|
|
36 // Date: 1999-02-09 |
|
0
|
37 // Purpose: |
|
2
|
38 // Description: Internal implementation-specific header for math library |
|
|
39 // based on fdlibm |
|
|
40 // Usage: From within this package, #include "mathincl/fdlibm.h" |
|
0
|
41 // |
|
|
42 //####DESCRIPTIONEND#### |
|
|
43 // |
|
|
44 //=========================================================================== |
|
|
45 |
|
|
46 // CONFIGURATION |
|
|
47 |
|
|
48 #include <pkgconf/libm.h> // Configuration header |
|
|
49 |
|
|
50 // Include the Math library? |
|
|
51 #ifdef CYGPKG_LIBM |
|
|
52 |
|
|
53 // INCLUDES |
|
|
54 |
|
|
55 #include <cyg/infra/cyg_type.h> // Common type definitions and support |
|
|
56 #include <math.h> // Main header for math library |
|
|
57 #include <float.h> // Properties of FP representation on this |
|
|
58 // platform |
|
|
59 |
|
|
60 // SANITY CHECKS |
|
|
61 |
|
|
62 // Just check that we support IEEE-style 64-bit doubles. If not, this |
|
|
63 // math library will not work |
|
|
64 // This check will go away when support for single-precision alternatives are |
|
|
65 // provided |
|
|
66 |
|
|
67 #if DBL_MAX_EXP != 1024 |
|
|
68 # error IEEE-style 64-bit doubles are required to use the math library |
|
|
69 #endif // if DBL_MAX_EXP == 1024 |
|
|
70 |
|
|
71 |
|
|
72 // MACRO DEFINITIONS |
|
|
73 |
|
2
|
74 #define CYG_LIBM_HI(__x) (*cyg_libm_hi(&__x)) |
|
|
75 #define CYG_LIBM_LO(__x) (*cyg_libm_lo(&__x)) |
|
|
76 #define CYG_LIBM_HIp(__x) (*cyg_libm_hi(__x)) |
|
|
77 #define CYG_LIBM_LOp(__x) (*cyg_libm_lo(__x)) |
|
0
|
78 |
|
|
79 // REPLACEMENTS FOR STUFF FROM MATH.H DUE TO CONFIG OPTION |
|
|
80 |
|
|
81 #ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION |
|
|
82 |
|
|
83 #define HUGE FLT_MAX // from float.h |
|
|
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 struct exception { |
|
|
92 int type; // One of DOMAIN, SING, OVERFLOW, UNDERFLOW, TLOSS, PLOSS |
|
|
93 char *name; // Name of the function generating the exception |
|
|
94 double arg1; // First argument to the function |
|
|
95 double arg2; // Second argument to the function |
|
|
96 double retval; // Value to be returned - can be altered by matherr() |
|
|
97 }; |
|
|
98 |
|
|
99 externC int |
|
|
100 matherr( struct exception * ); // User-overridable error handling - see |
|
|
101 // <pkgconf/libm.h> for a discussion |
|
|
102 #endif // ifdef CYGSYM_LIBM_NO_XOPEN_SVID_NAMESPACE_POLLUTION |
|
|
103 |
|
|
104 |
|
2
|
105 // INLINE FUNCTIONS |
|
|
106 |
|
|
107 static __inline__ cyg_uint32 * |
|
|
108 cyg_libm_hi(double *__x) |
|
|
109 { |
|
|
110 Cyg_libm_ieee_double_shape_type *__y; |
|
|
111 __y = (Cyg_libm_ieee_double_shape_type *)__x; |
|
|
112 return &__y->parts.msw; |
|
|
113 } |
|
|
114 |
|
|
115 static __inline__ cyg_uint32 * |
|
|
116 cyg_libm_lo(double *__x) |
|
|
117 { |
|
|
118 Cyg_libm_ieee_double_shape_type *__y; |
|
|
119 __y = (Cyg_libm_ieee_double_shape_type *)__x; |
|
|
120 return &__y->parts.lsw; |
|
|
121 } |
|
|
122 |
|
0
|
123 |
|
|
124 // FUNCTION PROTOTYPES |
|
|
125 |
|
|
126 // IEEE-754 style elementary functions */ |
|
|
127 |
|
|
128 externC double |
|
|
129 __ieee754_sqrt( double ); |
|
|
130 |
|
|
131 externC double |
|
|
132 __ieee754_acos( double ); |
|
|
133 |
|
|
134 |
|
|
135 externC double |
|
|
136 __ieee754_log( double ); |
|
|
137 |
|
|
138 |
|
|
139 externC double |
|
|
140 __ieee754_asin( double ); |
|
|
141 |
|
|
142 externC double |
|
|
143 __ieee754_atan2( double, double ); |
|
|
144 |
|
|
145 externC double |
|
|
146 __ieee754_exp( double ); |
|
|
147 |
|
|
148 externC double |
|
|
149 __ieee754_cosh( double ); |
|
|
150 |
|
|
151 externC double |
|
|
152 __ieee754_fmod( double, double ); |
|
|
153 |
|
|
154 externC double |
|
|
155 __ieee754_pow( double, double ); |
|
|
156 |
|
|
157 |
|
|
158 externC double |
|
|
159 __ieee754_log10( double ); |
|
|
160 |
|
|
161 externC double |
|
|
162 __ieee754_sinh( double ); |
|
|
163 |
|
|
164 |
|
|
165 externC int |
|
|
166 __ieee754_rem_pio2( double, double * ); |
|
|
167 |
|
|
168 #ifdef CYGFUN_LIBM_SVID3_scalb |
|
|
169 externC double |
|
|
170 __ieee754_scalb( double, double ); |
|
|
171 #else |
|
|
172 externC double |
|
|
173 __ieee754_scalb( double, int ); |
|
|
174 #endif |
|
|
175 |
|
|
176 // FDLIBM kernel functions |
|
|
177 |
|
|
178 externC double |
|
|
179 __kernel_standard( double, double, int ); |
|
|
180 |
|
|
181 externC double |
|
|
182 __kernel_sin( double, double, int ); |
|
|
183 |
|
|
184 externC double |
|
|
185 __kernel_cos( double, double ); |
|
|
186 |
|
|
187 externC double |
|
|
188 __kernel_tan( double, double, int ); |
|
|
189 |
|
|
190 externC int |
|
|
191 __kernel_rem_pio2( double *, double *, int, int, int, const int * ); |
|
|
192 |
|
|
193 #endif // ifdef CYGPKG_LIBM |
|
|
194 |
|
|
195 #endif // CYGONCE_LIBM_MATHINCL_FDLIBM_H multiple inclusion protection |
|
|
196 |
|
|
197 // EOF fdlibm.h |