summaryrefslogtreecommitdiffstats
path: root/gl/math.in.h
diff options
context:
space:
mode:
authorThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 09:22:57 (GMT)
committerThomas Guyot-Sionnest <dermoth@aei.ca>2009-01-15 10:19:08 (GMT)
commit71cdb52799220f8d9052643baf1d3e9836a9c755 (patch)
tree27aee97a35d9ab51f0d8f64a46690bd41a5f8c1b /gl/math.in.h
parentf7afa46586645e50498d8b2d0c67884f014dc3a4 (diff)
downloadmonitoring-plugins-71cdb52799220f8d9052643baf1d3e9836a9c755.tar.gz
Sync with gnulib
Diffstat (limited to 'gl/math.in.h')
-rw-r--r--gl/math.in.h157
1 files changed, 154 insertions, 3 deletions
diff --git a/gl/math.in.h b/gl/math.in.h
index c3515d7..6e1b9a2 100644
--- a/gl/math.in.h
+++ b/gl/math.in.h
@@ -1,6 +1,6 @@
1/* A GNU-like <math.h>. 1/* A GNU-like <math.h>.
2 2
3 Copyright (C) 2002-2003, 2007 Free Software Foundation, Inc. 3 Copyright (C) 2002-2003, 2007-2008 Free Software Foundation, Inc.
4 4
5 This program is free software: you can redistribute it and/or modify 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 6 it under the terms of the GNU General Public License as published by
@@ -17,8 +17,12 @@
17 17
18#ifndef _GL_MATH_H 18#ifndef _GL_MATH_H
19 19
20#if __GNUC__ >= 3
21@PRAGMA_SYSTEM_HEADER@
22#endif
23
20/* The include_next requires a split double-inclusion guard. */ 24/* The include_next requires a split double-inclusion guard. */
21#@INCLUDE_NEXT@ @NEXT_MATH_H@ 25#@INCLUDE_NEXT_AS_FIRST_DIRECTIVE@ @NEXT_MATH_H@
22 26
23#ifndef _GL_MATH_H 27#ifndef _GL_MATH_H
24#define _GL_MATH_H 28#define _GL_MATH_H
@@ -32,6 +36,34 @@ extern "C" {
32#endif 36#endif
33 37
34 38
39/* POSIX allows platforms that don't support NAN. But all major
40 machines in the past 15 years have supported something close to
41 IEEE NaN, so we define this unconditionally. We also must define
42 it on platforms like Solaris 10, where NAN is present but defined
43 as a function pointer rather than a floating point constant. */
44#if !defined NAN || @REPLACE_NAN@
45# undef NAN
46 /* The Compaq (ex-DEC) C 6.4 compiler chokes on the expression 0.0 / 0.0. */
47# ifdef __DECC
48static float
49_NaN ()
50{
51 static float zero = 0.0f;
52 return zero / zero;
53}
54# define NAN (_NaN())
55# else
56# define NAN (0.0f / 0.0f)
57# endif
58#endif
59
60/* Solaris 10 defines HUGE_VAL, but as a function pointer rather
61 than a floating point constant. */
62#if @REPLACE_HUGE_VAL@
63# undef HUGE_VAL
64# define HUGE_VAL (1.0 / 0.0)
65#endif
66
35/* Write x as 67/* Write x as
36 x = mantissa * 2^exp 68 x = mantissa * 2^exp
37 where 69 where
@@ -323,7 +355,8 @@ extern double trunc (double x);
323#endif 355#endif
324 356
325#if @GNULIB_TRUNCL@ 357#if @GNULIB_TRUNCL@
326# if !@HAVE_DECL_TRUNCL@ 358# if @REPLACE_TRUNCL@
359# undef truncl
327# define truncl rpl_truncl 360# define truncl rpl_truncl
328extern long double truncl (long double x); 361extern long double truncl (long double x);
329# endif 362# endif
@@ -352,6 +385,124 @@ extern int gl_isfinitel (long double x);
352#endif 385#endif
353 386
354 387
388#if @GNULIB_ISINF@
389# if @REPLACE_ISINF@
390extern int gl_isinff (float x);
391extern int gl_isinfd (double x);
392extern int gl_isinfl (long double x);
393# undef isinf
394# define isinf(x) \
395 (sizeof (x) == sizeof (long double) ? gl_isinfl (x) : \
396 sizeof (x) == sizeof (double) ? gl_isinfd (x) : \
397 gl_isinff (x))
398# endif
399#elif defined GNULIB_POSIXCHECK
400 /* How to override a macro? */
401#endif
402
403
404#if @GNULIB_ISNANF@
405/* Test for NaN for 'float' numbers. */
406# if @HAVE_ISNANF@
407/* The original <math.h> included above provides a declaration of isnan macro
408 or (older) isnanf function. */
409# include <math.h>
410# if __GNUC__ >= 4
411 /* GCC 4.0 and newer provides three built-ins for isnan. */
412# undef isnanf
413# define isnanf(x) __builtin_isnanf ((float)(x))
414# elif defined isnan
415# undef isnanf
416# define isnanf(x) isnan ((float)(x))
417# endif
418# else
419/* Test whether X is a NaN. */
420# undef isnanf
421# define isnanf rpl_isnanf
422extern int isnanf (float x);
423# endif
424#endif
425
426#if @GNULIB_ISNAND@
427/* Test for NaN for 'double' numbers.
428 This function is a gnulib extension, unlike isnan() which applied only
429 to 'double' numbers earlier but now is a type-generic macro. */
430# if @HAVE_ISNAND@
431/* The original <math.h> included above provides a declaration of isnan macro. */
432# include <math.h>
433# if __GNUC__ >= 4
434 /* GCC 4.0 and newer provides three built-ins for isnan. */
435# undef isnand
436# define isnand(x) __builtin_isnan ((double)(x))
437# else
438# undef isnand
439# define isnand(x) isnan ((double)(x))
440# endif
441# else
442/* Test whether X is a NaN. */
443# undef isnand
444# define isnand rpl_isnand
445extern int isnand (double x);
446# endif
447#endif
448
449#if @GNULIB_ISNANL@
450/* Test for NaN for 'long double' numbers. */
451# if @HAVE_ISNANL@
452/* The original <math.h> included above provides a declaration of isnan macro or (older) isnanl function. */
453# include <math.h>
454# if __GNUC__ >= 4
455 /* GCC 4.0 and newer provides three built-ins for isnan. */
456# undef isnanl
457# define isnanl(x) __builtin_isnanl ((long double)(x))
458# elif defined isnan
459# undef isnanl
460# define isnanl(x) isnan ((long double)(x))
461# endif
462# else
463/* Test whether X is a NaN. */
464# undef isnanl
465# define isnanl rpl_isnanl
466extern int isnanl (long double x);
467# endif
468#endif
469
470/* This must come *after* the snippets for GNULIB_ISNANF and GNULIB_ISNANL! */
471#if @GNULIB_ISNAN@
472# if @REPLACE_ISNAN@
473/* We can't just use the isnanf macro (e.g.) as exposed by
474 isnanf.h (e.g.) here, because those may end up being macros
475 that recursively expand back to isnan. So use the gnulib
476 replacements for them directly. */
477# if @HAVE_ISNANF@ && __GNUC__ >= 4
478# define gl_isnan_f(x) __builtin_isnan ((float)(x))
479# else
480extern int rpl_isnanf (float x);
481# define gl_isnan_f(x) rpl_isnanf (x)
482# endif
483# if @HAVE_ISNAND@ && __GNUC__ >= 4
484# define gl_isnan_d(x) __builtin_isnan ((double)(x))
485# else
486extern int rpl_isnand (double x);
487# define gl_isnan_d(x) rpl_isnand (x)
488# endif
489# if @HAVE_ISNANL@ && __GNUC__ >= 4
490# define gl_isnan_l(x) __builtin_isnan ((long double)(x))
491# else
492extern int rpl_isnanl (long double x);
493# define gl_isnan_l(x) rpl_isnanl (x)
494# endif
495# undef isnan
496# define isnan(x) \
497 (sizeof (x) == sizeof (long double) ? gl_isnan_l (x) : \
498 sizeof (x) == sizeof (double) ? gl_isnan_d (x) : \
499 gl_isnan_f (x))
500# endif
501#elif defined GNULIB_POSIXCHECK
502 /* How to override a macro? */
503#endif
504
505
355#if @GNULIB_SIGNBIT@ 506#if @GNULIB_SIGNBIT@
356# if @REPLACE_SIGNBIT_USING_GCC@ 507# if @REPLACE_SIGNBIT_USING_GCC@
357# undef signbit 508# undef signbit