@@ -132,19 +132,31 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
132
132
133
133
#if CYTHON_USE_PYLONG_INTERNALS
134
134
#if PY_VERSION_HEX >= 0x030C00A7
135
- #define __Pyx_PyLong_Sign (x ) (((PyLongObject*)x)->long_value.lv_tag & 3)
135
+ #ifndef _PyLong_SIGN_MASK
136
+ #define _PyLong_SIGN_MASK 3
137
+ #endif
138
+ #ifndef _PyLong_NON_SIZE_BITS
139
+ #define _PyLong_NON_SIZE_BITS 3
140
+ #endif
141
+ #define __Pyx_PyLong_Sign (x ) (((PyLongObject*)x)->long_value.lv_tag & _PyLong_SIGN_MASK)
136
142
#define __Pyx_PyLong_IsNeg (x ) ((__Pyx_PyLong_Sign(x) & 2) != 0)
137
143
#define __Pyx_PyLong_IsNonNeg (x ) (!__Pyx_PyLong_IsNeg(x))
138
144
#define __Pyx_PyLong_IsZero (x ) (__Pyx_PyLong_Sign(x) & 1)
139
145
#define __Pyx_PyLong_IsPos (x ) (__Pyx_PyLong_Sign(x) == 0)
140
- #define __Pyx_PyLong_IsCompact (x ) (((PyLongObject*)x)->long_value.lv_tag < (2 << 3)) // (2 << NON_SIZE_BITS)
141
- #define __Pyx_PyLong_CompactValue (x ) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
142
146
#define __Pyx_PyLong_CompactValueUnsigned (x ) (__Pyx_PyLong_Digits(x)[0])
143
- #define __Pyx_PyLong_DigitCount (x ) (((PyLongObject*)x)->long_value.lv_tag >> 3) // (>> NON_SIZE_BITS )
147
+ #define __Pyx_PyLong_DigitCount (x ) (((PyLongObject*)x)->long_value.lv_tag >> _PyLong_NON_SIZE_BITS )
144
148
#define __Pyx_PyLong_SignedDigitCount (x ) \
145
- ((1 - (Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag & 3)) * (Py_ssize_t) (((PyLongObject*)x)->long_value.lv_tag >> 3)) // (>> NON_SIZE_BITS)
149
+ ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_DigitCount(x))
150
+
151
+ #if defined(PyUnstable_Long_IsCompact ) && defined(PyUnstable_Long_CompactValue )
152
+ #define __Pyx_PyLong_IsCompact (x ) PyUnstable_Long_IsCompact(x)
153
+ #define __Pyx_PyLong_CompactValue (x ) PyUnstable_Long_CompactValue(x)
154
+ #else
155
+ #define __Pyx_PyLong_IsCompact (x ) (((PyLongObject*)x)->long_value.lv_tag < (2 << _PyLong_NON_SIZE_BITS))
156
+ #define __Pyx_PyLong_CompactValue (x ) ((1 - (Py_ssize_t) __Pyx_PyLong_Sign(x)) * (Py_ssize_t) __Pyx_PyLong_Digits(x)[0])
157
+ #endif
146
158
147
- // CPython 3.12 requires C99
159
+ // CPython 3.12 requires C99, which defines 'size_t' (but not 'ssize_t')
148
160
typedef Py_ssize_t __Pyx_compact_pylong ;
149
161
typedef size_t __Pyx_compact_upylong ;
150
162
@@ -153,13 +165,14 @@ static CYTHON_INLINE Py_hash_t __Pyx_PyIndex_AsHash_t(PyObject*);
153
165
#define __Pyx_PyLong_IsNonNeg (x ) (Py_SIZE(x) >= 0)
154
166
#define __Pyx_PyLong_IsZero (x ) (Py_SIZE(x) == 0)
155
167
#define __Pyx_PyLong_IsPos (x ) (Py_SIZE(x) > 0)
156
- #define __Pyx_PyLong_IsCompact (x ) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
157
- #define __Pyx_PyLong_CompactValue (x ) \
158
- ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
159
168
#define __Pyx_PyLong_CompactValueUnsigned (x ) ((Py_SIZE(x) == 0) ? 0 : __Pyx_PyLong_Digits(x)[0])
160
169
#define __Pyx_PyLong_DigitCount (x ) __Pyx_sst_abs(Py_SIZE(x))
161
170
#define __Pyx_PyLong_SignedDigitCount (x ) Py_SIZE(x)
162
171
172
+ #define __Pyx_PyLong_IsCompact (x ) (Py_SIZE(x) == 0 || Py_SIZE(x) == 1 || Py_SIZE(x) == -1)
173
+ #define __Pyx_PyLong_CompactValue (x ) \
174
+ ((Py_SIZE(x) == 0) ? (sdigit) 0 : ((Py_SIZE(x) < 0) ? -(sdigit)__Pyx_PyLong_Digits(x)[0] : (sdigit)__Pyx_PyLong_Digits(x)[0]))
175
+
163
176
typedef sdigit __Pyx_compact_pylong ;
164
177
typedef digit __Pyx_compact_upylong ;
165
178
#endif
0 commit comments