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 3 of the License, or
8 (at your option) any later version.
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, see <http://www.gnu.org/licenses/>. */
20 /* The include_next requires a split double-inclusion guard. */
21 #@INCLUDE_NEXT@ @NEXT_MATH_H@
27 /* The definition of GL_LINK_WARNING is copied here. */
38 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
39 If x is zero: mantissa = x, exp = 0.
40 If x is infinite or NaN: mantissa = x, exp unspecified.
41 Store exp in *EXPPTR and return mantissa. */
44 # define frexp rpl_frexp
45 extern double frexp (double x, int *expptr);
47 #elif defined GNULIB_POSIXCHECK
50 (GL_LINK_WARNING ("frexp is unportable - " \
51 "use gnulib module frexp for portability"), \
56 #if @GNULIB_MATHL@ || !@HAVE_DECL_ACOSL@
57 extern long double acosl (long double x);
59 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
62 (GL_LINK_WARNING ("acosl is unportable - " \
63 "use gnulib module mathl for portability"), \
68 #if @GNULIB_MATHL@ || !@HAVE_DECL_ASINL@
69 extern long double asinl (long double x);
71 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
74 (GL_LINK_WARNING ("asinl is unportable - " \
75 "use gnulib module mathl for portability"), \
80 #if @GNULIB_MATHL@ || !@HAVE_DECL_ATANL@
81 extern long double atanl (long double x);
83 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
86 (GL_LINK_WARNING ("atanl is unportable - " \
87 "use gnulib module mathl for portability"), \
93 # if !@HAVE_DECL_CEILF@
94 # define ceilf rpl_ceilf
95 extern float ceilf (float x);
97 #elif defined GNULIB_POSIXCHECK
100 (GL_LINK_WARNING ("ceilf is unportable - " \
101 "use gnulib module ceilf for portability"), \
106 # if !@HAVE_DECL_CEILL@
107 # define ceill rpl_ceill
108 extern long double ceill (long double x);
110 #elif defined GNULIB_POSIXCHECK
113 (GL_LINK_WARNING ("ceill is unportable - " \
114 "use gnulib module ceill for portability"), \
119 #if @GNULIB_MATHL@ || !@HAVE_DECL_COSL@
120 extern long double cosl (long double x);
122 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
125 (GL_LINK_WARNING ("cosl is unportable - " \
126 "use gnulib module mathl for portability"), \
131 #if @GNULIB_MATHL@ || !@HAVE_DECL_EXPL@
132 extern long double expl (long double x);
134 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
137 (GL_LINK_WARNING ("expl is unportable - " \
138 "use gnulib module mathl for portability"), \
144 # if !@HAVE_DECL_FLOORF@
145 # define floorf rpl_floorf
146 extern float floorf (float x);
148 #elif defined GNULIB_POSIXCHECK
151 (GL_LINK_WARNING ("floorf is unportable - " \
152 "use gnulib module floorf for portability"), \
157 # if !@HAVE_DECL_FLOORL@
158 # define floorl rpl_floorl
159 extern long double floorl (long double x);
161 #elif defined GNULIB_POSIXCHECK
164 (GL_LINK_WARNING ("floorl is unportable - " \
165 "use gnulib module floorl for portability"), \
173 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
174 If x is zero: mantissa = x, exp = 0.
175 If x is infinite or NaN: mantissa = x, exp unspecified.
176 Store exp in *EXPPTR and return mantissa. */
177 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
178 # define frexpl rpl_frexpl
180 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
181 extern long double frexpl (long double x, int *expptr);
183 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
185 # define frexpl(x,e) \
186 (GL_LINK_WARNING ("frexpl is unportable - " \
187 "use gnulib module frexpl for portability"), \
192 /* Return x * 2^exp. */
193 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
194 # define ldexpl rpl_ldexpl
196 #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@
197 extern long double ldexpl (long double x, int exp);
199 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
201 # define ldexpl(x,e) \
202 (GL_LINK_WARNING ("ldexpl is unportable - " \
203 "use gnulib module ldexpl for portability"), \
208 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@
209 extern long double logl (long double x);
211 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
214 (GL_LINK_WARNING ("logl is unportable - " \
215 "use gnulib module mathl for portability"), \
221 # if !@HAVE_DECL_ROUNDF@
222 # define roundf rpl_roundf
223 extern float roundf (float x);
225 #elif defined GNULIB_POSIXCHECK
228 (GL_LINK_WARNING ("roundf is unportable - " \
229 "use gnulib module roundf for portability"), \
235 # if !@HAVE_DECL_ROUND@
236 # define round rpl_round
237 extern double round (double x);
239 #elif defined GNULIB_POSIXCHECK
242 (GL_LINK_WARNING ("round is unportable - " \
243 "use gnulib module round for portability"), \
249 # if !@HAVE_DECL_ROUNDL@
250 # define roundl rpl_roundl
251 extern long double roundl (long double x);
253 #elif defined GNULIB_POSIXCHECK
256 (GL_LINK_WARNING ("roundl is unportable - " \
257 "use gnulib module roundl for portability"), \
262 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@
263 extern long double sinl (long double x);
265 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
268 (GL_LINK_WARNING ("sinl is unportable - " \
269 "use gnulib module mathl for portability"), \
274 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@
275 extern long double sqrtl (long double x);
277 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
280 (GL_LINK_WARNING ("sqrtl is unportable - " \
281 "use gnulib module mathl for portability"), \
286 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@
287 extern long double tanl (long double x);
289 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
292 (GL_LINK_WARNING ("tanl is unportable - " \
293 "use gnulib module mathl for portability"), \
299 # if !@HAVE_DECL_TRUNCF@
300 # define truncf rpl_truncf
301 extern float truncf (float x);
303 #elif defined GNULIB_POSIXCHECK
306 (GL_LINK_WARNING ("truncf is unportable - " \
307 "use gnulib module truncf for portability"), \
312 # if !@HAVE_DECL_TRUNC@
313 # define trunc rpl_trunc
314 extern double trunc (double x);
316 #elif defined GNULIB_POSIXCHECK
319 (GL_LINK_WARNING ("trunc is unportable - " \
320 "use gnulib module trunc for portability"), \
325 # if !@HAVE_DECL_TRUNCL@
326 # define truncl rpl_truncl
327 extern long double truncl (long double x);
329 #elif defined GNULIB_POSIXCHECK
332 (GL_LINK_WARNING ("truncl is unportable - " \
333 "use gnulib module truncl for portability"), \
339 # if @REPLACE_SIGNBIT@
341 extern int gl_signbitf (float arg);
342 extern int gl_signbitd (double arg);
343 extern int gl_signbitl (long double arg);
344 # if __GNUC__ >= 2 && !__STRICT_ANSI__
345 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT
346 # define gl_signbitf(arg) \
347 ({ union { float _value; \
348 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
351 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
354 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT
355 # define gl_signbitd(arg) \
356 ({ union { double _value; \
357 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
360 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
363 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT
364 # define gl_signbitl(arg) \
365 ({ union { long double _value; \
366 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
369 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
373 # define signbit(x) \
374 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
375 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
378 #elif defined GNULIB_POSIXCHECK
379 /* How to override a macro? */
387 #endif /* _GL_MATH_H */
388 #endif /* _GL_MATH_H */