Commit 3a85795d authored by scoder's avatar scoder

Merge pull request #403 from codewarrior0/sst-abs-macros

Rewrite __Pyx_sst_abs using only preprocessor macros, and add a case for 64-bit MSVC
parents 349fbcfb aa8f79b1
......@@ -17,15 +17,20 @@
v == (type)PY_SSIZE_T_MAX))) )
// fast and unsafe abs(Py_ssize_t) that ignores the overflow for (-PY_SSIZE_T_MAX-1)
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __Pyx_sst_abs(value) \
(sizeof(int) >= sizeof(Py_ssize_t) ? abs(value) : \
(sizeof(long) >= sizeof(Py_ssize_t) ? labs(value) : llabs(value)))
#if defined (__cplusplus) && __cplusplus >= 201103L
#define __Pyx_sst_abs(value) std::abs(value)
#elif SIZEOF_INT >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) abs(value)
#elif SIZEOF_LONG >= SIZEOF_SIZE_T
#define __Pyx_sst_abs(value) labs(value)
#elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
#define __Pyx_sst_abs(value) llabs(value)
#elif defined (_MSC_VER) && defined (_M_X64)
// abs() is defined for long, but 64-bits type on MSVC is long long.
// Use MS-specific _abs64 instead.
#define __Pyx_sst_abs(value) _abs64(value)
#else
#define __Pyx_sst_abs(value) \
(sizeof(int) >= sizeof(Py_ssize_t) ? abs(value) : \
(sizeof(long) >= sizeof(Py_ssize_t) ? labs(value) : \
((value<0) ? -value : value)))
#define __Pyx_sst_abs(value) ((value<0) ? -value : value))
#endif
static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
......
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