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, { ...@@ -83,8 +83,8 @@ static CYTHON_INLINE {{UINT}} __Pyx_mul_{{NAME}}_checking_overflow({{UINT}} a, {
{{UINT}} r = ({{UINT}}) big_r; {{UINT}} r = ({{UINT}}) big_r;
*overflow |= big_r != r; *overflow |= big_r != r;
return r; return r;
} else if (sizeof({{UINT}}) < sizeof(unsigned long long)) { } else if (sizeof({{UINT}}) < sizeof(unsigned PY_LONG_LONG)) {
unsigned long long big_r = ((unsigned long long) a) * ((unsigned long long) b); unsigned PY_LONG_LONG big_r = ((unsigned PY_LONG_LONG) a) * ((unsigned PY_LONG_LONG) b);
{{UINT}} r = ({{UINT}}) big_r; {{UINT}} r = ({{UINT}}) big_r;
*overflow |= big_r != r; *overflow |= big_r != r;
return r; return r;
...@@ -137,8 +137,8 @@ static CYTHON_INLINE {{INT}} __Pyx_add_{{NAME}}_checking_overflow({{INT}} a, {{I ...@@ -137,8 +137,8 @@ static CYTHON_INLINE {{INT}} __Pyx_add_{{NAME}}_checking_overflow({{INT}} a, {{I
{{INT}} r = ({{INT}}) big_r; {{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r; *overflow |= big_r != r;
return r; return r;
} else if (sizeof({{INT}}) < sizeof(long long)) { } else if (sizeof({{INT}}) < sizeof(PY_LONG_LONG)) {
long long big_r = ((long long) a) + ((long long) b); PY_LONG_LONG big_r = ((PY_LONG_LONG) a) + ((PY_LONG_LONG) b);
{{INT}} r = ({{INT}}) big_r; {{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r; *overflow |= big_r != r;
return r; return r;
...@@ -181,8 +181,8 @@ static CYTHON_INLINE {{INT}} __Pyx_mul_{{NAME}}_checking_overflow({{INT}} a, {{I ...@@ -181,8 +181,8 @@ static CYTHON_INLINE {{INT}} __Pyx_mul_{{NAME}}_checking_overflow({{INT}} a, {{I
{{INT}} r = ({{INT}}) big_r; {{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r; *overflow |= big_r != r;
return ({{INT}}) r; return ({{INT}}) r;
} else if (sizeof({{INT}}) < sizeof(long long)) { } else if (sizeof({{INT}}) < sizeof(PY_LONG_LONG)) {
long long big_r = ((long long) a) * ((long long) b); PY_LONG_LONG big_r = ((PY_LONG_LONG) a) * ((PY_LONG_LONG) b);
{{INT}} r = ({{INT}}) big_r; {{INT}} r = ({{INT}}) big_r;
*overflow |= big_r != r; *overflow |= big_r != r;
return ({{INT}}) r; return ({{INT}}) r;
...@@ -228,7 +228,7 @@ __Pyx_check_sane_{{NAME}}(); ...@@ -228,7 +228,7 @@ __Pyx_check_sane_{{NAME}}();
static int __Pyx_check_sane_{{NAME}}(void) { static int __Pyx_check_sane_{{NAME}}(void) {
if (sizeof({{TYPE}}) <= sizeof(int) || if (sizeof({{TYPE}}) <= sizeof(int) ||
sizeof({{TYPE}}) == sizeof(long) || sizeof({{TYPE}}) == sizeof(long) ||
sizeof({{TYPE}}) == sizeof(long long)) { sizeof({{TYPE}}) == sizeof(PY_LONG_LONG)) {
return 0; return 0;
} else { } else {
PyErr_Format(PyExc_RuntimeError, \ PyErr_Format(PyExc_RuntimeError, \
...@@ -252,7 +252,7 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE} ...@@ -252,7 +252,7 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}
return __Pyx_{{BINOP}}_unsigned_int_checking_overflow(a, b, overflow); return __Pyx_{{BINOP}}_unsigned_int_checking_overflow(a, b, overflow);
} else if (sizeof({{TYPE}}) == sizeof(unsigned long)) { } else if (sizeof({{TYPE}}) == sizeof(unsigned long)) {
return __Pyx_{{BINOP}}_unsigned_long_checking_overflow(a, b, overflow); 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); return __Pyx_{{BINOP}}_unsigned_long_long_checking_overflow(a, b, overflow);
} else { } else {
abort(); return 0; // handled elsewhere abort(); return 0; // handled elsewhere
...@@ -262,7 +262,7 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE} ...@@ -262,7 +262,7 @@ static CYTHON_INLINE {{TYPE}} __Pyx_{{BINOP}}_{{NAME}}_checking_overflow({{TYPE}
return __Pyx_{{BINOP}}_int_checking_overflow(a, b, overflow); return __Pyx_{{BINOP}}_int_checking_overflow(a, b, overflow);
} else if (sizeof({{TYPE}}) == sizeof(long)) { } else if (sizeof({{TYPE}}) == sizeof(long)) {
return __Pyx_{{BINOP}}_long_checking_overflow(a, b, overflow); 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); return __Pyx_{{BINOP}}_long_long_checking_overflow(a, b, overflow);
} else { } else {
abort(); return 0; // handled elsewhere abort(); return 0; // handled elsewhere
......
...@@ -475,14 +475,14 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value) { ...@@ -475,14 +475,14 @@ static CYTHON_INLINE PyObject* {{TO_PY_FUNCTION}}({{TYPE}} value) {
return PyInt_FromLong((long) value); return PyInt_FromLong((long) value);
} else if (sizeof({{TYPE}}) <= sizeof(unsigned long)) { } else if (sizeof({{TYPE}}) <= sizeof(unsigned long)) {
return PyLong_FromUnsignedLong((unsigned long) value); return PyLong_FromUnsignedLong((unsigned long) value);
} else if (sizeof({{TYPE}}) <= sizeof(unsigned long long)) { } else if (sizeof({{TYPE}}) <= sizeof(unsigned PY_LONG_LONG)) {
return PyLong_FromUnsignedLongLong((unsigned long long) value); return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
} }
} else { } else {
if (sizeof({{TYPE}}) <= sizeof(long)) { if (sizeof({{TYPE}}) <= sizeof(long)) {
return PyInt_FromLong((long) value); return PyInt_FromLong((long) value);
} else if (sizeof({{TYPE}}) <= sizeof(long long)) { } else if (sizeof({{TYPE}}) <= sizeof(PY_LONG_LONG)) {
return PyLong_FromLongLong((long long) value); return PyLong_FromLongLong((PY_LONG_LONG) value);
} }
} }
{ {
...@@ -563,8 +563,8 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { ...@@ -563,8 +563,8 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
#endif #endif
if (sizeof({{TYPE}}) <= sizeof(unsigned long)) { if (sizeof({{TYPE}}) <= sizeof(unsigned long)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long, PyLong_AsUnsignedLong(x)) __PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long, PyLong_AsUnsignedLong(x))
} else if (sizeof({{TYPE}}) <= sizeof(unsigned long long)) { } else if (sizeof({{TYPE}}) <= sizeof(unsigned PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned long long, PyLong_AsUnsignedLongLong(x)) __PYX_VERIFY_RETURN_INT({{TYPE}}, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
} }
} else { } else {
#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3 #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
...@@ -578,8 +578,8 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) { ...@@ -578,8 +578,8 @@ static CYTHON_INLINE {{TYPE}} {{FROM_PY_FUNCTION}}(PyObject *x) {
#endif #endif
if (sizeof({{TYPE}}) <= sizeof(long)) { if (sizeof({{TYPE}}) <= sizeof(long)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, long, PyLong_AsLong(x)) __PYX_VERIFY_RETURN_INT({{TYPE}}, long, PyLong_AsLong(x))
} else if (sizeof({{TYPE}}) <= sizeof(long long)) { } else if (sizeof({{TYPE}}) <= sizeof(PY_LONG_LONG)) {
__PYX_VERIFY_RETURN_INT({{TYPE}}, long long, PyLong_AsLongLong(x)) __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