1 /* A GNU-like <math.h>.
3 Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2, or (at your option)
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software Foundation,
17 Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
21 /* The include_next requires a split double-inclusion guard. */
22 #@INCLUDE_NEXT@ @NEXT_MATH_H@
28 /* The definition of GL_LINK_WARNING is copied here. */
39 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
40 If x is zero: mantissa = x, exp = 0.
41 If x is infinite or NaN: mantissa = x, exp unspecified.
42 Store exp and return mantissa. */
45 # define frexp rpl_frexp
46 extern double frexp (double x, int *exp);
48 #elif defined GNULIB_POSIXCHECK
51 (GL_LINK_WARNING ("frexp is unportable - " \
52 "use gnulib module frexp for portability"), \
57 #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@
58 extern long double acosl (long double x);
60 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
63 (GL_LINK_WARNING ("acosl is unportable - " \
64 "use gnulib module mathl for portability"), \
69 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@
70 extern long double asinl (long double x);
72 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
75 (GL_LINK_WARNING ("asinl is unportable - " \
76 "use gnulib module mathl for portability"), \
81 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@
82 extern long double atanl (long double x);
84 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
87 (GL_LINK_WARNING ("atanl is unportable - " \
88 "use gnulib module mathl for portability"), \
93 #if @GNULIB_MATHL@ || !@HAVE_DECL_CEILL@
94 extern long double ceill (long double x);
96 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
99 (GL_LINK_WARNING ("ceill is unportable - " \
100 "use gnulib module mathl for portability"), \
105 #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@
106 extern long double cosl (long double x);
108 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
111 (GL_LINK_WARNING ("cosl is unportable - " \
112 "use gnulib module mathl for portability"), \
117 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@
118 extern long double expl (long double x);
120 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
123 (GL_LINK_WARNING ("expl is unportable - " \
124 "use gnulib module mathl for portability"), \
130 # if !@HAVE_DECL_FLOORF@
131 # define floorf rpl_floorf
132 extern float floorf (float x);
134 #elif defined GNULIB_POSIXCHECK
137 (GL_LINK_WARNING ("floorf is unportable - " \
138 "use gnulib module floorf for portability"), \
142 #if @GNULIB_MATHL@ || !@HAVE_DECL_FLOORL@
143 extern long double floorl (long double x);
145 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
148 (GL_LINK_WARNING ("floorl is unportable - " \
149 "use gnulib module mathl for portability"), \
157 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
158 If x is zero: mantissa = x, exp = 0.
159 If x is infinite or NaN: mantissa = x, exp unspecified.
160 Store exp and return mantissa. */
161 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
162 # define frexpl rpl_frexpl
164 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
165 extern long double frexpl (long double x, int *exp);
167 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
169 # define frexpl(x,e) \
170 (GL_LINK_WARNING ("frexpl is unportable - " \
171 "use gnulib module frexpl for portability"), \
176 /* Return x * 2^exp. */
177 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
178 # define ldexpl rpl_ldexpl
180 #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@
181 extern long double ldexpl (long double x, int exp);
183 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
185 # define ldexpl(x,e) \
186 (GL_LINK_WARNING ("ldexpl is unportable - " \
187 "use gnulib module ldexpl for portability"), \
192 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@
193 extern long double logl (long double x);
195 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
198 (GL_LINK_WARNING ("logl is unportable - " \
199 "use gnulib module mathl for portability"), \
204 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@
205 extern long double sinl (long double x);
207 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
210 (GL_LINK_WARNING ("sinl is unportable - " \
211 "use gnulib module mathl for portability"), \
216 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@
217 extern long double sqrtl (long double x);
219 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
222 (GL_LINK_WARNING ("sqrtl is unportable - " \
223 "use gnulib module mathl for portability"), \
228 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@
229 extern long double tanl (long double x);
231 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
234 (GL_LINK_WARNING ("tanl is unportable - " \
235 "use gnulib module mathl for portability"), \
241 # if !@HAVE_DECL_TRUNCF@
242 # define truncf rpl_truncf
243 extern float truncf (float x);
245 #elif defined GNULIB_POSIXCHECK
248 (GL_LINK_WARNING ("truncf is unportable - " \
249 "use gnulib module truncf for portability"), \
254 # if !@HAVE_DECL_TRUNC@
255 # define trunc rpl_trunc
256 extern double trunc (double x);
258 #elif defined GNULIB_POSIXCHECK
261 (GL_LINK_WARNING ("trunc is unportable - " \
262 "use gnulib module trunc for portability"), \
267 # if !@HAVE_DECL_TRUNCL@
268 # define truncl rpl_truncl
269 extern long double truncl (long double x);
271 #elif defined GNULIB_POSIXCHECK
274 (GL_LINK_WARNING ("truncl is unportable - " \
275 "use gnulib module truncl for portability"), \
281 # if @REPLACE_SIGNBIT@
283 extern int gl_signbitf (float arg);
284 extern int gl_signbitd (double arg);
285 extern int gl_signbitl (long double arg);
286 # if __GNUC__ >= 2 && !__STRICT_ANSI__
287 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT
288 # define gl_signbitf(arg) \
289 ({ union { float _value; \
290 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
293 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
296 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT
297 # define gl_signbitd(arg) \
298 ({ union { double _value; \
299 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
302 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
305 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT
306 # define gl_signbitl(arg) \
307 ({ union { long double _value; \
308 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
311 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
315 # define signbit(x) \
316 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
317 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
320 #elif defined GNULIB_POSIXCHECK
321 /* How to override a macro? */
329 #endif /* _GL_MATH_H */
330 #endif /* _GL_MATH_H */