Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 655c955

Browse files
committed
Patch #453627: Define the following macros when compiling on a UnixWare 7.x system:
SCO_ATAN2_BUG, SCO_ACCEPT_BUG, and STRICT_SYSV_CURSES. Work aroudn a bug in the SCO UnixWare atan2() implementation.
1 parent 0ace326 commit 655c955

4 files changed

Lines changed: 59 additions & 4 deletions

File tree

Modules/cmathmodule.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,22 @@
2121
#define M_PI (3.141592653589793239)
2222
#endif
2323

24+
#ifdef SCO_ATAN2_BUG
25+
/*
26+
* UnixWare 7+ is known to have a bug in atan2 that will return PI instead
27+
* of ZERO (0) if the first argument is ZERO(0).
28+
*/
29+
static double atan2_sco(double x, double y)
30+
{
31+
if (x == 0.0)
32+
return (double)0.0;
33+
return atan2(x, y);
34+
}
35+
#define ATAN2 atan2_sco
36+
#else
37+
#define ATAN2 atan2
38+
#endif
39+
2440
/* First, the C functions that do the real work */
2541

2642
/* constants */
@@ -172,7 +188,7 @@ c_log(Py_complex x)
172188
{
173189
Py_complex r;
174190
double l = hypot(x.real,x.imag);
175-
r.imag = atan2(x.imag, x.real);
191+
r.imag = ATAN2(x.imag, x.real);
176192
r.real = log(l);
177193
return r;
178194
}
@@ -188,7 +204,7 @@ c_log10(Py_complex x)
188204
{
189205
Py_complex r;
190206
double l = hypot(x.real,x.imag);
191-
r.imag = atan2(x.imag, x.real)/log(10.);
207+
r.imag = ATAN2(x.imag, x.real)/log(10.);
192208
r.real = log10(l);
193209
return r;
194210
}

Modules/mathmodule.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,22 @@ extern double modf (double, double *);
3131
#define CHECK(x) /* Don't know how to check */
3232
#endif
3333

34+
#ifdef SCO_ATAN2_BUG
35+
/*
36+
* UnixWare 7+ is known to have a bug in atan2 that will return PI instead
37+
* of ZERO (0) if the first argument is ZERO(0).
38+
*/
39+
static double atan2_sco(double x, double y)
40+
{
41+
if (x == 0.0)
42+
return (double)0.0;
43+
return atan2(x, y);
44+
}
45+
#define ATAN2 atan2_sco
46+
#else
47+
#define ATAN2 atan2
48+
#endif
49+
3450
/* Call is_error when errno != 0, and where x is the result libm
3551
* returned. is_error will usually set up an exception and return
3652
* true (1), but may return false (0) without setting up an exception.
@@ -115,7 +131,7 @@ FUNC1(asin, asin,
115131
"asin(x)\n\nReturn the arc sine (measured in radians) of x.")
116132
FUNC1(atan, atan,
117133
"atan(x)\n\nReturn the arc tangent (measured in radians) of x.")
118-
FUNC2(atan2, atan2,
134+
FUNC2(atan2, ATAN2,
119135
"atan2(y, x)\n\nReturn the arc tangent (measured in radians) of y/x.\n"
120136
"Unlike atan(y/x), the signs of both x and y are considered.")
121137
FUNC1(ceil, ceil,

Objects/complexobject.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,22 @@
2626
#define PREC_REPR 17
2727
#define PREC_STR 12
2828

29+
#ifdef SCO_ATAN2_BUG
30+
/*
31+
* UnixWare 7+ is known to have a bug in atan2 that will return PI instead
32+
* of ZERO (0) if the first argument is ZERO(0).
33+
*/
34+
static double atan2_sco(double x, double y)
35+
{
36+
if (x == 0.0)
37+
return (double)0.0;
38+
return atan2(x, y);
39+
}
40+
#define ATAN2 atan2_sco
41+
#else
42+
#define ATAN2 atan2
43+
#endif
44+
2945
/* elementary operations on complex numbers */
3046

3147
static Py_complex c_1 = {1., 0.};
@@ -138,7 +154,7 @@ c_pow(Py_complex a, Py_complex b)
138154
else {
139155
vabs = hypot(a.real,a.imag);
140156
len = pow(vabs,b.real);
141-
at = atan2(a.imag, a.real);
157+
at = ATAN2(a.imag, a.real);
142158
phase = at*b.real;
143159
if (b.imag != 0.0) {
144160
len /= exp(at*b.imag);

pyconfig.h.in

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -716,3 +716,10 @@
716716
#define DL_EXPORT(RTYPE) __declspec(dllexport) RTYPE
717717
#endif
718718
#endif
719+
720+
/* Define the macros needed if on a UnixWare 7.x system. */
721+
#if defined(__USLC__) && defined(__SCO_VERSION__)
722+
#define SCO_ACCEPT_BUG /* Use workaround for UnixWare accept() bug */
723+
#define SCO_ATAN2_BUG /* Use workaround for UnixWare atan2() bug */
724+
#define STRICT_SYSV_CURSES /* Don't use ncurses extensions */
725+
#endif

0 commit comments

Comments
 (0)