+++ /dev/null
-/** @file\r
- Floating-point Math functions and macros.\r
-\r
- Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
- This program and the accompanying materials are licensed and made available under\r
- the terms and conditions of the BSD License that accompanies this distribution.\r
- The full text of the license may be found at\r
- http://opensource.org/licenses/bsd-license.\r
-\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
- * ====================================================\r
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.\r
- *\r
- * Developed at SunPro, a Sun Microsystems, Inc. business.\r
- * Permission to use, copy, modify, and distribute this\r
- * software is freely granted, provided that this notice\r
- * is preserved.\r
- * ====================================================\r
-\r
- NetBSD: math.h,v 1.44 2006/03/25 16:41:11 xtraeme Exp\r
- dlibm.h 5.1 93/09/24\r
-**/\r
-#ifndef _MATH_H_\r
-#define _MATH_H_\r
-\r
-#include <sys/EfiCdefs.h>\r
-#include <sys/featuretest.h>\r
-\r
-/** @{\r
- @brief These are forward references to unions and macros used internaly\r
- by the implementation of the math functions and macros.\r
-**/\r
-union __float_u {\r
- unsigned char __dummy[sizeof(float)];\r
- float __val;\r
-};\r
-\r
-union __double_u {\r
- unsigned char __dummy[sizeof(double)];\r
- double __val;\r
-};\r
-\r
-union __long_double_u {\r
- unsigned char __dummy[sizeof(long double)];\r
- long double __val;\r
-};\r
-\r
-#include <machine/math.h> /* may use __float_u, __double_u, or __long_double_u */\r
-\r
-#ifdef __HAVE_LONG_DOUBLE\r
-#define __fpmacro_unary_floating(__name, __arg0) \\r
- /* LINTED */ \\r
- ((sizeof (__arg0) == sizeof (float)) \\r
- ? __ ## __name ## f (__arg0) \\r
- : (sizeof (__arg0) == sizeof (double)) \\r
- ? __ ## __name ## d (__arg0) \\r
- : __ ## __name ## l (__arg0))\r
-#else\r
-#define __fpmacro_unary_floating(__name, __arg0) \\r
- /* LINTED */ \\r
- ((sizeof (__arg0) == sizeof (float)) \\r
- ? __ ## __name ## f (__arg0) \\r
- : __ ## __name ## d (__arg0))\r
-#endif /* __HAVE_LONG_DOUBLE */\r
-\r
-extern const union __double_u __infinity;\r
-extern const union __float_u __infinityf;\r
-extern const union __long_double_u __infinityl;\r
-\r
-/* C99 7.12.3.1 int fpclassify(real-floating x) */\r
-#define fpclassify(__x) __fpmacro_unary_floating(fpclassify, __x)\r
-\r
-/* C99 7.12.3.3 int isinf(real-floating x) */\r
-#ifdef __isinf\r
- #define isinf(__x) __isinf(__x)\r
-#else\r
- #define isinf(__x) __fpmacro_unary_floating(isinf, __x)\r
-#endif\r
-\r
-/* C99 7.12.3.4 int isnan(real-floating x) */\r
-#ifdef __isnan\r
- #define isnan(__x) __isnan(__x)\r
-#else\r
- #define isnan(__x) __fpmacro_unary_floating(isnan, __x)\r
-#endif\r
-/*@)*/\r
-\r
-/*#############################################################\r
- * ISO C95\r
- */\r
-\r
-/**@{\r
- Double, float, and long double versions, respectively, of HUGE_VAL.\r
-*/\r
-#define HUGE_VAL __infinity.__val\r
-#define HUGE_VALF __infinityf.__val\r
-#define HUGE_VALL __infinityl.__val\r
-/*@)*/\r
-\r
-__BEGIN_DECLS\r
-/*\r
- * ANSI/POSIX\r
- */\r
-/** Compute the principal value of the arc cosine of Arg.\r
-\r
- @param[in] Arg The value to compute the arc cosine of.\r
-\r
- @return The computed value of the arc cosine of Arg in the interval [0,pi] radians.\r
- If Arg is not in the interval [-1,+1], errno is set to EDOM.\r
-**/\r
-double acos(double Arg);\r
-\r
-/** Compute the principal value of the arc sine of Arg.\r
-\r
- @param[in] Arg The value to compute the arc sine of.\r
-\r
- @return The computed value of the arc sine of Arg in the interval [-pi/2,+pi/2] radians.\r
- If Arg is not in the interval [-1,+1], errno is set to EDOM.\r
-**/\r
-double asin(double Arg);\r
-\r
-/** Compute the principal value of the arc tangent of Arg.\r
-\r
- @param[in] Arg The value to compute the arc tangent of.\r
-\r
- @return The computed value of the arc tangent of Arg in the interval [-pi/2,+pi/2] radians.\r
-**/\r
-double atan(double Arg);\r
-\r
-/** Compute the value of the arc tangent of (Num / Denom).\r
- The sign of both arguments is used to determine the quadrant of the return value.\r
-\r
- @param[in] Num The numerator of the value to compute the arc tangent of.\r
- @param[in] Denom The denominator of the value to compute the arc tangent of.\r
-\r
- @return The computed value of the arc tangent of (Num / Denom) in the interval [-pi,+pi] radians.\r
-**/\r
-double atan2(double Num, double Denom);\r
-\r
-/** Compute the value of the cosine of Arg, measured in radians.\r
-\r
- @param[in] Arg The value to compute the cosine of.\r
-\r
- @return The computed value of the cosine of Arg.\r
-**/\r
-double cos(double Arg);\r
-\r
-/** Compute the value of the sine of Arg.\r
-\r
- @param[in] Arg The value to compute the sine of.\r
-\r
- @return The computed value of the sine of Arg.\r
-**/\r
-double sin(double Arg);\r
-\r
-/** Compute the value of the tangent of Arg.\r
-\r
- @param[in] Arg The value to compute the tangent of.\r
-\r
- @return The computed value of the tangent of Arg.\r
-**/\r
-double tan(double Arg);\r
-\r
-\r
-/** Compute the value of the hyperbolic cosine of Arg.\r
-\r
- @param[in] Arg The value to compute the hyperbolic cosine of.\r
-\r
- @return The computed value of the hyperbolic cosine of Arg.\r
- If the magnitude of Arg is too large, errno is set to ERANGE.\r
-**/\r
-double cosh(double Arg);\r
-\r
-/** Compute the value of the hyperbolic sine of Arg.\r
-\r
- @param[in] Arg The value to compute the hyperbolic sine of.\r
-\r
- @return The computed value of the hyperbolic sine of Arg.\r
- If the magnitude of Arg is too large, errno is set to ERANGE.\r
-**/\r
-double sinh(double Arg);\r
-\r
-/** Compute the value of the hyperbolic tangent of Arg.\r
-\r
- @param[in] Arg The value to compute the hyperbolic tangent of.\r
-\r
- @return The computed value of the hyperbolic tangent of Arg.\r
-**/\r
-double tanh(double Arg);\r
-\r
-\r
-/** Compute the base-e exponential of Arg.\r
-\r
- @param[in] Arg The value to compute the base-e exponential of.\r
-\r
- @return The computed value of e**Arg.\r
- If the magnitude of Arg is too large, errno is set to ERANGE.\r
-**/\r
-double exp(double Arg);\r
-\r
-/** Break a floating-point number into a normalized fraction and an integral power of 2.\r
-\r
- @param[in] Value The floating-point value to be broken down.\r
- @param[out] Exp A pointer to an integer object to receive the integral power of 2 exponent.\r
-\r
- @return The frexp function returns a value R, such that Value == R**Exp.\r
- If Value is zero, both parts of the result are zero.\r
-**/\r
-double frexp(double Value, int *Exp);\r
-\r
-/** Multiply a floating-point number, Value, by an integral power of 2, Exp.\r
-\r
- @param[in] Value The floating-point value to be multiplied.\r
- @param[out] Exp The integral power of 2 to multiply Value by.\r
-\r
- @return The ldexp function returns a value R, such that R = Value x 2**Exp.\r
- If a range error occurs, errno will be set to ERANGE.\r
-**/\r
-double ldexp(double Value, int Exp);\r
-\r
-/** Compute the natural logarithm of Arg.\r
-\r
- @param[in] Arg The value to compute the natural logarithm of.\r
-\r
- @return The log function returns log base-e of Arg. If Arg is negative, errno is set to EDOM.\r
- Otherwise, errno will be set to ERANGE if a range error occurs.\r
-**/\r
-double log(double Arg);\r
-\r
-/** Compute the common (base-10) logarithm of Arg.\r
-\r
- @param[in] Arg The value to compute the common logarithm of.\r
-\r
- @return The log10 function returns log base-10 of Arg. If Arg is negative, errno is set to EDOM.\r
- Otherwise, errno will be set to ERANGE if Arg is 0.\r
-**/\r
-double log10(double Arg);\r
-\r
-/** Compute the base-2 logarithm of Arg.\r
-\r
- @param[in] Arg The value to compute the base-2 logarithm of.\r
-\r
- @return The log function returns log base-2 of Arg. If Arg is negative, errno is set to EDOM.\r
- Otherwise, errno will be set to ERANGE if Arg is 0.\r
-**/\r
-double log2(double Arg);\r
-\r
-/** Break Value into integral and fractional parts, each of which has the same type and sign\r
- as Value. Store the integral part in the object pointed to by Integ and return the\r
- fractional part.\r
-\r
- @param[in] Value The value to compute the arc cosine of.\r
- @param[out] Integ Pointer to where the integral component is to be stored.\r
-\r
- @return The fractional part of Value is returned directly while the integral part is\r
- returned in the location pointed to by Integ.\r
-**/\r
-double modf(double Value, double *Integ);\r
-\r
-/** Compute Value raised to the power Exp.\r
-\r
- @param[in] Value The value to be raised.\r
- @param[in] Exp The power Value is to be raised to.\r
-\r
- @return The pow function returns Value**Exp. If an error occurs, errno will be set as follows:\r
- - EDOM: Value is finite and negative and Exp is finite and not an integer.\r
- - EDOM: Both Value and Exp are zero.\r
- - EDOM: Value is zero and Exp is less than zero.\r
-**/\r
-double pow(double Value, double Exp);\r
-\r
-/** Compute the non-negative square root of Arg.\r
-\r
- @param[in] Arg The value to compute the square root of.\r
-\r
- @return The square root of Arg. If Arg is less than zero, errno is set to EDOM.\r
-**/\r
-double sqrt(double Arg);\r
-\r
-\r
-/** Compute the smallest integer value not less than Arg.\r
-\r
- @param[in] Arg The value to compute the ceiling of.\r
-\r
- @return The ceiling of Arg expressed as a floating-point number.\r
-**/\r
-double ceil(double Arg);\r
-\r
-/** Compute the absolute value of Arg.\r
-\r
- @param[in] Arg The value to compute the absolute value of.\r
-\r
- @return The absolute value of Arg.\r
-**/\r
-double fabs(double Arg);\r
-\r
-/** Compute the largest integer value not greater than Arg.\r
-\r
- @param[in] Arg The value to compute the floor of.\r
-\r
- @return The largest integer value not greater than Arg, expressed as a floating-point number.\r
-**/\r
-double floor(double);\r
-\r
-/** Compute the floating-point remainder of A1 / A2.\r
-\r
- @param[in] A1 The dividend.\r
- @param[in] A2 The divisor.\r
-\r
- @return The remainder of A1 / A2 with the same sign as A1. If A2 is zero, the fmod function\r
- returns 0.\r
-**/\r
-double fmod(double A1, double A2);\r
-\r
-\r
-int finite(double);\r
-double expm1(double);\r
-\r
-/**@{\r
- C99, Posix, or NetBSD functions that are not part of the C95 specification.\r
-**/\r
-/*\r
- * Functions callable from C, intended to support IEEE arithmetic.\r
- */\r
-double copysign(double, double);\r
-double scalbn(double, int);\r
-\r
-/*\r
- * Library implementation\r
- */\r
-int __fpclassifyf(float);\r
-int __fpclassifyd(double);\r
-int __isinff(float);\r
-int __isinfd(double);\r
-int __isnanf(float);\r
-int __isnand(double);\r
-\r
-#ifdef __HAVE_LONG_DOUBLE\r
- int __fpclassifyl(long double);\r
- int __isinfl(long double);\r
- int __isnanl(long double);\r
-#endif /* __HAVE_LONG_DOUBLE */\r
-/*@}*/\r
-\r
-__END_DECLS\r
-\r
-/**@{\r
- Extensions provided by NetBSD but not required by the C95 standard.\r
-**/\r
-extern int signgam;\r
-\r
-enum fdversion {fdlibm_ieee = -1, fdlibm_svid, fdlibm_xopen, fdlibm_posix};\r
-\r
-#define _LIB_VERSION_TYPE enum fdversion\r
-#define _LIB_VERSION _fdlib_version\r
-\r
-/** If global variable _LIB_VERSION is not desirable, one may\r
- * change the following to be a constant by:\r
- * #define _LIB_VERSION_TYPE const enum version\r
- * In that case, after one initializes the value _LIB_VERSION (see\r
- * s_lib_version.c) during compile time, it cannot be modified\r
- * in the middle of a program\r
- */\r
-extern _LIB_VERSION_TYPE _LIB_VERSION;\r
-\r
-#define _IEEE_ fdlibm_ieee\r
-#define _SVID_ fdlibm_svid\r
-#define _XOPEN_ fdlibm_xopen\r
-#define _POSIX_ fdlibm_posix\r
-\r
-#ifndef __cplusplus\r
-struct exception {\r
- int type;\r
- char *name;\r
- double arg1;\r
- double arg2;\r
- double retval;\r
-};\r
-#endif\r
-\r
-#define HUGE MAXFLOAT\r
-\r
-/** set X_TLOSS = pi*2**52 **/\r
-#define X_TLOSS 1.41484755040568800000e+16\r
-\r
-#define DOMAIN 1\r
-#define SING 2\r
-#define OVERFLOW 3\r
-#define UNDERFLOW 4\r
-#define TLOSS 5\r
-#define PLOSS 6\r
-/*@}*/\r
-\r
-/* 7.12#4 INFINITY */\r
-#ifdef __INFINITY\r
-#define INFINITY __INFINITY /**< float constant which overflows */\r
-#else\r
-#define INFINITY HUGE_VALF /**< positive infinity */\r
-#endif /* __INFINITY */\r
-\r
-/* 7.12#5 NAN: a quiet NaN, if supported */\r
-#ifdef __HAVE_NANF\r
-extern const union __float_u __nanf;\r
-#define NAN __nanf.__val\r
-#endif /* __HAVE_NANF */\r
-\r
-/**@{\r
- C99 7.12#6 Number classification macros represent mutually exclusive kinds of floating-point\r
- values.\r
-**/\r
-#define FP_INFINITE 0x00\r
-#define FP_NAN 0x01\r
-#define FP_NORMAL 0x02\r
-#define FP_SUBNORMAL 0x03\r
-#define FP_ZERO 0x04\r
-/* NetBSD extensions */\r
-#define _FP_LOMD 0x80 /**< range for machine-specific classes */\r
-#define _FP_HIMD 0xff\r
-/*@)*/\r
-\r
-/**@{\r
- * Constants ala XOPEN/SVID.\r
- */\r
-#define M_E 2.7182818284590452354 /**< e */\r
-#define M_LOG2E 1.4426950408889634074 /**< log 2e */\r
-#define M_LOG10E 0.43429448190325182765 /**< log 10e */\r
-#define M_LN2 0.69314718055994530942 /**< log e2 */\r
-#define M_LN10 2.30258509299404568402 /**< log e10 */\r
-#define M_PI 3.14159265358979323846 /**< pi */\r
-#define M_PI_2 1.57079632679489661923 /**< pi/2 */\r
-#define M_PI_4 0.78539816339744830962 /**< pi/4 */\r
-#define M_1_PI 0.31830988618379067154 /**< 1/pi */\r
-#define M_2_PI 0.63661977236758134308 /**< 2/pi */\r
-#define M_2_SQRTPI 1.12837916709551257390 /**< 2/sqrt(pi) */\r
-#define M_SQRT2 1.41421356237309504880 /**< sqrt(2) */\r
-#define M_SQRT1_2 0.70710678118654752440 /**< 1/sqrt(2) */\r
-#define MAXFLOAT ((float)3.40282346638528860e+38)\r
-/*@}*/\r
-\r
-#endif /* _MATH_H_ */\r