[BACK]Return to math.h CVS log [TXT][DIR] Up to [local] / src / include

Annotation of src/include/math.h, Revision 1.6

1.6     ! millert     1: /*     $OpenBSD: math.h,v 1.5 2001/05/26 01:49:25 millert Exp $        */
1.1       deraadt     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: /*
1.3       millert    14:  * from: @(#)fdlibm.h 5.1 93/09/24
1.1       deraadt    15:  */
                     16:
                     17: #ifndef _MATH_H_
                     18: #define _MATH_H_
                     19:
                     20: /*
                     21:  * ANSI/POSIX
                     22:  */
                     23: extern char __infinity[];
                     24: #define HUGE_VAL       (*(double *) __infinity)
                     25:
                     26: /*
                     27:  * XOPEN/SVID
                     28:  */
                     29: #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
                     30: #define        M_E             2.7182818284590452354   /* e */
                     31: #define        M_LOG2E         1.4426950408889634074   /* log 2e */
                     32: #define        M_LOG10E        0.43429448190325182765  /* log 10e */
                     33: #define        M_LN2           0.69314718055994530942  /* log e2 */
                     34: #define        M_LN10          2.30258509299404568402  /* log e10 */
                     35: #define        M_PI            3.14159265358979323846  /* pi */
                     36: #define        M_PI_2          1.57079632679489661923  /* pi/2 */
                     37: #define        M_PI_4          0.78539816339744830962  /* pi/4 */
                     38: #define        M_1_PI          0.31830988618379067154  /* 1/pi */
                     39: #define        M_2_PI          0.63661977236758134308  /* 2/pi */
                     40: #define        M_2_SQRTPI      1.12837916709551257390  /* 2/sqrt(pi) */
                     41: #define        M_SQRT2         1.41421356237309504880  /* sqrt(2) */
                     42: #define        M_SQRT1_2       0.70710678118654752440  /* 1/sqrt(2) */
                     43:
                     44: #define        MAXFLOAT        ((float)3.40282346638528860e+38)
                     45: extern int signgam;
                     46:
                     47: #if !defined(_XOPEN_SOURCE)
                     48: enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};
                     49:
                     50: #define _LIB_VERSION_TYPE enum fdversion
                     51: #define _LIB_VERSION _fdlib_version
                     52:
                     53: /* if global variable _LIB_VERSION is not desirable, one may
                     54:  * change the following to be a constant by:
                     55:  *     #define _LIB_VERSION_TYPE const enum version
                     56:  * In that case, after one initializes the value _LIB_VERSION (see
                     57:  * s_lib_version.c) during compile time, it cannot be modified
                     58:  * in the middle of a program
                     59:  */
                     60: extern  _LIB_VERSION_TYPE  _LIB_VERSION;
                     61:
                     62: #define _IEEE_  fdlibm_ieee
                     63: #define _SVID_  fdlibm_svid
                     64: #define _XOPEN_ fdlibm_xopen
                     65: #define _POSIX_ fdlibm_posix
                     66:
1.5       millert    67: #ifndef __cplusplus
1.1       deraadt    68: struct exception {
                     69:        int type;
                     70:        char *name;
                     71:        double arg1;
                     72:        double arg2;
                     73:        double retval;
                     74: };
1.3       millert    75: #endif
1.1       deraadt    76:
                     77: #define        HUGE            MAXFLOAT
                     78:
                     79: /*
                     80:  * set X_TLOSS = pi*2**52, which is possibly defined in <values.h>
                     81:  * (one may replace the following line by "#include <values.h>")
                     82:  */
                     83:
                     84: #define X_TLOSS                1.41484755040568800000e+16
                     85:
                     86: #define        DOMAIN          1
                     87: #define        SING            2
                     88: #define        OVERFLOW        3
                     89: #define        UNDERFLOW       4
                     90: #define        TLOSS           5
                     91: #define        PLOSS           6
                     92:
                     93: #endif /* !_XOPEN_SOURCE */
                     94: #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
                     95:
                     96:
                     97: #include <sys/cdefs.h>
                     98: __BEGIN_DECLS
                     99: /*
                    100:  * ANSI/POSIX
                    101:  */
1.6     ! millert   102: extern double acos(double);
        !           103: extern double asin(double);
        !           104: extern double atan(double);
        !           105: extern double atan2(double, double);
        !           106: extern double cos(double);
        !           107: extern double sin(double);
        !           108: extern double tan(double);
        !           109:
        !           110: extern double cosh(double);
        !           111: extern double sinh(double);
        !           112: extern double tanh(double);
        !           113:
        !           114: extern double exp(double);
        !           115: extern double frexp(double, int *);
        !           116: extern double ldexp(double, int);
        !           117: extern double log(double);
        !           118: extern double log10(double);
        !           119: extern double modf(double, double *);
        !           120:
        !           121: extern double pow(double, double);
        !           122: extern double sqrt(double);
        !           123:
        !           124: extern double ceil(double);
        !           125: extern double fabs(double);
        !           126: extern double floor(double);
        !           127: extern double fmod(double, double);
1.1       deraadt   128:
                    129: #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE)
1.6     ! millert   130: extern double erf(double);
        !           131: extern double erfc(double);
        !           132: extern double gamma(double);
        !           133: extern double hypot(double, double);
        !           134: extern int isinf(double);
        !           135: extern int isnan(double);
        !           136: extern int finite(double);
        !           137: extern double j0(double);
        !           138: extern double j1(double);
        !           139: extern double jn(int, double);
        !           140: extern double lgamma(double);
        !           141: extern double y0(double);
        !           142: extern double y1(double);
        !           143: extern double yn(int, double);
