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 #if 0 80 /* Old value from 4.4BSD-Lite math.h; this is probably better. */ 81 #define HUGE HUGE_VAL 82 #else 83 #define HUGE MAXFLOAT 84 #endif 85 86 /* 87 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> 88 * (one may replace the following line by "#include <values.h>") 89 */ 90 91 #define X_TLOSS 1.41484755040568800000e+16 92 93 #define DOMAIN 1 94 #define SING 2 95 #define OVERFLOW 3 96 #define UNDERFLOW 4 97 #define TLOSS 5 98 #define PLOSS 6 99 100 #endif /* !_XOPEN_SOURCE */ 101 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 102 103 #include <sys/cdefs.h> 104 105 /* 106 * Most of these functions have the side effect of setting errno, so they 107 * are not declared as __pure2. (XXX: this point needs to be revisited, 108 * since C99 doesn't require the mistake of setting errno, and we mostly 109 * don't set it anyway. In C99, pragmas and functions for changing the 110 * rounding mode affect the purity of these functions.) 111 */ 112 __BEGIN_DECLS 113 /* 114 * ANSI/POSIX 115 */ 116 double acos(double); 117 double asin(double); 118 double atan(double); 119 double atan2(double, double); 120 double cos(double); 121 double sin(double); 122 double tan(double); 123 124 double cosh(double); 125 double sinh(double); 126 double tanh(double); 127 128 double exp(double); 129 double frexp(double, int *); /* fundamentally !__pure2 */ 130 double ldexp(double, int); 131 double log(double); 132 double log10(double); 133 double modf(double, double *); /* fundamentally !__pure2 */ 134 135 double pow(double, double); 136 double sqrt(double); 137 138 double ceil(double); 139 double fabs(double); 140 double floor(double); 141 double fmod(double, double); 142 143 /* 144 * These functions are not in C90 so they can be "right". The ones that 145 * never set errno in lib/msun are declared as __pure2. 146 */ 147 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 148 double erf(double); 149 double erfc(double) __pure2; 150 int finite(double) __pure2; 151 double gamma(double); 152 double hypot(double, double); 153 int isinf(double) __pure2; 154 int isnan(double) __pure2; 155 double j0(double); 156 double j1(double); 157 double jn(int, double); 158 double lgamma(double); 159 double y0(double); 160 double y1(double); 161 double yn(int, double); 162 163 #if !defined(_XOPEN_SOURCE) 164 double acosh(double); 165 double asinh(double); 166 double atanh(double); 167 double cbrt(double) __pure2; 168 double logb(double) __pure2; 169 double nextafter(double, double); 170 double remainder(double, double); 171 double scalb(double, double); 172 double tgamma(double); 173 174 #ifndef __cplusplus 175 int matherr(struct exception *); 176 #endif 177 178 /* 179 * IEEE Test Vector 180 */ 181 double significand(double); 182 183 /* 184 * Functions callable from C, intended to support IEEE arithmetic. 185 */ 186 double copysign(double, double) __pure2; 187 int ilogb(double); 188 double rint(double) __pure2; 189 double scalbn(double, int); 190 191 /* 192 * BSD math library entry points 193 */ 194 double drem(double, double); 195 double expm1(double) __pure2; 196 double log1p(double) __pure2; 197 198 /* 199 * Reentrant version of gamma & lgamma; passes signgam back by reference 200 * as the second argument; user must allocate space for signgam. 201 */ 202 #ifdef _REENTRANT 203 double gamma_r(double, int *); 204 double lgamma_r(double, int *); 205 #endif /* _REENTRANT */ 206 207 /* float versions of ANSI/POSIX functions */ 208 float acosf(float); 209 float asinf(float); 210 float atanf(float); 211 float atan2f(float, float); 212 float cosf(float); 213 float sinf(float); 214 float tanf(float); 215 216 float coshf(float); 217 float sinhf(float); 218 float tanhf(float); 219 220 float expf(float); 221 float frexpf(float, int *); /* fundamentally !__pure2 */ 222 float ldexpf(float, int); 223 float logf(float); 224 float log10f(float); 225 float modff(float, float *); /* fundamentally !__pure2 */ 226 227 float powf(float, float); 228 float sqrtf(float); 229 230 float ceilf(float); 231 float fabsf(float); 232 float floorf(float); 233 float fmodf(float, float); 234 235 float erff(float); 236 float erfcf(float) __pure2; 237 int finitef(float) __pure2; 238 float gammaf(float); 239 float hypotf(float, float) __pure2; 240 int isnanf(float) __pure2; 241 float j0f(float); 242 float j1f(float); 243 float jnf(int, float); 244 float lgammaf(float); 245 float y0f(float); 246 float y1f(float); 247 float ynf(int, float); 248 249 float acoshf(float); 250 float asinhf(float); 251 float atanhf(float); 252 float cbrtf(float) __pure2; 253 float logbf(float) __pure2; 254 float nextafterf(float, float); 255 float remainderf(float, float); 256 float scalbf(float, float); 257 258 /* 259 * float version of IEEE Test Vector 260 */ 261 float significandf(float); 262 263 /* 264 * Float versions of functions callable from C, intended to support 265 * IEEE arithmetic. 266 */ 267 float copysignf(float, float) __pure2; 268 int ilogbf(float); 269 float rintf(float); 270 float scalbnf(float, int); 271 272 /* 273 * float versions of BSD math library entry points 274 */ 275 float dremf(float, float); 276 float expm1f(float) __pure2; 277 float log1pf(float) __pure2; 278 279 /* 280 * Float versions of reentrant version of gamma & lgamma; passes 281 * signgam back by reference as the second argument; user must 282 * allocate space for signgam. 283 */ 284 #ifdef _REENTRANT 285 float gammaf_r(float, int *); 286 float lgammaf_r(float, int *); 287 #endif /* _REENTRANT */ 288 289 #endif /* !_XOPEN_SOURCE */ 290 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 291 __END_DECLS 292 293 #endif /* !_MATH_H_ */ 294