1 /* 2 * ==================================================== 3 * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. 4 * 5 * Developed at SunPro, a Sun Microsystems, Inc. business. 6 * Permission to use, copy, modify, and distribute this 7 * software is freely granted, provided that this notice 8 * is preserved. 9 * ==================================================== 10 */ 11 12 /* 13 * from: @(#)fdlibm.h 5.1 93/09/24 14 * $FreeBSD$ 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 67 /* We have a problem when using C++ since `exception' is a reserved 68 name in C++. */ 69 #ifndef __cplusplus 70 struct exception { 71 int type; 72 char *name; 73 double arg1; 74 double arg2; 75 double retval; 76 }; 77 #endif 78 79 #define HUGE MAXFLOAT 80 81 /* 82 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> 83 * (one may replace the following line by "#include <values.h>") 84 */ 85 86 #define X_TLOSS 1.41484755040568800000e+16 87 88 #define DOMAIN 1 89 #define SING 2 90 #define OVERFLOW 3 91 #define UNDERFLOW 4 92 #define TLOSS 5 93 #define PLOSS 6 94 95 #endif /* !_XOPEN_SOURCE */ 96 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 97 98 #include <sys/cdefs.h> 99 100 __BEGIN_DECLS 101 /* 102 * ANSI/POSIX 103 */ 104 double acos(double); 105 double asin(double); 106 double atan(double); 107 double atan2(double, double); 108 double cos(double); 109 double sin(double); 110 double tan(double); 111 112 double cosh(double); 113 double sinh(double); 114 double tanh(double); 115 116 double exp(double); 117 double frexp(double, int *); 118 double ldexp(double, int); 119 double log(double); 120 double log10(double); 121 double modf(double, double *); 122 123 double pow(double, double); 124 double sqrt(double); 125 126 double ceil(double); 127 double fabs(double); 128 double floor(double); 129 double fmod(double, double); 130 131 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 132 double erf(double); 133 double erfc(double); 134 double gamma(double); 135 double hypot(double, double); 136 int isinf(double); 137 int isnan(double); 138 int finite(double); 139 double j0(double); 140 double j1(double); 141 double jn(int, double); 142 double lgamma(double); 143 double y0(double); 144 double y1(double); 145 double yn(int, double); 146 147 #if !defined(_XOPEN_SOURCE) 148 double acosh(double); 149 double asinh(double); 150 double atanh(double); 151 double cbrt(double); 152 double logb(double); 153 double nextafter(double, double); 154 double remainder(double, double); 155 double scalb(double, double); 156 double tgamma(double); 157 158 #ifndef __cplusplus 159 int matherr(struct exception *); 160 #endif 161 162 /* 163 * IEEE Test Vector 164 */ 165 double significand(double); 166 167 /* 168 * Functions callable from C, intended to support IEEE arithmetic. 169 */ 170 double copysign(double, double); 171 int ilogb(double); 172 double rint(double); 173 double scalbn(double, int); 174 175 /* 176 * BSD math library entry points 177 */ 178 double drem(double, double); 179 double expm1(double); 180 double log1p(double); 181 182 /* 183 * Reentrant version of gamma & lgamma; passes signgam back by reference 184 * as the second argument; user must allocate space for signgam. 185 */ 186 #ifdef _REENTRANT 187 double gamma_r(double, int *); 188 double lgamma_r(double, int *); 189 #endif /* _REENTRANT */ 190 191 /* float versions of ANSI/POSIX functions */ 192 float acosf(float); 193 float asinf(float); 194 float atanf(float); 195 float atan2f(float, float); 196 float cosf(float); 197 float sinf(float); 198 float tanf(float); 199 200 float coshf(float); 201 float sinhf(float); 202 float tanhf(float); 203 204 float expf(float); 205 float frexpf(float, int *); 206 float ldexpf(float, int); 207 float logf(float); 208 float log10f(float); 209 float modff(float, float *); 210 211 float powf(float, float); 212 float sqrtf(float); 213 214 float ceilf(float); 215 float fabsf(float); 216 float floorf(float); 217 float fmodf(float, float); 218 219 float erff(float); 220 float erfcf(float); 221 float gammaf(float); 222 float hypotf(float, float); 223 int isnanf(float); 224 int finitef(float); 225 float j0f(float); 226 float j1f(float); 227 float jnf(int, float); 228 float lgammaf(float); 229 float y0f(float); 230 float y1f(float); 231 float ynf(int, float); 232 233 float acoshf(float); 234 float asinhf(float); 235 float atanhf(float); 236 float cbrtf(float); 237 float logbf(float); 238 float nextafterf(float, float); 239 float remainderf(float, float); 240 float scalbf(float, float); 241 242 /* 243 * float version of IEEE Test Vector 244 */ 245 float significandf(float); 246 247 /* 248 * Float versions of functions callable from C, intended to support 249 * IEEE arithmetic. 250 */ 251 float copysignf(float, float); 252 int ilogbf(float); 253 float rintf(float); 254 float scalbnf(float, int); 255 256 /* 257 * float versions of BSD math library entry points 258 */ 259 float dremf(float, float); 260 float expm1f(float); 261 float log1pf(float); 262 263 /* 264 * Float versions of reentrant version of gamma & lgamma; passes 265 * signgam back by reference as the second argument; user must 266 * allocate space for signgam. 267 */ 268 #ifdef _REENTRANT 269 float gammaf_r(float, int *); 270 float lgammaf_r(float, int *); 271 #endif /* _REENTRANT */ 272 273 #endif /* !_XOPEN_SOURCE */ 274 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 275 __END_DECLS 276 277 #endif /* !_MATH_H_ */ 278