1 /* DO NOT EDIT! GENERATED AUTOMATICALLY! */
2 /* A GNU-like <math.h>.
4 Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc.
6 This program is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>. */
19 #ifndef _GL_MATH_H
21 /* The include_next requires a split double-inclusion guard. */
22 #include_next <math.h>
24 #ifndef _GL_MATH_H
25 #define _GL_MATH_H
28 /* The definition of GL_LINK_WARNING is copied here. */
29 /* GL_LINK_WARNING("literal string") arranges to emit the literal string as
30 a linker warning on most glibc systems.
31 We use a linker warning rather than a preprocessor warning, because
32 #warning cannot be used inside macros. */
33 #ifndef GL_LINK_WARNING
34 /* This works on platforms with GNU ld and ELF object format.
35 Testing __GLIBC__ is sufficient for asserting that GNU ld is in use.
36 Testing __ELF__ guarantees the ELF object format.
37 Testing __GNUC__ is necessary for the compound expression syntax. */
38 # if defined __GLIBC__ && defined __ELF__ && defined __GNUC__
39 # define GL_LINK_WARNING(message) \
40 GL_LINK_WARNING1 (__FILE__, __LINE__, message)
41 # define GL_LINK_WARNING1(file, line, message) \
42 GL_LINK_WARNING2 (file, line, message) /* macroexpand file and line */
43 # define GL_LINK_WARNING2(file, line, message) \
44 GL_LINK_WARNING3 (file ":" #line ": warning: " message)
45 # define GL_LINK_WARNING3(message) \
46 ({ static const char warning[sizeof (message)] \
47 __attribute__ ((__unused__, \
48 __section__ (".gnu.warning"), \
49 __aligned__ (1))) \
50 = message "\n"; \
51 (void)0; \
52 })
53 # else
54 # define GL_LINK_WARNING(message) ((void) 0)
55 # endif
56 #endif
59 #ifdef __cplusplus
60 extern "C" {
61 #endif
64 /* Write x as
65 x = mantissa * 2^exp
66 where
67 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
68 If x is zero: mantissa = x, exp = 0.
69 If x is infinite or NaN: mantissa = x, exp unspecified.
70 Store exp in *EXPPTR and return mantissa. */
71 #if 0
72 # if 0
73 # define frexp rpl_frexp
74 extern double frexp (double x, int *expptr);
75 # endif
76 #elif defined GNULIB_POSIXCHECK
77 # undef frexp
78 # define frexp(x,e) \
79 (GL_LINK_WARNING ("frexp is unportable - " \
80 "use gnulib module frexp for portability"), \
81 frexp (x, e))
82 #endif
85 #if 0 || !1
86 extern long double acosl (long double x);
87 #endif
88 #if !0 && defined GNULIB_POSIXCHECK
89 # undef acosl
90 # define acosl(x) \
91 (GL_LINK_WARNING ("acosl is unportable - " \
92 "use gnulib module mathl for portability"), \
93 acosl (x))
94 #endif
97 #if 0 || !1
98 extern long double asinl (long double x);
99 #endif
100 #if !0 && defined GNULIB_POSIXCHECK
101 # undef asinl
102 # define asinl(x) \
103 (GL_LINK_WARNING ("asinl is unportable - " \
104 "use gnulib module mathl for portability"), \
105 asinl (x))
106 #endif
109 #if 0 || !1
110 extern long double atanl (long double x);
111 #endif
112 #if !0 && defined GNULIB_POSIXCHECK
113 # undef atanl
114 # define atanl(x) \
115 (GL_LINK_WARNING ("atanl is unportable - " \
116 "use gnulib module mathl for portability"), \
117 atanl (x))
118 #endif
121 #if 0
122 # if 0
123 # define ceilf rpl_ceilf
124 extern float ceilf (float x);
125 # endif
126 #elif defined GNULIB_POSIXCHECK
127 # undef ceilf
128 # define ceilf(x) \
129 (GL_LINK_WARNING ("ceilf is unportable - " \
130 "use gnulib module ceilf for portability"), \
131 ceilf (x))
132 #endif
134 #if 0
135 # if 0
136 # define ceill rpl_ceill
137 extern long double ceill (long double x);
138 # endif
139 #elif defined GNULIB_POSIXCHECK
140 # undef ceill
141 # define ceill(x) \
142 (GL_LINK_WARNING ("ceill is unportable - " \
143 "use gnulib module ceill for portability"), \
144 ceill (x))
145 #endif
148 #if 0 || !1
149 extern long double cosl (long double x);
150 #endif
151 #if !0 && defined GNULIB_POSIXCHECK
152 # undef cosl
153 # define cosl(x) \
154 (GL_LINK_WARNING ("cosl is unportable - " \
155 "use gnulib module mathl for portability"), \
156 cosl (x))
157 #endif
160 #if 0 || !1
161 extern long double expl (long double x);
162 #endif
163 #if !0 && defined GNULIB_POSIXCHECK
164 # undef expl
165 # define expl(x) \
166 (GL_LINK_WARNING ("expl is unportable - " \
167 "use gnulib module mathl for portability"), \
168 expl (x))
169 #endif
172 #if 1
173 # if 0
174 # define floorf rpl_floorf
175 extern float floorf (float x);
176 # endif
177 #elif defined GNULIB_POSIXCHECK
178 # undef floorf
179 # define floorf(x) \
180 (GL_LINK_WARNING ("floorf is unportable - " \
181 "use gnulib module floorf for portability"), \
182 floorf (x))
183 #endif
185 #if 0
186 # if 0
187 # define floorl rpl_floorl
188 extern long double floorl (long double x);
189 # endif
190 #elif defined GNULIB_POSIXCHECK
191 # undef floorl
192 # define floorl(x) \
193 (GL_LINK_WARNING ("floorl is unportable - " \
194 "use gnulib module floorl for portability"), \
195 floorl (x))
196 #endif
199 /* Write x as
200 x = mantissa * 2^exp
201 where
202 If x finite and nonzero: 0.5 <= |mantissa| < 1.0.
203 If x is zero: mantissa = x, exp = 0.
204 If x is infinite or NaN: mantissa = x, exp unspecified.
205 Store exp in *EXPPTR and return mantissa. */
206 #if 0 && 0
207 # define frexpl rpl_frexpl
208 #endif
209 #if (0 && 0) || !1
210 extern long double frexpl (long double x, int *expptr);
211 #endif
212 #if !0 && defined GNULIB_POSIXCHECK
213 # undef frexpl
214 # define frexpl(x,e) \
215 (GL_LINK_WARNING ("frexpl is unportable - " \
216 "use gnulib module frexpl for portability"), \
217 frexpl (x, e))
218 #endif
221 /* Return x * 2^exp. */
222 #if 0 && 0
223 # define ldexpl rpl_ldexpl
224 #endif
225 #if (0 && 0) || !1
226 extern long double ldexpl (long double x, int exp);
227 #endif
228 #if !0 && defined GNULIB_POSIXCHECK
229 # undef ldexpl
230 # define ldexpl(x,e) \
231 (GL_LINK_WARNING ("ldexpl is unportable - " \
232 "use gnulib module ldexpl for portability"), \
233 ldexpl (x, e))
234 #endif
237 #if 0 || !1
238 extern long double logl (long double x);
239 #endif
240 #if !0 && defined GNULIB_POSIXCHECK
241 # undef logl
242 # define logl(x) \
243 (GL_LINK_WARNING ("logl is unportable - " \
244 "use gnulib module mathl for portability"), \
245 logl (x))
246 #endif
249 #if 0
250 # if 0
251 # undef roundf
252 # define roundf rpl_roundf
253 extern float roundf (float x);
254 # endif
255 #elif defined GNULIB_POSIXCHECK
256 # undef roundf
257 # define roundf(x) \
258 (GL_LINK_WARNING ("roundf is unportable - " \
259 "use gnulib module roundf for portability"), \
260 roundf (x))
261 #endif
263 #if 0
264 # if 0
265 # undef round
266 # define round rpl_round
267 extern double round (double x);
268 # endif
269 #elif defined GNULIB_POSIXCHECK
270 # undef round
271 # define round(x) \
272 (GL_LINK_WARNING ("round is unportable - " \
273 "use gnulib module round for portability"), \
274 round (x))
275 #endif
277 #if 0
278 # if 0
279 # undef roundl
280 # define roundl rpl_roundl
281 extern long double roundl (long double x);
282 # endif
283 #elif defined GNULIB_POSIXCHECK
284 # undef roundl
285 # define roundl(x) \
286 (GL_LINK_WARNING ("roundl is unportable - " \
287 "use gnulib module roundl for portability"), \
288 roundl (x))
289 #endif
292 #if 0 || !1
293 extern long double sinl (long double x);
294 #endif
295 #if !0 && defined GNULIB_POSIXCHECK
296 # undef sinl
297 # define sinl(x) \
298 (GL_LINK_WARNING ("sinl is unportable - " \
299 "use gnulib module mathl for portability"), \
300 sinl (x))
301 #endif
304 #if 0 || !1
305 extern long double sqrtl (long double x);
306 #endif
307 #if !0 && defined GNULIB_POSIXCHECK
308 # undef sqrtl
309 # define sqrtl(x) \
310 (GL_LINK_WARNING ("sqrtl is unportable - " \
311 "use gnulib module mathl for portability"), \
312 sqrtl (x))
313 #endif
316 #if 0 || !1
317 extern long double tanl (long double x);
318 #endif
319 #if !0 && defined GNULIB_POSIXCHECK
320 # undef tanl
321 # define tanl(x) \
322 (GL_LINK_WARNING ("tanl is unportable - " \
323 "use gnulib module mathl for portability"), \
324 tanl (x))
325 #endif
328 #if 0
329 # if !1
330 # define truncf rpl_truncf
331 extern float truncf (float x);
332 # endif
333 #elif defined GNULIB_POSIXCHECK
334 # undef truncf
335 # define truncf(x) \
336 (GL_LINK_WARNING ("truncf is unportable - " \
337 "use gnulib module truncf for portability"), \
338 truncf (x))
339 #endif
341 #if 0
342 # if !1
343 # define trunc rpl_trunc
344 extern double trunc (double x);
345 # endif
346 #elif defined GNULIB_POSIXCHECK
347 # undef trunc
348 # define trunc(x) \
349 (GL_LINK_WARNING ("trunc is unportable - " \
350 "use gnulib module trunc for portability"), \
351 trunc (x))
352 #endif
354 #if 0
355 # if !1
356 # define truncl rpl_truncl
357 extern long double truncl (long double x);
358 # endif
359 #elif defined GNULIB_POSIXCHECK
360 # undef truncl
361 # define truncl(x) \
362 (GL_LINK_WARNING ("truncl is unportable - " \
363 "use gnulib module truncl for portability"), \
364 truncl (x))
365 #endif
368 #if 0
369 # if 0
370 extern int gl_isfinitef (float x);
371 extern int gl_isfinited (double x);
372 extern int gl_isfinitel (long double x);
373 # undef isfinite
374 # define isfinite(x) \
375 (sizeof (x) == sizeof (long double) ? gl_isfinitel (x) : \
376 sizeof (x) == sizeof (double) ? gl_isfinited (x) : \
377 gl_isfinitef (x))
378 # endif
379 #elif defined GNULIB_POSIXCHECK
380 /* How to override a macro? */
381 #endif
384 #if 0
385 # if 0
386 # undef signbit
387 /* GCC 4.0 and newer provides three built-ins for signbit. */
388 # define signbit(x) \
389 (sizeof (x) == sizeof (long double) ? __builtin_signbitl (x) : \
390 sizeof (x) == sizeof (double) ? __builtin_signbit (x) : \
391 __builtin_signbitf (x))
392 # endif
393 # if 0
394 # undef signbit
395 extern int gl_signbitf (float arg);
396 extern int gl_signbitd (double arg);
397 extern int gl_signbitl (long double arg);
398 # if __GNUC__ >= 2 && !__STRICT_ANSI__
399 # if defined FLT_SIGNBIT_WORD && defined FLT_SIGNBIT_BIT
400 # define gl_signbitf(arg) \
401 ({ union { float _value; \
402 unsigned int _word[(sizeof (float) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
403 } _m; \
404 _m._value = (arg); \
405 (_m._word[FLT_SIGNBIT_WORD] >> FLT_SIGNBIT_BIT) & 1; \
406 })
407 # endif
408 # if defined DBL_SIGNBIT_WORD && defined DBL_SIGNBIT_BIT
409 # define gl_signbitd(arg) \
410 ({ union { double _value; \
411 unsigned int _word[(sizeof (double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
412 } _m; \
413 _m._value = (arg); \
414 (_m._word[DBL_SIGNBIT_WORD] >> DBL_SIGNBIT_BIT) & 1; \
415 })
416 # endif
417 # if defined LDBL_SIGNBIT_WORD && defined LDBL_SIGNBIT_BIT
418 # define gl_signbitl(arg) \
419 ({ union { long double _value; \
420 unsigned int _word[(sizeof (long double) + sizeof (unsigned int) - 1) / sizeof (unsigned int)]; \
421 } _m; \
422 _m._value = (arg); \
423 (_m._word[LDBL_SIGNBIT_WORD] >> LDBL_SIGNBIT_BIT) & 1; \
424 })
425 # endif
426 # endif
427 # define signbit(x) \
428 (sizeof (x) == sizeof (long double) ? gl_signbitl (x) : \
429 sizeof (x) == sizeof (double) ? gl_signbitd (x) : \
430 gl_signbitf (x))
431 # endif
432 #elif defined GNULIB_POSIXCHECK
433 /* How to override a macro? */
434 #endif
437 #ifdef __cplusplus
438 }
439 #endif
441 #endif /* _GL_MATH_H */
442 #endif /* _GL_MATH_H */