]> granicus.if.org Git - python/commitdiff
Patch #453627: Define the following macros when compiling on a UnixWare 7.x system:
authorMartin v. Löwis <martin@v.loewis.de>
Wed, 5 Sep 2001 14:45:54 +0000 (14:45 +0000)
committerMartin v. Löwis <martin@v.loewis.de>
Wed, 5 Sep 2001 14:45:54 +0000 (14:45 +0000)
SCO_ATAN2_BUG, SCO_ACCEPT_BUG, and STRICT_SYSV_CURSES.
Work aroudn a bug in the SCO UnixWare atan2() implementation.

Modules/cmathmodule.c
Modules/mathmodule.c
Objects/complexobject.c
pyconfig.h.in

index 521d3aa6fc3a6e899d14aec1265776febcc609a4..2cef27cd30bd3729b99155e42659e5db77708f0e 100644 (file)
 #define M_PI (3.141592653589793239)
 #endif
 
+#ifdef SCO_ATAN2_BUG
+/*
+ * UnixWare 7+ is known to have a bug in atan2 that will return PI instead
+ * of ZERO (0) if the first argument is ZERO(0).
+ */
+static double atan2_sco(double x, double y)
+{
+       if (x == 0.0)
+               return (double)0.0;
+       return atan2(x, y);
+}
+#define ATAN2  atan2_sco
+#else
+#define ATAN2  atan2
+#endif
+
 /* First, the C functions that do the real work */
 
 /* constants */
@@ -172,7 +188,7 @@ c_log(Py_complex x)
 {
        Py_complex r;
        double l = hypot(x.real,x.imag);
-       r.imag = atan2(x.imag, x.real);
+       r.imag = ATAN2(x.imag, x.real);
        r.real = log(l);
        return r;
 }
@@ -188,7 +204,7 @@ c_log10(Py_complex x)
 {
        Py_complex r;
        double l = hypot(x.real,x.imag);
-       r.imag = atan2(x.imag, x.real)/log(10.);
+       r.imag = ATAN2(x.imag, x.real)/log(10.);
        r.real = log10(l);
        return r;
 }
index c206ddc0314a73715c0ea401d29342ec6c8907da..7f4839a12fdfad93f09d5803b6232d95b43f8e90 100644 (file)
@@ -31,6 +31,22 @@ extern double modf (double, double *);
 #define CHECK(x) /* Don't know how to check */
 #endif
 
+#ifdef SCO_ATAN2_BUG
+/*
+ * UnixWare 7+ is known to have a bug in atan2 that will return PI instead
+ * of ZERO (0) if the first argument is ZERO(0).
+ */
+static double atan2_sco(double x, double y)
+{
+       if (x == 0.0)
+               return (double)0.0;
+       return atan2(x, y);
+}
+#define ATAN2  atan2_sco
+#else
+#define ATAN2  atan2
+#endif
+
 /* Call is_error when errno != 0, and where x is the result libm
  * returned.  is_error will usually set up an exception and return
  * true (1), but may return false (0) without setting up an exception.
@@ -115,7 +131,7 @@ FUNC1(asin, asin,
       "asin(x)\n\nReturn the arc sine (measured in radians) of x.")
 FUNC1(atan, atan,
       "atan(x)\n\nReturn the arc tangent (measured in radians) of x.")
-FUNC2(atan2, atan2,
+FUNC2(atan2, ATAN2,
       "atan2(y, x)\n\nReturn the arc tangent (measured in radians) of y/x.\n"
       "Unlike atan(y/x), the signs of both x and y are considered.")
 FUNC1(ceil, ceil,
index 740499319a9fef3b754eb5332adde7bf63afd9ae..dde64498936c0758102a00c237b80752974d8db5 100644 (file)
 #define PREC_REPR      17
 #define PREC_STR       12
 
+#ifdef SCO_ATAN2_BUG
+/*
+ * UnixWare 7+ is known to have a bug in atan2 that will return PI instead
+ * of ZERO (0) if the first argument is ZERO(0).
+ */
+static double atan2_sco(double x, double y)
+{
+       if (x == 0.0)
+               return (double)0.0;
+       return atan2(x, y);
+}
+#define ATAN2  atan2_sco
+#else
+#define ATAN2  atan2
+#endif
+
 /* elementary operations on complex numbers */
 
 static Py_complex c_1 = {1., 0.};
@@ -138,7 +154,7 @@ c_pow(Py_complex a, Py_complex b)
        else {
                vabs = hypot(a.real,a.imag);
                len = pow(vabs,b.real);
-               at = atan2(a.imag, a.real);
+               at = ATAN2(a.imag, a.real);
                phase = at*b.real;
                if (b.imag != 0.0) {
                        len /= exp(at*b.imag);
index 72fad87c6d3db27e94e71e062f71fe8585ba628e..14fb375fc9711ac5313f689f050be98af7e4b0bf 100644 (file)
 #define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
 #endif
 #endif
+
+/* Define the macros needed if on a UnixWare 7.x system. */
+#if defined(__USLC__) && defined(__SCO_VERSION__)
+#define SCO_ACCEPT_BUG     /* Use workaround for UnixWare accept() bug */
+#define SCO_ATAN2_BUG      /* Use workaround for UnixWare atan2() bug */
+#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
+#endif