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