Home | History | Annotate | Download | only in bits
      1 /* Prototype declarations for math functions; helper file for <math.h>.
      2    Copyright (C) 1996-2002, 2003, 2006 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, write to the Free
     17    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
     18    02111-1307 USA.  */
     19 
     20 /* NOTE: Because of the special way this file is used by <math.h>, this
     21    file must NOT be protected from multiple inclusion as header files
     22    usually are.
     23 
     24    This file provides prototype declarations for the math functions.
     25    Most functions are declared using the macro:
     26 
     27    __MATHCALL (NAME,[_r], (ARGS...));
     28 
     29    This means there is a function `NAME' returning `double' and a function
     30    `NAMEf' returning `float'.  Each place `_Mdouble_' appears in the
     31    prototype, that is actually `double' in the prototype for `NAME' and
     32    `float' in the prototype for `NAMEf'.  Reentrant variant functions are
     33    called `NAME_r' and `NAMEf_r'.
     34 
     35    Functions returning other types like `int' are declared using the macro:
     36 
     37    __MATHDECL (TYPE, NAME,[_r], (ARGS...));
     38 
     39    This is just like __MATHCALL but for a function returning `TYPE'
     40    instead of `_Mdouble_'.  In all of these cases, there is still
     41    both a `NAME' and a `NAMEf' that takes `float' arguments.
     42 
     43    Note that there must be no whitespace before the argument passed for
     44    NAME, to make token pasting work with -traditional.  */
     45 
     46 #ifndef _MATH_H
     47 # error "Never include <bits/mathcalls.h> directly; include <math.h> instead."
     48 #endif
     49 
     50 
     51 /* Trigonometric functions.  */
     52 
     53 _Mdouble_BEGIN_NAMESPACE
     54 /* Arc cosine of X.  */
     55 __MATHCALL (acos,, (_Mdouble_ __x));
     56 /* Arc sine of X.  */
     57 __MATHCALL (asin,, (_Mdouble_ __x));
     58 /* Arc tangent of X.  */
     59 __MATHCALL (atan,, (_Mdouble_ __x));
     60 /* Arc tangent of Y/X.  */
     61 __MATHCALL (atan2,, (_Mdouble_ __y, _Mdouble_ __x));
     62 
     63 /* Cosine of X.  */
     64 __MATHCALL (cos,, (_Mdouble_ __x));
     65 /* Sine of X.  */
     66 __MATHCALL (sin,, (_Mdouble_ __x));
     67 /* Tangent of X.  */
     68 __MATHCALL (tan,, (_Mdouble_ __x));
     69 
     70 /* Hyperbolic functions.  */
     71 
     72 /* Hyperbolic cosine of X.  */
     73 __MATHCALL (cosh,, (_Mdouble_ __x));
     74 /* Hyperbolic sine of X.  */
     75 __MATHCALL (sinh,, (_Mdouble_ __x));
     76 /* Hyperbolic tangent of X.  */
     77 __MATHCALL (tanh,, (_Mdouble_ __x));
     78 _Mdouble_END_NAMESPACE
     79 
     80 #ifdef __USE_GNU
     81 /* Cosine and sine of X.  */
     82 __MATHDECL (void,sincos,,
     83 	    (_Mdouble_ __x, _Mdouble_ *__sinx, _Mdouble_ *__cosx));
     84 #endif
     85 
     86 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
     87 __BEGIN_NAMESPACE_C99
     88 /* Hyperbolic arc cosine of X.  */
     89 __MATHCALL (acosh,, (_Mdouble_ __x));
     90 /* Hyperbolic arc sine of X.  */
     91 __MATHCALL (asinh,, (_Mdouble_ __x));
     92 /* Hyperbolic arc tangent of X.  */
     93 __MATHCALL (atanh,, (_Mdouble_ __x));
     94 __END_NAMESPACE_C99
     95 #endif
     96 
     97 /* Exponential and logarithmic functions.  */
     98 
     99 _Mdouble_BEGIN_NAMESPACE
    100 /* Exponential function of X.  */
    101 __MATHCALL (exp,, (_Mdouble_ __x));
    102 
    103 /* Break VALUE into a normalized fraction and an integral power of 2.  */
    104 __MATHCALL (frexp,, (_Mdouble_ __x, int *__exponent));
    105 
    106 /* X times (two to the EXP power).  */
    107 __MATHCALL (ldexp,, (_Mdouble_ __x, int __exponent));
    108 
    109 /* Natural logarithm of X.  */
    110 __MATHCALL (log,, (_Mdouble_ __x));
    111 
    112 /* Base-ten logarithm of X.  */
    113 __MATHCALL (log10,, (_Mdouble_ __x));
    114 
    115 /* Break VALUE into integral and fractional parts.  */
    116 __MATHCALL (modf,, (_Mdouble_ __x, _Mdouble_ *__iptr));
    117 _Mdouble_END_NAMESPACE
    118 
    119 #ifdef __USE_GNU
    120 /* A function missing in all standards: compute exponent to base ten.  */
    121 __MATHCALL (exp10,, (_Mdouble_ __x));
    122 /* Another name occasionally used.  */
    123 __MATHCALL (pow10,, (_Mdouble_ __x));
    124 #endif
    125 
    126 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
    127 __BEGIN_NAMESPACE_C99
    128 /* Return exp(X) - 1.  */
    129 __MATHCALL (expm1,, (_Mdouble_ __x));
    130 
    131 /* Return log(1 + X).  */
    132 __MATHCALL (log1p,, (_Mdouble_ __x));
    133 
    134 /* Return the base 2 signed integral exponent of X.  */
    135 __MATHCALL (logb,, (_Mdouble_ __x));
    136 __END_NAMESPACE_C99
    137 #endif
    138 
    139 #ifdef __USE_ISOC99
    140 __BEGIN_NAMESPACE_C99
    141 /* Compute base-2 exponential of X.  */
    142 __MATHCALL (exp2,, (_Mdouble_ __x));
    143 
    144 /* Compute base-2 logarithm of X.  */
    145 __MATHCALL (log2,, (_Mdouble_ __x));
    146 __END_NAMESPACE_C99
    147 #endif
    148 
    149 
    150 /* Power functions.  */
    151 
    152 _Mdouble_BEGIN_NAMESPACE
    153 /* Return X to the Y power.  */
    154 __MATHCALL (pow,, (_Mdouble_ __x, _Mdouble_ __y));
    155 
    156 /* Return the square root of X.  */
    157 __MATHCALL (sqrt,, (_Mdouble_ __x));
    158 _Mdouble_END_NAMESPACE
    159 
    160 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
    161 __BEGIN_NAMESPACE_C99
    162 /* Return `sqrt(X*X + Y*Y)'.  */
    163 __MATHCALL (hypot,, (_Mdouble_ __x, _Mdouble_ __y));
    164 __END_NAMESPACE_C99
    165 #endif
    166 
    167 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
    168 __BEGIN_NAMESPACE_C99
    169 /* Return the cube root of X.  */
    170 __MATHCALL (cbrt,, (_Mdouble_ __x));
    171 __END_NAMESPACE_C99
    172 #endif
    173 
    174 
    175 /* Nearest integer, absolute value, and remainder functions.  */
    176 
    177 _Mdouble_BEGIN_NAMESPACE
    178 /* Smallest integral value not less than X.  */
    179 __MATHCALLX (ceil,, (_Mdouble_ __x), (__const__));
    180 
    181 /* Absolute value of X.  */
    182 __MATHCALLX (fabs,, (_Mdouble_ __x), (__const__));
    183 
    184 /* Largest integer not greater than X.  */
    185 __MATHCALLX (floor,, (_Mdouble_ __x), (__const__));
    186 
    187 /* Floating-point modulo remainder of X/Y.  */
    188 __MATHCALL (fmod,, (_Mdouble_ __x, _Mdouble_ __y));
    189 
    190 
    191 /* Return 0 if VALUE is finite or NaN, +1 if it
    192    is +Infinity, -1 if it is -Infinity.  */
    193 __MATHDECL_1 (int,__isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
    194 
    195 /* Return nonzero if VALUE is finite and not NaN.  */
    196 __MATHDECL_1 (int,__finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
    197 _Mdouble_END_NAMESPACE
    198 
    199 #ifdef __USE_MISC
    200 /* Return 0 if VALUE is finite or NaN, +1 if it
    201    is +Infinity, -1 if it is -Infinity.  */
    202 __MATHDECL_1 (int,isinf,, (_Mdouble_ __value)) __attribute__ ((__const__));
    203 
    204 /* Return nonzero if VALUE is finite and not NaN.  */
    205 __MATHDECL_1 (int,finite,, (_Mdouble_ __value)) __attribute__ ((__const__));
    206 
    207 /* Return the remainder of X/Y.  */
    208 __MATHCALL (drem,, (_Mdouble_ __x, _Mdouble_ __y));
    209 
    210 
    211 /* Return the fractional part of X after dividing out `ilogb (X)'.  */
    212 __MATHCALL (significand,, (_Mdouble_ __x));
    213 #endif /* Use misc.  */
    214 
    215 #if defined __USE_MISC || defined __USE_ISOC99
    216 __BEGIN_NAMESPACE_C99
    217 /* Return X with its signed changed to Y's.  */
    218 __MATHCALLX (copysign,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
    219 __END_NAMESPACE_C99
    220 #endif
    221 
    222 #ifdef __USE_ISOC99
    223 __BEGIN_NAMESPACE_C99
    224 /* Return representation of NaN for double type.  */
    225 __MATHCALLX (nan,, (__const char *__tagb), (__const__));
    226 __END_NAMESPACE_C99
    227 #endif
    228 
    229 
    230 /* Return nonzero if VALUE is not a number.  */
    231 __MATHDECL_1 (int,__isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
    232 
    233 #if defined __USE_MISC || defined __USE_XOPEN
    234 /* Return nonzero if VALUE is not a number.  */
    235 __MATHDECL_1 (int,isnan,, (_Mdouble_ __value)) __attribute__ ((__const__));
    236 
    237 /* Bessel functions.  */
    238 __MATHCALL (j0,, (_Mdouble_));
    239 __MATHCALL (j1,, (_Mdouble_));
    240 __MATHCALL (jn,, (int, _Mdouble_));
    241 __MATHCALL (y0,, (_Mdouble_));
    242 __MATHCALL (y1,, (_Mdouble_));
    243 __MATHCALL (yn,, (int, _Mdouble_));
    244 #endif
    245 
    246 
    247 #if defined __USE_MISC || defined __USE_XOPEN || defined __USE_ISOC99
    248 __BEGIN_NAMESPACE_C99
    249 /* Error and gamma functions.  */
    250 __MATHCALL (erf,, (_Mdouble_));
    251 __MATHCALL (erfc,, (_Mdouble_));
    252 __MATHCALL (lgamma,, (_Mdouble_));
    253 __END_NAMESPACE_C99
    254 #endif
    255 
    256 #ifdef __USE_ISOC99
    257 __BEGIN_NAMESPACE_C99
    258 /* True gamma function.  */
    259 __MATHCALL (tgamma,, (_Mdouble_));
    260 __END_NAMESPACE_C99
    261 #endif
    262 
    263 #if defined __USE_MISC || defined __USE_XOPEN
    264 /* Obsolete alias for `lgamma'.  */
    265 __MATHCALL (gamma,, (_Mdouble_));
    266 #endif
    267 
    268 #ifdef __USE_MISC
    269 /* Reentrant version of lgamma.  This function uses the global variable
    270    `signgam'.  The reentrant version instead takes a pointer and stores
    271    the value through it.  */
    272 __MATHCALL (lgamma,_r, (_Mdouble_, int *__signgamp));
    273 #endif
    274 
    275 
    276 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
    277 __BEGIN_NAMESPACE_C99
    278 /* Return the integer nearest X in the direction of the
    279    prevailing rounding mode.  */
    280 __MATHCALL (rint,, (_Mdouble_ __x));
    281 
    282 /* Return X + epsilon if X < Y, X - epsilon if X > Y.  */
    283 __MATHCALLX (nextafter,, (_Mdouble_ __x, _Mdouble_ __y), (__const__));
    284 # if defined __USE_ISOC99 && !defined __LDBL_COMPAT
    285 __MATHCALLX (nexttoward,, (_Mdouble_ __x, long double __y), (__const__));
    286 # endif
    287 
    288 /* Return the remainder of integer divison X / Y with infinite precision.  */
    289 __MATHCALL (remainder,, (_Mdouble_ __x, _Mdouble_ __y));
    290 
    291 # if defined __USE_MISC || defined __USE_ISOC99
    292 /* Return X times (2 to the Nth power).  */
    293 __MATHCALL (scalbn,, (_Mdouble_ __x, int __n));
    294 # endif
    295 
    296 /* Return the binary exponent of X, which must be nonzero.  */
    297 __MATHDECL (int,ilogb,, (_Mdouble_ __x));
    298 #endif
    299 
    300 #ifdef __USE_ISOC99
    301 /* Return X times (2 to the Nth power).  */
    302 __MATHCALL (scalbln,, (_Mdouble_ __x, long int __n));
    303 
    304 /* Round X to integral value in floating-point format using current
    305    rounding direction, but do not raise inexact exception.  */
    306 __MATHCALL (nearbyint,, (_Mdouble_ __x));
    307 
    308 /* Round X to nearest integral value, rounding halfway cases away from
    309    zero.  */
    310 __MATHCALLX (round,, (_Mdouble_ __x), (__const__));
    311 
    312 /* Round X to the integral value in floating-point format nearest but
    313    not larger in magnitude.  */
    314 __MATHCALLX (trunc,, (_Mdouble_ __x), (__const__));
    315 
    316 /* Compute remainder of X and Y and put in *QUO a value with sign of x/y
    317    and magnitude congruent `mod 2^n' to the magnitude of the integral
    318    quotient x/y, with n >= 3.  */
    319 __MATHCALL (remquo,, (_Mdouble_ __x, _Mdouble_ __y, int *__quo));
    320 
    321 
    322 /* Conversion functions.  */
    323 
    324 /* Round X to nearest integral value according to current rounding
    325    direction.  */
    326 __MATHDECL (long int,lrint,, (_Mdouble_ __x));
    327 __MATHDECL (long long int,llrint,, (_Mdouble_ __x));
    328 
    329 /* Round X to nearest integral value, rounding halfway cases away from
    330    zero.  */
    331 __MATHDECL (long int,lround,, (_Mdouble_ __x));
    332 __MATHDECL (long long int,llround,, (_Mdouble_ __x));
    333 
    334 
    335 /* Return positive difference between X and Y.  */
    336 __MATHCALL (fdim,, (_Mdouble_ __x, _Mdouble_ __y));
    337 
    338 /* Return maximum numeric value from X and Y.  */
    339 __MATHCALL (fmax,, (_Mdouble_ __x, _Mdouble_ __y));
    340 
    341 /* Return minimum numeric value from X and Y.  */
    342 __MATHCALL (fmin,, (_Mdouble_ __x, _Mdouble_ __y));
    343 
    344 
    345 /* Classify given number.  */
    346 __MATHDECL_1 (int, __fpclassify,, (_Mdouble_ __value))
    347      __attribute__ ((__const__));
    348 
    349 /* Test for negative number.  */
    350 __MATHDECL_1 (int, __signbit,, (_Mdouble_ __value))
    351      __attribute__ ((__const__));
    352 
    353 
    354 /* Multiply-add function computed as a ternary operation.  */
    355 __MATHCALL (fma,, (_Mdouble_ __x, _Mdouble_ __y, _Mdouble_ __z));
    356 #endif /* Use ISO C99.  */
    357 
    358 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED || defined __USE_ISOC99
    359 __END_NAMESPACE_C99
    360 #endif
    361 
    362 #if defined __USE_MISC || defined __USE_XOPEN_EXTENDED
    363 /* Return X times (2 to the Nth power).  */
    364 __MATHCALL (scalb,, (_Mdouble_ __x, _Mdouble_ __n));
    365 #endif
    366