gonzui


Format: Advanced Search

t2ex/bsd_source/lib/libc/src_bsd/include/math.hbare sourcepermlink (0.03 seconds)

Search this content:

    1: /*      $OpenBSD: math.h,v 1.30 2011/07/06 00:02:42 martynas Exp $   */
    2: /*
    3:  * ====================================================
    4:  * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
    5:  *
    6:  * Developed at SunPro, a Sun Microsystems, Inc. business.
    7:  * Permission to use, copy, modify, and distribute this
    8:  * software is freely granted, provided that this notice 
    9:  * is preserved.
   10:  * ====================================================
   11:  */
   12: 
   13: /*
   14:  * from: @(#)fdlibm.h 5.1 93/09/24
   15:  */
   16: 
   17: #ifndef _MATH_H_
   18: #define _MATH_H_
   19: 
   20: #include <sys/cdefs.h>
   21: #include <sys/_types.h>
   22: #include <sys/limits.h>
   23: 
   24: __BEGIN_DECLS
   25: /*
   26:  * ANSI/POSIX
   27:  */
   28: extern char __infinity[];
   29: #if __GNUC_PREREQ__(3, 3)
   30: #define HUGE_VAL        __builtin_huge_val()
   31: #else /* __GNUC_PREREQ__(3, 3) */
   32: #define HUGE_VAL        (*(double *)(void *)__infinity)
   33: #endif /* __GNUC_PREREQ__(3, 3) */
   34: 
   35: /*
   36:  * C99
   37:  */
   38: #if __ISO_C_VISIBLE >= 1999
   39: typedef __double_t      double_t;
   40: typedef __float_t       float_t;
   41: 
   42: #if __GNUC_PREREQ__(3, 3)
   43: #define HUGE_VALF       __builtin_huge_valf()
   44: #define HUGE_VALL       __builtin_huge_vall()
   45: #define INFINITY        __builtin_inff()
   46: #define NAN             __builtin_nanf("")
   47: #else /* __GNUC_PREREQ__(3, 3) */
   48: #ifdef __vax__
   49: extern char __infinityf[];
   50: #define HUGE_VALF       (*(float *)(void *)__infinityf)
   51: #else /* __vax__ */
   52: #define HUGE_VALF       ((float)HUGE_VAL)
   53: #endif /* __vax__ */
   54: #define HUGE_VALL       ((long double)HUGE_VAL)
   55: #define INFINITY        HUGE_VALF
   56: #ifndef __vax__
   57: extern char __nan[];
   58: #define NAN             (*(float *)(void *)__nan)
   59: #endif /* !__vax__ */
   60: #endif /* __GNUC_PREREQ__(3, 3) */
   61: 
   62: #define FP_INFINITE     0x01
   63: #define FP_NAN          0x02
   64: #define FP_NORMAL       0x04
   65: #define FP_SUBNORMAL    0x08
   66: #define FP_ZERO         0x10
   67: 
   68: #define FP_ILOGB0       (-INT_MAX)
   69: #define FP_ILOGBNAN     INT_MAX
   70: 
   71: #define fpclassify(x) \
   72:         ((sizeof (x) == sizeof (float)) ? \
   73:                 __fpclassifyf(x) \
   74:         : (sizeof (x) == sizeof (double)) ? \
   75:                 __fpclassify(x) \
   76:         :      __fpclassifyl(x))
   77: #define isfinite(x) \
   78:         ((sizeof (x) == sizeof (float)) ? \
   79:                 __isfinitef(x) \
   80:         : (sizeof (x) == sizeof (double)) ? \
   81:                 __isfinite(x) \
   82:         :      __isfinitel(x))
   83: #define isnormal(x) \
   84:         ((sizeof (x) == sizeof (float)) ? \
   85:                 __isnormalf(x) \
   86:         : (sizeof (x) == sizeof (double)) ? \
   87:                 __isnormal(x) \
   88:         :      __isnormall(x))
   89: #define signbit(x) \
   90:         ((sizeof (x) == sizeof (float)) ? \
   91:                 __signbitf(x) \
   92:         : (sizeof (x) == sizeof (double)) ? \
   93:                 __signbit(x) \
   94:         :      __signbitl(x))
   95: 
   96: #define isgreater(x, y)         (!isunordered((x), (y)) && (x) > (y))
   97: #define isgreaterequal(x, y)    (!isunordered((x), (y)) && (x) >= (y))
   98: #define isless(x, y)            (!isunordered((x), (y)) && (x) < (y))
   99: #define islessequal(x, y)       (!isunordered((x), (y)) && (x) <= (y))
  100: #define islessgreater(x, y)     (!isunordered((x), (y)) && \
  101:                                         ((x) > (y) || (y) > (x)))
  102: #define isunordered(x, y)       (isnan(x) || isnan(y))
  103: #endif /* __ISO_C_VISIBLE >= 1999 */
  104: 
  105: #define isinf(x) \
  106:         ((sizeof (x) == sizeof (float)) ? \
  107:                 __isinff(x) \
  108:         : (sizeof (x) == sizeof (double)) ? \
  109:                 __isinf(x) \
  110:         :      __isinfl(x))
  111: #define isnan(x) \
  112:         ((sizeof (x) == sizeof (float)) ? \
  113:                 __isnanf(x) \
  114:         : (sizeof (x) == sizeof (double)) ? \
  115:                 __isnan(x) \
  116:         :      __isnanl(x))
  117: 
  118: /*
  119:  * XOPEN/SVID
  120:  */
  121: #if __BSD_VISIBLE || __XPG_VISIBLE
  122: #define M_E             2.7182818284590452354      /* e */
  123: #define M_LOG2E         1.4426950408889634074  /* log 2e */
  124: #define M_LOG10E        0.43429448190325182765 /* log 10e */
  125: #define M_LN2           0.69314718055994530942   /* log e2 */
  126: #define M_LN10          2.30258509299404568402  /* log e10 */
  127: #define M_PI            3.14159265358979323846    /* pi */
  128: #define M_PI_2          1.57079632679489661923  /* pi/2 */
  129: #define M_PI_4          0.78539816339744830962  /* pi/4 */
  130: #define M_1_PI          0.31830988618379067154  /* 1/pi */
  131: #define M_2_PI          0.63661977236758134308  /* 2/pi */
  132: #define M_2_SQRTPI      1.12837916709551257390       /* 2/sqrt(pi) */
  133: #define M_SQRT2         1.41421356237309504880 /* sqrt(2) */
  134: #define M_SQRT1_2       0.70710678118654752440        /* 1/sqrt(2) */
  135: 
  136: #ifdef __vax__
  137: #define MAXFLOAT        ((float)1.70141173319264430e+38)
  138: #else
  139: #define MAXFLOAT        ((float)3.40282346638528860e+38)
  140: #endif /* __vax__ */
  141: 
  142: extern int signgam;
  143: #endif /* __BSD_VISIBLE || __XPG_VISIBLE */
  144: 
  145: #if __BSD_VISIBLE
  146: #define HUGE            MAXFLOAT
  147: #endif /* __BSD_VISIBLE */
  148: 
  149: /*
  150:  * ANSI/POSIX
  151:  */
  152: double acos(double);
  153: double asin(double);
  154: double atan(double);
  155: double atan2(double, double);
  156: double cos(double);
  157: double sin(double);
  158: double tan(double);
  159: 
  160: double cosh(double);
  161: double sinh(double);
  162: double tanh(double);
  163: 
  164: double exp(double);
  165: double frexp(double, int *);
  166: double ldexp(double, int);
  167: double log(double);
  168: double log10(double);
  169: double modf(double, double *);
  170: 
  171: double pow(double, double);
  172: double sqrt(double);
  173: 
  174: double ceil(double);
  175: double fabs(double);
  176: double floor(double);
  177: double fmod(double, double);
  178: 
  179: /*
  180:  * C99
  181:  */
  182: #if __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE
  183: double acosh(double);
  184: double asinh(double);
  185: double atanh(double);
  186: 
  187: double exp2(double);
  188: double expm1(double);
  189: int ilogb(double);
  190: double log1p(double);
  191: double log2(double);
  192: double logb(double);
  193: double scalbn(double, int);
  194: double scalbln(double, long int);
  195: 
  196: double cbrt(double);
  197: double hypot(double, double);
  198: 
  199: double erf(double);
  200: double erfc(double);
  201: double lgamma(double);
  202: double tgamma(double);
  203: 
  204: double nearbyint(double);
  205: double rint(double);
  206: long int lrint(double);
  207: long long int llrint(double);
  208: double round(double);
  209: long int lround(double);
  210: long long int llround(double);
  211: double trunc(double);
  212: 
  213: double remainder(double, double);
  214: double remquo(double, double, int *);
  215: 
  216: double copysign(double, double);
  217: double nan(const char *);
  218: double nextafter(double, double);
  219: double nexttoward(double, long double);
  220: 
  221: double fdim(double, double);
  222: double fmax(double, double);
  223: double fmin(double, double);
  224: 
  225: double fma(double, double, double);
  226: #endif /* __BSD_VISIBLE || __ISO_C_VISIBLE >= 1999 || __XPG_VISIBLE */
  227: 
  228: #if __BSD_VISIBLE || __XPG_VISIBLE
  229: double j0(double);
  230: double j1(double);
  231: double jn(int, double);
  232: double scalb(double, double);
  233: double y0(double);
  234: double y1(double);
  235: double yn(int, double);
  236: #endif /* __BSD_VISIBLE || __XPG_VISIBLE */
  237: 
  238: #if __BSD_VISIBLE || __XPG_VISIBLE <= 500
  239: double gamma(double);
  240: #endif /* __BSD_VISIBLE || __XPG_VISIBLE <= 500 */
  241: 
  242: /*
  243:  * BSD math library entry points
  244:  */
  245: #if __BSD_VISIBLE
  246: double drem(double, double);
  247: int finite(double);
  248: 
  249: /*
  250:  * Reentrant version of gamma & lgamma; passes signgam back by reference
  251:  * as the second argument; user must allocate space for signgam.
  252:  */
  253: double gamma_r(double, int *);
  254: double lgamma_r(double, int *);
  255: 
  256: /*
  257:  * IEEE Test Vector
  258:  */
  259: double significand(double);
  260: #endif /* __BSD_VISIBLE */
  261: 
  262: /*
  263:  * Float versions of C99 functions
  264:  */
  265: #if __ISO_C_VISIBLE >= 1999
  266: float acosf(float);
  267: float asinf(float);
  268: float atanf(float);
  269: float atan2f(float, float);
  270: float cosf(float);
  271: float sinf(float);
  272: float tanf(float);
  273: 
  274: float acoshf(float);
  275: float asinhf(float);
  276: float atanhf(float);
  277: float coshf(float);
  278: float sinhf(float);
  279: float tanhf(float);
  280: 
  281: float expf(float);
  282: float exp2f(float);
  283: float expm1f(float);
  284: float frexpf(float, int *);
  285: int ilogbf(float);
  286: float ldexpf(float, int);
  287: float logf(float);
  288: float log10f(float);
  289: float log1pf(float);
  290: float log2f(float);
  291: float logbf(float);
  292: float modff(float, float *);
  293: float scalbnf(float, int);
  294: float scalblnf(float, long int);
  295: 
  296: float cbrtf(float);
  297: float fabsf(float);
  298: float hypotf(float, float);
  299: float powf(float, float);
  300: float sqrtf(float);
  301: 
  302: float erff(float);
  303: float erfcf(float);
  304: float lgammaf(float);
  305: float tgammaf(float);
  306: 
  307: float ceilf(float);
  308: float floorf(float);
  309: float nearbyintf(float);
  310: float rintf(float);
  311: long int lrintf(float);
  312: long long int llrintf(float);
  313: float roundf(float);
  314: long int lroundf(float);
  315: long long int llroundf(float);
  316: float truncf(float);
  317: 
  318: float fmodf(float, float);
  319: float remainderf(float, float);
  320: float remquof(float, float, int *);
  321: 
  322: float copysignf(float, float);
  323: float nanf(const char *);
  324: float nextafterf(float, float);
  325: float nexttowardf(float, long double);
  326: 
  327: float fdimf(float, float);
  328: float fmaxf(float, float);
  329: float fminf(float, float);
  330: 
  331: float fmaf(float, float, float);
  332: #endif /* __ISO_C_VISIBLE >= 1999 */
  333: 
  334: #if __BSD_VISIBLE || __XPG_VISIBLE
  335: float j0f(float);
  336: float j1f(float);
  337: float jnf(int, float);
  338: float scalbf(float, float);
  339: float y0f(float);
  340: float y1f(float);
  341: float ynf(int, float);
  342: #endif /* __BSD_VISIBLE || __XPG_VISIBLE */
  343: 
  344: #if __BSD_VISIBLE || __XPG_VISIBLE <= 500
  345: float gammaf(float);
  346: #endif /* __BSD_VISIBLE || __XPG_VISIBLE <= 500 */
  347: 
  348: /*
  349:  * Float versions of BSD math library entry points
  350:  */
  351: #if __BSD_VISIBLE
  352: float dremf(float, float);
  353: int finitef(float);
  354: int isinff(float);
  355: int isnanf(float);
  356: 
  357: /*
  358:  * Float versions of reentrant version of gamma & lgamma; passes
  359:  * signgam back by reference as the second argument; user must
  360:  * allocate space for signgam.
  361:  */
  362: float gammaf_r(float, int *);
  363: float lgammaf_r(float, int *);
  364: 
  365: /*
  366:  * Float version of IEEE Test Vector
  367:  */
  368: float significandf(float);
  369: #endif /* __BSD_VISIBLE */
  370: 
  371: /*
  372:  * Long double versions of C99 functions
  373:  */
  374: #if __ISO_C_VISIBLE >= 1999
  375: long double acosl(long double);
  376: long double asinl(long double);
  377: long double atanl(long double);
  378: long double atan2l(long double, long double);
  379: long double cosl(long double);
  380: long double sinl(long double);
  381: long double tanl(long double);
  382: 
  383: long double acoshl(long double);
  384: long double asinhl(long double);
  385: long double atanhl(long double);
  386: long double coshl(long double);
  387: long double sinhl(long double);
  388: long double tanhl(long double);
  389: 
  390: long double expl(long double);
  391: long double exp2l(long double);
  392: long double expm1l(long double);
  393: long double frexpl(long double, int *);
  394: int ilogbl(long double);
  395: long double ldexpl(long double, int);
  396: long double logl(long double);
  397: long double log10l(long double);
  398: long double log1pl(long double);
  399: long double log2l(long double);
  400: long double logbl(long double);
  401: long double modfl(long double, long double *);
  402: long double scalbnl(long double, int);
  403: long double scalblnl(long double, long int);
  404: 
  405: long double cbrtl(long double);
  406: long double fabsl(long double);
  407: long double hypotl(long double, long double);
  408: long double powl(long double, long double);
  409: long double sqrtl(long double);
  410: 
  411: long double erfl(long double);
  412: long double erfcl(long double);
  413: long double lgammal(long double);
  414: long double tgammal(long double);
  415: 
  416: long double ceill(long double);
  417: long double floorl(long double);
  418: long double nearbyintl(long double);
  419: long double rintl(long double);
  420: long int lrintl(long double);
  421: long long int llrintl(long double);
  422: long double roundl(long double);
  423: long int lroundl(long double);
  424: long long int llroundl(long double);
  425: long double truncl(long double);
  426: 
  427: long double fmodl(long double, long double);
  428: long double remainderl(long double, long double);
  429: long double remquol(long double, long double, int *);
  430: 
  431: long double copysignl(long double, long double);
  432: long double nanl(const char *);
  433: long double nextafterl(long double, long double);
  434: long double nexttowardl(long double, long double);
  435: 
  436: long double fdiml(long double, long double);
  437: long double fmaxl(long double, long double);
  438: long double fminl(long double, long double);
  439: 
  440: long double fmal(long double, long double, long double);
  441: #endif /* __ISO_C_VISIBLE >= 1999 */
  442: 
  443: /*
  444:  * Library implementation
  445:  */
  446: int __fpclassify(double);
  447: int __fpclassifyf(float);
  448: int __fpclassifyl(long double);
  449: int __isfinite(double);
  450: int __isfinitef(float);
  451: int __isfinitel(long double);
  452: int __isinf(double);
  453: int __isinff(float);
  454: int __isinfl(long double);
  455: int __isnan(double);
  456: int __isnanf(float);
  457: int __isnanl(long double);
  458: int __isnormal(double);
  459: int __isnormalf(float);
  460: int __isnormall(long double);
  461: int __signbit(double);
  462: int __signbitf(float);
  463: int __signbitl(long double);
  464: 
  465: #if __BSD_VISIBLE && defined(__vax__)
  466: double infnan(int);
  467: #endif /* __BSD_VISIBLE && defined(__vax__) */
  468: __END_DECLS
  469: 
  470: #endif /* !_MATH_H_ */