Add -endian patch to fix s390x problems.
This commit is contained in:
parent
5bde3c26f7
commit
ebf37bc154
|
@ -0,0 +1,132 @@
|
|||
--- a/src/gmpy2.h
|
||||
+++ b/src/gmpy2.h
|
||||
@@ -336,7 +336,8 @@ typedef struct {
|
||||
#define Py2or3String_FromFormat PyUnicode_FromFormat
|
||||
#define Py2or3String_Check PyUnicode_Check
|
||||
#define Py2or3String_Format PyUnicode_Format
|
||||
-#define Py2or3String_AsString PyUnicode_AS_DATA
|
||||
+#define Py2or3String_Type Py_UCS4
|
||||
+#define Py2or3String_1Char(obj) (PyUnicode_READY(obj) ? (Py_UCS4)0 : PyUnicode_READ_CHAR(obj, 0))
|
||||
#define PyStrOrUnicode_Check(op) (PyBytes_Check(op) || PyUnicode_Check(op))
|
||||
#define PyIntOrLong_FromLong PyLong_FromLong
|
||||
#define PyIntOrLong_Check(op) PyLong_Check(op)
|
||||
@@ -350,7 +351,8 @@ typedef struct {
|
||||
#define Py2or3String_FromFormat PyString_FromFormat
|
||||
#define Py2or3String_Check PyString_Check
|
||||
#define Py2or3String_Format PyString_Format
|
||||
-#define Py2or3String_AsString PyString_AsString
|
||||
+#define Py2or3String_Type char
|
||||
+#define Py2or3String_1Char(obj) PyString_AsString(obj)[0]
|
||||
#define PyStrOrUnicode_Check(op) (PyString_Check(op) || PyUnicode_Check(op))
|
||||
#define PyIntOrLong_FromLong PyInt_FromLong
|
||||
#define PyIntOrLong_Check(op) (PyInt_Check(op) || PyLong_Check(op))
|
||||
--- a/src/gmpy2_mpmath.c
|
||||
+++ b/src/gmpy2_mpmath.c
|
||||
@@ -73,7 +73,7 @@ Pympz_mpmath_normalize(PyObject *self, P
|
||||
long carry = 0;
|
||||
PyObject *exp = 0, *newexp = 0, *newexp2 = 0, *tmp = 0, *rndstr = 0;
|
||||
MPZ_Object *man = 0, *upper = 0, *lower = 0;
|
||||
- char rnd = 0;
|
||||
+ Py2or3String_Type rnd = 0;
|
||||
int err1, err2, err3;
|
||||
|
||||
if (PyTuple_GET_SIZE(args) == 6) {
|
||||
@@ -105,7 +105,7 @@ Pympz_mpmath_normalize(PyObject *self, P
|
||||
|
||||
/* If rndstr really is a string, extract the first character. */
|
||||
if (Py2or3String_Check(rndstr)) {
|
||||
- rnd = Py2or3String_AsString(rndstr)[0];
|
||||
+ rnd = Py2or3String_1Char(rndstr);
|
||||
}
|
||||
else {
|
||||
VALUE_ERROR("invalid rounding mode specified");
|
||||
@@ -134,7 +134,7 @@ Pympz_mpmath_normalize(PyObject *self, P
|
||||
if (bc > prec) {
|
||||
shift = bc - prec;
|
||||
switch (rnd) {
|
||||
- case 'f':
|
||||
+ case (Py2or3String_Type)'f':
|
||||
if(sign) {
|
||||
mpz_cdiv_q_2exp(upper->z, man->z, shift);
|
||||
}
|
||||
@@ -142,7 +142,7 @@ Pympz_mpmath_normalize(PyObject *self, P
|
||||
mpz_fdiv_q_2exp(upper->z, man->z, shift);
|
||||
}
|
||||
break;
|
||||
- case 'c':
|
||||
+ case (Py2or3String_Type)'c':
|
||||
if(sign) {
|
||||
mpz_fdiv_q_2exp(upper->z, man->z, shift);
|
||||
}
|
||||
@@ -150,13 +150,13 @@ Pympz_mpmath_normalize(PyObject *self, P
|
||||
mpz_cdiv_q_2exp(upper->z, man->z, shift);
|
||||
}
|
||||
break;
|
||||
- case 'd':
|
||||
+ case (Py2or3String_Type)'d':
|
||||
mpz_fdiv_q_2exp(upper->z, man->z, shift);
|
||||
break;
|
||||
- case 'u':
|
||||
+ case (Py2or3String_Type)'u':
|
||||
mpz_cdiv_q_2exp(upper->z, man->z, shift);
|
||||
break;
|
||||
- case 'n':
|
||||
+ case (Py2or3String_Type)'n':
|
||||
default:
|
||||
mpz_tdiv_r_2exp(lower->z, man->z, shift);
|
||||
mpz_tdiv_q_2exp(upper->z, man->z, shift);
|
||||
@@ -241,7 +241,7 @@ Pympz_mpmath_create(PyObject *self, PyOb
|
||||
MPZ_Object *man = 0, *upper = 0, *lower = 0;
|
||||
int error;
|
||||
|
||||
- const char *rnd = "f";
|
||||
+ Py2or3String_Type rnd = (Py2or3String_Type)'f';
|
||||
|
||||
if (PyTuple_GET_SIZE(args) < 2) {
|
||||
TYPE_ERROR("mpmath_create() expects 'mpz','int'[,'int','str'] arguments");
|
||||
@@ -250,7 +250,7 @@ Pympz_mpmath_create(PyObject *self, PyOb
|
||||
|
||||
switch (PyTuple_GET_SIZE(args)) {
|
||||
case 4:
|
||||
- rnd = Py2or3String_AsString(PyTuple_GET_ITEM(args, 3));
|
||||
+ rnd = Py2or3String_1Char(PyTuple_GET_ITEM(args, 3));
|
||||
case 3:
|
||||
prec = GMPy_Integer_AsMpBitCntAndError(PyTuple_GET_ITEM(args, 2), &error);
|
||||
if (error)
|
||||
@@ -291,8 +291,8 @@ Pympz_mpmath_create(PyObject *self, PyOb
|
||||
|
||||
if (bc > prec) {
|
||||
shift = bc - prec;
|
||||
- switch (rnd[0]) {
|
||||
- case 'f':
|
||||
+ switch (rnd) {
|
||||
+ case (Py2or3String_Type)'f':
|
||||
if (sign) {
|
||||
mpz_cdiv_q_2exp(upper->z, upper->z, shift);
|
||||
}
|
||||
@@ -300,7 +300,7 @@ Pympz_mpmath_create(PyObject *self, PyOb
|
||||
mpz_fdiv_q_2exp(upper->z, upper->z, shift);
|
||||
}
|
||||
break;
|
||||
- case 'c':
|
||||
+ case (Py2or3String_Type)'c':
|
||||
if (sign) {
|
||||
mpz_fdiv_q_2exp(upper->z, upper->z, shift);
|
||||
}
|
||||
@@ -308,13 +308,13 @@ Pympz_mpmath_create(PyObject *self, PyOb
|
||||
mpz_cdiv_q_2exp(upper->z, upper->z, shift);
|
||||
}
|
||||
break;
|
||||
- case 'd':
|
||||
+ case (Py2or3String_Type)'d':
|
||||
mpz_fdiv_q_2exp(upper->z, upper->z, shift);
|
||||
break;
|
||||
- case 'u':
|
||||
+ case (Py2or3String_Type)'u':
|
||||
mpz_cdiv_q_2exp(upper->z, upper->z, shift);
|
||||
break;
|
||||
- case 'n':
|
||||
+ case (Py2or3String_Type)'n':
|
||||
default:
|
||||
mpz_tdiv_r_2exp(lower->z, upper->z, shift);
|
||||
mpz_tdiv_q_2exp(upper->z, upper->z, shift);
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
Name: python-%{srcname}
|
||||
Version: 2.1.0
|
||||
Release: 0.16%{?prerelease:.%{prerelease}}%{?dist}
|
||||
Release: 0.17%{?prerelease:.%{prerelease}}%{?dist}
|
||||
Summary: Python interface to GMP, MPFR, and MPC
|
||||
|
||||
License: LGPLv3+
|
||||
|
@ -11,6 +11,9 @@ URL: https://pypi.python.org/pypi/gmpy2
|
|||
Source0: https://github.com/aleaxit/gmpy/archive/%{srcname}-%{version}%{?prerelease}.tar.gz
|
||||
# Work around an apparent inflooping bug in MPFR on 32-bit systems
|
||||
Patch0: %{name}-factorial-32bit.patch
|
||||
# Fix a problem with reading the rounding mode on big endian systems
|
||||
# https://github.com/aleaxit/gmpy/issues/276
|
||||
Patch1: %{name}-endian.patch
|
||||
|
||||
BuildRequires: gcc
|
||||
BuildRequires: gmp-devel
|
||||
|
@ -48,6 +51,7 @@ Provides: bundled(jquery)
|
|||
%if 0%{?__isa_bits} == 32
|
||||
%patch0 -p1
|
||||
%endif
|
||||
%patch1 -p1
|
||||
|
||||
# Update the sphinx theme name
|
||||
sed -i "s/'default'/'classic'/" docs/conf.py
|
||||
|
@ -83,6 +87,9 @@ cd -
|
|||
%{python3_sitearch}/%{srcname}*
|
||||
|
||||
%changelog
|
||||
* Wed Jun 24 2020 Jerry James <loganjerry@gmail.com> - 2.1.0-0.17.b4
|
||||
- Add -endian patch to fix s390x problems
|
||||
|
||||
* Tue May 26 2020 Miro Hrončok <mhroncok@redhat.com> - 2.1.0-0.16.b4
|
||||
- Rebuilt for Python 3.9
|
||||
|
||||
|
|
Loading…
Reference in New Issue