Home | History | Annotate | Download | only in posix
      1 /*
      2  * Copyright (C) 2017 The Android Open Source Project
      3  * All rights reserved.
      4  *
      5  * Redistribution and use in source and binary forms, with or without
      6  * modification, are permitted provided that the following conditions
      7  * are met:
      8  *  * Redistributions of source code must retain the above copyright
      9  *    notice, this list of conditions and the following disclaimer.
     10  *  * Redistributions in binary form must reproduce the above copyright
     11  *    notice, this list of conditions and the following disclaimer in
     12  *    the documentation and/or other materials provided with the
     13  *    distribution.
     14  *
     15  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
     16  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
     17  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
     18  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
     19  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
     20  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     21  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
     22  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
     23  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
     24  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
     25  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     26  * SUCH DAMAGE.
     27  */
     28 
     29 #include <math.h>
     30 
     31 #include "header_checks.h"
     32 
     33 static void math_h() {
     34   TYPE(float_t);
     35   TYPE(double_t);
     36 
     37 #if !defined(fpclassify)
     38 #error fpclassify
     39 #endif
     40 #if !defined(isfinite)
     41 #error isfinite
     42 #endif
     43 #if !defined(isgreater)
     44 #error isgreater
     45 #endif
     46 #if !defined(isgreaterequal)
     47 #error isgreaterequal
     48 #endif
     49 #if !defined(isinf)
     50 #error isinf
     51 #endif
     52 #if !defined(isless)
     53 #error isless
     54 #endif
     55 #if !defined(islessequal)
     56 #error islessequal
     57 #endif
     58 #if !defined(islessgreater)
     59 #error islessgreater
     60 #endif
     61 #if !defined(isnan)
     62 #error isnan
     63 #endif
     64 #if !defined(isnormal)
     65 #error isnormal
     66 #endif
     67 #if !defined(isunordered)
     68 #error isunordered
     69 #endif
     70 #if !defined(signbit)
     71 #error signbit
     72 #endif
     73 
     74   MACRO(M_E);
     75   MACRO(M_LOG2E);
     76   MACRO(M_LOG10E);
     77   MACRO(M_LN2);
     78   MACRO(M_LN10);
     79   MACRO(M_PI);
     80   MACRO(M_PI_2);
     81   MACRO(M_PI_4);
     82   MACRO(M_1_PI);
     83   MACRO(M_2_PI);
     84   MACRO(M_2_SQRTPI);
     85   MACRO(M_SQRT2);
     86   MACRO(M_SQRT1_2);
     87 
     88   MACRO(MAXFLOAT);
     89 
     90   MACRO(HUGE_VAL);
     91   MACRO(HUGE_VALF);
     92   MACRO(HUGE_VALL);
     93   MACRO(INFINITY);
     94   MACRO(NAN);
     95 
     96   MACRO(FP_INFINITE);
     97   MACRO(FP_NAN);
     98   MACRO(FP_NORMAL);
     99   MACRO(FP_SUBNORMAL);
    100   MACRO(FP_ZERO);
    101 
    102 #if defined(FP_FAST_FMA) && FP_FAST_FMA != 1
    103 #error FP_FAST_FMA
    104 #endif
    105 #if defined(FP_FAST_FMAF) && FP_FAST_FMAF != 1
    106 #error FP_FAST_FMAF
    107 #endif
    108 #if defined(FP_FAST_FMAL) && FP_FAST_FMAL != 1
    109 #error FP_FAST_FMAL
    110 #endif
    111 
    112   MACRO(FP_ILOGB0);
    113   MACRO(FP_ILOGBNAN);
    114 
    115   MACRO_VALUE(MATH_ERRNO, 1);
    116   MACRO_VALUE(MATH_ERREXCEPT, 2);
    117 
    118 #if !defined(math_errhandling)
    119 #error math_errhandling
    120 #endif
    121   MACRO_TYPE(int, math_errhandling);
    122 
    123   FUNCTION(acos, double (*f)(double));
    124   FUNCTION(acosf, float (*f)(float));
    125   FUNCTION(acosh, double (*f)(double));
    126   FUNCTION(acoshf, float (*f)(float));
    127   FUNCTION(acoshl, long double (*f)(long double));
    128   FUNCTION(acosl, long double (*f)(long double));
    129 
    130   FUNCTION(asin, double (*f)(double));
    131   FUNCTION(asinf, float (*f)(float));
    132   FUNCTION(asinh, double (*f)(double));
    133   FUNCTION(asinhf, float (*f)(float));
    134   FUNCTION(asinhl, long double (*f)(long double));
    135   FUNCTION(asinl, long double (*f)(long double));
    136 
    137   FUNCTION(atan, double (*f)(double));
    138   FUNCTION(atan2, double (*f)(double, double));
    139   FUNCTION(atan2f, float (*f)(float, float));
    140   FUNCTION(atan2l, long double (*f)(long double, long double));
    141   FUNCTION(atanf, float (*f)(float));
    142   FUNCTION(atanh, double (*f)(double));
    143   FUNCTION(atanhf, float (*f)(float));
    144   FUNCTION(atanhl, long double (*f)(long double));
    145   FUNCTION(atanl, long double (*f)(long double));
    146 
    147   FUNCTION(cbrt, double (*f)(double));
    148   FUNCTION(cbrtf, float (*f)(float));
    149   FUNCTION(cbrtl, long double (*f)(long double));
    150 
    151   FUNCTION(ceil, double (*f)(double));
    152   FUNCTION(ceilf, float (*f)(float));
    153   FUNCTION(ceill, long double (*f)(long double));
    154 
    155   FUNCTION(copysign, double (*f)(double, double));
    156   FUNCTION(copysignf, float (*f)(float, float));
    157   FUNCTION(copysignl, long double (*f)(long double, long double));
    158 
    159   FUNCTION(cos, double (*f)(double));
    160   FUNCTION(cosf, float (*f)(float));
    161   FUNCTION(cosh, double (*f)(double));
    162   FUNCTION(coshf, float (*f)(float));
    163   FUNCTION(coshl, long double (*f)(long double));
    164   FUNCTION(cosl, long double (*f)(long double));
    165 
    166   FUNCTION(erf, double (*f)(double));
    167   FUNCTION(erfc, double (*f)(double));
    168   FUNCTION(erfcf, float (*f)(float));
    169   FUNCTION(erfcl, long double (*f)(long double));
    170   FUNCTION(erff, float (*f)(float));
    171   FUNCTION(erfl, long double (*f)(long double));
    172 
    173   FUNCTION(exp, double (*f)(double));
    174   FUNCTION(exp2, double (*f)(double));
    175   FUNCTION(exp2f, float (*f)(float));
    176   FUNCTION(exp2l, long double (*f)(long double));
    177   FUNCTION(expf, float (*f)(float));
    178   FUNCTION(expl, long double (*f)(long double));
    179   FUNCTION(expm1, double (*f)(double));
    180   FUNCTION(expm1f, float (*f)(float));
    181   FUNCTION(expm1l, long double (*f)(long double));
    182 
    183   FUNCTION(fabs, double (*f)(double));
    184   FUNCTION(fabsf, float (*f)(float));
    185   FUNCTION(fabsl, long double (*f)(long double));
    186 
    187   FUNCTION(fdim, double (*f)(double, double));
    188   FUNCTION(fdimf, float (*f)(float, float));
    189   FUNCTION(fdiml, long double (*f)(long double, long double));
    190 
    191   FUNCTION(floor, double (*f)(double));
    192   FUNCTION(floorf, float (*f)(float));
    193   FUNCTION(floorl, long double (*f)(long double));
    194 
    195   FUNCTION(fma, double (*f)(double, double, double));
    196   FUNCTION(fmaf, float (*f)(float, float, float));
    197   FUNCTION(fmal, long double (*f)(long double, long double, long double));
    198 
    199   FUNCTION(fmax, double (*f)(double, double));
    200   FUNCTION(fmaxf, float (*f)(float, float));
    201   FUNCTION(fmaxl, long double (*f)(long double, long double));
    202 
    203   FUNCTION(fmin, double (*f)(double, double));
    204   FUNCTION(fminf, float (*f)(float, float));
    205   FUNCTION(fminl, long double (*f)(long double, long double));
    206 
    207   FUNCTION(fmod, double (*f)(double, double));
    208   FUNCTION(fmodf, float (*f)(float, float));
    209   FUNCTION(fmodl, long double (*f)(long double, long double));
    210 
    211   FUNCTION(frexp, double (*f)(double, int*));
    212   FUNCTION(frexpf, float (*f)(float, int*));
    213   FUNCTION(frexpl, long double (*f)(long double, int*));
    214 
    215   FUNCTION(hypot, double (*f)(double, double));
    216   FUNCTION(hypotf, float (*f)(float, float));
    217   FUNCTION(hypotl, long double (*f)(long double, long double));
    218 
    219   FUNCTION(ilogb, int (*f)(double));
    220   FUNCTION(ilogbf, int (*f)(float));
    221   FUNCTION(ilogbl, int (*f)(long double));
    222 
    223   FUNCTION(j0, double (*f)(double));
    224   FUNCTION(j1, double (*f)(double));
    225   FUNCTION(jn, double (*f)(int, double));
    226 
    227   FUNCTION(ldexp, double (*f)(double, int));
    228   FUNCTION(ldexpf, float (*f)(float, int));
    229   FUNCTION(ldexpl, long double (*f)(long double, int));
    230 
    231   FUNCTION(lgamma, double (*f)(double));
    232   FUNCTION(lgammaf, float (*f)(float));
    233   FUNCTION(lgammal, long double (*f)(long double));
    234 
    235   FUNCTION(llrint, long long (*f)(double));
    236   FUNCTION(llrintf, long long (*f)(float));
    237   FUNCTION(llrintl, long long (*f)(long double));
    238 
    239   FUNCTION(llround, long long (*f)(double));
    240   FUNCTION(llroundf, long long (*f)(float));
    241   FUNCTION(llroundl, long long (*f)(long double));
    242 
    243   FUNCTION(log, double (*f)(double));
    244   FUNCTION(log10, double (*f)(double));
    245   FUNCTION(log10f, float (*f)(float));
    246   FUNCTION(log10l, long double (*f)(long double));
    247   FUNCTION(log1p, double (*f)(double));
    248   FUNCTION(log1pf, float (*f)(float));
    249   FUNCTION(log1pl, long double (*f)(long double));
    250   FUNCTION(log2, double (*f)(double));
    251   FUNCTION(log2f, float (*f)(float));
    252   FUNCTION(log2l, long double (*f)(long double));
    253   FUNCTION(logb, double (*f)(double));
    254   FUNCTION(logbf, float (*f)(float));
    255   FUNCTION(logbl, long double (*f)(long double));
    256   FUNCTION(logf, float (*f)(float));
    257   FUNCTION(logl, long double (*f)(long double));
    258 
    259   FUNCTION(lrint, long (*f)(double));
    260   FUNCTION(lrintf, long (*f)(float));
    261   FUNCTION(lrintl, long (*f)(long double));
    262 
    263   FUNCTION(lround, long (*f)(double));
    264   FUNCTION(lroundf, long (*f)(float));
    265   FUNCTION(lroundl, long (*f)(long double));
    266 
    267   FUNCTION(modf, double (*f)(double, double*));
    268   FUNCTION(modff, float (*f)(float, float*));
    269   FUNCTION(modfl, long double (*f)(long double, long double*));
    270 
    271   FUNCTION(nan, double (*f)(const char*));
    272   FUNCTION(nanf, float (*f)(const char*));
    273   FUNCTION(nanl, long double (*f)(const char*));
    274 
    275   FUNCTION(nearbyint, double (*f)(double));
    276   FUNCTION(nearbyintf, float (*f)(float));
    277   FUNCTION(nearbyintl, long double (*f)(long double));
    278 
    279   FUNCTION(nextafter, double (*f)(double, double));
    280   FUNCTION(nextafterf, float (*f)(float, float));
    281   FUNCTION(nextafterl, long double (*f)(long double, long double));
    282 
    283   FUNCTION(nexttoward, double (*f)(double, long double));
    284   FUNCTION(nexttowardf, float (*f)(float, long double));
    285   FUNCTION(nexttowardl, long double (*f)(long double, long double));
    286 
    287   FUNCTION(pow, double (*f)(double, double));
    288   FUNCTION(powf, float (*f)(float, float));
    289   FUNCTION(powl, long double (*f)(long double, long double));
    290 
    291   FUNCTION(remainder, double (*f)(double, double));
    292   FUNCTION(remainderf, float (*f)(float, float));
    293   FUNCTION(remainderl, long double (*f)(long double, long double));
    294 
    295   FUNCTION(remquo, double (*f)(double, double, int*));
    296   FUNCTION(remquof, float (*f)(float, float, int*));
    297   FUNCTION(remquol, long double (*f)(long double, long double, int*));
    298 
    299   FUNCTION(rint, double (*f)(double));
    300   FUNCTION(rintf, float (*f)(float));
    301   FUNCTION(rintl, long double (*f)(long double));
    302 
    303   FUNCTION(round, double (*f)(double));
    304   FUNCTION(roundf, float (*f)(float));
    305   FUNCTION(roundl, long double (*f)(long double));
    306 
    307   FUNCTION(scalbln, double (*f)(double, long));
    308   FUNCTION(scalblnf, float (*f)(float, long));
    309   FUNCTION(scalblnl, long double (*f)(long double, long));
    310 
    311   FUNCTION(scalbn, double (*f)(double, int));
    312   FUNCTION(scalbnf, float (*f)(float, int));
    313   FUNCTION(scalbnl, long double (*f)(long double, int));
    314 
    315   FUNCTION(sin, double (*f)(double));
    316   FUNCTION(sinf, float (*f)(float));
    317   FUNCTION(sinh, double (*f)(double));
    318   FUNCTION(sinhf, float (*f)(float));
    319   FUNCTION(sinhl, long double (*f)(long double));
    320   FUNCTION(sinl, long double (*f)(long double));
    321 
    322   FUNCTION(sqrt, double (*f)(double));
    323   FUNCTION(sqrtf, float (*f)(float));
    324   FUNCTION(sqrtl, long double (*f)(long double));
    325 
    326   FUNCTION(tan, double (*f)(double));
    327   FUNCTION(tanf, float (*f)(float));
    328   FUNCTION(tanh, double (*f)(double));
    329   FUNCTION(tanhf, float (*f)(float));
    330   FUNCTION(tanhl, long double (*f)(long double));
    331   FUNCTION(tanl, long double (*f)(long double));
    332 
    333   FUNCTION(tgamma, double (*f)(double));
    334   FUNCTION(tgammaf, float (*f)(float));
    335   FUNCTION(tgammal, long double (*f)(long double));
    336 
    337   FUNCTION(trunc, double (*f)(double));
    338   FUNCTION(truncf, float (*f)(float));
    339   FUNCTION(truncl, long double (*f)(long double));
    340 
    341   FUNCTION(y0, double (*f)(double));
    342   FUNCTION(y1, double (*f)(double));
    343   FUNCTION(yn, double (*f)(int, double));
    344 
    345   int s = signgam;
    346 }
    347