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 99 #include <sys/cdefs.h> 100 /* 101 * ANSI/POSIX 102 */ 103 __BEGIN_DECLS 104 double acos __P((double)); 105 double asin __P((double)); 106 double atan __P((double)); 107 double atan2 __P((double, double)); 108 double cos __P((double)); 109 double sin __P((double)); 110 double tan __P((double)); 111 112 double cosh __P((double)); 113 double sinh __P((double)); 114 double tanh __P((double)); 115 116 double exp __P((double)); 117 double frexp __P((double, int *)); 118 double ldexp __P((double, int)); 119 double log __P((double)); 120 double log10 __P((double)); 121 double modf __P((double, double *)); 122 123 double pow __P((double, double)); 124 double sqrt __P((double)); 125 126 double ceil __P((double)); 127 double fabs __P((double)); 128 double floor __P((double)); 129 double fmod __P((double, double)); 130 131 #if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 132 double erf __P((double)); 133 double erfc __P((double)); 134 double gamma __P((double)); 135 double hypot __P((double, double)); 136 int isinf __P((double)); 137 int isnan __P((double)); 138 int finite __P((double)); 139 double j0 __P((double)); 140 double j1 __P((double)); 141 double jn __P((int, double)); 142 double lgamma __P((double)); 143 double y0 __P((double)); 144 double y1 __P((double)); 145 double yn __P((int, double)); 146 147 #if !defined(_XOPEN_SOURCE) 148 double acosh __P((double)); 149 double asinh __P((double)); 150 double atanh __P((double)); 151 double cbrt __P((double)); 152 double logb __P((double)); 153 double nextafter __P((double, double)); 154 double remainder __P((double, double)); 155 double scalb __P((double, double)); 156 157 #ifndef __cplusplus 158 int matherr __P((struct exception *)); 159 #endif 160 161 /* 162 * IEEE Test Vector 163 */ 164 double significand __P((double)); 165 166 /* 167 * Functions callable from C, intended to support IEEE arithmetic. 168 */ 169 double copysign __P((double, double)); 170 int ilogb __P((double)); 171 double rint __P((double)); 172 double scalbn __P((double, int)); 173 174 /* 175 * BSD math library entry points 176 */ 177 double drem __P((double, double)); 178 double expm1 __P((double)); 179 double log1p __P((double)); 180 181 /* 182 * Reentrant version of gamma & lgamma; passes signgam back by reference 183 * as the second argument; user must allocate space for signgam. 184 */ 185 #ifdef _REENTRANT 186 double gamma_r __P((double, int *)); 187 double lgamma_r __P((double, int *)); 188 #endif /* _REENTRANT */ 189 190 /* float versions of ANSI/POSIX functions */ 191 float acosf __P((float)); 192 float asinf __P((float)); 193 float atanf __P((float)); 194 float atan2f __P((float, float)); 195 float cosf __P((float)); 196 float sinf __P((float)); 197 float tanf __P((float)); 198 199 float coshf __P((float)); 200 float sinhf __P((float)); 201 float tanhf __P((float)); 202 203 float expf __P((float)); 204 float frexpf __P((float, int *)); 205 float ldexpf __P((float, int)); 206 float logf __P((float)); 207 float log10f __P((float)); 208 float modff __P((float, float *)); 209 210 float powf __P((float, float)); 211 float sqrtf __P((float)); 212 213 float ceilf __P((float)); 214 float fabsf __P((float)); 215 float floorf __P((float)); 216 float fmodf __P((float, float)); 217 218 float erff __P((float)); 219 float erfcf __P((float)); 220 float gammaf __P((float)); 221 float hypotf __P((float, float)); 222 int isnanf __P((float)); 223 int finitef __P((float)); 224 float j0f __P((float)); 225 float j1f __P((float)); 226 float jnf __P((int, float)); 227 float lgammaf __P((float)); 228 float y0f __P((float)); 229 float y1f __P((float)); 230 float ynf __P((int, float)); 231 232 float acoshf __P((float)); 233 float asinhf __P((float)); 234 float atanhf __P((float)); 235 float cbrtf __P((float)); 236 float logbf __P((float)); 237 float nextafterf __P((float, float)); 238 float remainderf __P((float, float)); 239 float scalbf __P((float, float)); 240 241 /* 242 * float version of IEEE Test Vector 243 */ 244 float significandf __P((float)); 245 246 /* 247 * Float versions of functions callable from C, intended to support 248 * IEEE arithmetic. 249 */ 250 float copysignf __P((float, float)); 251 int ilogbf __P((float)); 252 float rintf __P((float)); 253 float scalbnf __P((float, int)); 254 255 /* 256 * float versions of BSD math library entry points 257 */ 258 float dremf __P((float, float)); 259 float expm1f __P((float)); 260 float log1pf __P((float)); 261 262 /* 263 * Float versions of reentrant version of gamma & lgamma; passes 264 * signgam back by reference as the second argument; user must 265 * allocate space for signgam. 266 */ 267 #ifdef _REENTRANT 268 float gammaf_r __P((float, int *)); 269 float lgammaf_r __P((float, int *)); 270 #endif /* _REENTRANT */ 271 272 #endif /* !_XOPEN_SOURCE */ 273 #endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 274 __END_DECLS 275 276 #endif /* !_MATH_H_ */ 277