]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.10/Include/pymath.h
AppPkg/Applications/Python/Python-2.7.10: Initial Checkin part 1/5.
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.10 / Include / pymath.h
diff --git a/AppPkg/Applications/Python/Python-2.7.10/Include/pymath.h b/AppPkg/Applications/Python/Python-2.7.10/Include/pymath.h
new file mode 100644 (file)
index 0000000..f63ddb7
--- /dev/null
@@ -0,0 +1,192 @@
+#ifndef Py_PYMATH_H\r
+#define Py_PYMATH_H\r
+\r
+#include "pyconfig.h" /* include for defines */\r
+\r
+/**************************************************************************\r
+Symbols and macros to supply platform-independent interfaces to mathematical\r
+functions and constants\r
+**************************************************************************/\r
+\r
+/* Python provides implementations for copysign, round and hypot in\r
+ * Python/pymath.c just in case your math library doesn't provide the\r
+ * functions.\r
+ *\r
+ *Note: PC/pyconfig.h defines copysign as _copysign\r
+ */\r
+#ifndef HAVE_COPYSIGN\r
+extern double copysign(double, double);\r
+#endif\r
+\r
+#ifndef HAVE_ROUND\r
+extern double round(double);\r
+#endif\r
+\r
+#ifndef HAVE_HYPOT\r
+extern double hypot(double, double);\r
+#endif\r
+\r
+/* extra declarations */\r
+#ifndef _MSC_VER\r
+#ifndef __STDC__\r
+extern double fmod (double, double);\r
+extern double frexp (double, int *);\r
+extern double ldexp (double, int);\r
+extern double modf (double, double *);\r
+extern double pow(double, double);\r
+#endif /* __STDC__ */\r
+#endif /* _MSC_VER */\r
+\r
+#ifdef _OSF_SOURCE\r
+/* OSF1 5.1 doesn't make these available with XOPEN_SOURCE_EXTENDED defined */\r
+extern int finite(double);\r
+extern double copysign(double, double);\r
+#endif\r
+\r
+/* High precision defintion of pi and e (Euler)\r
+ * The values are taken from libc6's math.h.\r
+ */\r
+#ifndef Py_MATH_PIl\r
+#define Py_MATH_PIl 3.1415926535897932384626433832795029L\r
+#endif\r
+#ifndef Py_MATH_PI\r
+#define Py_MATH_PI 3.14159265358979323846\r
+#endif\r
+\r
+#ifndef Py_MATH_El\r
+#define Py_MATH_El 2.7182818284590452353602874713526625L\r
+#endif\r
+\r
+#ifndef Py_MATH_E\r
+#define Py_MATH_E 2.7182818284590452354\r
+#endif\r
+\r
+/* On x86, Py_FORCE_DOUBLE forces a floating-point number out of an x87 FPU\r
+   register and into a 64-bit memory location, rounding from extended\r
+   precision to double precision in the process.  On other platforms it does\r
+   nothing. */\r
+\r
+/* we take double rounding as evidence of x87 usage */\r
+#ifndef Py_FORCE_DOUBLE\r
+#  ifdef X87_DOUBLE_ROUNDING\r
+PyAPI_FUNC(double) _Py_force_double(double);\r
+#    define Py_FORCE_DOUBLE(X) (_Py_force_double(X))\r
+#  else\r
+#    define Py_FORCE_DOUBLE(X) (X)\r
+#  endif\r
+#endif\r
+\r
+#ifdef HAVE_GCC_ASM_FOR_X87\r
+PyAPI_FUNC(unsigned short) _Py_get_387controlword(void);\r
+PyAPI_FUNC(void) _Py_set_387controlword(unsigned short);\r
+#endif\r
+\r
+/* Py_IS_NAN(X)\r
+ * Return 1 if float or double arg is a NaN, else 0.\r
+ * Caution:\r
+ *     X is evaluated more than once.\r
+ *     This may not work on all platforms.  Each platform has *some*\r
+ *     way to spell this, though -- override in pyconfig.h if you have\r
+ *     a platform where it doesn't work.\r
+ * Note: PC/pyconfig.h defines Py_IS_NAN as _isnan\r
+ */\r
+#ifndef Py_IS_NAN\r
+#if defined HAVE_DECL_ISNAN && HAVE_DECL_ISNAN == 1\r
+#define Py_IS_NAN(X) isnan(X)\r
+#else\r
+#define Py_IS_NAN(X) ((X) != (X))\r
+#endif\r
+#endif\r
+\r
+/* Py_IS_INFINITY(X)\r
+ * Return 1 if float or double arg is an infinity, else 0.\r
+ * Caution:\r
+ *    X is evaluated more than once.\r
+ *    This implementation may set the underflow flag if |X| is very small;\r
+ *    it really can't be implemented correctly (& easily) before C99.\r
+ *    Override in pyconfig.h if you have a better spelling on your platform.\r
+ *  Py_FORCE_DOUBLE is used to avoid getting false negatives from a\r
+ *    non-infinite value v sitting in an 80-bit x87 register such that\r
+ *    v becomes infinite when spilled from the register to 64-bit memory.\r
+ * Note: PC/pyconfig.h defines Py_IS_INFINITY as _isinf\r
+ */\r
+#ifndef Py_IS_INFINITY\r
+#  if defined HAVE_DECL_ISINF && HAVE_DECL_ISINF == 1\r
+#    define Py_IS_INFINITY(X) isinf(X)\r
+#  else\r
+#    define Py_IS_INFINITY(X) ((X) &&                                   \\r
+                               (Py_FORCE_DOUBLE(X)*0.5 == Py_FORCE_DOUBLE(X)))\r
+#  endif\r
+#endif\r
+\r
+/* Py_IS_FINITE(X)\r
+ * Return 1 if float or double arg is neither infinite nor NAN, else 0.\r
+ * Some compilers (e.g. VisualStudio) have intrisics for this, so a special\r
+ * macro for this particular test is useful\r
+ * Note: PC/pyconfig.h defines Py_IS_FINITE as _finite\r
+ */\r
+#ifndef Py_IS_FINITE\r
+#if defined HAVE_DECL_ISFINITE && HAVE_DECL_ISFINITE == 1\r
+#define Py_IS_FINITE(X) isfinite(X)\r
+#elif defined HAVE_FINITE\r
+#define Py_IS_FINITE(X) finite(X)\r
+#else\r
+#define Py_IS_FINITE(X) (!Py_IS_INFINITY(X) && !Py_IS_NAN(X))\r
+#endif\r
+#endif\r
+\r
+/* HUGE_VAL is supposed to expand to a positive double infinity.  Python\r
+ * uses Py_HUGE_VAL instead because some platforms are broken in this\r
+ * respect.  We used to embed code in pyport.h to try to worm around that,\r
+ * but different platforms are broken in conflicting ways.  If you're on\r
+ * a platform where HUGE_VAL is defined incorrectly, fiddle your Python\r
+ * config to #define Py_HUGE_VAL to something that works on your platform.\r
+ */\r
+#ifndef Py_HUGE_VAL\r
+#define Py_HUGE_VAL HUGE_VAL\r
+#endif\r
+\r
+/* Py_NAN\r
+ * A value that evaluates to a NaN. On IEEE 754 platforms INF*0 or\r
+ * INF/INF works. Define Py_NO_NAN in pyconfig.h if your platform\r
+ * doesn't support NaNs.\r
+ */\r
+#if !defined(Py_NAN) && !defined(Py_NO_NAN)\r
+#define Py_NAN (Py_HUGE_VAL * 0.)\r
+#endif\r
+\r
+/* Py_OVERFLOWED(X)\r
+ * Return 1 iff a libm function overflowed.  Set errno to 0 before calling\r
+ * a libm function, and invoke this macro after, passing the function\r
+ * result.\r
+ * Caution:\r
+ *    This isn't reliable.  C99 no longer requires libm to set errno under\r
+ *       any exceptional condition, but does require +- HUGE_VAL return\r
+ *       values on overflow.  A 754 box *probably* maps HUGE_VAL to a\r
+ *       double infinity, and we're cool if that's so, unless the input\r
+ *       was an infinity and an infinity is the expected result.  A C89\r
+ *       system sets errno to ERANGE, so we check for that too.  We're\r
+ *       out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or\r
+ *       if the returned result is a NaN, or if a C89 box returns HUGE_VAL\r
+ *       in non-overflow cases.\r
+ *    X is evaluated more than once.\r
+ * Some platforms have better way to spell this, so expect some #ifdef'ery.\r
+ *\r
+ * OpenBSD uses 'isinf()' because a compiler bug on that platform causes\r
+ * the longer macro version to be mis-compiled. This isn't optimal, and\r
+ * should be removed once a newer compiler is available on that platform.\r
+ * The system that had the failure was running OpenBSD 3.2 on Intel, with\r
+ * gcc 2.95.3.\r
+ *\r
+ * According to Tim's checkin, the FreeBSD systems use isinf() to work\r
+ * around a FPE bug on that platform.\r
+ */\r
+#if defined(__FreeBSD__) || defined(__OpenBSD__)\r
+#define Py_OVERFLOWED(X) isinf(X)\r
+#else\r
+#define Py_OVERFLOWED(X) ((X) != 0.0 && (errno == ERANGE ||    \\r
+                                        (X) == Py_HUGE_VAL || \\r
+                                        (X) == -Py_HUGE_VAL))\r
+#endif\r
+\r
+#endif /* Py_PYMATH_H */\r