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"), \
143 # if !@HAVE_DECL_FLOORL@
144 # define floorl rpl_floorl
145 extern long double floorl (long double x);
147 #elif defined GNULIB_POSIXCHECK
150 (GL_LINK_WARNING ("floorl is unportable - " \
151 "use gnulib module floorl for portability"), \
159 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
160 If x is zero: mantissa = x, exp = 0.
161 If x is infinite or NaN: mantissa = x, exp unspecified.
162 Store exp and return mantissa. */
163 #if @GNULIB_FREXPL@ && @REPLACE_FREXPL@
164 # define frexpl rpl_frexpl
166 #if (@GNULIB_FREXPL@ && @REPLACE_FREXPL@) || !@HAVE_DECL_FREXPL@
167 extern long double frexpl (long double x, int *exp);
169 #if !@GNULIB_FREXPL@ && defined GNULIB_POSIXCHECK
171 # define frexpl(x,e) \
172 (GL_LINK_WARNING ("frexpl is unportable - " \
173 "use gnulib module frexpl for portability"), \
178 /* Return x * 2^exp. */
179 #if @GNULIB_LDEXPL@ && @REPLACE_LDEXPL@
180 # define ldexpl rpl_ldexpl
182 #if (@GNULIB_LDEXPL@ && @REPLACE_LDEXPL@) || !@HAVE_DECL_LDEXPL@
183 extern long double ldexpl (long double x, int exp);
185 #if !@GNULIB_LDEXPL@ && defined GNULIB_POSIXCHECK
187 # define ldexpl(x,e) \
188 (GL_LINK_WARNING ("ldexpl is unportable - " \
189 "use gnulib module ldexpl for portability"), \
194 #if @GNULIB_MATHL@ || !@HAVE_DECL_LOGL@
195 extern long double logl (long double x);
197 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
200 (GL_LINK_WARNING ("logl is unportable - " \
201 "use gnulib module mathl for portability"), \
206 #if @GNULIB_MATHL@ || !@HAVE_DECL_SINL@
207 extern long double sinl (long double x);
209 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
212 (GL_LINK_WARNING ("sinl is unportable - " \
213 "use gnulib module mathl for portability"), \
218 #if @GNULIB_MATHL@ || !@HAVE_DECL_SQRTL@
219 extern long double sqrtl (long double x);
221 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
224 (GL_LINK_WARNING ("sqrtl is unportable - " \
225 "use gnulib module mathl for portability"), \
230 #if @GNULIB_MATHL@ || !@HAVE_DECL_TANL@
231 extern long double tanl (long double x);
233 #if !@GNULIB_MATHL@ && defined GNULIB_POSIXCHECK
236 (GL_LINK_WARNING ("tanl is unportable - " \
237 "use gnulib module mathl for portability"), \
243 # if !@HAVE_DECL_TRUNCF@
244 # define truncf rpl_truncf
245 extern float truncf (float x);
247 #elif defined GNULIB_POSIXCHECK
250 (GL_LINK_WARNING ("truncf is unportable - " \
251 "use gnulib module truncf for portability"), \
256 # if !@HAVE_DECL_TRUNC@
257 # define trunc rpl_trunc
258 extern double trunc (double x);
260 #elif defined GNULIB_POSIXCHECK
263 (GL_LINK_WARNING ("trunc is unportable - " \
264 "use gnulib module trunc for portability"), \
269 # if !@HAVE_DECL_TRUNCL@
270 # define truncl rpl_truncl
271 extern long double truncl (long double x);
273 #elif defined GNULIB_POSIXCHECK
276 (GL_LINK_WARNING ("truncl is unportable - " \
277 "use gnulib module truncl for portability"), \
283 # if @REPLACE_SIGNBIT@
285 extern int gl_signbitf (float arg);
286 extern int gl_signbitd (double arg);
287 extern int gl_signbitl (long double arg);
288 # if __GNUC__ >= 2 && !__STRICT_ANSI__
289 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT
290 # define gl_signbitf(arg) \
291 ({ union { float _value; \
292 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
295 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
298 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT
299 # define gl_signbitd(arg) \
300 ({ union { double _value; \
301 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
304 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
307 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT
308 # define gl_signbitl(arg) \
309 ({ union { long double _value; \
310 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
313 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
317 # define signbit(x) \
318 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
319 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
322 #elif defined GNULIB_POSIXCHECK
323 /* How to override a macro? */
331 #endif /* _GL_MATH_H */
332 #endif /* _GL_MATH_H */