1.1       deraadt   144:
                    145: #if !defined(_XOPEN_SOURCE)
1.6     ! millert   146: extern double acosh(double);
        !           147: extern double asinh(double);
        !           148: extern double atanh(double);
        !           149: extern double cbrt(double);
        !           150: extern double logb(double);
        !           151: extern double nextafter(double, double);
        !           152: extern double remainder(double, double);
        !           153: extern double scalb(double, double);
1.1       deraadt   154:
1.3       millert   155: #ifdef __LIBM_PRIVATE
1.6     ! millert   156: extern int matherr(struct exception *);
1.3       millert   157: #endif
1.1       deraadt   158:
                    159: /*
                    160:  * IEEE Test Vector
                    161:  */
1.6     ! millert   162: extern double significand(double);
1.1       deraadt   163:
                    164: /*
                    165:  * Functions callable from C, intended to support IEEE arithmetic.
                    166:  */
1.6     ! millert   167: extern double copysign(double, double);
        !           168: extern int ilogb(double);
        !           169: extern double rint(double);
        !           170: extern double scalbn(double, int);
1.1       deraadt   171:
                    172: /*
                    173:  * BSD math library entry points
                    174:  */
                    175: extern double cabs();
1.6     ! millert   176: extern double drem(double, double);
        !           177: extern double expm1(double);
        !           178: extern double log1p(double);
1.1       deraadt   179:
                    180: /*
                    181:  * Reentrant version of gamma & lgamma; passes signgam back by reference
                    182:  * as the second argument; user must allocate space for signgam.
                    183:  */
                    184: #ifdef _REENTRANT
1.6     ! millert   185: extern double gamma_r(double, int *);
        !           186: extern double lgamma_r(double, int *);
1.1       deraadt   187: #endif /* _REENTRANT */
                    188:
                    189:
                    190: /* float versions of ANSI/POSIX functions */
1.6     ! millert   191: extern float acosf(float);
        !           192: extern float asinf(float);
        !           193: extern float atanf(float);
        !           194: extern float atan2f(float, float);
        !           195: extern float cosf(float);
        !           196: extern float sinf(float);
        !           197: extern float tanf(float);
        !           198:
        !           199: extern float coshf(float);
        !           200: extern float sinhf(float);
        !           201: extern float tanhf(float);
        !           202:
        !           203: extern float expf(float);
        !           204: extern float frexpf(float, int *);
        !           205: extern float ldexpf(float, int);
        !           206: extern float logf(float);
        !           207: extern float log10f(float);
        !           208: extern float modff(float, float *);
        !           209:
        !           210: extern float powf(float, float);
        !           211: extern float sqrtf(float);
        !           212:
        !           213: extern float ceilf(float);
        !           214: extern float fabsf(float);
        !           215: extern float floorf(float);
        !           216: extern float fmodf(float, float);
        !           217:
        !           218: extern float erff(float);
        !           219: extern float erfcf(float);
        !           220: extern float gammaf(float);
        !           221: extern float hypotf(float, float);
        !           222: extern int isinff(float);
        !           223: extern int isnanf(float);
        !           224: extern int finitef(float);
        !           225: extern float j0f(float);
        !           226: extern float j1f(float);
        !           227: extern float jnf(int, float);
        !           228: extern float lgammaf(float);
        !           229: extern float y0f(float);
        !           230: extern float y1f(float);
        !           231: extern float ynf(int, float);
        !           232:
        !           233: extern float acoshf(float);
        !           234: extern float asinhf(float);
        !           235: extern float atanhf(float);
        !           236: extern float cbrtf(float);
        !           237: extern float logbf(float);
        !           238: extern float nextafterf(float, float);
        !           239: extern float remainderf(float, float);
        !           240: extern float scalbf(float, float);
1.1       deraadt   241:
                    242: /*
                    243:  * float version of IEEE Test Vector
                    244:  */
1.6     ! millert   245: extern float significandf(float);
1.1       deraadt   246:
                    247: /*
                    248:  * Float versions of functions callable from C, intended to support
                    249:  * IEEE arithmetic.
                    250:  */
1.6     ! millert   251: extern float copysignf(float, float);
        !           252: extern int ilogbf(float);
        !           253: extern float rintf(float);
        !           254: extern float scalbnf(float, int);
1.1       deraadt   255:
                    256: /*
                    257:  * float versions of BSD math library entry points
                    258:  */
                    259: extern float cabsf ();
1.6     ! millert   260: extern float dremf(float, float);
        !           261: extern float expm1f(float);
        !           262: extern float log1pf(float);
1.1       deraadt   263:
                    264: /*
                    265:  * Float versions of reentrant version of gamma & lgamma; passes
                    266:  * signgam back by reference as the second argument; user must
                    267:  * allocate space for signgam.
                    268:  */
                    269: #ifdef _REENTRANT
1.6     ! millert   270: extern float gammaf_r(float, int *);
        !           271: extern float lgammaf_r(float, int *);
1.1       deraadt   272: #endif /* _REENTRANT */
                    273:
                    274: #endif /* !_XOPEN_SOURCE */
                    275: #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */
                    276: __END_DECLS
                    277:
                    278: #endif /* _MATH_H_ */