modernc.org/cc@v1.0.1/v2/headers/linux_386/usr/include/math.h (about)

     1  /* Declarations for math functions.
     2     Copyright (C) 1991-2018 Free Software Foundation, Inc.
     3     This file is part of the GNU C Library.
     4  
     5     The GNU C Library is free software; you can redistribute it and/or
     6     modify it under the terms of the GNU Lesser General Public
     7     License as published by the Free Software Foundation; either
     8     version 2.1 of the License, or (at your option) any later version.
     9  
    10     The GNU C Library 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 GNU
    13     Lesser General Public License for more details.
    14  
    15     You should have received a copy of the GNU Lesser General Public
    16     License along with the GNU C Library; if not, see
    17     <http://www.gnu.org/licenses/>.  */
    18  
    19  /*
    20   *	ISO C99 Standard: 7.12 Mathematics	<math.h>
    21   */
    22  
    23  #ifndef	_MATH_H
    24  #define	_MATH_H	1
    25  
    26  #define __GLIBC_INTERNAL_STARTING_HEADER_IMPLEMENTATION
    27  #include <bits/libc-header-start.h>
    28  
    29  #if defined log && defined __GNUC__
    30  # warning A macro called log was already defined when <math.h> was included.
    31  # warning This will cause compilation problems.
    32  #endif
    33  
    34  __BEGIN_DECLS
    35  /* Get definitions of __intmax_t and __uintmax_t.  */
    36  #include <bits/types.h>
    37  /* Get machine-dependent vector math functions declarations.  */
    38  #include <bits/math-vector.h>
    39  /* Gather machine dependent type support.  */
    40  #include <bits/floatn.h>
    41  /* Value returned on overflow.  With IEEE 754 floating point, this is
    42     +Infinity, otherwise the largest representable positive value.  */
    43  #if __GNUC_PREREQ (3, 3)
    44  # define HUGE_VAL (__builtin_huge_val ())
    45  #else
    46  /* This may provoke compiler warnings, and may not be rounded to
    47     +Infinity in all IEEE 754 rounding modes, but is the best that can
    48     be done in ISO C while remaining a constant expression.  10,000 is
    49     greater than the maximum (decimal) exponent for all supported
    50     floating-point formats and widths.  */
    51  # define HUGE_VAL 1e10000
    52  #endif
    53  #ifdef __USE_ISOC99
    54  # if __GNUC_PREREQ (3, 3)
    55  #  define HUGE_VALF (__builtin_huge_valf ())
    56  #  define HUGE_VALL (__builtin_huge_vall ())
    57  # else
    58  #  define HUGE_VALF 1e10000f
    59  #  define HUGE_VALL 1e10000L
    60  # endif
    61  #endif
    62  #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
    63  # define HUGE_VAL_F16 (__builtin_huge_valf16 ())
    64  #endif
    65  #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
    66  # define HUGE_VAL_F32 (__builtin_huge_valf32 ())
    67  #endif
    68  #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
    69  # define HUGE_VAL_F64 (__builtin_huge_valf64 ())
    70  #endif
    71  #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
    72  # define HUGE_VAL_F128 (__builtin_huge_valf128 ())
    73  #endif
    74  #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
    75  # define HUGE_VAL_F32X (__builtin_huge_valf32x ())
    76  #endif
    77  #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
    78  # define HUGE_VAL_F64X (__builtin_huge_valf64x ())
    79  #endif
    80  #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
    81  # define HUGE_VAL_F128X (__builtin_huge_valf128x ())
    82  #endif
    83  #ifdef __USE_ISOC99
    84  /* IEEE positive infinity.  */
    85  # if __GNUC_PREREQ (3, 3)
    86  #  define INFINITY (__builtin_inff ())
    87  # else
    88  #  define INFINITY HUGE_VALF
    89  # endif
    90  /* IEEE Not A Number.  */
    91  # if __GNUC_PREREQ (3, 3)
    92  #  define NAN (__builtin_nanf (""))
    93  # else
    94  /* This will raise an "invalid" exception outside static initializers,
    95     but is the best that can be done in ISO C while remaining a
    96     constant expression.  */
    97  #  define NAN (0.0f / 0.0f)
    98  # endif
    99  #endif				/* __USE_ISOC99 */
   100  #if __GLIBC_USE (IEC_60559_BFP_EXT)
   101  /* Signaling NaN macros, if supported.  */
   102  # if __GNUC_PREREQ (3, 3)
   103  #  define SNANF (__builtin_nansf (""))
   104  #  define SNAN (__builtin_nans (""))
   105  #  define SNANL (__builtin_nansl (""))
   106  # endif
   107  #endif
   108  #if __HAVE_FLOAT16 && __GLIBC_USE (IEC_60559_TYPES_EXT)
   109  # define SNANF16 (__builtin_nansf16 (""))
   110  #endif
   111  #if __HAVE_FLOAT32 && __GLIBC_USE (IEC_60559_TYPES_EXT)
   112  # define SNANF32 (__builtin_nansf32 (""))
   113  #endif
   114  #if __HAVE_FLOAT64 && __GLIBC_USE (IEC_60559_TYPES_EXT)
   115  # define SNANF64 (__builtin_nansf64 (""))
   116  #endif
   117  #if __HAVE_FLOAT128 && __GLIBC_USE (IEC_60559_TYPES_EXT)
   118  # define SNANF128 (__builtin_nansf128 (""))
   119  #endif
   120  #if __HAVE_FLOAT32X && __GLIBC_USE (IEC_60559_TYPES_EXT)
   121  # define SNANF32X (__builtin_nansf32x (""))
   122  #endif
   123  #if __HAVE_FLOAT64X && __GLIBC_USE (IEC_60559_TYPES_EXT)
   124  # define SNANF64X (__builtin_nansf64x (""))
   125  #endif
   126  #if __HAVE_FLOAT128X && __GLIBC_USE (IEC_60559_TYPES_EXT)
   127  # define SNANF128X (__builtin_nansf128x (""))
   128  #endif
   129  /* Get __GLIBC_FLT_EVAL_METHOD.  */
   130  #include <bits/flt-eval-method.h>
   131  #ifdef __USE_ISOC99
   132  /* Define the following typedefs.
   133  
   134      float_t	floating-point type at least as wide as `float' used
   135  		to evaluate `float' expressions
   136      double_t	floating-point type at least as wide as `double' used
   137  		to evaluate `double' expressions
   138  */
   139  # if __GLIBC_FLT_EVAL_METHOD == 0 || __GLIBC_FLT_EVAL_METHOD == 16
   140  typedef float float_t;
   141  typedef double double_t;
   142  # elif __GLIBC_FLT_EVAL_METHOD == 1
   143  typedef double float_t;
   144  typedef double double_t;
   145  # elif __GLIBC_FLT_EVAL_METHOD == 2
   146  typedef long double float_t;
   147  typedef long double double_t;
   148  # elif __GLIBC_FLT_EVAL_METHOD == 32
   149  typedef _Float32 float_t;
   150  typedef double double_t;
   151  # elif __GLIBC_FLT_EVAL_METHOD == 33
   152  typedef _Float32x float_t;
   153  typedef _Float32x double_t;
   154  # elif __GLIBC_FLT_EVAL_METHOD == 64
   155  typedef _Float64 float_t;
   156  typedef _Float64 double_t;
   157  # elif __GLIBC_FLT_EVAL_METHOD == 65
   158  typedef _Float64x float_t;
   159  typedef _Float64x double_t;
   160  # elif __GLIBC_FLT_EVAL_METHOD == 128
   161  typedef _Float128 float_t;
   162  typedef _Float128 double_t;
   163  # elif __GLIBC_FLT_EVAL_METHOD == 129
   164  typedef _Float128x float_t;
   165  typedef _Float128x double_t;
   166  # else
   167  #  error "Unknown __GLIBC_FLT_EVAL_METHOD"
   168  # endif
   169  #endif
   170  /* Define macros for the return values of ilogb and llogb, based on
   171     __FP_LOGB0_IS_MIN and __FP_LOGBNAN_IS_MIN.
   172  
   173      FP_ILOGB0	Expands to a value returned by `ilogb (0.0)'.
   174      FP_ILOGBNAN	Expands to a value returned by `ilogb (NAN)'.
   175      FP_LLOGB0	Expands to a value returned by `llogb (0.0)'.
   176      FP_LLOGBNAN	Expands to a value returned by `llogb (NAN)'.
   177  
   178  */
   179  #include <bits/fp-logb.h>
   180  #ifdef __USE_ISOC99
   181  # if __FP_LOGB0_IS_MIN
   182  #  define FP_ILOGB0	(-2147483647 - 1)
   183  # else
   184  #  define FP_ILOGB0	(-2147483647)
   185  # endif
   186  # if __FP_LOGBNAN_IS_MIN
   187  #  define FP_ILOGBNAN	(-2147483647 - 1)
   188  # else
   189  #  define FP_ILOGBNAN	2147483647
   190  # endif
   191  #endif
   192  #if __GLIBC_USE (IEC_60559_BFP_EXT)
   193  # if __WORDSIZE == 32
   194  #  define __FP_LONG_MAX 0x7fffffffL
   195  # else
   196  #  define __FP_LONG_MAX 0x7fffffffffffffffL
   197  # endif
   198  # if __FP_LOGB0_IS_MIN
   199  #  define FP_LLOGB0	(-__FP_LONG_MAX - 1)
   200  # else
   201  #  define FP_LLOGB0	(-__FP_LONG_MAX)
   202  # endif
   203  # if __FP_LOGBNAN_IS_MIN
   204  #  define FP_LLOGBNAN	(-__FP_LONG_MAX - 1)
   205  # else
   206  #  define FP_LLOGBNAN	__FP_LONG_MAX
   207  # endif
   208  #endif
   209  /* Get the architecture specific values describing the floating-point
   210     evaluation.  The following symbols will get defined:
   211  
   212      FP_FAST_FMA
   213      FP_FAST_FMAF
   214      FP_FAST_FMAL
   215  		If defined it indicates that the `fma' function
   216  		generally executes about as fast as a multiply and an add.
   217  		This macro is defined only iff the `fma' function is
   218  		implemented directly with a hardware multiply-add instructions.
   219  */
   220  #include <bits/fp-fast.h>
   221  #if __GLIBC_USE (IEC_60559_BFP_EXT)
   222  /* Rounding direction macros for fromfp functions.  */
   223      enum {
   224  	FP_INT_UPWARD =
   225  # define FP_INT_UPWARD 0
   226  	    FP_INT_UPWARD,
   227  	FP_INT_DOWNWARD =
   228  # define FP_INT_DOWNWARD 1
   229  	    FP_INT_DOWNWARD,
   230  	FP_INT_TOWARDZERO =
   231  # define FP_INT_TOWARDZERO 2
   232  	    FP_INT_TOWARDZERO,
   233  	FP_INT_TONEARESTFROMZERO =
   234  # define FP_INT_TONEARESTFROMZERO 3
   235  	    FP_INT_TONEARESTFROMZERO,
   236  	FP_INT_TONEAREST =
   237  # define FP_INT_TONEAREST 4
   238  	    FP_INT_TONEAREST,
   239  };
   240  #endif
   241  
   242  /* The file <bits/mathcalls.h> contains the prototypes for all the
   243     actual math functions.  These macros are used for those prototypes,
   244     so we can easily declare each function as both `name' and `__name',
   245     and can declare the float versions `namef' and `__namef'.  */
   246  
   247  #define __SIMD_DECL(function) __CONCAT (__DECL_SIMD_, function)
   248  
   249  #define __MATHCALL_VEC(function, suffix, args) 	\
   250    __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
   251    __MATHCALL (function, suffix, args)
   252  
   253  #define __MATHDECL_VEC(type, function,suffix, args) \
   254    __SIMD_DECL (__MATH_PRECNAME (function, suffix)) \
   255    __MATHDECL(type, function,suffix, args)
   256  
   257  #define __MATHCALL(function,suffix, args)	\
   258    __MATHDECL (_Mdouble_,function,suffix, args)
   259  #define __MATHDECL(type, function,suffix, args) \
   260    __MATHDECL_1(type, function,suffix, args); \
   261    __MATHDECL_1(type, __CONCAT(__,function),suffix, args)
   262  #define __MATHCALLX(function,suffix, args, attrib)	\
   263    __MATHDECLX (_Mdouble_,function,suffix, args, attrib)
   264  #define __MATHDECLX(type, function,suffix, args, attrib) \
   265    __MATHDECL_1(type, function,suffix, args) __attribute__ (attrib); \
   266    __MATHDECL_1(type, __CONCAT(__,function),suffix, args) __attribute__ (attrib)
   267  #define __MATHDECL_1(type, function,suffix, args) \
   268    extern type __MATH_PRECNAME(function,suffix) args __THROW
   269  
   270  #define _Mdouble_		double
   271  #define __MATH_PRECNAME(name,r)	__CONCAT(name,r)
   272  #define __MATH_DECLARING_DOUBLE  1
   273  #define __MATH_DECLARING_FLOATN  0
   274  #include <bits/mathcalls-helper-functions.h>
   275  #include <bits/mathcalls.h>
   276  #undef	_Mdouble_
   277  #undef	__MATH_PRECNAME
   278  #undef __MATH_DECLARING_DOUBLE
   279  #undef __MATH_DECLARING_FLOATN
   280  
   281  #ifdef __USE_ISOC99
   282  
   283  /* Include the file of declarations again, this time using `float'
   284     instead of `double' and appending f to each function name.  */
   285  
   286  # define _Mdouble_		float
   287  # define __MATH_PRECNAME(name,r) name##f##r
   288  # define __MATH_DECLARING_DOUBLE  0
   289  # define __MATH_DECLARING_FLOATN  0
   290  # include <bits/mathcalls-helper-functions.h>
   291  # include <bits/mathcalls.h>
   292  # undef	_Mdouble_
   293  # undef	__MATH_PRECNAME
   294  # undef __MATH_DECLARING_DOUBLE
   295  # undef __MATH_DECLARING_FLOATN
   296  
   297  # if !(defined __NO_LONG_DOUBLE_MATH && defined _LIBC) \
   298       || defined __LDBL_COMPAT \
   299       || defined _LIBC_TEST
   300  #  ifdef __LDBL_COMPAT
   301  
   302  #   ifdef __USE_ISOC99
   303  extern float __nldbl_nexttowardf(float __x, long double __y)
   304  __THROW __attribute__ ((__const__));
   305  #    ifdef __REDIRECT_NTH
   306  extern float __REDIRECT_NTH(nexttowardf, (float __x, long double __y), __nldbl_nexttowardf)
   307      __attribute__ ((__const__));
   308  extern double __REDIRECT_NTH(nexttoward, (double __x, long double __y), nextafter) __attribute__ ((__const__));
   309  extern long double __REDIRECT_NTH(nexttowardl, (long double __x, long double __y), nextafter) __attribute__ ((__const__));
   310  #    endif
   311  #   endif
   312  
   313  #   undef __MATHDECL_1
   314  #   define __MATHDECL_2(type, function,suffix, args, alias) \
   315    extern type __REDIRECT_NTH(__MATH_PRECNAME(function,suffix), \
   316  			     args, alias)
   317  #   define __MATHDECL_1(type, function,suffix, args) \
   318    __MATHDECL_2(type, function,suffix, args, __CONCAT(function,suffix))
   319  #  endif
   320  
   321  /* Include the file of declarations again, this time using `long double'
   322     instead of `double' and appending l to each function name.  */
   323  
   324  #  define _Mdouble_		long double
   325  #  define __MATH_PRECNAME(name,r) name##l##r
   326  #  define __MATH_DECLARING_DOUBLE  0
   327  #  define __MATH_DECLARING_FLOATN  0
   328  #  define __MATH_DECLARE_LDOUBLE   1
   329  #  include <bits/mathcalls-helper-functions.h>
   330  #  include <bits/mathcalls.h>
   331  #  undef _Mdouble_
   332  #  undef __MATH_PRECNAME
   333  #  undef __MATH_DECLARING_DOUBLE
   334  #  undef __MATH_DECLARING_FLOATN
   335  
   336  # endif				/* !(__NO_LONG_DOUBLE_MATH && _LIBC) || __LDBL_COMPAT */
   337  
   338  #endif				/* Use ISO C99.  */
   339  
   340  /* Include the file of declarations for _FloatN and _FloatNx
   341     types.  */
   342  
   343  #if __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC)
   344  # define _Mdouble_		_Float16
   345  # define __MATH_PRECNAME(name,r) name##f16##r
   346  # define __MATH_DECLARING_DOUBLE  0
   347  # define __MATH_DECLARING_FLOATN  1
   348  # if __HAVE_DISTINCT_FLOAT16
   349  #  include <bits/mathcalls-helper-functions.h>
   350  # endif
   351  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   352  #  include <bits/mathcalls.h>
   353  # endif
   354  # undef _Mdouble_
   355  # undef __MATH_PRECNAME
   356  # undef __MATH_DECLARING_DOUBLE
   357  # undef __MATH_DECLARING_FLOATN
   358  #endif				/* __HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !_LIBC).  */
   359  
   360  #if __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC)
   361  # define _Mdouble_		_Float32
   362  # define __MATH_PRECNAME(name,r) name##f32##r
   363  # define __MATH_DECLARING_DOUBLE  0
   364  # define __MATH_DECLARING_FLOATN  1
   365  # if __HAVE_DISTINCT_FLOAT32
   366  #  include <bits/mathcalls-helper-functions.h>
   367  # endif
   368  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   369  #  include <bits/mathcalls.h>
   370  # endif
   371  # undef _Mdouble_
   372  # undef __MATH_PRECNAME
   373  # undef __MATH_DECLARING_DOUBLE
   374  # undef __MATH_DECLARING_FLOATN
   375  #endif				/* __HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !_LIBC).  */
   376  
   377  #if __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC)
   378  # define _Mdouble_		_Float64
   379  # define __MATH_PRECNAME(name,r) name##f64##r
   380  # define __MATH_DECLARING_DOUBLE  0
   381  # define __MATH_DECLARING_FLOATN  1
   382  # if __HAVE_DISTINCT_FLOAT64
   383  #  include <bits/mathcalls-helper-functions.h>
   384  # endif
   385  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   386  #  include <bits/mathcalls.h>
   387  # endif
   388  # undef _Mdouble_
   389  # undef __MATH_PRECNAME
   390  # undef __MATH_DECLARING_DOUBLE
   391  # undef __MATH_DECLARING_FLOATN
   392  #endif				/* __HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !_LIBC).  */
   393  
   394  #if __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC)
   395  # define _Mdouble_		_Float128
   396  # define __MATH_PRECNAME(name,r) name##f128##r
   397  # define __MATH_DECLARING_DOUBLE  0
   398  # define __MATH_DECLARING_FLOATN  1
   399  # if __HAVE_DISTINCT_FLOAT128
   400  #  include <bits/mathcalls-helper-functions.h>
   401  # endif
   402  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   403  #  include <bits/mathcalls.h>
   404  # endif
   405  # undef _Mdouble_
   406  # undef __MATH_PRECNAME
   407  # undef __MATH_DECLARING_DOUBLE
   408  # undef __MATH_DECLARING_FLOATN
   409  #endif				/* __HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !_LIBC).  */
   410  
   411  #if __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC)
   412  # define _Mdouble_		_Float32x
   413  # define __MATH_PRECNAME(name,r) name##f32x##r
   414  # define __MATH_DECLARING_DOUBLE  0
   415  # define __MATH_DECLARING_FLOATN  1
   416  # if __HAVE_DISTINCT_FLOAT32X
   417  #  include <bits/mathcalls-helper-functions.h>
   418  # endif
   419  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   420  #  include <bits/mathcalls.h>
   421  # endif
   422  # undef _Mdouble_
   423  # undef __MATH_PRECNAME
   424  # undef __MATH_DECLARING_DOUBLE
   425  # undef __MATH_DECLARING_FLOATN
   426  #endif				/* __HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !_LIBC).  */
   427  
   428  #if __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC)
   429  # define _Mdouble_		_Float64x
   430  # define __MATH_PRECNAME(name,r) name##f64x##r
   431  # define __MATH_DECLARING_DOUBLE  0
   432  # define __MATH_DECLARING_FLOATN  1
   433  # if __HAVE_DISTINCT_FLOAT64X
   434  #  include <bits/mathcalls-helper-functions.h>
   435  # endif
   436  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   437  #  include <bits/mathcalls.h>
   438  # endif
   439  # undef _Mdouble_
   440  # undef __MATH_PRECNAME
   441  # undef __MATH_DECLARING_DOUBLE
   442  # undef __MATH_DECLARING_FLOATN
   443  #endif				/* __HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !_LIBC).  */
   444  
   445  #if __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)
   446  # define _Mdouble_		_Float128x
   447  # define __MATH_PRECNAME(name,r) name##f128x##r
   448  # define __MATH_DECLARING_DOUBLE  0
   449  # define __MATH_DECLARING_FLOATN  1
   450  # if __HAVE_DISTINCT_FLOAT128X
   451  #  include <bits/mathcalls-helper-functions.h>
   452  # endif
   453  # if __GLIBC_USE (IEC_60559_TYPES_EXT)
   454  #  include <bits/mathcalls.h>
   455  # endif
   456  # undef _Mdouble_
   457  # undef __MATH_PRECNAME
   458  # undef __MATH_DECLARING_DOUBLE
   459  # undef __MATH_DECLARING_FLOATN
   460  #endif				/* __HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !_LIBC).  */
   461  
   462  #undef	__MATHDECL_1
   463  #undef	__MATHDECL
   464  #undef	__MATHCALL
   465  
   466  #if defined __USE_MISC || defined __USE_XOPEN
   467  /* This variable is used by `gamma' and `lgamma'.  */
   468  extern int signgam;
   469  #endif
   470  
   471  #if (__HAVE_DISTINCT_FLOAT16			\
   472       || __HAVE_DISTINCT_FLOAT32			\
   473       || __HAVE_DISTINCT_FLOAT64			\
   474       || __HAVE_DISTINCT_FLOAT32X		\
   475       || __HAVE_DISTINCT_FLOAT64X		\
   476       || __HAVE_DISTINCT_FLOAT128X)
   477  # error "Unsupported _FloatN or _FloatNx types for <math.h>."
   478  #endif
   479  
   480  /* Depending on the type of TG_ARG, call an appropriately suffixed
   481     version of FUNC with arguments (including parentheses) ARGS.
   482     Suffixed functions may not exist for long double if it has the same
   483     format as double, or for other types with the same format as float,
   484     double or long double.  The behavior is undefined if the argument
   485     does not have a real floating type.  The definition may use a
   486     conditional expression, so all suffixed versions of FUNC must
   487     return the same type (FUNC may include a cast if necessary rather
   488     than being a single identifier).  */
   489  #ifdef __NO_LONG_DOUBLE_MATH
   490  # if __HAVE_DISTINCT_FLOAT128
   491  #  error "Distinct _Float128 without distinct long double not supported."
   492  # endif
   493  # define __MATH_TG(TG_ARG, FUNC, ARGS)					\
   494    (sizeof (TG_ARG) == sizeof (float) ? FUNC ## f ARGS : FUNC ARGS)
   495  #elif __HAVE_DISTINCT_FLOAT128
   496  # if __HAVE_GENERIC_SELECTION
   497  #  if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT32
   498  #   define __MATH_TG_F32(FUNC, ARGS) _Float32: FUNC ## f ARGS,
   499  #  else
   500  #   define __MATH_TG_F32(FUNC, ARGS)
   501  #  endif
   502  #  if __HAVE_FLOATN_NOT_TYPEDEF && __HAVE_FLOAT64X
   503  #   if __HAVE_FLOAT64X_LONG_DOUBLE
   504  #    define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## l ARGS,
   505  #   else
   506  #    define __MATH_TG_F64X(FUNC, ARGS) _Float64x: FUNC ## f128 ARGS,
   507  #   endif
   508  #  else
   509  #   define __MATH_TG_F64X(FUNC, ARGS)
   510  #  endif
   511  #  define __MATH_TG(TG_ARG, FUNC, ARGS)	\
   512       _Generic ((TG_ARG),			\
   513  	       float: FUNC ## f ARGS,		\
   514  	       __MATH_TG_F32 (FUNC, ARGS)	\
   515  	       default: FUNC ARGS,		\
   516  	       long double: FUNC ## l ARGS,	\
   517  	       __MATH_TG_F64X (FUNC, ARGS)	\
   518  	       _Float128: FUNC ## f128 ARGS)
   519  # else
   520  #  if __HAVE_FLOATN_NOT_TYPEDEF
   521  #   error "Non-typedef _FloatN but no _Generic."
   522  #  endif
   523  #  define __MATH_TG(TG_ARG, FUNC, ARGS)					\
   524       __builtin_choose_expr						\
   525       (__builtin_types_compatible_p (__typeof (TG_ARG), float),		\
   526        FUNC ## f ARGS,							\
   527        __builtin_choose_expr						\
   528        (__builtin_types_compatible_p (__typeof (TG_ARG), double),	\
   529         FUNC ARGS,							\
   530         __builtin_choose_expr						\
   531         (__builtin_types_compatible_p (__typeof (TG_ARG), long double),	\
   532  	FUNC ## l ARGS,							\
   533  	FUNC ## f128 ARGS)))
   534  # endif
   535  #else
   536  # define __MATH_TG(TG_ARG, FUNC, ARGS)		\
   537    (sizeof (TG_ARG) == sizeof (float)		\
   538     ? FUNC ## f ARGS				\
   539     : sizeof (TG_ARG) == sizeof (double)		\
   540     ? FUNC ARGS					\
   541     : FUNC ## l ARGS)
   542  #endif
   543  
   544  /* ISO C99 defines some generic macros which work on any data type.  */
   545  #ifdef __USE_ISOC99
   546  
   547  /* All floating-point numbers can be put in one of these categories.  */
   548  enum {
   549  	FP_NAN =
   550  # define FP_NAN 0
   551  	    FP_NAN,
   552  	FP_INFINITE =
   553  # define FP_INFINITE 1
   554  	    FP_INFINITE,
   555  	FP_ZERO =
   556  # define FP_ZERO 2
   557  	    FP_ZERO,
   558  	FP_SUBNORMAL =
   559  # define FP_SUBNORMAL 3
   560  	    FP_SUBNORMAL,
   561  	FP_NORMAL =
   562  # define FP_NORMAL 4
   563  	FP_NORMAL
   564  };
   565  
   566  /* GCC bug 66462 means we cannot use the math builtins with -fsignaling-nan,
   567     so disable builtins if this is enabled.  When fixed in a newer GCC,
   568     the __SUPPORT_SNAN__ check may be skipped for those versions.  */
   569  
   570  /* Return number of classification appropriate for X.  */
   571  # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__			      \
   572       && (!defined __OPTIMIZE_SIZE__ || defined __cplusplus)
   573       /* The check for __cplusplus allows the use of the builtin, even
   574          when optimization for size is on.  This is provided for
   575          libstdc++, only to let its configure test work when it is built
   576          with -Os.  No further use of this definition of fpclassify is
   577          expected in C++ mode, since libstdc++ provides its own version
   578          of fpclassify in cmath (which undefines fpclassify).  */
   579  #  define fpclassify(x) __builtin_fpclassify (FP_NAN, FP_INFINITE,	      \
   580       FP_NORMAL, FP_SUBNORMAL, FP_ZERO, x)
   581  # else
   582  #  define fpclassify(x) __MATH_TG ((x), __fpclassify, (x))
   583  # endif
   584  
   585  /* Return nonzero value if sign of X is negative.  */
   586  # if __GNUC_PREREQ (6,0)
   587  #  define signbit(x) __builtin_signbit (x)
   588  # elif defined __cplusplus
   589    /* In C++ mode, __MATH_TG cannot be used, because it relies on
   590       __builtin_types_compatible_p, which is a C-only builtin.
   591       The check for __cplusplus allows the use of the builtin instead of
   592       __MATH_TG. This is provided for libstdc++, only to let its configure
   593       test work. No further use of this definition of signbit is expected
   594       in C++ mode, since libstdc++ provides its own version of signbit
   595       in cmath (which undefines signbit). */
   596  #  define signbit(x) __builtin_signbitl (x)
   597  # elif __GNUC_PREREQ (4,0)
   598  #  define signbit(x) __MATH_TG ((x), __builtin_signbit, (x))
   599  # else
   600  #  define signbit(x) __MATH_TG ((x), __signbit, (x))
   601  # endif
   602  
   603  /* Return nonzero value if X is not +-Inf or NaN.  */
   604  # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
   605  #  define isfinite(x) __builtin_isfinite (x)
   606  # else
   607  #  define isfinite(x) __MATH_TG ((x), __finite, (x))
   608  # endif
   609  
   610  /* Return nonzero value if X is neither zero, subnormal, Inf, nor NaN.  */
   611  # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
   612  #  define isnormal(x) __builtin_isnormal (x)
   613  # else
   614  #  define isnormal(x) (fpclassify (x) == FP_NORMAL)
   615  # endif
   616  
   617  /* Return nonzero value if X is a NaN.  We could use `fpclassify' but
   618     we already have this functions `__isnan' and it is faster.  */
   619  # if __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
   620  #  define isnan(x) __builtin_isnan (x)
   621  # else
   622  #  define isnan(x) __MATH_TG ((x), __isnan, (x))
   623  # endif
   624  
   625  /* Return nonzero value if X is positive or negative infinity.  */
   626  # if __HAVE_DISTINCT_FLOAT128 && !__GNUC_PREREQ (7,0) \
   627       && !defined __SUPPORT_SNAN__ && !defined __cplusplus
   628     /* Since __builtin_isinf_sign is broken for float128 before GCC 7.0,
   629        use the helper function, __isinff128, with older compilers.  This is
   630        only provided for C mode, because in C++ mode, GCC has no support
   631        for __builtin_types_compatible_p (and when in C++ mode, this macro is
   632        not used anyway, because libstdc++ headers undefine it).  */
   633  #  define isinf(x) \
   634      (__builtin_types_compatible_p (__typeof (x), _Float128) \
   635       ? __isinff128 (x) : __builtin_isinf_sign (x))
   636  # elif __GNUC_PREREQ (4,4) && !defined __SUPPORT_SNAN__
   637  #  define isinf(x) __builtin_isinf_sign (x)
   638  # else
   639  #  define isinf(x) __MATH_TG ((x), __isinf, (x))
   640  # endif
   641  
   642  /* Bitmasks for the math_errhandling macro.  */
   643  # define MATH_ERRNO	1	/* errno set by math functions.  */
   644  # define MATH_ERREXCEPT	2	/* Exceptions raised by math functions.  */
   645  
   646  /* By default all math functions support both errno and exception handling
   647     (except for soft floating point implementations which may only support
   648     errno handling).  If errno handling is disabled, exceptions are still
   649     supported by GLIBC.  Set math_errhandling to 0 with -ffast-math (this is
   650     nonconforming but it is more useful than leaving it undefined).  */
   651  # ifdef __FAST_MATH__
   652  #  define math_errhandling	0
   653  # elif defined __NO_MATH_ERRNO__
   654  #  define math_errhandling	(MATH_ERREXCEPT)
   655  # else
   656  #  define math_errhandling	(MATH_ERRNO | MATH_ERREXCEPT)
   657  # endif
   658  
   659  #endif				/* Use ISO C99.  */
   660  
   661  #if __GLIBC_USE (IEC_60559_BFP_EXT)
   662  # include <bits/iscanonical.h>
   663  
   664  /* Return nonzero value if X is a signaling NaN.  */
   665  # ifndef __cplusplus
   666  #  define issignaling(x) __MATH_TG ((x), __issignaling, (x))
   667  # else
   668     /* In C++ mode, __MATH_TG cannot be used, because it relies on
   669        __builtin_types_compatible_p, which is a C-only builtin.  On the
   670        other hand, overloading provides the means to distinguish between
   671        the floating-point types.  The overloading resolution will match
   672        the correct parameter (regardless of type qualifiers (i.e.: const
   673        and volatile)).  */
   674  extern "C++" {
   675  	inline int issignaling(float __val)
   676  {
   677  	return __issignalingf(__val);
   678  } inline int issignaling(double __val) {
   679  		return __issignaling(__val);
   680  }
   681  	inline int issignaling(long double __val) {
   682  #  ifdef __NO_LONG_DOUBLE_MATH
   683  		return __issignaling(__val);
   684  #  else
   685  		return __issignalingl(__val);
   686  #  endif
   687  	}
   688  #  if __HAVE_DISTINCT_FLOAT128
   689  	inline int issignaling(_Float128 __val) {
   690  		return __issignalingf128(__val);
   691  	}
   692  #  endif
   693  }				/* extern C++ */
   694  # endif
   695  
   696  /* Return nonzero value if X is subnormal.  */
   697  # define issubnormal(x) (fpclassify (x) == FP_SUBNORMAL)
   698  
   699  /* Return nonzero value if X is zero.  */
   700  # ifndef __cplusplus
   701  #  ifdef __SUPPORT_SNAN__
   702  #   define iszero(x) (fpclassify (x) == FP_ZERO)
   703  #  else
   704  #   define iszero(x) (((__typeof (x)) (x)) == 0)
   705  #  endif
   706  # else				/* __cplusplus */
   707  extern "C++" {
   708  #  ifdef __SUPPORT_SNAN__
   709  	inline int iszero(float __val) {
   710  		return __fpclassifyf(__val) == FP_ZERO;
   711  	} inline int iszero(double __val) {
   712  		return __fpclassify(__val) == FP_ZERO;
   713  	}
   714  	inline int iszero(long double __val) {
   715  #   ifdef __NO_LONG_DOUBLE_MATH
   716  		return __fpclassify(__val) == FP_ZERO;
   717  #   else
   718  		return __fpclassifyl(__val) == FP_ZERO;
   719  #   endif
   720  	}
   721  #   if __HAVE_DISTINCT_FLOAT128
   722  	inline int iszero(_Float128 __val) {
   723  		return __fpclassifyf128(__val) == FP_ZERO;
   724  	}
   725  #   endif
   726  #  else
   727  	template < class __T > inline bool iszero(__T __val) {
   728  		return __val == 0;
   729  	}
   730  #  endif
   731  }				/* extern C++ */
   732  # endif				/* __cplusplus */
   733  #endif				/* Use IEC_60559_BFP_EXT.  */
   734  #ifdef __USE_XOPEN
   735  /* X/Open wants another strange constant.  */
   736  # define MAXFLOAT	3.40282347e+38F
   737  #endif
   738  /* Some useful constants.  */
   739  #if defined __USE_MISC || defined __USE_XOPEN
   740  # define M_E		2.7182818284590452354	/* e */
   741  # define M_LOG2E	1.4426950408889634074	/* log_2 e */
   742  # define M_LOG10E	0.43429448190325182765	/* log_10 e */
   743  # define M_LN2		0.69314718055994530942	/* log_e 2 */
   744  # define M_LN10		2.30258509299404568402	/* log_e 10 */
   745  # define M_PI		3.14159265358979323846	/* pi */
   746  # define M_PI_2		1.57079632679489661923	/* pi/2 */
   747  # define M_PI_4		0.78539816339744830962	/* pi/4 */
   748  # define M_1_PI		0.31830988618379067154	/* 1/pi */
   749  # define M_2_PI		0.63661977236758134308	/* 2/pi */
   750  # define M_2_SQRTPI	1.12837916709551257390	/* 2/sqrt(pi) */
   751  # define M_SQRT2	1.41421356237309504880	/* sqrt(2) */
   752  # define M_SQRT1_2	0.70710678118654752440	/* 1/sqrt(2) */
   753  #endif
   754  /* The above constants are not adequate for computation using `long double's.
   755     Therefore we provide as an extension constants with similar names as a
   756     GNU extension.  Provide enough digits for the 128-bit IEEE quad.  */
   757  #ifdef __USE_GNU
   758  # define M_El		2.718281828459045235360287471352662498L	/* e */
   759  # define M_LOG2El	1.442695040888963407359924681001892137L	/* log_2 e */
   760  # define M_LOG10El	0.434294481903251827651128918916605082L	/* log_10 e */
   761  # define M_LN2l		0.693147180559945309417232121458176568L	/* log_e 2 */
   762  # define M_LN10l	2.302585092994045684017991454684364208L	/* log_e 10 */
   763  # define M_PIl		3.141592653589793238462643383279502884L	/* pi */
   764  # define M_PI_2l	1.570796326794896619231321691639751442L	/* pi/2 */
   765  # define M_PI_4l	0.785398163397448309615660845819875721L	/* pi/4 */
   766  # define M_1_PIl	0.318309886183790671537767526745028724L	/* 1/pi */
   767  # define M_2_PIl	0.636619772367581343075535053490057448L	/* 2/pi */
   768  # define M_2_SQRTPIl	1.128379167095512573896158903121545172L	/* 2/sqrt(pi) */
   769  # define M_SQRT2l	1.414213562373095048801688724209698079L	/* sqrt(2) */
   770  # define M_SQRT1_2l	0.707106781186547524400844362104849039L	/* 1/sqrt(2) */
   771  #endif
   772  #if __HAVE_FLOAT16 && defined __USE_GNU
   773  # define M_Ef16		__f16 (2.718281828459045235360287471352662498)	/* e */
   774  # define M_LOG2Ef16	__f16 (1.442695040888963407359924681001892137)	/* log_2 e */
   775  # define M_LOG10Ef16	__f16 (0.434294481903251827651128918916605082)	/* log_10 e */
   776  # define M_LN2f16	__f16 (0.693147180559945309417232121458176568)	/* log_e 2 */
   777  # define M_LN10f16	__f16 (2.302585092994045684017991454684364208)	/* log_e 10 */
   778  # define M_PIf16	__f16 (3.141592653589793238462643383279502884)	/* pi */
   779  # define M_PI_2f16	__f16 (1.570796326794896619231321691639751442)	/* pi/2 */
   780  # define M_PI_4f16	__f16 (0.785398163397448309615660845819875721)	/* pi/4 */
   781  # define M_1_PIf16	__f16 (0.318309886183790671537767526745028724)	/* 1/pi */
   782  # define M_2_PIf16	__f16 (0.636619772367581343075535053490057448)	/* 2/pi */
   783  # define M_2_SQRTPIf16	__f16 (1.128379167095512573896158903121545172)	/* 2/sqrt(pi) */
   784  # define M_SQRT2f16	__f16 (1.414213562373095048801688724209698079)	/* sqrt(2) */
   785  # define M_SQRT1_2f16	__f16 (0.707106781186547524400844362104849039)	/* 1/sqrt(2) */
   786  #endif
   787  #if __HAVE_FLOAT32 && defined __USE_GNU
   788  # define M_Ef32		__f32 (2.718281828459045235360287471352662498)	/* e */
   789  # define M_LOG2Ef32	__f32 (1.442695040888963407359924681001892137)	/* log_2 e */
   790  # define M_LOG10Ef32	__f32 (0.434294481903251827651128918916605082)	/* log_10 e */
   791  # define M_LN2f32	__f32 (0.693147180559945309417232121458176568)	/* log_e 2 */
   792  # define M_LN10f32	__f32 (2.302585092994045684017991454684364208)	/* log_e 10 */
   793  # define M_PIf32	__f32 (3.141592653589793238462643383279502884)	/* pi */
   794  # define M_PI_2f32	__f32 (1.570796326794896619231321691639751442)	/* pi/2 */
   795  # define M_PI_4f32	__f32 (0.785398163397448309615660845819875721)	/* pi/4 */
   796  # define M_1_PIf32	__f32 (0.318309886183790671537767526745028724)	/* 1/pi */
   797  # define M_2_PIf32	__f32 (0.636619772367581343075535053490057448)	/* 2/pi */
   798  # define M_2_SQRTPIf32	__f32 (1.128379167095512573896158903121545172)	/* 2/sqrt(pi) */
   799  # define M_SQRT2f32	__f32 (1.414213562373095048801688724209698079)	/* sqrt(2) */
   800  # define M_SQRT1_2f32	__f32 (0.707106781186547524400844362104849039)	/* 1/sqrt(2) */
   801  #endif
   802  #if __HAVE_FLOAT64 && defined __USE_GNU
   803  # define M_Ef64		__f64 (2.718281828459045235360287471352662498)	/* e */
   804  # define M_LOG2Ef64	__f64 (1.442695040888963407359924681001892137)	/* log_2 e */
   805  # define M_LOG10Ef64	__f64 (0.434294481903251827651128918916605082)	/* log_10 e */
   806  # define M_LN2f64	__f64 (0.693147180559945309417232121458176568)	/* log_e 2 */
   807  # define M_LN10f64	__f64 (2.302585092994045684017991454684364208)	/* log_e 10 */
   808  # define M_PIf64	__f64 (3.141592653589793238462643383279502884)	/* pi */
   809  # define M_PI_2f64	__f64 (1.570796326794896619231321691639751442)	/* pi/2 */
   810  # define M_PI_4f64	__f64 (0.785398163397448309615660845819875721)	/* pi/4 */
   811  # define M_1_PIf64	__f64 (0.318309886183790671537767526745028724)	/* 1/pi */
   812  # define M_2_PIf64	__f64 (0.636619772367581343075535053490057448)	/* 2/pi */
   813  # define M_2_SQRTPIf64	__f64 (1.128379167095512573896158903121545172)	/* 2/sqrt(pi) */
   814  # define M_SQRT2f64	__f64 (1.414213562373095048801688724209698079)	/* sqrt(2) */
   815  # define M_SQRT1_2f64	__f64 (0.707106781186547524400844362104849039)	/* 1/sqrt(2) */
   816  #endif
   817  #if __HAVE_FLOAT128 && defined __USE_GNU
   818  # define M_Ef128	__f128 (2.718281828459045235360287471352662498)	/* e */
   819  # define M_LOG2Ef128	__f128 (1.442695040888963407359924681001892137)	/* log_2 e */
   820  # define M_LOG10Ef128	__f128 (0.434294481903251827651128918916605082)	/* log_10 e */
   821  # define M_LN2f128	__f128 (0.693147180559945309417232121458176568)	/* log_e 2 */
   822  # define M_LN10f128	__f128 (2.302585092994045684017991454684364208)	/* log_e 10 */
   823  # define M_PIf128	__f128 (3.141592653589793238462643383279502884)	/* pi */
   824  # define M_PI_2f128	__f128 (1.570796326794896619231321691639751442)	/* pi/2 */
   825  # define M_PI_4f128	__f128 (0.785398163397448309615660845819875721)	/* pi/4 */
   826  # define M_1_PIf128	__f128 (0.318309886183790671537767526745028724)	/* 1/pi */
   827  # define M_2_PIf128	__f128 (0.636619772367581343075535053490057448)	/* 2/pi */
   828  # define M_2_SQRTPIf128	__f128 (1.128379167095512573896158903121545172)	/* 2/sqrt(pi) */
   829  # define M_SQRT2f128	__f128 (1.414213562373095048801688724209698079)	/* sqrt(2) */
   830  # define M_SQRT1_2f128	__f128 (0.707106781186547524400844362104849039)	/* 1/sqrt(2) */
   831  #endif
   832  #if __HAVE_FLOAT32X && defined __USE_GNU
   833  # define M_Ef32x	__f32x (2.718281828459045235360287471352662498)	/* e */
   834  # define M_LOG2Ef32x	__f32x (1.442695040888963407359924681001892137)	/* log_2 e */
   835  # define M_LOG10Ef32x	__f32x (0.434294481903251827651128918916605082)	/* log_10 e */
   836  # define M_LN2f32x	__f32x (0.693147180559945309417232121458176568)	/* log_e 2 */
   837  # define M_LN10f32x	__f32x (2.302585092994045684017991454684364208)	/* log_e 10 */
   838  # define M_PIf32x	__f32x (3.141592653589793238462643383279502884)	/* pi */
   839  # define M_PI_2f32x	__f32x (1.570796326794896619231321691639751442)	/* pi/2 */
   840  # define M_PI_4f32x	__f32x (0.785398163397448309615660845819875721)	/* pi/4 */
   841  # define M_1_PIf32x	__f32x (0.318309886183790671537767526745028724)	/* 1/pi */
   842  # define M_2_PIf32x	__f32x (0.636619772367581343075535053490057448)	/* 2/pi */
   843  # define M_2_SQRTPIf32x	__f32x (1.128379167095512573896158903121545172)	/* 2/sqrt(pi) */
   844  # define M_SQRT2f32x	__f32x (1.414213562373095048801688724209698079)	/* sqrt(2) */
   845  # define M_SQRT1_2f32x	__f32x (0.707106781186547524400844362104849039)	/* 1/sqrt(2) */
   846  #endif
   847  #if __HAVE_FLOAT64X && defined __USE_GNU
   848  # define M_Ef64x	__f64x (2.718281828459045235360287471352662498)	/* e */
   849  # define M_LOG2Ef64x	__f64x (1.442695040888963407359924681001892137)	/* log_2 e */
   850  # define M_LOG10Ef64x	__f64x (0.434294481903251827651128918916605082)	/* log_10 e */
   851  # define M_LN2f64x	__f64x (0.693147180559945309417232121458176568)	/* log_e 2 */
   852  # define M_LN10f64x	__f64x (2.302585092994045684017991454684364208)	/* log_e 10 */
   853  # define M_PIf64x	__f64x (3.141592653589793238462643383279502884)	/* pi */
   854  # define M_PI_2f64x	__f64x (1.570796326794896619231321691639751442)	/* pi/2 */
   855  # define M_PI_4f64x	__f64x (0.785398163397448309615660845819875721)	/* pi/4 */
   856  # define M_1_PIf64x	__f64x (0.318309886183790671537767526745028724)	/* 1/pi */
   857  # define M_2_PIf64x	__f64x (0.636619772367581343075535053490057448)	/* 2/pi */
   858  # define M_2_SQRTPIf64x	__f64x (1.128379167095512573896158903121545172)	/* 2/sqrt(pi) */
   859  # define M_SQRT2f64x	__f64x (1.414213562373095048801688724209698079)	/* sqrt(2) */
   860  # define M_SQRT1_2f64x	__f64x (0.707106781186547524400844362104849039)	/* 1/sqrt(2) */
   861  #endif
   862  #if __HAVE_FLOAT128X && defined __USE_GNU
   863  # error "M_* values needed for _Float128x"
   864  #endif
   865  /* When compiling in strict ISO C compatible mode we must not use the
   866     inline functions since they, among other things, do not set the
   867     `errno' variable correctly.  */
   868  #if defined __STRICT_ANSI__ && !defined __NO_MATH_INLINES
   869  # define __NO_MATH_INLINES	1
   870  #endif
   871  #ifdef __USE_ISOC99
   872  # if __GNUC_PREREQ (3, 1)
   873  /* ISO C99 defines some macros to compare number while taking care for
   874     unordered numbers.  Many FPUs provide special instructions to support
   875     these operations.  Generic support in GCC for these as builtins went
   876     in 2.97, but not all cpus added their patterns until 3.1.  Therefore
   877     we enable the builtins from 3.1 onwards and use a generic implementation
   878     othwerwise.  */
   879  #  define isgreater(x, y)	__builtin_isgreater(x, y)
   880  #  define isgreaterequal(x, y)	__builtin_isgreaterequal(x, y)
   881  #  define isless(x, y)		__builtin_isless(x, y)
   882  #  define islessequal(x, y)	__builtin_islessequal(x, y)
   883  #  define islessgreater(x, y)	__builtin_islessgreater(x, y)
   884  #  define isunordered(x, y)	__builtin_isunordered(x, y)
   885  # else
   886  #  define isgreater(x, y) \
   887    (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
   888  		    !isunordered (__x, __y) && __x > __y; }))
   889  #  define isgreaterequal(x, y) \
   890    (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
   891  		    !isunordered (__x, __y) && __x >= __y; }))
   892  #  define isless(x, y) \
   893    (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
   894  		    !isunordered (__x, __y) && __x < __y; }))
   895  #  define islessequal(x, y) \
   896    (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
   897  		    !isunordered (__x, __y) && __x <= __y; }))
   898  #  define islessgreater(x, y) \
   899    (__extension__ ({ __typeof__ (x) __x = (x); __typeof__ (y) __y = (y); \
   900  		    !isunordered (__x, __y) && __x != __y; }))
   901  /* isunordered must always check both operands first for signaling NaNs.  */
   902  #  define isunordered(x, y) \
   903    (__extension__ ({ __typeof__ (x) __u = (x); __typeof__ (y) __v = (y); \
   904  		    __u != __v && (__u != __u || __v != __v); }))
   905  # endif
   906  #endif
   907  /* Get machine-dependent inline versions (if there are any).  */
   908  #ifdef __USE_EXTERN_INLINES
   909  # include <bits/mathinline.h>
   910  #endif
   911  /* Define special entry points to use when the compiler got told to
   912     only expect finite results.  */
   913  #if defined __FINITE_MATH_ONLY__ && __FINITE_MATH_ONLY__ > 0
   914  /* Include bits/math-finite.h for double.  */
   915  # define _Mdouble_ double
   916  # define __MATH_DECLARING_DOUBLE 1
   917  # define __MATH_DECLARING_FLOATN 0
   918  # define __REDIRFROM_X(function, reentrant) \
   919    function ## reentrant
   920  # define __REDIRTO_X(function, reentrant) \
   921     __ ## function ## reentrant ## _finite
   922  # include <bits/math-finite.h>
   923  # undef _Mdouble_
   924  # undef __MATH_DECLARING_DOUBLE
   925  # undef __MATH_DECLARING_FLOATN
   926  # undef __REDIRFROM_X
   927  # undef __REDIRTO_X
   928  /* When __USE_ISOC99 is defined, include math-finite for float and
   929     long double, as well.  */
   930  # ifdef __USE_ISOC99
   931  /* Include bits/math-finite.h for float.  */
   932  #  define _Mdouble_ float
   933  #  define __MATH_DECLARING_DOUBLE 0
   934  #  define __MATH_DECLARING_FLOATN 0
   935  #  define __REDIRFROM_X(function, reentrant) \
   936    function ## f ## reentrant
   937  #  define __REDIRTO_X(function, reentrant) \
   938     __ ## function ## f ## reentrant ## _finite
   939  #  include <bits/math-finite.h>
   940  #  undef _Mdouble_
   941  #  undef __MATH_DECLARING_DOUBLE
   942  #  undef __MATH_DECLARING_FLOATN
   943  #  undef __REDIRFROM_X
   944  #  undef __REDIRTO_X
   945  /* Include bits/math-finite.h for long double.  */
   946  #  ifdef __MATH_DECLARE_LDOUBLE
   947  #   define _Mdouble_ long double
   948  #   define __MATH_DECLARING_DOUBLE 0
   949  #   define __MATH_DECLARING_FLOATN 0
   950  #   define __REDIRFROM_X(function, reentrant) \
   951    function ## l ## reentrant
   952  #   ifdef __NO_LONG_DOUBLE_MATH
   953  #    define __REDIRTO_X(function, reentrant) \
   954     __ ## function ## reentrant ## _finite
   955  #   else
   956  #    define __REDIRTO_X(function, reentrant) \
   957     __ ## function ## l ## reentrant ## _finite
   958  #   endif
   959  #   include <bits/math-finite.h>
   960  #   undef _Mdouble_
   961  #   undef __MATH_DECLARING_DOUBLE
   962  #   undef __MATH_DECLARING_FLOATN
   963  #   undef __REDIRFROM_X
   964  #   undef __REDIRTO_X
   965  #  endif
   966  # endif				/* __USE_ISOC99.  */
   967  /* Include bits/math-finite.h for _FloatN and _FloatNx.  */
   968  # if (__HAVE_DISTINCT_FLOAT16 || (__HAVE_FLOAT16 && !defined _LIBC))	\
   969        && __GLIBC_USE (IEC_60559_TYPES_EXT)
   970  #  define _Mdouble_ _Float16
   971  #  define __MATH_DECLARING_DOUBLE 0
   972  #  define __MATH_DECLARING_FLOATN 1
   973  #  define __REDIRFROM_X(function, reentrant) \
   974    function ## f16 ## reentrant
   975  #  if __HAVE_DISTINCT_FLOAT16
   976  #   define __REDIRTO_X(function, reentrant) \
   977     __ ## function ## f16 ## reentrant ## _finite
   978  #  else
   979  #   error "non-disinct _Float16"
   980  #  endif
   981  #  include <bits/math-finite.h>
   982  #  undef _Mdouble_
   983  #  undef __MATH_DECLARING_DOUBLE
   984  #  undef __MATH_DECLARING_FLOATN
   985  #  undef __REDIRFROM_X
   986  #  undef __REDIRTO_X
   987  # endif
   988  # if (__HAVE_DISTINCT_FLOAT32 || (__HAVE_FLOAT32 && !defined _LIBC))	\
   989        && __GLIBC_USE (IEC_60559_TYPES_EXT)
   990  #  define _Mdouble_ _Float32
   991  #  define __MATH_DECLARING_DOUBLE 0
   992  #  define __MATH_DECLARING_FLOATN 1
   993  #  define __REDIRFROM_X(function, reentrant) \
   994    function ## f32 ## reentrant
   995  #  if __HAVE_DISTINCT_FLOAT32
   996  #   define __REDIRTO_X(function, reentrant) \
   997     __ ## function ## f32 ## reentrant ## _finite
   998  #  else
   999  #   define __REDIRTO_X(function, reentrant) \
  1000     __ ## function ## f ## reentrant ## _finite
  1001  #  endif
  1002  #  include <bits/math-finite.h>
  1003  #  undef _Mdouble_
  1004  #  undef __MATH_DECLARING_DOUBLE
  1005  #  undef __MATH_DECLARING_FLOATN
  1006  #  undef __REDIRFROM_X
  1007  #  undef __REDIRTO_X
  1008  # endif
  1009  # if (__HAVE_DISTINCT_FLOAT64 || (__HAVE_FLOAT64 && !defined _LIBC))	\
  1010        && __GLIBC_USE (IEC_60559_TYPES_EXT)
  1011  #  define _Mdouble_ _Float64
  1012  #  define __MATH_DECLARING_DOUBLE 0
  1013  #  define __MATH_DECLARING_FLOATN 1
  1014  #  define __REDIRFROM_X(function, reentrant) \
  1015    function ## f64 ## reentrant
  1016  #  if __HAVE_DISTINCT_FLOAT64
  1017  #   define __REDIRTO_X(function, reentrant) \
  1018     __ ## function ## f64 ## reentrant ## _finite
  1019  #  else
  1020  #   define __REDIRTO_X(function, reentrant) \
  1021     __ ## function ## reentrant ## _finite
  1022  #  endif
  1023  #  include <bits/math-finite.h>
  1024  #  undef _Mdouble_
  1025  #  undef __MATH_DECLARING_DOUBLE
  1026  #  undef __MATH_DECLARING_FLOATN
  1027  #  undef __REDIRFROM_X
  1028  #  undef __REDIRTO_X
  1029  # endif
  1030  # if (__HAVE_DISTINCT_FLOAT128 || (__HAVE_FLOAT128 && !defined _LIBC))	\
  1031        && __GLIBC_USE (IEC_60559_TYPES_EXT)
  1032  #  define _Mdouble_ _Float128
  1033  #  define __MATH_DECLARING_DOUBLE 0
  1034  #  define __MATH_DECLARING_FLOATN 1
  1035  #  define __REDIRFROM_X(function, reentrant) \
  1036    function ## f128 ## reentrant
  1037  #  if __HAVE_DISTINCT_FLOAT128
  1038  #   define __REDIRTO_X(function, reentrant) \
  1039     __ ## function ## f128 ## reentrant ## _finite
  1040  #  else
  1041  #   define __REDIRTO_X(function, reentrant) \
  1042     __ ## function ## l ## reentrant ## _finite
  1043  #  endif
  1044  #  include <bits/math-finite.h>
  1045  #  undef _Mdouble_
  1046  #  undef __MATH_DECLARING_DOUBLE
  1047  #  undef __MATH_DECLARING_FLOATN
  1048  #  undef __REDIRFROM_X
  1049  #  undef __REDIRTO_X
  1050  # endif
  1051  # if (__HAVE_DISTINCT_FLOAT32X || (__HAVE_FLOAT32X && !defined _LIBC))	\
  1052        && __GLIBC_USE (IEC_60559_TYPES_EXT)
  1053  #  define _Mdouble_ _Float32x
  1054  #  define __MATH_DECLARING_DOUBLE 0
  1055  #  define __MATH_DECLARING_FLOATN 1
  1056  #  define __REDIRFROM_X(function, reentrant) \
  1057    function ## f32x ## reentrant
  1058  #  if __HAVE_DISTINCT_FLOAT32X
  1059  #   define __REDIRTO_X(function, reentrant) \
  1060     __ ## function ## f32x ## reentrant ## _finite
  1061  #  else
  1062  #   define __REDIRTO_X(function, reentrant) \
  1063     __ ## function ## reentrant ## _finite
  1064  #  endif
  1065  #  include <bits/math-finite.h>
  1066  #  undef _Mdouble_
  1067  #  undef __MATH_DECLARING_DOUBLE
  1068  #  undef __MATH_DECLARING_FLOATN
  1069  #  undef __REDIRFROM_X
  1070  #  undef __REDIRTO_X
  1071  # endif
  1072  # if (__HAVE_DISTINCT_FLOAT64X || (__HAVE_FLOAT64X && !defined _LIBC))	\
  1073        && __GLIBC_USE (IEC_60559_TYPES_EXT)
  1074  #  define _Mdouble_ _Float64x
  1075  #  define __MATH_DECLARING_DOUBLE 0
  1076  #  define __MATH_DECLARING_FLOATN 1
  1077  #  define __REDIRFROM_X(function, reentrant) \
  1078    function ## f64x ## reentrant
  1079  #  if __HAVE_DISTINCT_FLOAT64X
  1080  #   define __REDIRTO_X(function, reentrant) \
  1081     __ ## function ## f64x ## reentrant ## _finite
  1082  #  elif __HAVE_FLOAT64X_LONG_DOUBLE
  1083  #   define __REDIRTO_X(function, reentrant) \
  1084     __ ## function ## l ## reentrant ## _finite
  1085  #  else
  1086  #   define __REDIRTO_X(function, reentrant) \
  1087     __ ## function ## f128 ## reentrant ## _finite
  1088  #  endif
  1089  #  include <bits/math-finite.h>
  1090  #  undef _Mdouble_
  1091  #  undef __MATH_DECLARING_DOUBLE
  1092  #  undef __MATH_DECLARING_FLOATN
  1093  #  undef __REDIRFROM_X
  1094  #  undef __REDIRTO_X
  1095  # endif
  1096  # if (__HAVE_DISTINCT_FLOAT128X || (__HAVE_FLOAT128X && !defined _LIBC)) \
  1097        && __GLIBC_USE (IEC_60559_TYPES_EXT)
  1098  #  define _Mdouble_ _Float128x
  1099  #  define __MATH_DECLARING_DOUBLE 0
  1100  #  define __MATH_DECLARING_FLOATN 1
  1101  #  define __REDIRFROM_X(function, reentrant) \
  1102    function ## f128x ## reentrant
  1103  #  if __HAVE_DISTINCT_FLOAT128X
  1104  #   define __REDIRTO_X(function, reentrant) \
  1105     __ ## function ## f128x ## reentrant ## _finite
  1106  #  else
  1107  #   error "non-disinct _Float128x"
  1108  #  endif
  1109  #  include <bits/math-finite.h>
  1110  #  undef _Mdouble_
  1111  #  undef __MATH_DECLARING_DOUBLE
  1112  #  undef __MATH_DECLARING_FLOATN
  1113  #  undef __REDIRFROM_X
  1114  #  undef __REDIRTO_X
  1115  # endif
  1116  #endif				/* __FINITE_MATH_ONLY__ > 0.  */
  1117  #if __GLIBC_USE (IEC_60559_BFP_EXT)
  1118  /* An expression whose type has the widest of the evaluation formats
  1119     of X and Y (which are of floating-point types).  */
  1120  # if __FLT_EVAL_METHOD__ == 2 || __FLT_EVAL_METHOD__ > 64
  1121  #  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0L)
  1122  # elif __FLT_EVAL_METHOD__ == 1 || __FLT_EVAL_METHOD__ > 32
  1123  #  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0)
  1124  # elif __FLT_EVAL_METHOD__ == 0 || __FLT_EVAL_METHOD__ == 32
  1125  #  define __MATH_EVAL_FMT2(x, y) ((x) + (y) + 0.0f)
  1126  # else
  1127  #  define __MATH_EVAL_FMT2(x, y) ((x) + (y))
  1128  # endif
  1129  /* Return X == Y but raising "invalid" and setting errno if X or Y is
  1130     a NaN.  */
  1131  # if !defined __cplusplus || (__cplusplus < 201103L && !defined __GNUC__)
  1132  #  define iseqsig(x, y) \
  1133     __MATH_TG (__MATH_EVAL_FMT2 (x, y), __iseqsig, ((x), (y)))
  1134  # else
  1135  /* In C++ mode, __MATH_TG cannot be used, because it relies on
  1136     __builtin_types_compatible_p, which is a C-only builtin.  Moreover,
  1137     the comparison macros from ISO C take two floating-point arguments,
  1138     which need not have the same type.  Choosing what underlying function
  1139     to call requires evaluating the formats of the arguments, then
  1140     selecting which is wider.  The macro __MATH_EVAL_FMT2 provides this
  1141     information, however, only the type of the macro expansion is
  1142     relevant (actually evaluating the expression would be incorrect).
  1143     Thus, the type is used as a template parameter for __iseqsig_type,
  1144     which calls the appropriate underlying function.  */ extern "C++" {
  1145  	template < typename > struct __iseqsig_type;
  1146  
  1147  	 template <> struct __iseqsig_type <float > {
  1148  		static int __call(float __x, float __y) throw() {
  1149  			return __iseqsigf(__x, __y);
  1150  	}};
  1151  
  1152  	template <> struct __iseqsig_type <double > {
  1153  		static int __call(double __x, double __y) throw() {
  1154  			return __iseqsig(__x, __y);
  1155  	}};
  1156  
  1157  	template <> struct __iseqsig_type <long double > {
  1158  		static int __call(double __x, double __y) throw() {
  1159  #  ifndef __NO_LONG_DOUBLE_MATH
  1160  			return __iseqsigl(__x, __y);
  1161  #  else
  1162  			return __iseqsig(__x, __y);
  1163  #  endif
  1164  	}};
  1165  
  1166  #  if __HAVE_DISTINCT_FLOAT128
  1167  	template <> struct __iseqsig_type <_Float128 > {
  1168  		static int __call(_Float128 __x, _Float128 __y) throw() {
  1169  			return __iseqsigf128(__x, __y);
  1170  	}};
  1171  #  endif
  1172  
  1173  	template < typename _T1, typename _T2 > inline int iseqsig(_T1 __x, _T2 __y) throw() {
  1174  #  if __cplusplus >= 201103L
  1175  		typedef decltype(__MATH_EVAL_FMT2(__x, __y)) _T3;
  1176  #  else
  1177  		typedef __typeof(__MATH_EVAL_FMT2(__x, __y)) _T3;
  1178  #  endif
  1179  		return __iseqsig_type < _T3 >::__call(__x, __y);
  1180  	}
  1181  
  1182  }				/* extern "C++" */
  1183  # endif				/* __cplusplus */
  1184  
  1185  #endif
  1186  
  1187  __END_DECLS
  1188  #endif				/* math.h  */