Commit 60f0e2f9 authored by Lisandro Dalcin's avatar Lisandro Dalcin

Use PY_LONG_LONG instead of 'long long' in utility code

parent ddf9821e
......@@ -83,8 +83,8 @@ static CYTHON_INLINE {{UINT}} __Pyx_mul_{{NAME}}_checking_overflow({{UINT}} a, {
{{UINT}} r = ({{UINT}}) big_r;
*overflow |= big_r != r;
return r;
} else if (sizeof({{UINT}}) < sizeof(unsigned long long)) {
unsigned long long big_r = ((unsigned long long) a) * ((unsigned long long) b);
} else if (sizeof({{UINT}}) < sizeof(unsigned PY_LONG_LONG)) {
unsigned PY_LONG_LONG big_r = ((unsigned PY_LONG_LONG) a) * ((unsigned PY_LONG_LONG) b);
{{UINT}} r = ({{UINT}}) big_r;
*overflow |= big_r != r;
return r;
......@@ -137,8 +137,8 @@ static CYTHON_INLINE {{INT}} __Pyx_add_{{NAME}}_checking_overflow({{INT}} a, {{I
{{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r;
return r;
} else if (sizeof({{INT}}) < sizeof(long long)) {
long long big_r = ((long long) a) + ((long long) b);
} else if (sizeof({{INT}}) < sizeof(PY_LONG_LONG)) {
PY_LONG_LONG big_r = ((PY_LONG_LONG) a) + ((PY_LONG_LONG) b);
{{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r;
return r;
......@@ -181,8 +181,8 @@ static CYTHON_INLINE {{INT}} __Pyx_mul_{{NAME}}_checking_overflow({{INT}} a, {{I
{{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r;
return ({{INT}}) r;
} else if (sizeof({{INT}}) < sizeof(long long)) {
long long big_r = ((long long) a) * ((long long) b);
} else if (sizeof({{INT}}) < sizeof(PY_LONG_LONG)) {
PY_LONG_LONG big_r = ((PY_LONG_LONG) a) * ((PY_LONG_LONG) b);
{{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r;
return ({{INT}}) r;
......@@ -228,7 +228,7 @@ __Pyx_check_sane_{{NAME}}();
static int __Pyx_check_sane_{{NAME}}(void) {
if (sizeof({{TYPE}}) <= sizeof(int) ||
sizeof({{TYPE}}) == sizeof(long) ||
sizeof({{TYPE}}) == sizeof(long long)) {
sizeof({{TYPE}}) == sizeof(PY_LONG_LONG)) {
return 0;
} else {
PyErr_Format(PyExc_RuntimeError, \
......@@ -252,7 +252,7 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}
return __Pyx_{{BINOP}}_unsigned_int_checking_overflow(a, b, overflow);
} else if (sizeof({{TYPE}}) == sizeof(unsigned long)) {
return __Pyx_{{BINOP}}_unsigned_long_checking_overflow(a, b, overflow);
} else if (sizeof({{TYPE}}) == sizeof(unsigned long long)) {
} else if (sizeof({{TYPE}}) == sizeof(unsigned PY_LONG_LONG)) {
return __Pyx_{{BINOP}}_unsigned_long_long_checking_overflow(a, b, overflow);
} else {
abort(); return 0; // handled elsewhere
......@@ -262,7 +262,7 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}
return __Pyx_{{BINOP}}_int_checking_overflow(a, b, overflow);
} else if (sizeof({{TYPE}}) == sizeof(long)) {
return __Pyx_{{BINOP}}_long_checking_overflow(a, b, overflow);
} else if (sizeof({{TYPE}}) == sizeof(long long)) {
} else if (sizeof({{TYPE}}) == sizeof(PY_LONG_LONG)) {
return __Pyx_{{BINOP}}_long_long_checking_overflow(a, b, overflow);
} else {
abort(); return 0; // handled elsewhere
......
......@@ -475,14 +475,14 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value) {
return PyInt_FromLong((long) value);
} else if (sizeof({{TYPE}}) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof({{TYPE}}) <= sizeof(unsigned long long)) {
return PyLong_FromUnsignedLongLong((unsigned long long) value);
} else if (sizeof({{TYPE}}) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
}
} else {
if (sizeof({{TYPE}}) <= sizeof(long)) {
return PyInt_FromLong((long) value);
} else if (sizeof({{TYPE}}) <= sizeof(long long)) {
return PyLong_FromLongLong((long long) value);
} else if (sizeof({{TYPE}}) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((PY_LONG_LONG) value);
}
}
{
......@@ -563,8 +563,8 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
#endif
if (sizeof({{TYPE}}) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof({{TYPE}}) <= sizeof(unsigned long long)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long long, PyLong_AsUnsignedLongLong(x))
} else if (sizeof({{TYPE}}) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
}
} else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
......@@ -578,8 +578,8 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
#endif
if (sizeof({{TYPE}}) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, long, PyLong_AsLong(x))
} else if (sizeof({{TYPE}}) <= sizeof(long long)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, long long, PyLong_AsLongLong(x))
} else if (sizeof({{TYPE}}) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, PY_LONG_LONG, PyLong_AsLongLong(x))
}
}
{
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment