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: head/lib/msun/src/math.h 110566 2003-02-08 20:37:55Z mike $
|
14 * $FreeBSD: head/lib/msun/src/math.h 110734 2003-02-11 21:56:21Z mike $ |
15 */ 16 17#ifndef _MATH_H_ 18#define _MATH_H_ 19 20#include <sys/_types.h> 21 22/* 23 * ANSI/POSIX 24 */ 25extern const union __infinity_un { 26 unsigned char __uc[8]; 27 double __ud; 28} __infinity; 29 30extern const union __nan_un { 31 unsigned char __uc[sizeof(float)]; 32 float __uf; 33} __nan; 34 35#define FP_ILOGB0 (-0x7fffffff - 1) /* INT_MIN */ 36#define FP_ILOGBNAN 0x7fffffff /* INT_MAX */ 37#define HUGE_VAL (__infinity.__ud) 38#define HUGE_VALF (float)HUGE_VAL 39#define HUGE_VALL (long double)HUGE_VAL 40#define INFINITY HUGE_VALF 41#define NAN (__nan.__uf) 42 43/* Symbolic constants to classify floating point numbers. */ 44#define FP_INFINITE 1 45#define FP_NAN 2 46#define FP_NORMAL 3 47#define FP_SUBNORMAL 4 48#define FP_ZERO 5 49#define fpclassify(x) \ 50 ((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) \ 51 : (sizeof (x) == sizeof (double)) ? __fpclassifyd(x) \ 52 : __fpclassifyl(x))
|
53#define signbit(x) __signbit(x) |
54 55typedef __double_t double_t; 56typedef __float_t float_t; 57 58/* 59 * XOPEN/SVID 60 */ 61#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 62#define M_E 2.7182818284590452354 /* e */ 63#define M_LOG2E 1.4426950408889634074 /* log 2e */ 64#define M_LOG10E 0.43429448190325182765 /* log 10e */ 65#define M_LN2 0.69314718055994530942 /* log e2 */ 66#define M_LN10 2.30258509299404568402 /* log e10 */ 67#define M_PI 3.14159265358979323846 /* pi */ 68#define M_PI_2 1.57079632679489661923 /* pi/2 */ 69#define M_PI_4 0.78539816339744830962 /* pi/4 */ 70#define M_1_PI 0.31830988618379067154 /* 1/pi */ 71#define M_2_PI 0.63661977236758134308 /* 2/pi */ 72#define M_2_SQRTPI 1.12837916709551257390 /* 2/sqrt(pi) */ 73#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ 74#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ 75 76#define MAXFLOAT ((float)3.40282346638528860e+38) 77extern int signgam; 78 79#if !defined(_XOPEN_SOURCE) 80enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix}; 81 82#define _LIB_VERSION_TYPE enum fdversion 83#define _LIB_VERSION _fdlib_version 84 85/* if global variable _LIB_VERSION is not desirable, one may 86 * change the following to be a constant by: 87 * #define _LIB_VERSION_TYPE const enum version 88 * In that case, after one initializes the value _LIB_VERSION (see 89 * s_lib_version.c) during compile time, it cannot be modified 90 * in the middle of a program 91 */ 92extern _LIB_VERSION_TYPE _LIB_VERSION; 93 94#define _IEEE_ fdlibm_ieee 95#define _SVID_ fdlibm_svid 96#define _XOPEN_ fdlibm_xopen 97#define _POSIX_ fdlibm_posix 98 99/* We have a problem when using C++ since `exception' is a reserved 100 name in C++. */ 101#ifndef __cplusplus 102struct exception { 103 int type; 104 char *name; 105 double arg1; 106 double arg2; 107 double retval; 108}; 109#endif 110 111#if 0 112/* Old value from 4.4BSD-Lite math.h; this is probably better. */ 113#define HUGE HUGE_VAL 114#else 115#define HUGE MAXFLOAT 116#endif 117 118/* 119 * set X_TLOSS = pi*2**52, which is possibly defined in <values.h> 120 * (one may replace the following line by "#include <values.h>") 121 */ 122 123#define X_TLOSS 1.41484755040568800000e+16 124 125#define DOMAIN 1 126#define SING 2 127#define OVERFLOW 3 128#define UNDERFLOW 4 129#define TLOSS 5 130#define PLOSS 6 131 132#endif /* !_XOPEN_SOURCE */ 133#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 134 135#include <sys/cdefs.h> 136 137/* 138 * Most of these functions have the side effect of setting errno, so they 139 * are not declared as __pure2. (XXX: this point needs to be revisited, 140 * since C99 doesn't require the mistake of setting errno, and we mostly 141 * don't set it anyway. In C99, pragmas and functions for changing the 142 * rounding mode affect the purity of these functions.) 143 */ 144__BEGIN_DECLS 145/* 146 * ANSI/POSIX 147 */ 148int __fpclassifyd(double); 149int __fpclassifyf(float); 150int __fpclassifyl(long double);
|
151int __signbit(double); |
152 153double acos(double); 154double asin(double); 155double atan(double); 156double atan2(double, double); 157double cos(double); 158double sin(double); 159double tan(double); 160 161double cosh(double); 162double sinh(double); 163double tanh(double); 164 165double exp(double); 166double frexp(double, int *); /* fundamentally !__pure2 */ 167double ldexp(double, int); 168double log(double); 169double log10(double); 170double modf(double, double *); /* fundamentally !__pure2 */ 171 172double pow(double, double); 173double sqrt(double); 174 175double ceil(double); 176double fabs(double); 177double floor(double); 178double fmod(double, double); 179 180/* 181 * These functions are not in C90 so they can be "right". The ones that 182 * never set errno in lib/msun are declared as __pure2. 183 */ 184#if !defined(_ANSI_SOURCE) && !defined(_POSIX_SOURCE) 185double erf(double); 186double erfc(double) __pure2; 187int finite(double) __pure2; 188double gamma(double); 189double hypot(double, double); 190int isinf(double) __pure2; 191int isnan(double) __pure2; 192double j0(double); 193double j1(double); 194double jn(int, double); 195double lgamma(double); 196double y0(double); 197double y1(double); 198double yn(int, double); 199 200#if !defined(_XOPEN_SOURCE) 201double acosh(double); 202double asinh(double); 203double atanh(double); 204double cbrt(double) __pure2; 205double logb(double) __pure2; 206double nextafter(double, double); 207double remainder(double, double); 208double scalb(double, double); 209double tgamma(double); 210 211#ifndef __cplusplus 212int matherr(struct exception *); 213#endif 214 215/* 216 * IEEE Test Vector 217 */ 218double significand(double); 219 220/* 221 * Functions callable from C, intended to support IEEE arithmetic. 222 */ 223double copysign(double, double) __pure2; 224int ilogb(double); 225double rint(double) __pure2; 226double scalbn(double, int); 227 228/* 229 * BSD math library entry points 230 */ 231double drem(double, double); 232double expm1(double) __pure2; 233double log1p(double) __pure2; 234 235/* 236 * Reentrant version of gamma & lgamma; passes signgam back by reference 237 * as the second argument; user must allocate space for signgam. 238 */ 239#ifdef _REENTRANT 240double gamma_r(double, int *); 241double lgamma_r(double, int *); 242#endif /* _REENTRANT */ 243 244/* float versions of ANSI/POSIX functions */ 245float acosf(float); 246float asinf(float); 247float atanf(float); 248float atan2f(float, float); 249float cosf(float); 250float sinf(float); 251float tanf(float); 252 253float coshf(float); 254float sinhf(float); 255float tanhf(float); 256 257float expf(float); 258float frexpf(float, int *); /* fundamentally !__pure2 */ 259float ldexpf(float, int); 260float logf(float); 261float log10f(float); 262float modff(float, float *); /* fundamentally !__pure2 */ 263 264float powf(float, float); 265float sqrtf(float); 266 267float ceilf(float); 268float fabsf(float); 269float floorf(float); 270float fmodf(float, float); 271 272float erff(float); 273float erfcf(float) __pure2; 274int finitef(float) __pure2; 275float gammaf(float); 276float hypotf(float, float) __pure2; 277int isnanf(float) __pure2; 278float j0f(float); 279float j1f(float); 280float jnf(int, float); 281float lgammaf(float); 282float y0f(float); 283float y1f(float); 284float ynf(int, float); 285 286float acoshf(float); 287float asinhf(float); 288float atanhf(float); 289float cbrtf(float) __pure2; 290float logbf(float) __pure2; 291float nextafterf(float, float); 292float remainderf(float, float); 293float scalbf(float, float); 294 295/* 296 * float version of IEEE Test Vector 297 */ 298float significandf(float); 299 300/* 301 * Float versions of functions callable from C, intended to support 302 * IEEE arithmetic. 303 */ 304float copysignf(float, float) __pure2; 305int ilogbf(float); 306float rintf(float); 307float scalbnf(float, int); 308 309/* 310 * float versions of BSD math library entry points 311 */ 312float dremf(float, float); 313float expm1f(float) __pure2; 314float log1pf(float) __pure2; 315 316/* 317 * Float versions of reentrant version of gamma & lgamma; passes 318 * signgam back by reference as the second argument; user must 319 * allocate space for signgam. 320 */ 321#ifdef _REENTRANT 322float gammaf_r(float, int *); 323float lgammaf_r(float, int *); 324#endif /* _REENTRANT */ 325 326#endif /* !_XOPEN_SOURCE */ 327#endif /* !_ANSI_SOURCE && !_POSIX_SOURCE */ 328__END_DECLS 329 330#endif /* !_MATH_H_ */
|