1 /* Generated by Cython 0.29.23 */
2
3 #ifndef PY_SSIZE_T_CLEAN
4 #define PY_SSIZE_T_CLEAN
5 #endif /* PY_SSIZE_T_CLEAN */
6 #include "Python.h"
7 #ifndef Py_PYTHON_H
8 #error Python headers needed to compile C extensions, please install development version of Python.
9 #elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03030000)
10 #error Cython requires Python 2.6+ or Python 3.3+.
11 #else
12 #define CYTHON_ABI "0_29_23"
13 #define CYTHON_HEX_VERSION 0x001D17F0
14 #define CYTHON_FUTURE_DIVISION 1
15 #include <stddef.h>
16 #ifndef offsetof
17 #define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
18 #endif
19 #if !defined(WIN32) && !defined(MS_WINDOWS)
20 #ifndef __stdcall
21 #define __stdcall
22 #endif
23 #ifndef __cdecl
24 #define __cdecl
25 #endif
26 #ifndef __fastcall
27 #define __fastcall
28 #endif
29 #endif
30 #ifndef DL_IMPORT
31 #define DL_IMPORT(t) t
32 #endif
33 #ifndef DL_EXPORT
34 #define DL_EXPORT(t) t
35 #endif
36 #define __PYX_COMMA ,
37 #ifndef HAVE_LONG_LONG
38 #if PY_VERSION_HEX >= 0x02070000
39 #define HAVE_LONG_LONG
40 #endif
41 #endif
42 #ifndef PY_LONG_LONG
43 #define PY_LONG_LONG LONG_LONG
44 #endif
45 #ifndef Py_HUGE_VAL
46 #define Py_HUGE_VAL HUGE_VAL
47 #endif
48 #ifdef PYPY_VERSION
49 #define CYTHON_COMPILING_IN_PYPY 1
50 #define CYTHON_COMPILING_IN_PYSTON 0
51 #define CYTHON_COMPILING_IN_CPYTHON 0
52 #undef CYTHON_USE_TYPE_SLOTS
53 #define CYTHON_USE_TYPE_SLOTS 0
54 #undef CYTHON_USE_PYTYPE_LOOKUP
55 #define CYTHON_USE_PYTYPE_LOOKUP 0
56 #if PY_VERSION_HEX < 0x03050000
57 #undef CYTHON_USE_ASYNC_SLOTS
58 #define CYTHON_USE_ASYNC_SLOTS 0
59 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
60 #define CYTHON_USE_ASYNC_SLOTS 1
61 #endif
62 #undef CYTHON_USE_PYLIST_INTERNALS
63 #define CYTHON_USE_PYLIST_INTERNALS 0
64 #undef CYTHON_USE_UNICODE_INTERNALS
65 #define CYTHON_USE_UNICODE_INTERNALS 0
66 #undef CYTHON_USE_UNICODE_WRITER
67 #define CYTHON_USE_UNICODE_WRITER 0
68 #undef CYTHON_USE_PYLONG_INTERNALS
69 #define CYTHON_USE_PYLONG_INTERNALS 0
70 #undef CYTHON_AVOID_BORROWED_REFS
71 #define CYTHON_AVOID_BORROWED_REFS 1
72 #undef CYTHON_ASSUME_SAFE_MACROS
73 #define CYTHON_ASSUME_SAFE_MACROS 0
74 #undef CYTHON_UNPACK_METHODS
75 #define CYTHON_UNPACK_METHODS 0
76 #undef CYTHON_FAST_THREAD_STATE
77 #define CYTHON_FAST_THREAD_STATE 0
78 #undef CYTHON_FAST_PYCALL
79 #define CYTHON_FAST_PYCALL 0
80 #undef CYTHON_PEP489_MULTI_PHASE_INIT
81 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
82 #undef CYTHON_USE_TP_FINALIZE
83 #define CYTHON_USE_TP_FINALIZE 0
84 #undef CYTHON_USE_DICT_VERSIONS
85 #define CYTHON_USE_DICT_VERSIONS 0
86 #undef CYTHON_USE_EXC_INFO_STACK
87 #define CYTHON_USE_EXC_INFO_STACK 0
88 #elif defined(PYSTON_VERSION)
89 #define CYTHON_COMPILING_IN_PYPY 0
90 #define CYTHON_COMPILING_IN_PYSTON 1
91 #define CYTHON_COMPILING_IN_CPYTHON 0
92 #ifndef CYTHON_USE_TYPE_SLOTS
93 #define CYTHON_USE_TYPE_SLOTS 1
94 #endif
95 #undef CYTHON_USE_PYTYPE_LOOKUP
96 #define CYTHON_USE_PYTYPE_LOOKUP 0
97 #undef CYTHON_USE_ASYNC_SLOTS
98 #define CYTHON_USE_ASYNC_SLOTS 0
99 #undef CYTHON_USE_PYLIST_INTERNALS
100 #define CYTHON_USE_PYLIST_INTERNALS 0
101 #ifndef CYTHON_USE_UNICODE_INTERNALS
102 #define CYTHON_USE_UNICODE_INTERNALS 1
103 #endif
104 #undef CYTHON_USE_UNICODE_WRITER
105 #define CYTHON_USE_UNICODE_WRITER 0
106 #undef CYTHON_USE_PYLONG_INTERNALS
107 #define CYTHON_USE_PYLONG_INTERNALS 0
108 #ifndef CYTHON_AVOID_BORROWED_REFS
109 #define CYTHON_AVOID_BORROWED_REFS 0
110 #endif
111 #ifndef CYTHON_ASSUME_SAFE_MACROS
112 #define CYTHON_ASSUME_SAFE_MACROS 1
113 #endif
114 #ifndef CYTHON_UNPACK_METHODS
115 #define CYTHON_UNPACK_METHODS 1
116 #endif
117 #undef CYTHON_FAST_THREAD_STATE
118 #define CYTHON_FAST_THREAD_STATE 0
119 #undef CYTHON_FAST_PYCALL
120 #define CYTHON_FAST_PYCALL 0
121 #undef CYTHON_PEP489_MULTI_PHASE_INIT
122 #define CYTHON_PEP489_MULTI_PHASE_INIT 0
123 #undef CYTHON_USE_TP_FINALIZE
124 #define CYTHON_USE_TP_FINALIZE 0
125 #undef CYTHON_USE_DICT_VERSIONS
126 #define CYTHON_USE_DICT_VERSIONS 0
127 #undef CYTHON_USE_EXC_INFO_STACK
128 #define CYTHON_USE_EXC_INFO_STACK 0
129 #else
130 #define CYTHON_COMPILING_IN_PYPY 0
131 #define CYTHON_COMPILING_IN_PYSTON 0
132 #define CYTHON_COMPILING_IN_CPYTHON 1
133 #ifndef CYTHON_USE_TYPE_SLOTS
134 #define CYTHON_USE_TYPE_SLOTS 1
135 #endif
136 #if PY_VERSION_HEX < 0x02070000
137 #undef CYTHON_USE_PYTYPE_LOOKUP
138 #define CYTHON_USE_PYTYPE_LOOKUP 0
139 #elif !defined(CYTHON_USE_PYTYPE_LOOKUP)
140 #define CYTHON_USE_PYTYPE_LOOKUP 1
141 #endif
142 #if PY_MAJOR_VERSION < 3
143 #undef CYTHON_USE_ASYNC_SLOTS
144 #define CYTHON_USE_ASYNC_SLOTS 0
145 #elif !defined(CYTHON_USE_ASYNC_SLOTS)
146 #define CYTHON_USE_ASYNC_SLOTS 1
147 #endif
148 #if PY_VERSION_HEX < 0x02070000
149 #undef CYTHON_USE_PYLONG_INTERNALS
150 #define CYTHON_USE_PYLONG_INTERNALS 0
151 #elif !defined(CYTHON_USE_PYLONG_INTERNALS)
152 #define CYTHON_USE_PYLONG_INTERNALS 1
153 #endif
154 #ifndef CYTHON_USE_PYLIST_INTERNALS
155 #define CYTHON_USE_PYLIST_INTERNALS 1
156 #endif
157 #ifndef CYTHON_USE_UNICODE_INTERNALS
158 #define CYTHON_USE_UNICODE_INTERNALS 1
159 #endif
160 #if PY_VERSION_HEX < 0x030300F0
161 #undef CYTHON_USE_UNICODE_WRITER
162 #define CYTHON_USE_UNICODE_WRITER 0
163 #elif !defined(CYTHON_USE_UNICODE_WRITER)
164 #define CYTHON_USE_UNICODE_WRITER 1
165 #endif
166 #ifndef CYTHON_AVOID_BORROWED_REFS
167 #define CYTHON_AVOID_BORROWED_REFS 0
168 #endif
169 #ifndef CYTHON_ASSUME_SAFE_MACROS
170 #define CYTHON_ASSUME_SAFE_MACROS 1
171 #endif
172 #ifndef CYTHON_UNPACK_METHODS
173 #define CYTHON_UNPACK_METHODS 1
174 #endif
175 #ifndef CYTHON_FAST_THREAD_STATE
176 #define CYTHON_FAST_THREAD_STATE 1
177 #endif
178 #ifndef CYTHON_FAST_PYCALL
179 #define CYTHON_FAST_PYCALL 1
180 #endif
181 #ifndef CYTHON_PEP489_MULTI_PHASE_INIT
182 #define CYTHON_PEP489_MULTI_PHASE_INIT (PY_VERSION_HEX >= 0x03050000)
183 #endif
184 #ifndef CYTHON_USE_TP_FINALIZE
185 #define CYTHON_USE_TP_FINALIZE (PY_VERSION_HEX >= 0x030400a1)
186 #endif
187 #ifndef CYTHON_USE_DICT_VERSIONS
188 #define CYTHON_USE_DICT_VERSIONS (PY_VERSION_HEX >= 0x030600B1)
189 #endif
190 #ifndef CYTHON_USE_EXC_INFO_STACK
191 #define CYTHON_USE_EXC_INFO_STACK (PY_VERSION_HEX >= 0x030700A3)
192 #endif
193 #endif
194 #if !defined(CYTHON_FAST_PYCCALL)
195 #define CYTHON_FAST_PYCCALL (CYTHON_FAST_PYCALL && PY_VERSION_HEX >= 0x030600B1)
196 #endif
197 #if CYTHON_USE_PYLONG_INTERNALS
198 #include "longintrepr.h"
199 #undef SHIFT
200 #undef BASE
201 #undef MASK
202 #ifdef SIZEOF_VOID_P
203 enum { __pyx_check_sizeof_voidp = 1 / (int)(SIZEOF_VOID_P == sizeof(void*)) };
204 #endif
205 #endif
206 #ifndef __has_attribute
207 #define __has_attribute(x) 0
208 #endif
209 #ifndef __has_cpp_attribute
210 #define __has_cpp_attribute(x) 0
211 #endif
212 #ifndef CYTHON_RESTRICT
213 #if defined(__GNUC__)
214 #define CYTHON_RESTRICT __restrict__
215 #elif defined(_MSC_VER) && _MSC_VER >= 1400
216 #define CYTHON_RESTRICT __restrict
217 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
218 #define CYTHON_RESTRICT restrict
219 #else
220 #define CYTHON_RESTRICT
221 #endif
222 #endif
223 #ifndef CYTHON_UNUSED
224 # if defined(__GNUC__)
225 # if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
226 # define CYTHON_UNUSED __attribute__ ((__unused__))
227 # else
228 # define CYTHON_UNUSED
229 # endif
230 # elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
231 # define CYTHON_UNUSED __attribute__ ((__unused__))
232 # else
233 # define CYTHON_UNUSED
234 # endif
235 #endif
236 #ifndef CYTHON_MAYBE_UNUSED_VAR
237 # if defined(__cplusplus)
CYTHON_MAYBE_UNUSED_VAR(const T &)238 template<class T> void CYTHON_MAYBE_UNUSED_VAR( const T& ) { }
239 # else
240 # define CYTHON_MAYBE_UNUSED_VAR(x) (void)(x)
241 # endif
242 #endif
243 #ifndef CYTHON_NCP_UNUSED
244 # if CYTHON_COMPILING_IN_CPYTHON
245 # define CYTHON_NCP_UNUSED
246 # else
247 # define CYTHON_NCP_UNUSED CYTHON_UNUSED
248 # endif
249 #endif
250 #define __Pyx_void_to_None(void_result) ((void)(void_result), Py_INCREF(Py_None), Py_None)
251 #ifdef _MSC_VER
252 #ifndef _MSC_STDINT_H_
253 #if _MSC_VER < 1300
254 typedef unsigned char uint8_t;
255 typedef unsigned int uint32_t;
256 #else
257 typedef unsigned __int8 uint8_t;
258 typedef unsigned __int32 uint32_t;
259 #endif
260 #endif
261 #else
262 #include <stdint.h>
263 #endif
264 #ifndef CYTHON_FALLTHROUGH
265 #if defined(__cplusplus) && __cplusplus >= 201103L
266 #if __has_cpp_attribute(fallthrough)
267 #define CYTHON_FALLTHROUGH [[fallthrough]]
268 #elif __has_cpp_attribute(clang::fallthrough)
269 #define CYTHON_FALLTHROUGH [[clang::fallthrough]]
270 #elif __has_cpp_attribute(gnu::fallthrough)
271 #define CYTHON_FALLTHROUGH [[gnu::fallthrough]]
272 #endif
273 #endif
274 #ifndef CYTHON_FALLTHROUGH
275 #if __has_attribute(fallthrough)
276 #define CYTHON_FALLTHROUGH __attribute__((fallthrough))
277 #else
278 #define CYTHON_FALLTHROUGH
279 #endif
280 #endif
281 #if defined(__clang__ ) && defined(__apple_build_version__)
282 #if __apple_build_version__ < 7000000
283 #undef CYTHON_FALLTHROUGH
284 #define CYTHON_FALLTHROUGH
285 #endif
286 #endif
287 #endif
288
289 #ifndef CYTHON_INLINE
290 #if defined(__clang__)
291 #define CYTHON_INLINE __inline__ __attribute__ ((__unused__))
292 #elif defined(__GNUC__)
293 #define CYTHON_INLINE __inline__
294 #elif defined(_MSC_VER)
295 #define CYTHON_INLINE __inline
296 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
297 #define CYTHON_INLINE inline
298 #else
299 #define CYTHON_INLINE
300 #endif
301 #endif
302
303 #if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
304 #define Py_OptimizeFlag 0
305 #endif
306 #define __PYX_BUILD_PY_SSIZE_T "n"
307 #define CYTHON_FORMAT_SSIZE_T "z"
308 #if PY_MAJOR_VERSION < 3
309 #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
310 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
311 PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
312 #define __Pyx_DefaultClassType PyClass_Type
313 #else
314 #define __Pyx_BUILTIN_MODULE_NAME "builtins"
315 #if PY_VERSION_HEX >= 0x030800A4 && PY_VERSION_HEX < 0x030800B2
316 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
317 PyCode_New(a, 0, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
318 #else
319 #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)\
320 PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
321 #endif
322 #define __Pyx_DefaultClassType PyType_Type
323 #endif
324 #ifndef Py_TPFLAGS_CHECKTYPES
325 #define Py_TPFLAGS_CHECKTYPES 0
326 #endif
327 #ifndef Py_TPFLAGS_HAVE_INDEX
328 #define Py_TPFLAGS_HAVE_INDEX 0
329 #endif
330 #ifndef Py_TPFLAGS_HAVE_NEWBUFFER
331 #define Py_TPFLAGS_HAVE_NEWBUFFER 0
332 #endif
333 #ifndef Py_TPFLAGS_HAVE_FINALIZE
334 #define Py_TPFLAGS_HAVE_FINALIZE 0
335 #endif
336 #ifndef METH_STACKLESS
337 #define METH_STACKLESS 0
338 #endif
339 #if PY_VERSION_HEX <= 0x030700A3 || !defined(METH_FASTCALL)
340 #ifndef METH_FASTCALL
341 #define METH_FASTCALL 0x80
342 #endif
343 typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *const *args, Py_ssize_t nargs);
344 typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, PyObject *const *args,
345 Py_ssize_t nargs, PyObject *kwnames);
346 #else
347 #define __Pyx_PyCFunctionFast _PyCFunctionFast
348 #define __Pyx_PyCFunctionFastWithKeywords _PyCFunctionFastWithKeywords
349 #endif
350 #if CYTHON_FAST_PYCCALL
351 #define __Pyx_PyFastCFunction_Check(func)\
352 ((PyCFunction_Check(func) && (METH_FASTCALL == (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST | METH_KEYWORDS | METH_STACKLESS)))))
353 #else
354 #define __Pyx_PyFastCFunction_Check(func) 0
355 #endif
356 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Malloc)
357 #define PyObject_Malloc(s) PyMem_Malloc(s)
358 #define PyObject_Free(p) PyMem_Free(p)
359 #define PyObject_Realloc(p) PyMem_Realloc(p)
360 #endif
361 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX < 0x030400A1
362 #define PyMem_RawMalloc(n) PyMem_Malloc(n)
363 #define PyMem_RawRealloc(p, n) PyMem_Realloc(p, n)
364 #define PyMem_RawFree(p) PyMem_Free(p)
365 #endif
366 #if CYTHON_COMPILING_IN_PYSTON
367 #define __Pyx_PyCode_HasFreeVars(co) PyCode_HasFreeVars(co)
368 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) PyFrame_SetLineNumber(frame, lineno)
369 #else
370 #define __Pyx_PyCode_HasFreeVars(co) (PyCode_GetNumFree(co) > 0)
371 #define __Pyx_PyFrame_SetLineNumber(frame, lineno) (frame)->f_lineno = (lineno)
372 #endif
373 #if !CYTHON_FAST_THREAD_STATE || PY_VERSION_HEX < 0x02070000
374 #define __Pyx_PyThreadState_Current PyThreadState_GET()
375 #elif PY_VERSION_HEX >= 0x03060000
376 #define __Pyx_PyThreadState_Current _PyThreadState_UncheckedGet()
377 #elif PY_VERSION_HEX >= 0x03000000
378 #define __Pyx_PyThreadState_Current PyThreadState_GET()
379 #else
380 #define __Pyx_PyThreadState_Current _PyThreadState_Current
381 #endif
382 #if PY_VERSION_HEX < 0x030700A2 && !defined(PyThread_tss_create) && !defined(Py_tss_NEEDS_INIT)
383 #include "pythread.h"
384 #define Py_tss_NEEDS_INIT 0
385 typedef int Py_tss_t;
PyThread_tss_create(Py_tss_t * key)386 static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
387 *key = PyThread_create_key();
388 return 0;
389 }
PyThread_tss_alloc(void)390 static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
391 Py_tss_t *key = (Py_tss_t *)PyObject_Malloc(sizeof(Py_tss_t));
392 *key = Py_tss_NEEDS_INIT;
393 return key;
394 }
PyThread_tss_free(Py_tss_t * key)395 static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
396 PyObject_Free(key);
397 }
PyThread_tss_is_created(Py_tss_t * key)398 static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
399 return *key != Py_tss_NEEDS_INIT;
400 }
PyThread_tss_delete(Py_tss_t * key)401 static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
402 PyThread_delete_key(*key);
403 *key = Py_tss_NEEDS_INIT;
404 }
PyThread_tss_set(Py_tss_t * key,void * value)405 static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
406 return PyThread_set_key_value(*key, value);
407 }
PyThread_tss_get(Py_tss_t * key)408 static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
409 return PyThread_get_key_value(*key);
410 }
411 #endif
412 #if CYTHON_COMPILING_IN_CPYTHON || defined(_PyDict_NewPresized)
413 #define __Pyx_PyDict_NewPresized(n) ((n <= 8) ? PyDict_New() : _PyDict_NewPresized(n))
414 #else
415 #define __Pyx_PyDict_NewPresized(n) PyDict_New()
416 #endif
417 #if PY_MAJOR_VERSION >= 3 || CYTHON_FUTURE_DIVISION
418 #define __Pyx_PyNumber_Divide(x,y) PyNumber_TrueDivide(x,y)
419 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceTrueDivide(x,y)
420 #else
421 #define __Pyx_PyNumber_Divide(x,y) PyNumber_Divide(x,y)
422 #define __Pyx_PyNumber_InPlaceDivide(x,y) PyNumber_InPlaceDivide(x,y)
423 #endif
424 #if CYTHON_COMPILING_IN_CPYTHON && PY_VERSION_HEX >= 0x030500A1 && CYTHON_USE_UNICODE_INTERNALS
425 #define __Pyx_PyDict_GetItemStr(dict, name) _PyDict_GetItem_KnownHash(dict, name, ((PyASCIIObject *) name)->hash)
426 #else
427 #define __Pyx_PyDict_GetItemStr(dict, name) PyDict_GetItem(dict, name)
428 #endif
429 #if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
430 #define CYTHON_PEP393_ENABLED 1
431 #define __Pyx_PyUnicode_READY(op) (likely(PyUnicode_IS_READY(op)) ?\
432 0 : _PyUnicode_Ready((PyObject *)(op)))
433 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_LENGTH(u)
434 #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
435 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) PyUnicode_MAX_CHAR_VALUE(u)
436 #define __Pyx_PyUnicode_KIND(u) PyUnicode_KIND(u)
437 #define __Pyx_PyUnicode_DATA(u) PyUnicode_DATA(u)
438 #define __Pyx_PyUnicode_READ(k, d, i) PyUnicode_READ(k, d, i)
439 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) PyUnicode_WRITE(k, d, i, ch)
440 #if defined(PyUnicode_IS_READY) && defined(PyUnicode_GET_SIZE)
441 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != (likely(PyUnicode_IS_READY(u)) ? PyUnicode_GET_LENGTH(u) : PyUnicode_GET_SIZE(u)))
442 #else
443 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_LENGTH(u))
444 #endif
445 #else
446 #define CYTHON_PEP393_ENABLED 0
447 #define PyUnicode_1BYTE_KIND 1
448 #define PyUnicode_2BYTE_KIND 2
449 #define PyUnicode_4BYTE_KIND 4
450 #define __Pyx_PyUnicode_READY(op) (0)
451 #define __Pyx_PyUnicode_GET_LENGTH(u) PyUnicode_GET_SIZE(u)
452 #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
453 #define __Pyx_PyUnicode_MAX_CHAR_VALUE(u) ((sizeof(Py_UNICODE) == 2) ? 65535 : 1114111)
454 #define __Pyx_PyUnicode_KIND(u) (sizeof(Py_UNICODE))
455 #define __Pyx_PyUnicode_DATA(u) ((void*)PyUnicode_AS_UNICODE(u))
456 #define __Pyx_PyUnicode_READ(k, d, i) ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
457 #define __Pyx_PyUnicode_WRITE(k, d, i, ch) (((void)(k)), ((Py_UNICODE*)d)[i] = ch)
458 #define __Pyx_PyUnicode_IS_TRUE(u) (0 != PyUnicode_GET_SIZE(u))
459 #endif
460 #if CYTHON_COMPILING_IN_PYPY
461 #define __Pyx_PyUnicode_Concat(a, b) PyNumber_Add(a, b)
462 #define __Pyx_PyUnicode_ConcatSafe(a, b) PyNumber_Add(a, b)
463 #else
464 #define __Pyx_PyUnicode_Concat(a, b) PyUnicode_Concat(a, b)
465 #define __Pyx_PyUnicode_ConcatSafe(a, b) ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ?\
466 PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
467 #endif
468 #if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
469 #define PyUnicode_Contains(u, s) PySequence_Contains(u, s)
470 #endif
471 #if CYTHON_COMPILING_IN_PYPY && !defined(PyByteArray_Check)
472 #define PyByteArray_Check(obj) PyObject_TypeCheck(obj, &PyByteArray_Type)
473 #endif
474 #if CYTHON_COMPILING_IN_PYPY && !defined(PyObject_Format)
475 #define PyObject_Format(obj, fmt) PyObject_CallMethod(obj, "__format__", "O", fmt)
476 #endif
477 #define __Pyx_PyString_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyString_Check(b) && !PyString_CheckExact(b)))) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
478 #define __Pyx_PyUnicode_FormatSafe(a, b) ((unlikely((a) == Py_None || (PyUnicode_Check(b) && !PyUnicode_CheckExact(b)))) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
479 #if PY_MAJOR_VERSION >= 3
480 #define __Pyx_PyString_Format(a, b) PyUnicode_Format(a, b)
481 #else
482 #define __Pyx_PyString_Format(a, b) PyString_Format(a, b)
483 #endif
484 #if PY_MAJOR_VERSION < 3 && !defined(PyObject_ASCII)
485 #define PyObject_ASCII(o) PyObject_Repr(o)
486 #endif
487 #if PY_MAJOR_VERSION >= 3
488 #define PyBaseString_Type PyUnicode_Type
489 #define PyStringObject PyUnicodeObject
490 #define PyString_Type PyUnicode_Type
491 #define PyString_Check PyUnicode_Check
492 #define PyString_CheckExact PyUnicode_CheckExact
493 #ifndef PyObject_Unicode
494 #define PyObject_Unicode PyObject_Str
495 #endif
496 #endif
497 #if PY_MAJOR_VERSION >= 3
498 #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
499 #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
500 #else
501 #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
502 #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
503 #endif
504 #ifndef PySet_CheckExact
505 #define PySet_CheckExact(obj) (Py_TYPE(obj) == &PySet_Type)
506 #endif
507 #if PY_VERSION_HEX >= 0x030900A4
508 #define __Pyx_SET_REFCNT(obj, refcnt) Py_SET_REFCNT(obj, refcnt)
509 #define __Pyx_SET_SIZE(obj, size) Py_SET_SIZE(obj, size)
510 #else
511 #define __Pyx_SET_REFCNT(obj, refcnt) Py_REFCNT(obj) = (refcnt)
512 #define __Pyx_SET_SIZE(obj, size) Py_SIZE(obj) = (size)
513 #endif
514 #if CYTHON_ASSUME_SAFE_MACROS
515 #define __Pyx_PySequence_SIZE(seq) Py_SIZE(seq)
516 #else
517 #define __Pyx_PySequence_SIZE(seq) PySequence_Size(seq)
518 #endif
519 #if PY_MAJOR_VERSION >= 3
520 #define PyIntObject PyLongObject
521 #define PyInt_Type PyLong_Type
522 #define PyInt_Check(op) PyLong_Check(op)
523 #define PyInt_CheckExact(op) PyLong_CheckExact(op)
524 #define PyInt_FromString PyLong_FromString
525 #define PyInt_FromUnicode PyLong_FromUnicode
526 #define PyInt_FromLong PyLong_FromLong
527 #define PyInt_FromSize_t PyLong_FromSize_t
528 #define PyInt_FromSsize_t PyLong_FromSsize_t
529 #define PyInt_AsLong PyLong_AsLong
530 #define PyInt_AS_LONG PyLong_AS_LONG
531 #define PyInt_AsSsize_t PyLong_AsSsize_t
532 #define PyInt_AsUnsignedLongMask PyLong_AsUnsignedLongMask
533 #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
534 #define PyNumber_Int PyNumber_Long
535 #endif
536 #if PY_MAJOR_VERSION >= 3
537 #define PyBoolObject PyLongObject
538 #endif
539 #if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
540 #ifndef PyUnicode_InternFromString
541 #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
542 #endif
543 #endif
544 #if PY_VERSION_HEX < 0x030200A4
545 typedef long Py_hash_t;
546 #define __Pyx_PyInt_FromHash_t PyInt_FromLong
547 #define __Pyx_PyInt_AsHash_t PyInt_AsLong
548 #else
549 #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
550 #define __Pyx_PyInt_AsHash_t PyInt_AsSsize_t
551 #endif
552 #if PY_MAJOR_VERSION >= 3
553 #define __Pyx_PyMethod_New(func, self, klass) ((self) ? ((void)(klass), PyMethod_New(func, self)) : __Pyx_NewRef(func))
554 #else
555 #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
556 #endif
557 #if CYTHON_USE_ASYNC_SLOTS
558 #if PY_VERSION_HEX >= 0x030500B1
559 #define __Pyx_PyAsyncMethodsStruct PyAsyncMethods
560 #define __Pyx_PyType_AsAsync(obj) (Py_TYPE(obj)->tp_as_async)
561 #else
562 #define __Pyx_PyType_AsAsync(obj) ((__Pyx_PyAsyncMethodsStruct*) (Py_TYPE(obj)->tp_reserved))
563 #endif
564 #else
565 #define __Pyx_PyType_AsAsync(obj) NULL
566 #endif
567 #ifndef __Pyx_PyAsyncMethodsStruct
568 typedef struct {
569 unaryfunc am_await;
570 unaryfunc am_aiter;
571 unaryfunc am_anext;
572 } __Pyx_PyAsyncMethodsStruct;
573 #endif
574
575 #if defined(WIN32) || defined(MS_WINDOWS)
576 #define _USE_MATH_DEFINES
577 #endif
578 #include <math.h>
579 #ifdef NAN
580 #define __PYX_NAN() ((float) NAN)
581 #else
__PYX_NAN()582 static CYTHON_INLINE float __PYX_NAN() {
583 float value;
584 memset(&value, 0xFF, sizeof(value));
585 return value;
586 }
587 #endif
588 #if defined(__CYGWIN__) && defined(_LDBL_EQ_DBL)
589 #define __Pyx_truncl trunc
590 #else
591 #define __Pyx_truncl truncl
592 #endif
593
594 #define __PYX_MARK_ERR_POS(f_index, lineno) \
595 { __pyx_filename = __pyx_f[f_index]; (void)__pyx_filename; __pyx_lineno = lineno; (void)__pyx_lineno; __pyx_clineno = __LINE__; (void)__pyx_clineno; }
596 #define __PYX_ERR(f_index, lineno, Ln_error) \
597 { __PYX_MARK_ERR_POS(f_index, lineno) goto Ln_error; }
598
599 #ifndef __PYX_EXTERN_C
600 #ifdef __cplusplus
601 #define __PYX_EXTERN_C extern "C"
602 #else
603 #define __PYX_EXTERN_C extern
604 #endif
605 #endif
606
607 #define __PYX_HAVE__borg__platform__syncfilerange
608 #define __PYX_HAVE_API__borg__platform__syncfilerange
609 /* Early includes */
610 #include <stdint.h>
611 #include "fcntl.h"
612 #ifdef _OPENMP
613 #include <omp.h>
614 #endif /* _OPENMP */
615
616 #if defined(PYREX_WITHOUT_ASSERTIONS) && !defined(CYTHON_WITHOUT_ASSERTIONS)
617 #define CYTHON_WITHOUT_ASSERTIONS
618 #endif
619
620 typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const char* encoding;
621 const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
622
623 #define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
624 #define __PYX_DEFAULT_STRING_ENCODING_IS_UTF8 0
625 #define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT (PY_MAJOR_VERSION >= 3 && __PYX_DEFAULT_STRING_ENCODING_IS_UTF8)
626 #define __PYX_DEFAULT_STRING_ENCODING ""
627 #define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
628 #define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
629 #define __Pyx_uchar_cast(c) ((unsigned char)c)
630 #define __Pyx_long_cast(x) ((long)x)
631 #define __Pyx_fits_Py_ssize_t(v, type, is_signed) (\
632 (sizeof(type) < sizeof(Py_ssize_t)) ||\
633 (sizeof(type) > sizeof(Py_ssize_t) &&\
634 likely(v < (type)PY_SSIZE_T_MAX ||\
635 v == (type)PY_SSIZE_T_MAX) &&\
636 (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||\
637 v == (type)PY_SSIZE_T_MIN))) ||\
638 (sizeof(type) == sizeof(Py_ssize_t) &&\
639 (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||\
640 v == (type)PY_SSIZE_T_MAX))) )
__Pyx_is_valid_index(Py_ssize_t i,Py_ssize_t limit)641 static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t limit) {
642 return (size_t) i < (size_t) limit;
643 }
644 #if defined (__cplusplus) && __cplusplus >= 201103L
645 #include <cstdlib>
646 #define __Pyx_sst_abs(value) std::abs(value)
647 #elif SIZEOF_INT >= SIZEOF_SIZE_T
648 #define __Pyx_sst_abs(value) abs(value)
649 #elif SIZEOF_LONG >= SIZEOF_SIZE_T
650 #define __Pyx_sst_abs(value) labs(value)
651 #elif defined (_MSC_VER)
652 #define __Pyx_sst_abs(value) ((Py_ssize_t)_abs64(value))
653 #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
654 #define __Pyx_sst_abs(value) llabs(value)
655 #elif defined (__GNUC__)
656 #define __Pyx_sst_abs(value) __builtin_llabs(value)
657 #else
658 #define __Pyx_sst_abs(value) ((value<0) ? -value : value)
659 #endif
660 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject*);
661 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
662 #define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
663 #define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
664 #define __Pyx_PyBytes_FromString PyBytes_FromString
665 #define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
666 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
667 #if PY_MAJOR_VERSION < 3
668 #define __Pyx_PyStr_FromString __Pyx_PyBytes_FromString
669 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
670 #else
671 #define __Pyx_PyStr_FromString __Pyx_PyUnicode_FromString
672 #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
673 #endif
674 #define __Pyx_PyBytes_AsWritableString(s) ((char*) PyBytes_AS_STRING(s))
675 #define __Pyx_PyBytes_AsWritableSString(s) ((signed char*) PyBytes_AS_STRING(s))
676 #define __Pyx_PyBytes_AsWritableUString(s) ((unsigned char*) PyBytes_AS_STRING(s))
677 #define __Pyx_PyBytes_AsString(s) ((const char*) PyBytes_AS_STRING(s))
678 #define __Pyx_PyBytes_AsSString(s) ((const signed char*) PyBytes_AS_STRING(s))
679 #define __Pyx_PyBytes_AsUString(s) ((const unsigned char*) PyBytes_AS_STRING(s))
680 #define __Pyx_PyObject_AsWritableString(s) ((char*) __Pyx_PyObject_AsString(s))
681 #define __Pyx_PyObject_AsWritableSString(s) ((signed char*) __Pyx_PyObject_AsString(s))
682 #define __Pyx_PyObject_AsWritableUString(s) ((unsigned char*) __Pyx_PyObject_AsString(s))
683 #define __Pyx_PyObject_AsSString(s) ((const signed char*) __Pyx_PyObject_AsString(s))
684 #define __Pyx_PyObject_AsUString(s) ((const unsigned char*) __Pyx_PyObject_AsString(s))
685 #define __Pyx_PyObject_FromCString(s) __Pyx_PyObject_FromString((const char*)s)
686 #define __Pyx_PyBytes_FromCString(s) __Pyx_PyBytes_FromString((const char*)s)
687 #define __Pyx_PyByteArray_FromCString(s) __Pyx_PyByteArray_FromString((const char*)s)
688 #define __Pyx_PyStr_FromCString(s) __Pyx_PyStr_FromString((const char*)s)
689 #define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
__Pyx_Py_UNICODE_strlen(const Py_UNICODE * u)690 static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
691 const Py_UNICODE *u_end = u;
692 while (*u_end++) ;
693 return (size_t)(u_end - u - 1);
694 }
695 #define __Pyx_PyUnicode_FromUnicode(u) PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
696 #define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
697 #define __Pyx_PyUnicode_AsUnicode PyUnicode_AsUnicode
698 #define __Pyx_NewRef(obj) (Py_INCREF(obj), obj)
699 #define __Pyx_Owned_Py_None(b) __Pyx_NewRef(Py_None)
700 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b);
701 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
702 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject*);
703 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x);
704 #define __Pyx_PySequence_Tuple(obj)\
705 (likely(PyTuple_CheckExact(obj)) ? __Pyx_NewRef(obj) : PySequence_Tuple(obj))
706 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
707 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
708 #if CYTHON_ASSUME_SAFE_MACROS
709 #define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
710 #else
711 #define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
712 #endif
713 #define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
714 #if PY_MAJOR_VERSION >= 3
715 #define __Pyx_PyNumber_Int(x) (PyLong_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Long(x))
716 #else
717 #define __Pyx_PyNumber_Int(x) (PyInt_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Int(x))
718 #endif
719 #define __Pyx_PyNumber_Float(x) (PyFloat_CheckExact(x) ? __Pyx_NewRef(x) : PyNumber_Float(x))
720 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
721 static int __Pyx_sys_getdefaultencoding_not_ascii;
__Pyx_init_sys_getdefaultencoding_params(void)722 static int __Pyx_init_sys_getdefaultencoding_params(void) {
723 PyObject* sys;
724 PyObject* default_encoding = NULL;
725 PyObject* ascii_chars_u = NULL;
726 PyObject* ascii_chars_b = NULL;
727 const char* default_encoding_c;
728 sys = PyImport_ImportModule("sys");
729 if (!sys) goto bad;
730 default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
731 Py_DECREF(sys);
732 if (!default_encoding) goto bad;
733 default_encoding_c = PyBytes_AsString(default_encoding);
734 if (!default_encoding_c) goto bad;
735 if (strcmp(default_encoding_c, "ascii") == 0) {
736 __Pyx_sys_getdefaultencoding_not_ascii = 0;
737 } else {
738 char ascii_chars[128];
739 int c;
740 for (c = 0; c < 128; c++) {
741 ascii_chars[c] = c;
742 }
743 __Pyx_sys_getdefaultencoding_not_ascii = 1;
744 ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
745 if (!ascii_chars_u) goto bad;
746 ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
747 if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
748 PyErr_Format(
749 PyExc_ValueError,
750 "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
751 default_encoding_c);
752 goto bad;
753 }
754 Py_DECREF(ascii_chars_u);
755 Py_DECREF(ascii_chars_b);
756 }
757 Py_DECREF(default_encoding);
758 return 0;
759 bad:
760 Py_XDECREF(default_encoding);
761 Py_XDECREF(ascii_chars_u);
762 Py_XDECREF(ascii_chars_b);
763 return -1;
764 }
765 #endif
766 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
767 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
768 #else
769 #define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
770 #if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
771 static char* __PYX_DEFAULT_STRING_ENCODING;
__Pyx_init_sys_getdefaultencoding_params(void)772 static int __Pyx_init_sys_getdefaultencoding_params(void) {
773 PyObject* sys;
774 PyObject* default_encoding = NULL;
775 char* default_encoding_c;
776 sys = PyImport_ImportModule("sys");
777 if (!sys) goto bad;
778 default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
779 Py_DECREF(sys);
780 if (!default_encoding) goto bad;
781 default_encoding_c = PyBytes_AsString(default_encoding);
782 if (!default_encoding_c) goto bad;
783 __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c) + 1);
784 if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
785 strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
786 Py_DECREF(default_encoding);
787 return 0;
788 bad:
789 Py_XDECREF(default_encoding);
790 return -1;
791 }
792 #endif
793 #endif
794
795
796 /* Test for GCC > 2.95 */
797 #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
798 #define likely(x) __builtin_expect(!!(x), 1)
799 #define unlikely(x) __builtin_expect(!!(x), 0)
800 #else /* !__GNUC__ or GCC < 2.95 */
801 #define likely(x) (x)
802 #define unlikely(x) (x)
803 #endif /* __GNUC__ */
__Pyx_pretend_to_initialize(void * ptr)804 static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void)ptr; }
805
806 static PyObject *__pyx_m = NULL;
807 static PyObject *__pyx_d;
808 static PyObject *__pyx_b;
809 static PyObject *__pyx_cython_runtime = NULL;
810 static PyObject *__pyx_empty_tuple;
811 static PyObject *__pyx_empty_bytes;
812 static PyObject *__pyx_empty_unicode;
813 static int __pyx_lineno;
814 static int __pyx_clineno = 0;
815 static const char * __pyx_cfilenm= __FILE__;
816 static const char *__pyx_filename;
817
818
819 static const char *__pyx_f[] = {
820 "src/borg/platform/syncfilerange.pyx",
821 };
822
823 /*--- Type declarations ---*/
824
825 /* --- Runtime support code (head) --- */
826 /* Refnanny.proto */
827 #ifndef CYTHON_REFNANNY
828 #define CYTHON_REFNANNY 0
829 #endif
830 #if CYTHON_REFNANNY
831 typedef struct {
832 void (*INCREF)(void*, PyObject*, int);
833 void (*DECREF)(void*, PyObject*, int);
834 void (*GOTREF)(void*, PyObject*, int);
835 void (*GIVEREF)(void*, PyObject*, int);
836 void* (*SetupContext)(const char*, int, const char*);
837 void (*FinishContext)(void**);
838 } __Pyx_RefNannyAPIStruct;
839 static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
840 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
841 #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
842 #ifdef WITH_THREAD
843 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
844 if (acquire_gil) {\
845 PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure();\
846 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
847 PyGILState_Release(__pyx_gilstate_save);\
848 } else {\
849 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__);\
850 }
851 #else
852 #define __Pyx_RefNannySetupContext(name, acquire_gil)\
853 __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
854 #endif
855 #define __Pyx_RefNannyFinishContext()\
856 __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
857 #define __Pyx_INCREF(r) __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
858 #define __Pyx_DECREF(r) __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
859 #define __Pyx_GOTREF(r) __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
860 #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
861 #define __Pyx_XINCREF(r) do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
862 #define __Pyx_XDECREF(r) do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
863 #define __Pyx_XGOTREF(r) do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
864 #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
865 #else
866 #define __Pyx_RefNannyDeclarations
867 #define __Pyx_RefNannySetupContext(name, acquire_gil)
868 #define __Pyx_RefNannyFinishContext()
869 #define __Pyx_INCREF(r) Py_INCREF(r)
870 #define __Pyx_DECREF(r) Py_DECREF(r)
871 #define __Pyx_GOTREF(r)
872 #define __Pyx_GIVEREF(r)
873 #define __Pyx_XINCREF(r) Py_XINCREF(r)
874 #define __Pyx_XDECREF(r) Py_XDECREF(r)
875 #define __Pyx_XGOTREF(r)
876 #define __Pyx_XGIVEREF(r)
877 #endif
878 #define __Pyx_XDECREF_SET(r, v) do {\
879 PyObject *tmp = (PyObject *) r;\
880 r = v; __Pyx_XDECREF(tmp);\
881 } while (0)
882 #define __Pyx_DECREF_SET(r, v) do {\
883 PyObject *tmp = (PyObject *) r;\
884 r = v; __Pyx_DECREF(tmp);\
885 } while (0)
886 #define __Pyx_CLEAR(r) do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
887 #define __Pyx_XCLEAR(r) do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
888
889 /* PyDictVersioning.proto */
890 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
891 #define __PYX_DICT_VERSION_INIT ((PY_UINT64_T) -1)
892 #define __PYX_GET_DICT_VERSION(dict) (((PyDictObject*)(dict))->ma_version_tag)
893 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)\
894 (version_var) = __PYX_GET_DICT_VERSION(dict);\
895 (cache_var) = (value);
896 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) {\
897 static PY_UINT64_T __pyx_dict_version = 0;\
898 static PyObject *__pyx_dict_cached_value = NULL;\
899 if (likely(__PYX_GET_DICT_VERSION(DICT) == __pyx_dict_version)) {\
900 (VAR) = __pyx_dict_cached_value;\
901 } else {\
902 (VAR) = __pyx_dict_cached_value = (LOOKUP);\
903 __pyx_dict_version = __PYX_GET_DICT_VERSION(DICT);\
904 }\
905 }
906 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj);
907 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj);
908 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version);
909 #else
910 #define __PYX_GET_DICT_VERSION(dict) (0)
911 #define __PYX_UPDATE_DICT_CACHE(dict, value, cache_var, version_var)
912 #define __PYX_PY_DICT_LOOKUP_IF_MODIFIED(VAR, DICT, LOOKUP) (VAR) = (LOOKUP);
913 #endif
914
915 /* PyObjectGetAttrStr.proto */
916 #if CYTHON_USE_TYPE_SLOTS
917 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name);
918 #else
919 #define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
920 #endif
921
922 /* PyThreadStateGet.proto */
923 #if CYTHON_FAST_THREAD_STATE
924 #define __Pyx_PyThreadState_declare PyThreadState *__pyx_tstate;
925 #define __Pyx_PyThreadState_assign __pyx_tstate = __Pyx_PyThreadState_Current;
926 #define __Pyx_PyErr_Occurred() __pyx_tstate->curexc_type
927 #else
928 #define __Pyx_PyThreadState_declare
929 #define __Pyx_PyThreadState_assign
930 #define __Pyx_PyErr_Occurred() PyErr_Occurred()
931 #endif
932
933 /* PyErrFetchRestore.proto */
934 #if CYTHON_FAST_THREAD_STATE
935 #define __Pyx_PyErr_Clear() __Pyx_ErrRestore(NULL, NULL, NULL)
936 #define __Pyx_ErrRestoreWithState(type, value, tb) __Pyx_ErrRestoreInState(PyThreadState_GET(), type, value, tb)
937 #define __Pyx_ErrFetchWithState(type, value, tb) __Pyx_ErrFetchInState(PyThreadState_GET(), type, value, tb)
938 #define __Pyx_ErrRestore(type, value, tb) __Pyx_ErrRestoreInState(__pyx_tstate, type, value, tb)
939 #define __Pyx_ErrFetch(type, value, tb) __Pyx_ErrFetchInState(__pyx_tstate, type, value, tb)
940 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb);
941 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb);
942 #if CYTHON_COMPILING_IN_CPYTHON
943 #define __Pyx_PyErr_SetNone(exc) (Py_INCREF(exc), __Pyx_ErrRestore((exc), NULL, NULL))
944 #else
945 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
946 #endif
947 #else
948 #define __Pyx_PyErr_Clear() PyErr_Clear()
949 #define __Pyx_PyErr_SetNone(exc) PyErr_SetNone(exc)
950 #define __Pyx_ErrRestoreWithState(type, value, tb) PyErr_Restore(type, value, tb)
951 #define __Pyx_ErrFetchWithState(type, value, tb) PyErr_Fetch(type, value, tb)
952 #define __Pyx_ErrRestoreInState(tstate, type, value, tb) PyErr_Restore(type, value, tb)
953 #define __Pyx_ErrFetchInState(tstate, type, value, tb) PyErr_Fetch(type, value, tb)
954 #define __Pyx_ErrRestore(type, value, tb) PyErr_Restore(type, value, tb)
955 #define __Pyx_ErrFetch(type, value, tb) PyErr_Fetch(type, value, tb)
956 #endif
957
958 /* CLineInTraceback.proto */
959 #ifdef CYTHON_CLINE_IN_TRACEBACK
960 #define __Pyx_CLineForTraceback(tstate, c_line) (((CYTHON_CLINE_IN_TRACEBACK)) ? c_line : 0)
961 #else
962 static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line);
963 #endif
964
965 /* CodeObjectCache.proto */
966 typedef struct {
967 PyCodeObject* code_object;
968 int code_line;
969 } __Pyx_CodeObjectCacheEntry;
970 struct __Pyx_CodeObjectCache {
971 int count;
972 int max_count;
973 __Pyx_CodeObjectCacheEntry* entries;
974 };
975 static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
976 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
977 static PyCodeObject *__pyx_find_code_object(int code_line);
978 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
979
980 /* AddTraceback.proto */
981 static void __Pyx_AddTraceback(const char *funcname, int c_line,
982 int py_line, const char *filename);
983
984 /* GCCDiagnostics.proto */
985 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6))
986 #define __Pyx_HAS_GCC_DIAGNOSTIC
987 #endif
988
989 /* CIntToPy.proto */
990 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
991
992 /* CIntFromPy.proto */
993 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
994
995 /* CIntFromPy.proto */
996 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
997
998 /* FastTypeChecks.proto */
999 #if CYTHON_COMPILING_IN_CPYTHON
1000 #define __Pyx_TypeCheck(obj, type) __Pyx_IsSubtype(Py_TYPE(obj), (PyTypeObject *)type)
1001 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b);
1002 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject *type);
1003 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *type1, PyObject *type2);
1004 #else
1005 #define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
1006 #define __Pyx_PyErr_GivenExceptionMatches(err, type) PyErr_GivenExceptionMatches(err, type)
1007 #define __Pyx_PyErr_GivenExceptionMatches2(err, type1, type2) (PyErr_GivenExceptionMatches(err, type1) || PyErr_GivenExceptionMatches(err, type2))
1008 #endif
1009 #define __Pyx_PyException_Check(obj) __Pyx_TypeCheck(obj, PyExc_Exception)
1010
1011 /* CheckBinaryVersion.proto */
1012 static int __Pyx_check_binary_version(void);
1013
1014 /* InitStrings.proto */
1015 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
1016
1017
1018 /* Module declarations from 'libc.stdint' */
1019
1020 /* Module declarations from 'borg.platform.syncfilerange' */
1021 #define __Pyx_MODULE_NAME "borg.platform.syncfilerange"
1022 extern int __pyx_module_is_main_borg__platform__syncfilerange;
1023 int __pyx_module_is_main_borg__platform__syncfilerange = 0;
1024
1025 /* Implementation of 'borg.platform.syncfilerange' */
1026 static const char __pyx_k_main[] = "__main__";
1027 static const char __pyx_k_name[] = "__name__";
1028 static const char __pyx_k_test[] = "__test__";
1029 static const char __pyx_k_cline_in_traceback[] = "cline_in_traceback";
1030 static PyObject *__pyx_n_s_cline_in_traceback;
1031 static PyObject *__pyx_n_s_main;
1032 static PyObject *__pyx_n_s_name;
1033 static PyObject *__pyx_n_s_test;
1034 /* Late includes */
1035
1036 static PyMethodDef __pyx_methods[] = {
1037 {0, 0, 0, 0}
1038 };
1039
1040 #if PY_MAJOR_VERSION >= 3
1041 #if CYTHON_PEP489_MULTI_PHASE_INIT
1042 static PyObject* __pyx_pymod_create(PyObject *spec, PyModuleDef *def); /*proto*/
1043 static int __pyx_pymod_exec_syncfilerange(PyObject* module); /*proto*/
1044 static PyModuleDef_Slot __pyx_moduledef_slots[] = {
1045 {Py_mod_create, (void*)__pyx_pymod_create},
1046 {Py_mod_exec, (void*)__pyx_pymod_exec_syncfilerange},
1047 {0, NULL}
1048 };
1049 #endif
1050
1051 static struct PyModuleDef __pyx_moduledef = {
1052 PyModuleDef_HEAD_INIT,
1053 "syncfilerange",
1054 0, /* m_doc */
1055 #if CYTHON_PEP489_MULTI_PHASE_INIT
1056 0, /* m_size */
1057 #else
1058 -1, /* m_size */
1059 #endif
1060 __pyx_methods /* m_methods */,
1061 #if CYTHON_PEP489_MULTI_PHASE_INIT
1062 __pyx_moduledef_slots, /* m_slots */
1063 #else
1064 NULL, /* m_reload */
1065 #endif
1066 NULL, /* m_traverse */
1067 NULL, /* m_clear */
1068 NULL /* m_free */
1069 };
1070 #endif
1071 #ifndef CYTHON_SMALL_CODE
1072 #if defined(__clang__)
1073 #define CYTHON_SMALL_CODE
1074 #elif defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
1075 #define CYTHON_SMALL_CODE __attribute__((cold))
1076 #else
1077 #define CYTHON_SMALL_CODE
1078 #endif
1079 #endif
1080
1081 static __Pyx_StringTabEntry __pyx_string_tab[] = {
1082 {&__pyx_n_s_cline_in_traceback, __pyx_k_cline_in_traceback, sizeof(__pyx_k_cline_in_traceback), 0, 0, 1, 1},
1083 {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
1084 {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
1085 {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
1086 {0, 0, 0, 0, 0, 0, 0}
1087 };
__Pyx_InitCachedBuiltins(void)1088 static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
1089 return 0;
1090 }
1091
__Pyx_InitCachedConstants(void)1092 static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
1093 __Pyx_RefNannyDeclarations
1094 __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
1095 __Pyx_RefNannyFinishContext();
1096 return 0;
1097 }
1098
__Pyx_InitGlobals(void)1099 static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
1100 if (__Pyx_InitStrings(__pyx_string_tab) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1101 return 0;
1102 __pyx_L1_error:;
1103 return -1;
1104 }
1105
1106 static CYTHON_SMALL_CODE int __Pyx_modinit_global_init_code(void); /*proto*/
1107 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_export_code(void); /*proto*/
1108 static CYTHON_SMALL_CODE int __Pyx_modinit_function_export_code(void); /*proto*/
1109 static CYTHON_SMALL_CODE int __Pyx_modinit_type_init_code(void); /*proto*/
1110 static CYTHON_SMALL_CODE int __Pyx_modinit_type_import_code(void); /*proto*/
1111 static CYTHON_SMALL_CODE int __Pyx_modinit_variable_import_code(void); /*proto*/
1112 static CYTHON_SMALL_CODE int __Pyx_modinit_function_import_code(void); /*proto*/
1113
__Pyx_modinit_global_init_code(void)1114 static int __Pyx_modinit_global_init_code(void) {
1115 __Pyx_RefNannyDeclarations
1116 __Pyx_RefNannySetupContext("__Pyx_modinit_global_init_code", 0);
1117 /*--- Global init code ---*/
1118 __Pyx_RefNannyFinishContext();
1119 return 0;
1120 }
1121
__Pyx_modinit_variable_export_code(void)1122 static int __Pyx_modinit_variable_export_code(void) {
1123 __Pyx_RefNannyDeclarations
1124 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_export_code", 0);
1125 /*--- Variable export code ---*/
1126 __Pyx_RefNannyFinishContext();
1127 return 0;
1128 }
1129
__Pyx_modinit_function_export_code(void)1130 static int __Pyx_modinit_function_export_code(void) {
1131 __Pyx_RefNannyDeclarations
1132 __Pyx_RefNannySetupContext("__Pyx_modinit_function_export_code", 0);
1133 /*--- Function export code ---*/
1134 __Pyx_RefNannyFinishContext();
1135 return 0;
1136 }
1137
__Pyx_modinit_type_init_code(void)1138 static int __Pyx_modinit_type_init_code(void) {
1139 __Pyx_RefNannyDeclarations
1140 __Pyx_RefNannySetupContext("__Pyx_modinit_type_init_code", 0);
1141 /*--- Type init code ---*/
1142 __Pyx_RefNannyFinishContext();
1143 return 0;
1144 }
1145
__Pyx_modinit_type_import_code(void)1146 static int __Pyx_modinit_type_import_code(void) {
1147 __Pyx_RefNannyDeclarations
1148 __Pyx_RefNannySetupContext("__Pyx_modinit_type_import_code", 0);
1149 /*--- Type import code ---*/
1150 __Pyx_RefNannyFinishContext();
1151 return 0;
1152 }
1153
__Pyx_modinit_variable_import_code(void)1154 static int __Pyx_modinit_variable_import_code(void) {
1155 __Pyx_RefNannyDeclarations
1156 __Pyx_RefNannySetupContext("__Pyx_modinit_variable_import_code", 0);
1157 /*--- Variable import code ---*/
1158 __Pyx_RefNannyFinishContext();
1159 return 0;
1160 }
1161
__Pyx_modinit_function_import_code(void)1162 static int __Pyx_modinit_function_import_code(void) {
1163 __Pyx_RefNannyDeclarations
1164 __Pyx_RefNannySetupContext("__Pyx_modinit_function_import_code", 0);
1165 /*--- Function import code ---*/
1166 __Pyx_RefNannyFinishContext();
1167 return 0;
1168 }
1169
1170
1171 #ifndef CYTHON_NO_PYINIT_EXPORT
1172 #define __Pyx_PyMODINIT_FUNC PyMODINIT_FUNC
1173 #elif PY_MAJOR_VERSION < 3
1174 #ifdef __cplusplus
1175 #define __Pyx_PyMODINIT_FUNC extern "C" void
1176 #else
1177 #define __Pyx_PyMODINIT_FUNC void
1178 #endif
1179 #else
1180 #ifdef __cplusplus
1181 #define __Pyx_PyMODINIT_FUNC extern "C" PyObject *
1182 #else
1183 #define __Pyx_PyMODINIT_FUNC PyObject *
1184 #endif
1185 #endif
1186
1187
1188 #if PY_MAJOR_VERSION < 3
1189 __Pyx_PyMODINIT_FUNC initsyncfilerange(void) CYTHON_SMALL_CODE; /*proto*/
initsyncfilerange(void)1190 __Pyx_PyMODINIT_FUNC initsyncfilerange(void)
1191 #else
1192 __Pyx_PyMODINIT_FUNC PyInit_syncfilerange(void) CYTHON_SMALL_CODE; /*proto*/
1193 __Pyx_PyMODINIT_FUNC PyInit_syncfilerange(void)
1194 #if CYTHON_PEP489_MULTI_PHASE_INIT
1195 {
1196 return PyModuleDef_Init(&__pyx_moduledef);
1197 }
1198 static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
1199 #if PY_VERSION_HEX >= 0x030700A1
1200 static PY_INT64_T main_interpreter_id = -1;
1201 PY_INT64_T current_id = PyInterpreterState_GetID(PyThreadState_Get()->interp);
1202 if (main_interpreter_id == -1) {
1203 main_interpreter_id = current_id;
1204 return (unlikely(current_id == -1)) ? -1 : 0;
1205 } else if (unlikely(main_interpreter_id != current_id))
1206 #else
1207 static PyInterpreterState *main_interpreter = NULL;
1208 PyInterpreterState *current_interpreter = PyThreadState_Get()->interp;
1209 if (!main_interpreter) {
1210 main_interpreter = current_interpreter;
1211 } else if (unlikely(main_interpreter != current_interpreter))
1212 #endif
1213 {
1214 PyErr_SetString(
1215 PyExc_ImportError,
1216 "Interpreter change detected - this module can only be loaded into one interpreter per process.");
1217 return -1;
1218 }
1219 return 0;
1220 }
1221 static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, PyObject *moddict, const char* from_name, const char* to_name, int allow_none) {
1222 PyObject *value = PyObject_GetAttrString(spec, from_name);
1223 int result = 0;
1224 if (likely(value)) {
1225 if (allow_none || value != Py_None) {
1226 result = PyDict_SetItemString(moddict, to_name, value);
1227 }
1228 Py_DECREF(value);
1229 } else if (PyErr_ExceptionMatches(PyExc_AttributeError)) {
1230 PyErr_Clear();
1231 } else {
1232 result = -1;
1233 }
1234 return result;
1235 }
1236 static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CYTHON_UNUSED PyModuleDef *def) {
1237 PyObject *module = NULL, *moddict, *modname;
1238 if (__Pyx_check_single_interpreter())
1239 return NULL;
1240 if (__pyx_m)
1241 return __Pyx_NewRef(__pyx_m);
1242 modname = PyObject_GetAttrString(spec, "name");
1243 if (unlikely(!modname)) goto bad;
1244 module = PyModule_NewObject(modname);
1245 Py_DECREF(modname);
1246 if (unlikely(!module)) goto bad;
1247 moddict = PyModule_GetDict(module);
1248 if (unlikely(!moddict)) goto bad;
1249 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "loader", "__loader__", 1) < 0)) goto bad;
1250 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "origin", "__file__", 1) < 0)) goto bad;
1251 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "parent", "__package__", 1) < 0)) goto bad;
1252 if (unlikely(__Pyx_copy_spec_to_module(spec, moddict, "submodule_search_locations", "__path__", 0) < 0)) goto bad;
1253 return module;
1254 bad:
1255 Py_XDECREF(module);
1256 return NULL;
1257 }
1258
1259
1260 static CYTHON_SMALL_CODE int __pyx_pymod_exec_syncfilerange(PyObject *__pyx_pyinit_module)
1261 #endif
1262 #endif
1263 {
1264 PyObject *__pyx_t_1 = NULL;
1265 int __pyx_lineno = 0;
1266 const char *__pyx_filename = NULL;
1267 int __pyx_clineno = 0;
1268 __Pyx_RefNannyDeclarations
1269 #if CYTHON_PEP489_MULTI_PHASE_INIT
1270 if (__pyx_m) {
1271 if (__pyx_m == __pyx_pyinit_module) return 0;
1272 PyErr_SetString(PyExc_RuntimeError, "Module 'syncfilerange' has already been imported. Re-initialisation is not supported.");
1273 return -1;
1274 }
1275 #elif PY_MAJOR_VERSION >= 3
1276 if (__pyx_m) return __Pyx_NewRef(__pyx_m);
1277 #endif
1278 #if CYTHON_REFNANNY
1279 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
1280 if (!__Pyx_RefNanny) {
1281 PyErr_Clear();
1282 __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
1283 if (!__Pyx_RefNanny)
1284 Py_FatalError("failed to import 'refnanny' module");
1285 }
1286 #endif
1287 __Pyx_RefNannySetupContext("__Pyx_PyMODINIT_FUNC PyInit_syncfilerange(void)", 0);
1288 if (__Pyx_check_binary_version() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1289 #ifdef __Pxy_PyFrame_Initialize_Offsets
1290 __Pxy_PyFrame_Initialize_Offsets();
1291 #endif
1292 __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) __PYX_ERR(0, 1, __pyx_L1_error)
1293 __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) __PYX_ERR(0, 1, __pyx_L1_error)
1294 __pyx_empty_unicode = PyUnicode_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_unicode)) __PYX_ERR(0, 1, __pyx_L1_error)
1295 #ifdef __Pyx_CyFunction_USED
1296 if (__pyx_CyFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1297 #endif
1298 #ifdef __Pyx_FusedFunction_USED
1299 if (__pyx_FusedFunction_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1300 #endif
1301 #ifdef __Pyx_Coroutine_USED
1302 if (__pyx_Coroutine_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1303 #endif
1304 #ifdef __Pyx_Generator_USED
1305 if (__pyx_Generator_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1306 #endif
1307 #ifdef __Pyx_AsyncGen_USED
1308 if (__pyx_AsyncGen_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1309 #endif
1310 #ifdef __Pyx_StopAsyncIteration_USED
1311 if (__pyx_StopAsyncIteration_init() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1312 #endif
1313 /*--- Library function declarations ---*/
1314 /*--- Threads initialization code ---*/
1315 #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
1316 #ifdef WITH_THREAD /* Python build with threading support? */
1317 PyEval_InitThreads();
1318 #endif
1319 #endif
1320 /*--- Module creation code ---*/
1321 #if CYTHON_PEP489_MULTI_PHASE_INIT
1322 __pyx_m = __pyx_pyinit_module;
1323 Py_INCREF(__pyx_m);
1324 #else
1325 #if PY_MAJOR_VERSION < 3
1326 __pyx_m = Py_InitModule4("syncfilerange", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
1327 #else
1328 __pyx_m = PyModule_Create(&__pyx_moduledef);
1329 #endif
1330 if (unlikely(!__pyx_m)) __PYX_ERR(0, 1, __pyx_L1_error)
1331 #endif
1332 __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) __PYX_ERR(0, 1, __pyx_L1_error)
1333 Py_INCREF(__pyx_d);
1334 __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) __PYX_ERR(0, 1, __pyx_L1_error)
1335 Py_INCREF(__pyx_b);
1336 __pyx_cython_runtime = PyImport_AddModule((char *) "cython_runtime"); if (unlikely(!__pyx_cython_runtime)) __PYX_ERR(0, 1, __pyx_L1_error)
1337 Py_INCREF(__pyx_cython_runtime);
1338 if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) __PYX_ERR(0, 1, __pyx_L1_error);
1339 /*--- Initialize various global constants etc. ---*/
1340 if (__Pyx_InitGlobals() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1341 #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
1342 if (__Pyx_init_sys_getdefaultencoding_params() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1343 #endif
1344 if (__pyx_module_is_main_borg__platform__syncfilerange) {
1345 if (PyObject_SetAttr(__pyx_m, __pyx_n_s_name, __pyx_n_s_main) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1346 }
1347 #if PY_MAJOR_VERSION >= 3
1348 {
1349 PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) __PYX_ERR(0, 1, __pyx_L1_error)
1350 if (!PyDict_GetItemString(modules, "borg.platform.syncfilerange")) {
1351 if (unlikely(PyDict_SetItemString(modules, "borg.platform.syncfilerange", __pyx_m) < 0)) __PYX_ERR(0, 1, __pyx_L1_error)
1352 }
1353 }
1354 #endif
1355 /*--- Builtin init code ---*/
1356 if (__Pyx_InitCachedBuiltins() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1357 /*--- Constants init code ---*/
1358 if (__Pyx_InitCachedConstants() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1359 /*--- Global type/function init code ---*/
1360 (void)__Pyx_modinit_global_init_code();
1361 (void)__Pyx_modinit_variable_export_code();
1362 (void)__Pyx_modinit_function_export_code();
1363 (void)__Pyx_modinit_type_init_code();
1364 (void)__Pyx_modinit_type_import_code();
1365 (void)__Pyx_modinit_variable_import_code();
1366 (void)__Pyx_modinit_function_import_code();
1367 /*--- Execution code ---*/
1368 #if defined(__Pyx_Generator_USED) || defined(__Pyx_Coroutine_USED)
1369 if (__Pyx_patch_abc() < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1370 #endif
1371
1372 /* "borg/platform/syncfilerange.pyx":1
1373 * # cython: language_level=3 # <<<<<<<<<<<<<<
1374 *
1375 * from libc.stdint cimport int64_t
1376 */
1377 __pyx_t_1 = __Pyx_PyDict_NewPresized(0); if (unlikely(!__pyx_t_1)) __PYX_ERR(0, 1, __pyx_L1_error)
1378 __Pyx_GOTREF(__pyx_t_1);
1379 if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) __PYX_ERR(0, 1, __pyx_L1_error)
1380 __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1381
1382 /*--- Wrapped vars code ---*/
1383
1384 goto __pyx_L0;
1385 __pyx_L1_error:;
1386 __Pyx_XDECREF(__pyx_t_1);
1387 if (__pyx_m) {
1388 if (__pyx_d) {
1389 __Pyx_AddTraceback("init borg.platform.syncfilerange", __pyx_clineno, __pyx_lineno, __pyx_filename);
1390 }
1391 Py_CLEAR(__pyx_m);
1392 } else if (!PyErr_Occurred()) {
1393 PyErr_SetString(PyExc_ImportError, "init borg.platform.syncfilerange");
1394 }
1395 __pyx_L0:;
1396 __Pyx_RefNannyFinishContext();
1397 #if CYTHON_PEP489_MULTI_PHASE_INIT
1398 return (__pyx_m != NULL) ? 0 : -1;
1399 #elif PY_MAJOR_VERSION >= 3
1400 return __pyx_m;
1401 #else
1402 return;
1403 #endif
1404 }
1405
1406 /* --- Runtime support code --- */
1407 /* Refnanny */
1408 #if CYTHON_REFNANNY
__Pyx_RefNannyImportAPI(const char * modname)1409 static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
1410 PyObject *m = NULL, *p = NULL;
1411 void *r = NULL;
1412 m = PyImport_ImportModule(modname);
1413 if (!m) goto end;
1414 p = PyObject_GetAttrString(m, "RefNannyAPI");
1415 if (!p) goto end;
1416 r = PyLong_AsVoidPtr(p);
1417 end:
1418 Py_XDECREF(p);
1419 Py_XDECREF(m);
1420 return (__Pyx_RefNannyAPIStruct *)r;
1421 }
1422 #endif
1423
1424 /* PyDictVersioning */
1425 #if CYTHON_USE_DICT_VERSIONS && CYTHON_USE_TYPE_SLOTS
__Pyx_get_tp_dict_version(PyObject * obj)1426 static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
1427 PyObject *dict = Py_TYPE(obj)->tp_dict;
1428 return likely(dict) ? __PYX_GET_DICT_VERSION(dict) : 0;
1429 }
__Pyx_get_object_dict_version(PyObject * obj)1430 static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject *obj) {
1431 PyObject **dictptr = NULL;
1432 Py_ssize_t offset = Py_TYPE(obj)->tp_dictoffset;
1433 if (offset) {
1434 #if CYTHON_COMPILING_IN_CPYTHON
1435 dictptr = (likely(offset > 0)) ? (PyObject **) ((char *)obj + offset) : _PyObject_GetDictPtr(obj);
1436 #else
1437 dictptr = _PyObject_GetDictPtr(obj);
1438 #endif
1439 }
1440 return (dictptr && *dictptr) ? __PYX_GET_DICT_VERSION(*dictptr) : 0;
1441 }
__Pyx_object_dict_version_matches(PyObject * obj,PY_UINT64_T tp_dict_version,PY_UINT64_T obj_dict_version)1442 static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj, PY_UINT64_T tp_dict_version, PY_UINT64_T obj_dict_version) {
1443 PyObject *dict = Py_TYPE(obj)->tp_dict;
1444 if (unlikely(!dict) || unlikely(tp_dict_version != __PYX_GET_DICT_VERSION(dict)))
1445 return 0;
1446 return obj_dict_version == __Pyx_get_object_dict_version(obj);
1447 }
1448 #endif
1449
1450 /* PyObjectGetAttrStr */
1451 #if CYTHON_USE_TYPE_SLOTS
__Pyx_PyObject_GetAttrStr(PyObject * obj,PyObject * attr_name)1452 static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
1453 PyTypeObject* tp = Py_TYPE(obj);
1454 if (likely(tp->tp_getattro))
1455 return tp->tp_getattro(obj, attr_name);
1456 #if PY_MAJOR_VERSION < 3
1457 if (likely(tp->tp_getattr))
1458 return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
1459 #endif
1460 return PyObject_GetAttr(obj, attr_name);
1461 }
1462 #endif
1463
1464 /* PyErrFetchRestore */
1465 #if CYTHON_FAST_THREAD_STATE
__Pyx_ErrRestoreInState(PyThreadState * tstate,PyObject * type,PyObject * value,PyObject * tb)1466 static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate, PyObject *type, PyObject *value, PyObject *tb) {
1467 PyObject *tmp_type, *tmp_value, *tmp_tb;
1468 tmp_type = tstate->curexc_type;
1469 tmp_value = tstate->curexc_value;
1470 tmp_tb = tstate->curexc_traceback;
1471 tstate->curexc_type = type;
1472 tstate->curexc_value = value;
1473 tstate->curexc_traceback = tb;
1474 Py_XDECREF(tmp_type);
1475 Py_XDECREF(tmp_value);
1476 Py_XDECREF(tmp_tb);
1477 }
__Pyx_ErrFetchInState(PyThreadState * tstate,PyObject ** type,PyObject ** value,PyObject ** tb)1478 static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, PyObject **type, PyObject **value, PyObject **tb) {
1479 *type = tstate->curexc_type;
1480 *value = tstate->curexc_value;
1481 *tb = tstate->curexc_traceback;
1482 tstate->curexc_type = 0;
1483 tstate->curexc_value = 0;
1484 tstate->curexc_traceback = 0;
1485 }
1486 #endif
1487
1488 /* CLineInTraceback */
1489 #ifndef CYTHON_CLINE_IN_TRACEBACK
__Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState * tstate,int c_line)1490 static int __Pyx_CLineForTraceback(CYTHON_NCP_UNUSED PyThreadState *tstate, int c_line) {
1491 PyObject *use_cline;
1492 PyObject *ptype, *pvalue, *ptraceback;
1493 #if CYTHON_COMPILING_IN_CPYTHON
1494 PyObject **cython_runtime_dict;
1495 #endif
1496 if (unlikely(!__pyx_cython_runtime)) {
1497 return c_line;
1498 }
1499 __Pyx_ErrFetchInState(tstate, &ptype, &pvalue, &ptraceback);
1500 #if CYTHON_COMPILING_IN_CPYTHON
1501 cython_runtime_dict = _PyObject_GetDictPtr(__pyx_cython_runtime);
1502 if (likely(cython_runtime_dict)) {
1503 __PYX_PY_DICT_LOOKUP_IF_MODIFIED(
1504 use_cline, *cython_runtime_dict,
1505 __Pyx_PyDict_GetItemStr(*cython_runtime_dict, __pyx_n_s_cline_in_traceback))
1506 } else
1507 #endif
1508 {
1509 PyObject *use_cline_obj = __Pyx_PyObject_GetAttrStr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback);
1510 if (use_cline_obj) {
1511 use_cline = PyObject_Not(use_cline_obj) ? Py_False : Py_True;
1512 Py_DECREF(use_cline_obj);
1513 } else {
1514 PyErr_Clear();
1515 use_cline = NULL;
1516 }
1517 }
1518 if (!use_cline) {
1519 c_line = 0;
1520 PyObject_SetAttr(__pyx_cython_runtime, __pyx_n_s_cline_in_traceback, Py_False);
1521 }
1522 else if (use_cline == Py_False || (use_cline != Py_True && PyObject_Not(use_cline) != 0)) {
1523 c_line = 0;
1524 }
1525 __Pyx_ErrRestoreInState(tstate, ptype, pvalue, ptraceback);
1526 return c_line;
1527 }
1528 #endif
1529
1530 /* CodeObjectCache */
__pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry * entries,int count,int code_line)1531 static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
1532 int start = 0, mid = 0, end = count - 1;
1533 if (end >= 0 && code_line > entries[end].code_line) {
1534 return count;
1535 }
1536 while (start < end) {
1537 mid = start + (end - start) / 2;
1538 if (code_line < entries[mid].code_line) {
1539 end = mid;
1540 } else if (code_line > entries[mid].code_line) {
1541 start = mid + 1;
1542 } else {
1543 return mid;
1544 }
1545 }
1546 if (code_line <= entries[mid].code_line) {
1547 return mid;
1548 } else {
1549 return mid + 1;
1550 }
1551 }
__pyx_find_code_object(int code_line)1552 static PyCodeObject *__pyx_find_code_object(int code_line) {
1553 PyCodeObject* code_object;
1554 int pos;
1555 if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
1556 return NULL;
1557 }
1558 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
1559 if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
1560 return NULL;
1561 }
1562 code_object = __pyx_code_cache.entries[pos].code_object;
1563 Py_INCREF(code_object);
1564 return code_object;
1565 }
__pyx_insert_code_object(int code_line,PyCodeObject * code_object)1566 static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
1567 int pos, i;
1568 __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
1569 if (unlikely(!code_line)) {
1570 return;
1571 }
1572 if (unlikely(!entries)) {
1573 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
1574 if (likely(entries)) {
1575 __pyx_code_cache.entries = entries;
1576 __pyx_code_cache.max_count = 64;
1577 __pyx_code_cache.count = 1;
1578 entries[0].code_line = code_line;
1579 entries[0].code_object = code_object;
1580 Py_INCREF(code_object);
1581 }
1582 return;
1583 }
1584 pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
1585 if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
1586 PyCodeObject* tmp = entries[pos].code_object;
1587 entries[pos].code_object = code_object;
1588 Py_DECREF(tmp);
1589 return;
1590 }
1591 if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
1592 int new_max = __pyx_code_cache.max_count + 64;
1593 entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
1594 __pyx_code_cache.entries, ((size_t)new_max) * sizeof(__Pyx_CodeObjectCacheEntry));
1595 if (unlikely(!entries)) {
1596 return;
1597 }
1598 __pyx_code_cache.entries = entries;
1599 __pyx_code_cache.max_count = new_max;
1600 }
1601 for (i=__pyx_code_cache.count; i>pos; i--) {
1602 entries[i] = entries[i-1];
1603 }
1604 entries[pos].code_line = code_line;
1605 entries[pos].code_object = code_object;
1606 __pyx_code_cache.count++;
1607 Py_INCREF(code_object);
1608 }
1609
1610 /* AddTraceback */
1611 #include "compile.h"
1612 #include "frameobject.h"
1613 #include "traceback.h"
__Pyx_CreateCodeObjectForTraceback(const char * funcname,int c_line,int py_line,const char * filename)1614 static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
1615 const char *funcname, int c_line,
1616 int py_line, const char *filename) {
1617 PyCodeObject *py_code = 0;
1618 PyObject *py_srcfile = 0;
1619 PyObject *py_funcname = 0;
1620 #if PY_MAJOR_VERSION < 3
1621 py_srcfile = PyString_FromString(filename);
1622 #else
1623 py_srcfile = PyUnicode_FromString(filename);
1624 #endif
1625 if (!py_srcfile) goto bad;
1626 if (c_line) {
1627 #if PY_MAJOR_VERSION < 3
1628 py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
1629 #else
1630 py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
1631 #endif
1632 }
1633 else {
1634 #if PY_MAJOR_VERSION < 3
1635 py_funcname = PyString_FromString(funcname);
1636 #else
1637 py_funcname = PyUnicode_FromString(funcname);
1638 #endif
1639 }
1640 if (!py_funcname) goto bad;
1641 py_code = __Pyx_PyCode_New(
1642 0,
1643 0,
1644 0,
1645 0,
1646 0,
1647 __pyx_empty_bytes, /*PyObject *code,*/
1648 __pyx_empty_tuple, /*PyObject *consts,*/
1649 __pyx_empty_tuple, /*PyObject *names,*/
1650 __pyx_empty_tuple, /*PyObject *varnames,*/
1651 __pyx_empty_tuple, /*PyObject *freevars,*/
1652 __pyx_empty_tuple, /*PyObject *cellvars,*/
1653 py_srcfile, /*PyObject *filename,*/
1654 py_funcname, /*PyObject *name,*/
1655 py_line,
1656 __pyx_empty_bytes /*PyObject *lnotab*/
1657 );
1658 Py_DECREF(py_srcfile);
1659 Py_DECREF(py_funcname);
1660 return py_code;
1661 bad:
1662 Py_XDECREF(py_srcfile);
1663 Py_XDECREF(py_funcname);
1664 return NULL;
1665 }
__Pyx_AddTraceback(const char * funcname,int c_line,int py_line,const char * filename)1666 static void __Pyx_AddTraceback(const char *funcname, int c_line,
1667 int py_line, const char *filename) {
1668 PyCodeObject *py_code = 0;
1669 PyFrameObject *py_frame = 0;
1670 PyThreadState *tstate = __Pyx_PyThreadState_Current;
1671 if (c_line) {
1672 c_line = __Pyx_CLineForTraceback(tstate, c_line);
1673 }
1674 py_code = __pyx_find_code_object(c_line ? -c_line : py_line);
1675 if (!py_code) {
1676 py_code = __Pyx_CreateCodeObjectForTraceback(
1677 funcname, c_line, py_line, filename);
1678 if (!py_code) goto bad;
1679 __pyx_insert_code_object(c_line ? -c_line : py_line, py_code);
1680 }
1681 py_frame = PyFrame_New(
1682 tstate, /*PyThreadState *tstate,*/
1683 py_code, /*PyCodeObject *code,*/
1684 __pyx_d, /*PyObject *globals,*/
1685 0 /*PyObject *locals*/
1686 );
1687 if (!py_frame) goto bad;
1688 __Pyx_PyFrame_SetLineNumber(py_frame, py_line);
1689 PyTraceBack_Here(py_frame);
1690 bad:
1691 Py_XDECREF(py_code);
1692 Py_XDECREF(py_frame);
1693 }
1694
1695 /* CIntToPy */
__Pyx_PyInt_From_long(long value)1696 static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
1697 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
1698 #pragma GCC diagnostic push
1699 #pragma GCC diagnostic ignored "-Wconversion"
1700 #endif
1701 const long neg_one = (long) -1, const_zero = (long) 0;
1702 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
1703 #pragma GCC diagnostic pop
1704 #endif
1705 const int is_unsigned = neg_one > const_zero;
1706 if (is_unsigned) {
1707 if (sizeof(long) < sizeof(long)) {
1708 return PyInt_FromLong((long) value);
1709 } else if (sizeof(long) <= sizeof(unsigned long)) {
1710 return PyLong_FromUnsignedLong((unsigned long) value);
1711 #ifdef HAVE_LONG_LONG
1712 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
1713 return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
1714 #endif
1715 }
1716 } else {
1717 if (sizeof(long) <= sizeof(long)) {
1718 return PyInt_FromLong((long) value);
1719 #ifdef HAVE_LONG_LONG
1720 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
1721 return PyLong_FromLongLong((PY_LONG_LONG) value);
1722 #endif
1723 }
1724 }
1725 {
1726 int one = 1; int little = (int)*(unsigned char *)&one;
1727 unsigned char *bytes = (unsigned char *)&value;
1728 return _PyLong_FromByteArray(bytes, sizeof(long),
1729 little, !is_unsigned);
1730 }
1731 }
1732
1733 /* CIntFromPyVerify */
1734 #define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)\
1735 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 0)
1736 #define __PYX_VERIFY_RETURN_INT_EXC(target_type, func_type, func_value)\
1737 __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, 1)
1738 #define __PYX__VERIFY_RETURN_INT(target_type, func_type, func_value, exc)\
1739 {\
1740 func_type value = func_value;\
1741 if (sizeof(target_type) < sizeof(func_type)) {\
1742 if (unlikely(value != (func_type) (target_type) value)) {\
1743 func_type zero = 0;\
1744 if (exc && unlikely(value == (func_type)-1 && PyErr_Occurred()))\
1745 return (target_type) -1;\
1746 if (is_unsigned && unlikely(value < zero))\
1747 goto raise_neg_overflow;\
1748 else\
1749 goto raise_overflow;\
1750 }\
1751 }\
1752 return (target_type) value;\
1753 }
1754
1755 /* CIntFromPy */
__Pyx_PyInt_As_long(PyObject * x)1756 static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
1757 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
1758 #pragma GCC diagnostic push
1759 #pragma GCC diagnostic ignored "-Wconversion"
1760 #endif
1761 const long neg_one = (long) -1, const_zero = (long) 0;
1762 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
1763 #pragma GCC diagnostic pop
1764 #endif
1765 const int is_unsigned = neg_one > const_zero;
1766 #if PY_MAJOR_VERSION < 3
1767 if (likely(PyInt_Check(x))) {
1768 if (sizeof(long) < sizeof(long)) {
1769 __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
1770 } else {
1771 long val = PyInt_AS_LONG(x);
1772 if (is_unsigned && unlikely(val < 0)) {
1773 goto raise_neg_overflow;
1774 }
1775 return (long) val;
1776 }
1777 } else
1778 #endif
1779 if (likely(PyLong_Check(x))) {
1780 if (is_unsigned) {
1781 #if CYTHON_USE_PYLONG_INTERNALS
1782 const digit* digits = ((PyLongObject*)x)->ob_digit;
1783 switch (Py_SIZE(x)) {
1784 case 0: return (long) 0;
1785 case 1: __PYX_VERIFY_RETURN_INT(long, digit, digits[0])
1786 case 2:
1787 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
1788 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1789 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1790 } else if (8 * sizeof(long) >= 2 * PyLong_SHIFT) {
1791 return (long) (((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
1792 }
1793 }
1794 break;
1795 case 3:
1796 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
1797 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1798 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1799 } else if (8 * sizeof(long) >= 3 * PyLong_SHIFT) {
1800 return (long) (((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
1801 }
1802 }
1803 break;
1804 case 4:
1805 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
1806 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1807 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1808 } else if (8 * sizeof(long) >= 4 * PyLong_SHIFT) {
1809 return (long) (((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0]));
1810 }
1811 }
1812 break;
1813 }
1814 #endif
1815 #if CYTHON_COMPILING_IN_CPYTHON
1816 if (unlikely(Py_SIZE(x) < 0)) {
1817 goto raise_neg_overflow;
1818 }
1819 #else
1820 {
1821 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
1822 if (unlikely(result < 0))
1823 return (long) -1;
1824 if (unlikely(result == 1))
1825 goto raise_neg_overflow;
1826 }
1827 #endif
1828 if (sizeof(long) <= sizeof(unsigned long)) {
1829 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned long, PyLong_AsUnsignedLong(x))
1830 #ifdef HAVE_LONG_LONG
1831 } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
1832 __PYX_VERIFY_RETURN_INT_EXC(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
1833 #endif
1834 }
1835 } else {
1836 #if CYTHON_USE_PYLONG_INTERNALS
1837 const digit* digits = ((PyLongObject*)x)->ob_digit;
1838 switch (Py_SIZE(x)) {
1839 case 0: return (long) 0;
1840 case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, (sdigit) (-(sdigit)digits[0]))
1841 case 1: __PYX_VERIFY_RETURN_INT(long, digit, +digits[0])
1842 case -2:
1843 if (8 * sizeof(long) - 1 > 1 * PyLong_SHIFT) {
1844 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1845 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1846 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
1847 return (long) (((long)-1)*(((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1848 }
1849 }
1850 break;
1851 case 2:
1852 if (8 * sizeof(long) > 1 * PyLong_SHIFT) {
1853 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1854 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1855 } else if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
1856 return (long) ((((((long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1857 }
1858 }
1859 break;
1860 case -3:
1861 if (8 * sizeof(long) - 1 > 2 * PyLong_SHIFT) {
1862 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1863 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1864 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
1865 return (long) (((long)-1)*(((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1866 }
1867 }
1868 break;
1869 case 3:
1870 if (8 * sizeof(long) > 2 * PyLong_SHIFT) {
1871 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1872 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1873 } else if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
1874 return (long) ((((((((long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1875 }
1876 }
1877 break;
1878 case -4:
1879 if (8 * sizeof(long) - 1 > 3 * PyLong_SHIFT) {
1880 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1881 __PYX_VERIFY_RETURN_INT(long, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1882 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
1883 return (long) (((long)-1)*(((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1884 }
1885 }
1886 break;
1887 case 4:
1888 if (8 * sizeof(long) > 3 * PyLong_SHIFT) {
1889 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
1890 __PYX_VERIFY_RETURN_INT(long, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1891 } else if (8 * sizeof(long) - 1 > 4 * PyLong_SHIFT) {
1892 return (long) ((((((((((long)digits[3]) << PyLong_SHIFT) | (long)digits[2]) << PyLong_SHIFT) | (long)digits[1]) << PyLong_SHIFT) | (long)digits[0])));
1893 }
1894 }
1895 break;
1896 }
1897 #endif
1898 if (sizeof(long) <= sizeof(long)) {
1899 __PYX_VERIFY_RETURN_INT_EXC(long, long, PyLong_AsLong(x))
1900 #ifdef HAVE_LONG_LONG
1901 } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
1902 __PYX_VERIFY_RETURN_INT_EXC(long, PY_LONG_LONG, PyLong_AsLongLong(x))
1903 #endif
1904 }
1905 }
1906 {
1907 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
1908 PyErr_SetString(PyExc_RuntimeError,
1909 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
1910 #else
1911 long val;
1912 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
1913 #if PY_MAJOR_VERSION < 3
1914 if (likely(v) && !PyLong_Check(v)) {
1915 PyObject *tmp = v;
1916 v = PyNumber_Long(tmp);
1917 Py_DECREF(tmp);
1918 }
1919 #endif
1920 if (likely(v)) {
1921 int one = 1; int is_little = (int)*(unsigned char *)&one;
1922 unsigned char *bytes = (unsigned char *)&val;
1923 int ret = _PyLong_AsByteArray((PyLongObject *)v,
1924 bytes, sizeof(val),
1925 is_little, !is_unsigned);
1926 Py_DECREF(v);
1927 if (likely(!ret))
1928 return val;
1929 }
1930 #endif
1931 return (long) -1;
1932 }
1933 } else {
1934 long val;
1935 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
1936 if (!tmp) return (long) -1;
1937 val = __Pyx_PyInt_As_long(tmp);
1938 Py_DECREF(tmp);
1939 return val;
1940 }
1941 raise_overflow:
1942 PyErr_SetString(PyExc_OverflowError,
1943 "value too large to convert to long");
1944 return (long) -1;
1945 raise_neg_overflow:
1946 PyErr_SetString(PyExc_OverflowError,
1947 "can't convert negative value to long");
1948 return (long) -1;
1949 }
1950
1951 /* CIntFromPy */
__Pyx_PyInt_As_int(PyObject * x)1952 static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
1953 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
1954 #pragma GCC diagnostic push
1955 #pragma GCC diagnostic ignored "-Wconversion"
1956 #endif
1957 const int neg_one = (int) -1, const_zero = (int) 0;
1958 #ifdef __Pyx_HAS_GCC_DIAGNOSTIC
1959 #pragma GCC diagnostic pop
1960 #endif
1961 const int is_unsigned = neg_one > const_zero;
1962 #if PY_MAJOR_VERSION < 3
1963 if (likely(PyInt_Check(x))) {
1964 if (sizeof(int) < sizeof(long)) {
1965 __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
1966 } else {
1967 long val = PyInt_AS_LONG(x);
1968 if (is_unsigned && unlikely(val < 0)) {
1969 goto raise_neg_overflow;
1970 }
1971 return (int) val;
1972 }
1973 } else
1974 #endif
1975 if (likely(PyLong_Check(x))) {
1976 if (is_unsigned) {
1977 #if CYTHON_USE_PYLONG_INTERNALS
1978 const digit* digits = ((PyLongObject*)x)->ob_digit;
1979 switch (Py_SIZE(x)) {
1980 case 0: return (int) 0;
1981 case 1: __PYX_VERIFY_RETURN_INT(int, digit, digits[0])
1982 case 2:
1983 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
1984 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
1985 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1986 } else if (8 * sizeof(int) >= 2 * PyLong_SHIFT) {
1987 return (int) (((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
1988 }
1989 }
1990 break;
1991 case 3:
1992 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
1993 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
1994 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
1995 } else if (8 * sizeof(int) >= 3 * PyLong_SHIFT) {
1996 return (int) (((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
1997 }
1998 }
1999 break;
2000 case 4:
2001 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
2002 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2003 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2004 } else if (8 * sizeof(int) >= 4 * PyLong_SHIFT) {
2005 return (int) (((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0]));
2006 }
2007 }
2008 break;
2009 }
2010 #endif
2011 #if CYTHON_COMPILING_IN_CPYTHON
2012 if (unlikely(Py_SIZE(x) < 0)) {
2013 goto raise_neg_overflow;
2014 }
2015 #else
2016 {
2017 int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
2018 if (unlikely(result < 0))
2019 return (int) -1;
2020 if (unlikely(result == 1))
2021 goto raise_neg_overflow;
2022 }
2023 #endif
2024 if (sizeof(int) <= sizeof(unsigned long)) {
2025 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned long, PyLong_AsUnsignedLong(x))
2026 #ifdef HAVE_LONG_LONG
2027 } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
2028 __PYX_VERIFY_RETURN_INT_EXC(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
2029 #endif
2030 }
2031 } else {
2032 #if CYTHON_USE_PYLONG_INTERNALS
2033 const digit* digits = ((PyLongObject*)x)->ob_digit;
2034 switch (Py_SIZE(x)) {
2035 case 0: return (int) 0;
2036 case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, (sdigit) (-(sdigit)digits[0]))
2037 case 1: __PYX_VERIFY_RETURN_INT(int, digit, +digits[0])
2038 case -2:
2039 if (8 * sizeof(int) - 1 > 1 * PyLong_SHIFT) {
2040 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2041 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2042 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
2043 return (int) (((int)-1)*(((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
2044 }
2045 }
2046 break;
2047 case 2:
2048 if (8 * sizeof(int) > 1 * PyLong_SHIFT) {
2049 if (8 * sizeof(unsigned long) > 2 * PyLong_SHIFT) {
2050 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2051 } else if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
2052 return (int) ((((((int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
2053 }
2054 }
2055 break;
2056 case -3:
2057 if (8 * sizeof(int) - 1 > 2 * PyLong_SHIFT) {
2058 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2059 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2060 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
2061 return (int) (((int)-1)*(((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
2062 }
2063 }
2064 break;
2065 case 3:
2066 if (8 * sizeof(int) > 2 * PyLong_SHIFT) {
2067 if (8 * sizeof(unsigned long) > 3 * PyLong_SHIFT) {
2068 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2069 } else if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
2070 return (int) ((((((((int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
2071 }
2072 }
2073 break;
2074 case -4:
2075 if (8 * sizeof(int) - 1 > 3 * PyLong_SHIFT) {
2076 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2077 __PYX_VERIFY_RETURN_INT(int, long, -(long) (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2078 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
2079 return (int) (((int)-1)*(((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
2080 }
2081 }
2082 break;
2083 case 4:
2084 if (8 * sizeof(int) > 3 * PyLong_SHIFT) {
2085 if (8 * sizeof(unsigned long) > 4 * PyLong_SHIFT) {
2086 __PYX_VERIFY_RETURN_INT(int, unsigned long, (((((((((unsigned long)digits[3]) << PyLong_SHIFT) | (unsigned long)digits[2]) << PyLong_SHIFT) | (unsigned long)digits[1]) << PyLong_SHIFT) | (unsigned long)digits[0])))
2087 } else if (8 * sizeof(int) - 1 > 4 * PyLong_SHIFT) {
2088 return (int) ((((((((((int)digits[3]) << PyLong_SHIFT) | (int)digits[2]) << PyLong_SHIFT) | (int)digits[1]) << PyLong_SHIFT) | (int)digits[0])));
2089 }
2090 }
2091 break;
2092 }
2093 #endif
2094 if (sizeof(int) <= sizeof(long)) {
2095 __PYX_VERIFY_RETURN_INT_EXC(int, long, PyLong_AsLong(x))
2096 #ifdef HAVE_LONG_LONG
2097 } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
2098 __PYX_VERIFY_RETURN_INT_EXC(int, PY_LONG_LONG, PyLong_AsLongLong(x))
2099 #endif
2100 }
2101 }
2102 {
2103 #if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
2104 PyErr_SetString(PyExc_RuntimeError,
2105 "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
2106 #else
2107 int val;
2108 PyObject *v = __Pyx_PyNumber_IntOrLong(x);
2109 #if PY_MAJOR_VERSION < 3
2110 if (likely(v) && !PyLong_Check(v)) {
2111 PyObject *tmp = v;
2112 v = PyNumber_Long(tmp);
2113 Py_DECREF(tmp);
2114 }
2115 #endif
2116 if (likely(v)) {
2117 int one = 1; int is_little = (int)*(unsigned char *)&one;
2118 unsigned char *bytes = (unsigned char *)&val;
2119 int ret = _PyLong_AsByteArray((PyLongObject *)v,
2120 bytes, sizeof(val),
2121 is_little, !is_unsigned);
2122 Py_DECREF(v);
2123 if (likely(!ret))
2124 return val;
2125 }
2126 #endif
2127 return (int) -1;
2128 }
2129 } else {
2130 int val;
2131 PyObject *tmp = __Pyx_PyNumber_IntOrLong(x);
2132 if (!tmp) return (int) -1;
2133 val = __Pyx_PyInt_As_int(tmp);
2134 Py_DECREF(tmp);
2135 return val;
2136 }
2137 raise_overflow:
2138 PyErr_SetString(PyExc_OverflowError,
2139 "value too large to convert to int");
2140 return (int) -1;
2141 raise_neg_overflow:
2142 PyErr_SetString(PyExc_OverflowError,
2143 "can't convert negative value to int");
2144 return (int) -1;
2145 }
2146
2147 /* FastTypeChecks */
2148 #if CYTHON_COMPILING_IN_CPYTHON
__Pyx_InBases(PyTypeObject * a,PyTypeObject * b)2149 static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
2150 while (a) {
2151 a = a->tp_base;
2152 if (a == b)
2153 return 1;
2154 }
2155 return b == &PyBaseObject_Type;
2156 }
__Pyx_IsSubtype(PyTypeObject * a,PyTypeObject * b)2157 static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *b) {
2158 PyObject *mro;
2159 if (a == b) return 1;
2160 mro = a->tp_mro;
2161 if (likely(mro)) {
2162 Py_ssize_t i, n;
2163 n = PyTuple_GET_SIZE(mro);
2164 for (i = 0; i < n; i++) {
2165 if (PyTuple_GET_ITEM(mro, i) == (PyObject *)b)
2166 return 1;
2167 }
2168 return 0;
2169 }
2170 return __Pyx_InBases(a, b);
2171 }
2172 #if PY_MAJOR_VERSION == 2
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)2173 static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject* exc_type2) {
2174 PyObject *exception, *value, *tb;
2175 int res;
2176 __Pyx_PyThreadState_declare
2177 __Pyx_PyThreadState_assign
2178 __Pyx_ErrFetch(&exception, &value, &tb);
2179 res = exc_type1 ? PyObject_IsSubclass(err, exc_type1) : 0;
2180 if (unlikely(res == -1)) {
2181 PyErr_WriteUnraisable(err);
2182 res = 0;
2183 }
2184 if (!res) {
2185 res = PyObject_IsSubclass(err, exc_type2);
2186 if (unlikely(res == -1)) {
2187 PyErr_WriteUnraisable(err);
2188 res = 0;
2189 }
2190 }
2191 __Pyx_ErrRestore(exception, value, tb);
2192 return res;
2193 }
2194 #else
__Pyx_inner_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)2195 static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObject* exc_type1, PyObject *exc_type2) {
2196 int res = exc_type1 ? __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type1) : 0;
2197 if (!res) {
2198 res = __Pyx_IsSubtype((PyTypeObject*)err, (PyTypeObject*)exc_type2);
2199 }
2200 return res;
2201 }
2202 #endif
__Pyx_PyErr_GivenExceptionMatchesTuple(PyObject * exc_type,PyObject * tuple)2203 static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, PyObject *tuple) {
2204 Py_ssize_t i, n;
2205 assert(PyExceptionClass_Check(exc_type));
2206 n = PyTuple_GET_SIZE(tuple);
2207 #if PY_MAJOR_VERSION >= 3
2208 for (i=0; i<n; i++) {
2209 if (exc_type == PyTuple_GET_ITEM(tuple, i)) return 1;
2210 }
2211 #endif
2212 for (i=0; i<n; i++) {
2213 PyObject *t = PyTuple_GET_ITEM(tuple, i);
2214 #if PY_MAJOR_VERSION < 3
2215 if (likely(exc_type == t)) return 1;
2216 #endif
2217 if (likely(PyExceptionClass_Check(t))) {
2218 if (__Pyx_inner_PyErr_GivenExceptionMatches2(exc_type, NULL, t)) return 1;
2219 } else {
2220 }
2221 }
2222 return 0;
2223 }
__Pyx_PyErr_GivenExceptionMatches(PyObject * err,PyObject * exc_type)2224 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err, PyObject* exc_type) {
2225 if (likely(err == exc_type)) return 1;
2226 if (likely(PyExceptionClass_Check(err))) {
2227 if (likely(PyExceptionClass_Check(exc_type))) {
2228 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, NULL, exc_type);
2229 } else if (likely(PyTuple_Check(exc_type))) {
2230 return __Pyx_PyErr_GivenExceptionMatchesTuple(err, exc_type);
2231 } else {
2232 }
2233 }
2234 return PyErr_GivenExceptionMatches(err, exc_type);
2235 }
__Pyx_PyErr_GivenExceptionMatches2(PyObject * err,PyObject * exc_type1,PyObject * exc_type2)2236 static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *err, PyObject *exc_type1, PyObject *exc_type2) {
2237 assert(PyExceptionClass_Check(exc_type1));
2238 assert(PyExceptionClass_Check(exc_type2));
2239 if (likely(err == exc_type1 || err == exc_type2)) return 1;
2240 if (likely(PyExceptionClass_Check(err))) {
2241 return __Pyx_inner_PyErr_GivenExceptionMatches2(err, exc_type1, exc_type2);
2242 }
2243 return (PyErr_GivenExceptionMatches(err, exc_type1) || PyErr_GivenExceptionMatches(err, exc_type2));
2244 }
2245 #endif
2246
2247 /* CheckBinaryVersion */
__Pyx_check_binary_version(void)2248 static int __Pyx_check_binary_version(void) {
2249 char ctversion[4], rtversion[4];
2250 PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
2251 PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
2252 if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
2253 char message[200];
2254 PyOS_snprintf(message, sizeof(message),
2255 "compiletime version %s of module '%.100s' "
2256 "does not match runtime version %s",
2257 ctversion, __Pyx_MODULE_NAME, rtversion);
2258 return PyErr_WarnEx(NULL, message, 1);
2259 }
2260 return 0;
2261 }
2262
2263 /* InitStrings */
__Pyx_InitStrings(__Pyx_StringTabEntry * t)2264 static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
2265 while (t->p) {
2266 #if PY_MAJOR_VERSION < 3
2267 if (t->is_unicode) {
2268 *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
2269 } else if (t->intern) {
2270 *t->p = PyString_InternFromString(t->s);
2271 } else {
2272 *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
2273 }
2274 #else
2275 if (t->is_unicode | t->is_str) {
2276 if (t->intern) {
2277 *t->p = PyUnicode_InternFromString(t->s);
2278 } else if (t->encoding) {
2279 *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
2280 } else {
2281 *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
2282 }
2283 } else {
2284 *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
2285 }
2286 #endif
2287 if (!*t->p)
2288 return -1;
2289 if (PyObject_Hash(*t->p) == -1)
2290 return -1;
2291 ++t;
2292 }
2293 return 0;
2294 }
2295
__Pyx_PyUnicode_FromString(const char * c_str)2296 static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
2297 return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
2298 }
__Pyx_PyObject_AsString(PyObject * o)2299 static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
2300 Py_ssize_t ignore;
2301 return __Pyx_PyObject_AsStringAndSize(o, &ignore);
2302 }
2303 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
2304 #if !CYTHON_PEP393_ENABLED
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)2305 static const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
2306 char* defenc_c;
2307 PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
2308 if (!defenc) return NULL;
2309 defenc_c = PyBytes_AS_STRING(defenc);
2310 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
2311 {
2312 char* end = defenc_c + PyBytes_GET_SIZE(defenc);
2313 char* c;
2314 for (c = defenc_c; c < end; c++) {
2315 if ((unsigned char) (*c) >= 128) {
2316 PyUnicode_AsASCIIString(o);
2317 return NULL;
2318 }
2319 }
2320 }
2321 #endif
2322 *length = PyBytes_GET_SIZE(defenc);
2323 return defenc_c;
2324 }
2325 #else
__Pyx_PyUnicode_AsStringAndSize(PyObject * o,Py_ssize_t * length)2326 static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
2327 if (unlikely(__Pyx_PyUnicode_READY(o) == -1)) return NULL;
2328 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
2329 if (likely(PyUnicode_IS_ASCII(o))) {
2330 *length = PyUnicode_GET_LENGTH(o);
2331 return PyUnicode_AsUTF8(o);
2332 } else {
2333 PyUnicode_AsASCIIString(o);
2334 return NULL;
2335 }
2336 #else
2337 return PyUnicode_AsUTF8AndSize(o, length);
2338 #endif
2339 }
2340 #endif
2341 #endif
__Pyx_PyObject_AsStringAndSize(PyObject * o,Py_ssize_t * length)2342 static CYTHON_INLINE const char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
2343 #if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
2344 if (
2345 #if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
2346 __Pyx_sys_getdefaultencoding_not_ascii &&
2347 #endif
2348 PyUnicode_Check(o)) {
2349 return __Pyx_PyUnicode_AsStringAndSize(o, length);
2350 } else
2351 #endif
2352 #if (!CYTHON_COMPILING_IN_PYPY) || (defined(PyByteArray_AS_STRING) && defined(PyByteArray_GET_SIZE))
2353 if (PyByteArray_Check(o)) {
2354 *length = PyByteArray_GET_SIZE(o);
2355 return PyByteArray_AS_STRING(o);
2356 } else
2357 #endif
2358 {
2359 char* result;
2360 int r = PyBytes_AsStringAndSize(o, &result, length);
2361 if (unlikely(r < 0)) {
2362 return NULL;
2363 } else {
2364 return result;
2365 }
2366 }
2367 }
__Pyx_PyObject_IsTrue(PyObject * x)2368 static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
2369 int is_true = x == Py_True;
2370 if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
2371 else return PyObject_IsTrue(x);
2372 }
__Pyx_PyObject_IsTrueAndDecref(PyObject * x)2373 static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
2374 int retval;
2375 if (unlikely(!x)) return -1;
2376 retval = __Pyx_PyObject_IsTrue(x);
2377 Py_DECREF(x);
2378 return retval;
2379 }
__Pyx_PyNumber_IntOrLongWrongResultType(PyObject * result,const char * type_name)2380 static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* result, const char* type_name) {
2381 #if PY_MAJOR_VERSION >= 3
2382 if (PyLong_Check(result)) {
2383 if (PyErr_WarnFormat(PyExc_DeprecationWarning, 1,
2384 "__int__ returned non-int (type %.200s). "
2385 "The ability to return an instance of a strict subclass of int "
2386 "is deprecated, and may be removed in a future version of Python.",
2387 Py_TYPE(result)->tp_name)) {
2388 Py_DECREF(result);
2389 return NULL;
2390 }
2391 return result;
2392 }
2393 #endif
2394 PyErr_Format(PyExc_TypeError,
2395 "__%.4s__ returned non-%.4s (type %.200s)",
2396 type_name, type_name, Py_TYPE(result)->tp_name);
2397 Py_DECREF(result);
2398 return NULL;
2399 }
__Pyx_PyNumber_IntOrLong(PyObject * x)2400 static CYTHON_INLINE PyObject* __Pyx_PyNumber_IntOrLong(PyObject* x) {
2401 #if CYTHON_USE_TYPE_SLOTS
2402 PyNumberMethods *m;
2403 #endif
2404 const char *name = NULL;
2405 PyObject *res = NULL;
2406 #if PY_MAJOR_VERSION < 3
2407 if (likely(PyInt_Check(x) || PyLong_Check(x)))
2408 #else
2409 if (likely(PyLong_Check(x)))
2410 #endif
2411 return __Pyx_NewRef(x);
2412 #if CYTHON_USE_TYPE_SLOTS
2413 m = Py_TYPE(x)->tp_as_number;
2414 #if PY_MAJOR_VERSION < 3
2415 if (m && m->nb_int) {
2416 name = "int";
2417 res = m->nb_int(x);
2418 }
2419 else if (m && m->nb_long) {
2420 name = "long";
2421 res = m->nb_long(x);
2422 }
2423 #else
2424 if (likely(m && m->nb_int)) {
2425 name = "int";
2426 res = m->nb_int(x);
2427 }
2428 #endif
2429 #else
2430 if (!PyBytes_CheckExact(x) && !PyUnicode_CheckExact(x)) {
2431 res = PyNumber_Int(x);
2432 }
2433 #endif
2434 if (likely(res)) {
2435 #if PY_MAJOR_VERSION < 3
2436 if (unlikely(!PyInt_Check(res) && !PyLong_Check(res))) {
2437 #else
2438 if (unlikely(!PyLong_CheckExact(res))) {
2439 #endif
2440 return __Pyx_PyNumber_IntOrLongWrongResultType(res, name);
2441 }
2442 }
2443 else if (!PyErr_Occurred()) {
2444 PyErr_SetString(PyExc_TypeError,
2445 "an integer is required");
2446 }
2447 return res;
2448 }
2449 static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
2450 Py_ssize_t ival;
2451 PyObject *x;
2452 #if PY_MAJOR_VERSION < 3
2453 if (likely(PyInt_CheckExact(b))) {
2454 if (sizeof(Py_ssize_t) >= sizeof(long))
2455 return PyInt_AS_LONG(b);
2456 else
2457 return PyInt_AsSsize_t(b);
2458 }
2459 #endif
2460 if (likely(PyLong_CheckExact(b))) {
2461 #if CYTHON_USE_PYLONG_INTERNALS
2462 const digit* digits = ((PyLongObject*)b)->ob_digit;
2463 const Py_ssize_t size = Py_SIZE(b);
2464 if (likely(__Pyx_sst_abs(size) <= 1)) {
2465 ival = likely(size) ? digits[0] : 0;
2466 if (size == -1) ival = -ival;
2467 return ival;
2468 } else {
2469 switch (size) {
2470 case 2:
2471 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
2472 return (Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
2473 }
2474 break;
2475 case -2:
2476 if (8 * sizeof(Py_ssize_t) > 2 * PyLong_SHIFT) {
2477 return -(Py_ssize_t) (((((size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
2478 }
2479 break;
2480 case 3:
2481 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
2482 return (Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
2483 }
2484 break;
2485 case -3:
2486 if (8 * sizeof(Py_ssize_t) > 3 * PyLong_SHIFT) {
2487 return -(Py_ssize_t) (((((((size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
2488 }
2489 break;
2490 case 4:
2491 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
2492 return (Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
2493 }
2494 break;
2495 case -4:
2496 if (8 * sizeof(Py_ssize_t) > 4 * PyLong_SHIFT) {
2497 return -(Py_ssize_t) (((((((((size_t)digits[3]) << PyLong_SHIFT) | (size_t)digits[2]) << PyLong_SHIFT) | (size_t)digits[1]) << PyLong_SHIFT) | (size_t)digits[0]));
2498 }
2499 break;
2500 }
2501 }
2502 #endif
2503 return PyLong_AsSsize_t(b);
2504 }
2505 x = PyNumber_Index(b);
2506 if (!x) return -1;
2507 ival = PyInt_AsSsize_t(x);
2508 Py_DECREF(x);
2509 return ival;
2510 }
2511 static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
2512 return b ? __Pyx_NewRef(Py_True) : __Pyx_NewRef(Py_False);
2513 }
2514 static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
2515 return PyInt_FromSize_t(ival);
2516 }
2517
2518
2519 #endif /* Py_PYTHON_H */
2520