1/* Generated by Cython 0.21.2 */
2
3#define PY_SSIZE_T_CLEAN
4#ifndef CYTHON_USE_PYLONG_INTERNALS
5#ifdef PYLONG_BITS_IN_DIGIT
6#define CYTHON_USE_PYLONG_INTERNALS 0
7#else
8#include "pyconfig.h"
9#ifdef PYLONG_BITS_IN_DIGIT
10#define CYTHON_USE_PYLONG_INTERNALS 1
11#else
12#define CYTHON_USE_PYLONG_INTERNALS 0
13#endif
14#endif
15#endif
16#include "Python.h"
17#ifndef Py_PYTHON_H
18    #error Python headers needed to compile C extensions, please install development version of Python.
19#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
20    #error Cython requires Python 2.6+ or Python 3.2+.
21#else
22#define CYTHON_ABI "0_21_2"
23#include <stddef.h>
24#ifndef offsetof
25#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
26#endif
27#if !defined(WIN32) && !defined(MS_WINDOWS)
28  #ifndef __stdcall
29    #define __stdcall
30  #endif
31  #ifndef __cdecl
32    #define __cdecl
33  #endif
34  #ifndef __fastcall
35    #define __fastcall
36  #endif
37#endif
38#ifndef DL_IMPORT
39  #define DL_IMPORT(t) t
40#endif
41#ifndef DL_EXPORT
42  #define DL_EXPORT(t) t
43#endif
44#ifndef PY_LONG_LONG
45  #define PY_LONG_LONG LONG_LONG
46#endif
47#ifndef Py_HUGE_VAL
48  #define Py_HUGE_VAL HUGE_VAL
49#endif
50#ifdef PYPY_VERSION
51#define CYTHON_COMPILING_IN_PYPY 1
52#define CYTHON_COMPILING_IN_CPYTHON 0
53#else
54#define CYTHON_COMPILING_IN_PYPY 0
55#define CYTHON_COMPILING_IN_CPYTHON 1
56#endif
57#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600
58#define Py_OptimizeFlag 0
59#endif
60#define __PYX_BUILD_PY_SSIZE_T "n"
61#define CYTHON_FORMAT_SSIZE_T "z"
62#if PY_MAJOR_VERSION < 3
63  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
64  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
65          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
66  #define __Pyx_DefaultClassType PyClass_Type
67#else
68  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
69  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
70          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
71  #define __Pyx_DefaultClassType PyType_Type
72#endif
73#if PY_MAJOR_VERSION >= 3
74  #define Py_TPFLAGS_CHECKTYPES 0
75  #define Py_TPFLAGS_HAVE_INDEX 0
76  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
77#endif
78#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
79  #define Py_TPFLAGS_HAVE_FINALIZE 0
80#endif
81#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
82  #define CYTHON_PEP393_ENABLED 1
83  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
84                                              0 : _PyUnicode_Ready((PyObject *)(op)))
85  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
86  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
87  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
88  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
89  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
90#else
91  #define CYTHON_PEP393_ENABLED 0
92  #define __Pyx_PyUnicode_READY(op)       (0)
93  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
94  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
95  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
96  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
97  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
98#endif
99#if CYTHON_COMPILING_IN_PYPY
100  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
101  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
102  #define __Pyx_PyFrozenSet_Size(s)         PyObject_Size(s)
103#else
104  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
105  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
106      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
107  #define __Pyx_PyFrozenSet_Size(s)         PySet_Size(s)
108#endif
109#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
110#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
111#if PY_MAJOR_VERSION >= 3
112  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
113#else
114  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
115#endif
116#if PY_MAJOR_VERSION >= 3
117  #define PyBaseString_Type            PyUnicode_Type
118  #define PyStringObject               PyUnicodeObject
119  #define PyString_Type                PyUnicode_Type
120  #define PyString_Check               PyUnicode_Check
121  #define PyString_CheckExact          PyUnicode_CheckExact
122#endif
123#if PY_MAJOR_VERSION >= 3
124  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
125  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
126#else
127  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
128  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
129#endif
130#ifndef PySet_CheckExact
131  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
132#endif
133#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
134#if PY_MAJOR_VERSION >= 3
135  #define PyIntObject                  PyLongObject
136  #define PyInt_Type                   PyLong_Type
137  #define PyInt_Check(op)              PyLong_Check(op)
138  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
139  #define PyInt_FromString             PyLong_FromString
140  #define PyInt_FromUnicode            PyLong_FromUnicode
141  #define PyInt_FromLong               PyLong_FromLong
142  #define PyInt_FromSize_t             PyLong_FromSize_t
143  #define PyInt_FromSsize_t            PyLong_FromSsize_t
144  #define PyInt_AsLong                 PyLong_AsLong
145  #define PyInt_AS_LONG                PyLong_AS_LONG
146  #define PyInt_AsSsize_t              PyLong_AsSsize_t
147  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
148  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
149  #define PyNumber_Int                 PyNumber_Long
150#endif
151#if PY_MAJOR_VERSION >= 3
152  #define PyBoolObject                 PyLongObject
153#endif
154#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
155  #ifndef PyUnicode_InternFromString
156    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
157  #endif
158#endif
159#if PY_VERSION_HEX < 0x030200A4
160  typedef long Py_hash_t;
161  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
162  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
163#else
164  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
165  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
166#endif
167#if PY_MAJOR_VERSION >= 3
168  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
169#else
170  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
171#endif
172#ifndef CYTHON_INLINE
173  #if defined(__GNUC__)
174    #define CYTHON_INLINE __inline__
175  #elif defined(_MSC_VER)
176    #define CYTHON_INLINE __inline
177  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
178    #define CYTHON_INLINE inline
179  #else
180    #define CYTHON_INLINE
181  #endif
182#endif
183#ifndef CYTHON_RESTRICT
184  #if defined(__GNUC__)
185    #define CYTHON_RESTRICT __restrict__
186  #elif defined(_MSC_VER) && _MSC_VER >= 1400
187    #define CYTHON_RESTRICT __restrict
188  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
189    #define CYTHON_RESTRICT restrict
190  #else
191    #define CYTHON_RESTRICT
192  #endif
193#endif
194#ifdef NAN
195#define __PYX_NAN() ((float) NAN)
196#else
197static CYTHON_INLINE float __PYX_NAN() {
198  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
199   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
200   a quiet NaN. */
201  float value;
202  memset(&value, 0xFF, sizeof(value));
203  return value;
204}
205#endif
206#ifdef __cplusplus
207template<typename T>
208void __Pyx_call_destructor(T* x) {
209    x->~T();
210}
211#endif
212
213
214#if PY_MAJOR_VERSION >= 3
215  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
216  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
217#else
218  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
219  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
220#endif
221
222#ifndef __PYX_EXTERN_C
223  #ifdef __cplusplus
224    #define __PYX_EXTERN_C extern "C"
225  #else
226    #define __PYX_EXTERN_C extern
227  #endif
228#endif
229
230#if defined(WIN32) || defined(MS_WINDOWS)
231#define _USE_MATH_DEFINES
232#endif
233#include <math.h>
234#define __PYX_HAVE__zmq__backend__cython__utils
235#define __PYX_HAVE_API__zmq__backend__cython__utils
236#include "zmq_compat.h"
237#include "zmq.h"
238#include "zmq_utils.h"
239#ifdef _OPENMP
240#include <omp.h>
241#endif /* _OPENMP */
242
243#ifdef PYREX_WITHOUT_ASSERTIONS
244#define CYTHON_WITHOUT_ASSERTIONS
245#endif
246
247#ifndef CYTHON_UNUSED
248# if defined(__GNUC__)
249#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
250#     define CYTHON_UNUSED __attribute__ ((__unused__))
251#   else
252#     define CYTHON_UNUSED
253#   endif
254# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
255#   define CYTHON_UNUSED __attribute__ ((__unused__))
256# else
257#   define CYTHON_UNUSED
258# endif
259#endif
260typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
261                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
262
263#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
264#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
265#define __PYX_DEFAULT_STRING_ENCODING ""
266#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
267#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
268#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
269    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
270    (sizeof(type) > sizeof(Py_ssize_t) &&               \
271          likely(v < (type)PY_SSIZE_T_MAX ||            \
272                 v == (type)PY_SSIZE_T_MAX)  &&         \
273          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
274                                v == (type)PY_SSIZE_T_MIN)))  ||  \
275    (sizeof(type) == sizeof(Py_ssize_t) &&              \
276          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
277                               v == (type)PY_SSIZE_T_MAX)))  )
278static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
279static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
280#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
281#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
282#define __Pyx_PyBytes_FromString        PyBytes_FromString
283#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
284static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
285#if PY_MAJOR_VERSION < 3
286    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
287    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
288#else
289    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
290    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
291#endif
292#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
293#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
294#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((const char*)s)
295#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((const char*)s)
296#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((const char*)s)
297#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((const char*)s)
298#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s)
299#if PY_MAJOR_VERSION < 3
300static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
301{
302    const Py_UNICODE *u_end = u;
303    while (*u_end++) ;
304    return (size_t)(u_end - u - 1);
305}
306#else
307#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
308#endif
309#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
310#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
311#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
312#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
313#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
314static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
315static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
316static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
317static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
318#if CYTHON_COMPILING_IN_CPYTHON
319#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
320#else
321#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
322#endif
323#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
324#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
325static int __Pyx_sys_getdefaultencoding_not_ascii;
326static int __Pyx_init_sys_getdefaultencoding_params(void) {
327    PyObject* sys;
328    PyObject* default_encoding = NULL;
329    PyObject* ascii_chars_u = NULL;
330    PyObject* ascii_chars_b = NULL;
331    const char* default_encoding_c;
332    sys = PyImport_ImportModule("sys");
333    if (!sys) goto bad;
334    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
335    Py_DECREF(sys);
336    if (!default_encoding) goto bad;
337    default_encoding_c = PyBytes_AsString(default_encoding);
338    if (!default_encoding_c) goto bad;
339    if (strcmp(default_encoding_c, "ascii") == 0) {
340        __Pyx_sys_getdefaultencoding_not_ascii = 0;
341    } else {
342        char ascii_chars[128];
343        int c;
344        for (c = 0; c < 128; c++) {
345            ascii_chars[c] = c;
346        }
347        __Pyx_sys_getdefaultencoding_not_ascii = 1;
348        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
349        if (!ascii_chars_u) goto bad;
350        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
351        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
352            PyErr_Format(
353                PyExc_ValueError,
354                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
355                default_encoding_c);
356            goto bad;
357        }
358        Py_DECREF(ascii_chars_u);
359        Py_DECREF(ascii_chars_b);
360    }
361    Py_DECREF(default_encoding);
362    return 0;
363bad:
364    Py_XDECREF(default_encoding);
365    Py_XDECREF(ascii_chars_u);
366    Py_XDECREF(ascii_chars_b);
367    return -1;
368}
369#endif
370#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
371#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
372#else
373#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
374#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
375static char* __PYX_DEFAULT_STRING_ENCODING;
376static int __Pyx_init_sys_getdefaultencoding_params(void) {
377    PyObject* sys;
378    PyObject* default_encoding = NULL;
379    char* default_encoding_c;
380    sys = PyImport_ImportModule("sys");
381    if (!sys) goto bad;
382    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
383    Py_DECREF(sys);
384    if (!default_encoding) goto bad;
385    default_encoding_c = PyBytes_AsString(default_encoding);
386    if (!default_encoding_c) goto bad;
387    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
388    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
389    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
390    Py_DECREF(default_encoding);
391    return 0;
392bad:
393    Py_XDECREF(default_encoding);
394    return -1;
395}
396#endif
397#endif
398
399
400/* Test for GCC > 2.95 */
401#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
402  #define likely(x)   __builtin_expect(!!(x), 1)
403  #define unlikely(x) __builtin_expect(!!(x), 0)
404#else /* !__GNUC__ or GCC < 2.95 */
405  #define likely(x)   (x)
406  #define unlikely(x) (x)
407#endif /* __GNUC__ */
408
409static PyObject *__pyx_m;
410static PyObject *__pyx_d;
411static PyObject *__pyx_b;
412static PyObject *__pyx_empty_tuple;
413static PyObject *__pyx_empty_bytes;
414static int __pyx_lineno;
415static int __pyx_clineno = 0;
416static const char * __pyx_cfilenm= __FILE__;
417static const char *__pyx_filename;
418
419
420static const char *__pyx_f[] = {
421  "zmq/backend/cython/utils.pyx",
422};
423
424/*--- Type declarations ---*/
425struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch;
426
427/* "zmq/backend/cython/utils.pxd":27
428 *
429 *
430 * cdef class Stopwatch:             # <<<<<<<<<<<<<<
431 *     cdef void *watch # The C handle for the underlying zmq object
432 *
433 */
434struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch {
435  PyObject_HEAD
436  void *watch;
437};
438
439#ifndef CYTHON_REFNANNY
440  #define CYTHON_REFNANNY 0
441#endif
442#if CYTHON_REFNANNY
443  typedef struct {
444    void (*INCREF)(void*, PyObject*, int);
445    void (*DECREF)(void*, PyObject*, int);
446    void (*GOTREF)(void*, PyObject*, int);
447    void (*GIVEREF)(void*, PyObject*, int);
448    void* (*SetupContext)(const char*, int, const char*);
449    void (*FinishContext)(void**);
450  } __Pyx_RefNannyAPIStruct;
451  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
452  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
453  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
454#ifdef WITH_THREAD
455  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
456          if (acquire_gil) { \
457              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
458              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
459              PyGILState_Release(__pyx_gilstate_save); \
460          } else { \
461              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
462          }
463#else
464  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
465          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
466#endif
467  #define __Pyx_RefNannyFinishContext() \
468          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
469  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
470  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
471  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
472  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
473  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
474  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
475  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
476  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
477#else
478  #define __Pyx_RefNannyDeclarations
479  #define __Pyx_RefNannySetupContext(name, acquire_gil)
480  #define __Pyx_RefNannyFinishContext()
481  #define __Pyx_INCREF(r) Py_INCREF(r)
482  #define __Pyx_DECREF(r) Py_DECREF(r)
483  #define __Pyx_GOTREF(r)
484  #define __Pyx_GIVEREF(r)
485  #define __Pyx_XINCREF(r) Py_XINCREF(r)
486  #define __Pyx_XDECREF(r) Py_XDECREF(r)
487  #define __Pyx_XGOTREF(r)
488  #define __Pyx_XGIVEREF(r)
489#endif
490#define __Pyx_XDECREF_SET(r, v) do {                            \
491        PyObject *tmp = (PyObject *) r;                         \
492        r = v; __Pyx_XDECREF(tmp);                              \
493    } while (0)
494#define __Pyx_DECREF_SET(r, v) do {                             \
495        PyObject *tmp = (PyObject *) r;                         \
496        r = v; __Pyx_DECREF(tmp);                               \
497    } while (0)
498#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
499#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
500
501#if CYTHON_COMPILING_IN_CPYTHON
502static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
503    PyTypeObject* tp = Py_TYPE(obj);
504    if (likely(tp->tp_getattro))
505        return tp->tp_getattro(obj, attr_name);
506#if PY_MAJOR_VERSION < 3
507    if (likely(tp->tp_getattr))
508        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
509#endif
510    return PyObject_GetAttr(obj, attr_name);
511}
512#else
513#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
514#endif
515
516static PyObject *__Pyx_GetBuiltinName(PyObject *name);
517
518static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
519
520#if CYTHON_COMPILING_IN_CPYTHON
521static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
522#else
523#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
524#endif
525
526#if CYTHON_COMPILING_IN_CPYTHON
527static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
528#endif
529
530static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
531
532static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
533    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
534
535static CYTHON_INLINE int __Pyx_CheckKeywordStrings(PyObject *kwdict, const char* function_name, int kw_allowed);
536
537static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
538static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
539
540static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
541
542static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
543
544typedef struct {
545    int code_line;
546    PyCodeObject* code_object;
547} __Pyx_CodeObjectCacheEntry;
548struct __Pyx_CodeObjectCache {
549    int count;
550    int max_count;
551    __Pyx_CodeObjectCacheEntry* entries;
552};
553static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
554static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
555static PyCodeObject *__pyx_find_code_object(int code_line);
556static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
557
558static void __Pyx_AddTraceback(const char *funcname, int c_line,
559                               int py_line, const char *filename);
560
561static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
562
563static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
564
565static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
566
567static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value);
568
569#ifndef __PYX_FORCE_INIT_THREADS
570  #define __PYX_FORCE_INIT_THREADS 0
571#endif
572
573static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
574
575static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
576
577static int __Pyx_check_binary_version(void);
578
579static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
580
581
582/* Module declarations from 'zmq.backend.cython.libzmq' */
583
584/* Module declarations from 'zmq.backend.cython.utils' */
585static PyTypeObject *__pyx_ptype_3zmq_7backend_6cython_5utils_Stopwatch = 0;
586#define __Pyx_MODULE_NAME "zmq.backend.cython.utils"
587int __pyx_module_is_main_zmq__backend__cython__utils = 0;
588
589/* Implementation of 'zmq.backend.cython.utils' */
590static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_has(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_capability); /* proto */
591static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_2curve_keypair(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
592static int __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch___cinit__(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self); /* proto */
593static void __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_2__dealloc__(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self); /* proto */
594static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_4start(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self); /* proto */
595static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_6stop(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self); /* proto */
596static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_8sleep(CYTHON_UNUSED struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self, int __pyx_v_seconds); /* proto */
597static PyObject *__pyx_tp_new_3zmq_7backend_6cython_5utils_Stopwatch(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
598static char __pyx_k_rc[] = "rc";
599static char __pyx_k_all[] = "__all__";
600static char __pyx_k_has[] = "has";
601static char __pyx_k_ccap[] = "ccap";
602static char __pyx_k_main[] = "__main__";
603static char __pyx_k_test[] = "__test__";
604static char __pyx_k_utf8[] = "utf8";
605static char __pyx_k_encode[] = "encode";
606static char __pyx_k_import[] = "__import__";
607static char __pyx_k_unicode[] = "unicode";
608static char __pyx_k_zmq_has[] = "zmq.has";
609static char __pyx_k_ZMQError[] = "ZMQError";
610static char __pyx_k_check_rc[] = "_check_rc";
611static char __pyx_k_0MQ_utils[] = "0MQ utils.";
612static char __pyx_k_Stopwatch[] = "Stopwatch";
613static char __pyx_k_zmq_error[] = "zmq.error";
614static char __pyx_k_capability[] = "capability";
615static char __pyx_k_public_key[] = "public_key";
616static char __pyx_k_secret_key[] = "secret_key";
617static char __pyx_k_check_version[] = "_check_version";
618static char __pyx_k_curve_keypair[] = "curve_keypair";
619static char __pyx_k_zmq_utils_strtypes[] = "zmq.utils.strtypes";
620static char __pyx_k_zmq_backend_cython_utils[] = "zmq.backend.cython.utils";
621static char __pyx_k_Stopwatch_is_already_running[] = "Stopwatch is already running.";
622static char __pyx_k_Must_start_the_Stopwatch_before[] = "Must start the Stopwatch before calling stop.";
623static char __pyx_k_private_tmp_pyzmq_release_zmq_b[] = "/private/tmp/pyzmq-release/zmq/backend/cython/utils.pyx";
624static PyObject *__pyx_kp_s_Must_start_the_Stopwatch_before;
625static PyObject *__pyx_n_s_Stopwatch;
626static PyObject *__pyx_kp_s_Stopwatch_is_already_running;
627static PyObject *__pyx_n_s_ZMQError;
628static PyObject *__pyx_n_s_all;
629static PyObject *__pyx_n_s_capability;
630static PyObject *__pyx_n_s_ccap;
631static PyObject *__pyx_n_s_check_rc;
632static PyObject *__pyx_n_s_check_version;
633static PyObject *__pyx_n_s_curve_keypair;
634static PyObject *__pyx_n_s_encode;
635static PyObject *__pyx_n_s_has;
636static PyObject *__pyx_n_s_import;
637static PyObject *__pyx_n_s_main;
638static PyObject *__pyx_kp_s_private_tmp_pyzmq_release_zmq_b;
639static PyObject *__pyx_n_s_public_key;
640static PyObject *__pyx_n_s_rc;
641static PyObject *__pyx_n_s_secret_key;
642static PyObject *__pyx_n_s_test;
643static PyObject *__pyx_n_s_unicode;
644static PyObject *__pyx_n_s_utf8;
645static PyObject *__pyx_n_s_zmq_backend_cython_utils;
646static PyObject *__pyx_n_s_zmq_error;
647static PyObject *__pyx_kp_s_zmq_has;
648static PyObject *__pyx_n_s_zmq_utils_strtypes;
649static PyObject *__pyx_int_0;
650static PyObject *__pyx_int_1;
651static PyObject *__pyx_int_4;
652static PyObject *__pyx_tuple_;
653static PyObject *__pyx_tuple__2;
654static PyObject *__pyx_tuple__3;
655static PyObject *__pyx_tuple__4;
656static PyObject *__pyx_tuple__5;
657static PyObject *__pyx_tuple__6;
658static PyObject *__pyx_tuple__7;
659static PyObject *__pyx_tuple__8;
660static PyObject *__pyx_tuple__10;
661static PyObject *__pyx_codeobj__9;
662static PyObject *__pyx_codeobj__11;
663
664/* "zmq/backend/cython/utils.pyx":29
665 * from zmq.utils.strtypes import unicode
666 *
667 * def has(capability):             # <<<<<<<<<<<<<<
668 *     """Check for zmq capability by name (e.g. 'ipc', 'curve')
669 *
670 */
671
672/* Python wrapper */
673static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_1has(PyObject *__pyx_self, PyObject *__pyx_v_capability); /*proto*/
674static char __pyx_doc_3zmq_7backend_6cython_5utils_has[] = "Check for zmq capability by name (e.g. 'ipc', 'curve')\n    \n    .. versionadded:: libzmq-4.1\n    .. versionadded:: 14.1\n    ";
675static PyMethodDef __pyx_mdef_3zmq_7backend_6cython_5utils_1has = {"has", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_5utils_1has, METH_O, __pyx_doc_3zmq_7backend_6cython_5utils_has};
676static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_1has(PyObject *__pyx_self, PyObject *__pyx_v_capability) {
677  PyObject *__pyx_r = 0;
678  __Pyx_RefNannyDeclarations
679  __Pyx_RefNannySetupContext("has (wrapper)", 0);
680  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5utils_has(__pyx_self, ((PyObject *)__pyx_v_capability));
681
682  /* function exit code */
683  __Pyx_RefNannyFinishContext();
684  return __pyx_r;
685}
686
687static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_has(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_capability) {
688  PyObject *__pyx_v_ccap = 0;
689  PyObject *__pyx_r = NULL;
690  __Pyx_RefNannyDeclarations
691  PyObject *__pyx_t_1 = NULL;
692  PyObject *__pyx_t_2 = NULL;
693  int __pyx_t_3;
694  int __pyx_t_4;
695  const char * __pyx_t_5;
696  int __pyx_lineno = 0;
697  const char *__pyx_filename = NULL;
698  int __pyx_clineno = 0;
699  __Pyx_RefNannySetupContext("has", 0);
700  __Pyx_INCREF(__pyx_v_capability);
701
702  /* "zmq/backend/cython/utils.pyx":35
703 *     .. versionadded:: 14.1
704 *     """
705 *     _check_version((4,1), 'zmq.has')             # <<<<<<<<<<<<<<
706 *     cdef bytes ccap
707 *     if isinstance(capability, unicode):
708 */
709  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_version); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
710  __Pyx_GOTREF(__pyx_t_1);
711  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
712  __Pyx_GOTREF(__pyx_t_2);
713  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
714  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
715
716  /* "zmq/backend/cython/utils.pyx":37
717 *     _check_version((4,1), 'zmq.has')
718 *     cdef bytes ccap
719 *     if isinstance(capability, unicode):             # <<<<<<<<<<<<<<
720 *         capability = capability.encode('utf8')
721 *     ccap = capability
722 */
723  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
724  __Pyx_GOTREF(__pyx_t_2);
725  __pyx_t_3 = PyObject_IsInstance(__pyx_v_capability, __pyx_t_2); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
726  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
727  __pyx_t_4 = (__pyx_t_3 != 0);
728  if (__pyx_t_4) {
729
730    /* "zmq/backend/cython/utils.pyx":38
731 *     cdef bytes ccap
732 *     if isinstance(capability, unicode):
733 *         capability = capability.encode('utf8')             # <<<<<<<<<<<<<<
734 *     ccap = capability
735 *     return bool(zmq_has(ccap))
736 */
737    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_capability, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
738    __Pyx_GOTREF(__pyx_t_2);
739    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
740    __Pyx_GOTREF(__pyx_t_1);
741    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
742    __Pyx_DECREF_SET(__pyx_v_capability, __pyx_t_1);
743    __pyx_t_1 = 0;
744    goto __pyx_L3;
745  }
746  __pyx_L3:;
747
748  /* "zmq/backend/cython/utils.pyx":39
749 *     if isinstance(capability, unicode):
750 *         capability = capability.encode('utf8')
751 *     ccap = capability             # <<<<<<<<<<<<<<
752 *     return bool(zmq_has(ccap))
753 *
754 */
755  if (!(likely(PyBytes_CheckExact(__pyx_v_capability))||((__pyx_v_capability) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_v_capability)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
756  __pyx_t_1 = __pyx_v_capability;
757  __Pyx_INCREF(__pyx_t_1);
758  __pyx_v_ccap = ((PyObject*)__pyx_t_1);
759  __pyx_t_1 = 0;
760
761  /* "zmq/backend/cython/utils.pyx":40
762 *         capability = capability.encode('utf8')
763 *     ccap = capability
764 *     return bool(zmq_has(ccap))             # <<<<<<<<<<<<<<
765 *
766 * def curve_keypair():
767 */
768  __Pyx_XDECREF(__pyx_r);
769  __pyx_t_5 = __Pyx_PyObject_AsString(__pyx_v_ccap); if (unlikely((__pyx_t_5 == (const char *)NULL) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
770  __pyx_t_1 = __Pyx_PyInt_From_int(zmq_has(__pyx_t_5)); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
771  __Pyx_GOTREF(__pyx_t_1);
772  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_t_1); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
773  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
774  __pyx_t_1 = __Pyx_PyBool_FromLong((!(!__pyx_t_4))); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
775  __Pyx_GOTREF(__pyx_t_1);
776  __pyx_r = __pyx_t_1;
777  __pyx_t_1 = 0;
778  goto __pyx_L0;
779
780  /* "zmq/backend/cython/utils.pyx":29
781 * from zmq.utils.strtypes import unicode
782 *
783 * def has(capability):             # <<<<<<<<<<<<<<
784 *     """Check for zmq capability by name (e.g. 'ipc', 'curve')
785 *
786 */
787
788  /* function exit code */
789  __pyx_L1_error:;
790  __Pyx_XDECREF(__pyx_t_1);
791  __Pyx_XDECREF(__pyx_t_2);
792  __Pyx_AddTraceback("zmq.backend.cython.utils.has", __pyx_clineno, __pyx_lineno, __pyx_filename);
793  __pyx_r = NULL;
794  __pyx_L0:;
795  __Pyx_XDECREF(__pyx_v_ccap);
796  __Pyx_XDECREF(__pyx_v_capability);
797  __Pyx_XGIVEREF(__pyx_r);
798  __Pyx_RefNannyFinishContext();
799  return __pyx_r;
800}
801
802/* "zmq/backend/cython/utils.pyx":42
803 *     return bool(zmq_has(ccap))
804 *
805 * def curve_keypair():             # <<<<<<<<<<<<<<
806 *     """generate a Z85 keypair for use with zmq.CURVE security
807 *
808 */
809
810/* Python wrapper */
811static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_3curve_keypair(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
812static char __pyx_doc_3zmq_7backend_6cython_5utils_2curve_keypair[] = "generate a Z85 keypair for use with zmq.CURVE security\n    \n    Requires libzmq (\342\211\245 4.0) to have been linked with libsodium.\n    \n    .. versionadded:: libzmq-4.0\n    .. versionadded:: 14.0\n    \n    Returns\n    -------\n    (public, secret) : two bytestrings\n        The public and private keypair as 40 byte z85-encoded bytestrings.\n    ";
813static PyMethodDef __pyx_mdef_3zmq_7backend_6cython_5utils_3curve_keypair = {"curve_keypair", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_5utils_3curve_keypair, METH_NOARGS, __pyx_doc_3zmq_7backend_6cython_5utils_2curve_keypair};
814static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_3curve_keypair(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
815  PyObject *__pyx_r = 0;
816  __Pyx_RefNannyDeclarations
817  __Pyx_RefNannySetupContext("curve_keypair (wrapper)", 0);
818  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5utils_2curve_keypair(__pyx_self);
819
820  /* function exit code */
821  __Pyx_RefNannyFinishContext();
822  return __pyx_r;
823}
824
825static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_2curve_keypair(CYTHON_UNUSED PyObject *__pyx_self) {
826  int __pyx_v_rc;
827  char __pyx_v_public_key[64];
828  char __pyx_v_secret_key[64];
829  PyObject *__pyx_r = NULL;
830  __Pyx_RefNannyDeclarations
831  PyObject *__pyx_t_1 = NULL;
832  PyObject *__pyx_t_2 = NULL;
833  PyObject *__pyx_t_3 = NULL;
834  PyObject *__pyx_t_4 = NULL;
835  PyObject *__pyx_t_5 = NULL;
836  int __pyx_lineno = 0;
837  const char *__pyx_filename = NULL;
838  int __pyx_clineno = 0;
839  __Pyx_RefNannySetupContext("curve_keypair", 0);
840
841  /* "zmq/backend/cython/utils.pyx":58
842 *     cdef char[64] public_key
843 *     cdef char[64] secret_key
844 *     _check_version((4,0), "curve_keypair")             # <<<<<<<<<<<<<<
845 *     rc = zmq_curve_keypair (public_key, secret_key)
846 *     _check_rc(rc)
847 */
848  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_version); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
849  __Pyx_GOTREF(__pyx_t_1);
850  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
851  __Pyx_GOTREF(__pyx_t_2);
852  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
853  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
854
855  /* "zmq/backend/cython/utils.pyx":59
856 *     cdef char[64] secret_key
857 *     _check_version((4,0), "curve_keypair")
858 *     rc = zmq_curve_keypair (public_key, secret_key)             # <<<<<<<<<<<<<<
859 *     _check_rc(rc)
860 *     return public_key, secret_key
861 */
862  __pyx_v_rc = zmq_curve_keypair(__pyx_v_public_key, __pyx_v_secret_key);
863
864  /* "zmq/backend/cython/utils.pyx":60
865 *     _check_version((4,0), "curve_keypair")
866 *     rc = zmq_curve_keypair (public_key, secret_key)
867 *     _check_rc(rc)             # <<<<<<<<<<<<<<
868 *     return public_key, secret_key
869 *
870 */
871  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_check_rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
872  __Pyx_GOTREF(__pyx_t_1);
873  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_rc); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
874  __Pyx_GOTREF(__pyx_t_3);
875  __pyx_t_4 = NULL;
876  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
877    __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_1);
878    if (likely(__pyx_t_4)) {
879      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
880      __Pyx_INCREF(__pyx_t_4);
881      __Pyx_INCREF(function);
882      __Pyx_DECREF_SET(__pyx_t_1, function);
883    }
884  }
885  if (!__pyx_t_4) {
886    __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_3); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
887    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
888    __Pyx_GOTREF(__pyx_t_2);
889  } else {
890    __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
891    __Pyx_GOTREF(__pyx_t_5);
892    PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
893    PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_t_3);
894    __Pyx_GIVEREF(__pyx_t_3);
895    __pyx_t_3 = 0;
896    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_5, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
897    __Pyx_GOTREF(__pyx_t_2);
898    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
899  }
900  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
901  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
902
903  /* "zmq/backend/cython/utils.pyx":61
904 *     rc = zmq_curve_keypair (public_key, secret_key)
905 *     _check_rc(rc)
906 *     return public_key, secret_key             # <<<<<<<<<<<<<<
907 *
908 *
909 */
910  __Pyx_XDECREF(__pyx_r);
911  __pyx_t_2 = __Pyx_PyBytes_FromString(__pyx_v_public_key); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
912  __Pyx_GOTREF(__pyx_t_2);
913  __pyx_t_1 = __Pyx_PyBytes_FromString(__pyx_v_secret_key); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
914  __Pyx_GOTREF(__pyx_t_1);
915  __pyx_t_5 = PyTuple_New(2); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 61; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
916  __Pyx_GOTREF(__pyx_t_5);
917  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_2);
918  __Pyx_GIVEREF(__pyx_t_2);
919  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
920  __Pyx_GIVEREF(__pyx_t_1);
921  __pyx_t_2 = 0;
922  __pyx_t_1 = 0;
923  __pyx_r = __pyx_t_5;
924  __pyx_t_5 = 0;
925  goto __pyx_L0;
926
927  /* "zmq/backend/cython/utils.pyx":42
928 *     return bool(zmq_has(ccap))
929 *
930 * def curve_keypair():             # <<<<<<<<<<<<<<
931 *     """generate a Z85 keypair for use with zmq.CURVE security
932 *
933 */
934
935  /* function exit code */
936  __pyx_L1_error:;
937  __Pyx_XDECREF(__pyx_t_1);
938  __Pyx_XDECREF(__pyx_t_2);
939  __Pyx_XDECREF(__pyx_t_3);
940  __Pyx_XDECREF(__pyx_t_4);
941  __Pyx_XDECREF(__pyx_t_5);
942  __Pyx_AddTraceback("zmq.backend.cython.utils.curve_keypair", __pyx_clineno, __pyx_lineno, __pyx_filename);
943  __pyx_r = NULL;
944  __pyx_L0:;
945  __Pyx_XGIVEREF(__pyx_r);
946  __Pyx_RefNannyFinishContext();
947  return __pyx_r;
948}
949
950/* "zmq/backend/cython/utils.pyx":72
951 *     """
952 *
953 *     def __cinit__(self):             # <<<<<<<<<<<<<<
954 *         self.watch = NULL
955 *
956 */
957
958/* Python wrapper */
959static int __pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
960static int __pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
961  int __pyx_r;
962  __Pyx_RefNannyDeclarations
963  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
964  if (unlikely(PyTuple_GET_SIZE(__pyx_args) > 0)) {
965    __Pyx_RaiseArgtupleInvalid("__cinit__", 1, 0, 0, PyTuple_GET_SIZE(__pyx_args)); return -1;}
966  if (unlikely(__pyx_kwds) && unlikely(PyDict_Size(__pyx_kwds) > 0) && unlikely(!__Pyx_CheckKeywordStrings(__pyx_kwds, "__cinit__", 0))) return -1;
967  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch___cinit__(((struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *)__pyx_v_self));
968
969  /* function exit code */
970  __Pyx_RefNannyFinishContext();
971  return __pyx_r;
972}
973
974static int __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch___cinit__(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self) {
975  int __pyx_r;
976  __Pyx_RefNannyDeclarations
977  __Pyx_RefNannySetupContext("__cinit__", 0);
978
979  /* "zmq/backend/cython/utils.pyx":73
980 *
981 *     def __cinit__(self):
982 *         self.watch = NULL             # <<<<<<<<<<<<<<
983 *
984 *     def __dealloc__(self):
985 */
986  __pyx_v_self->watch = NULL;
987
988  /* "zmq/backend/cython/utils.pyx":72
989 *     """
990 *
991 *     def __cinit__(self):             # <<<<<<<<<<<<<<
992 *         self.watch = NULL
993 *
994 */
995
996  /* function exit code */
997  __pyx_r = 0;
998  __Pyx_RefNannyFinishContext();
999  return __pyx_r;
1000}
1001
1002/* "zmq/backend/cython/utils.pyx":75
1003 *         self.watch = NULL
1004 *
1005 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1006 *         # copy of self.stop() we can't call object methods in dealloc as it
1007 *         # might already be partially deleted
1008 */
1009
1010/* Python wrapper */
1011static void __pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_3__dealloc__(PyObject *__pyx_v_self); /*proto*/
1012static void __pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_3__dealloc__(PyObject *__pyx_v_self) {
1013  __Pyx_RefNannyDeclarations
1014  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
1015  __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_2__dealloc__(((struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *)__pyx_v_self));
1016
1017  /* function exit code */
1018  __Pyx_RefNannyFinishContext();
1019}
1020
1021static void __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_2__dealloc__(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self) {
1022  __Pyx_RefNannyDeclarations
1023  int __pyx_t_1;
1024  __Pyx_RefNannySetupContext("__dealloc__", 0);
1025
1026  /* "zmq/backend/cython/utils.pyx":78
1027 *         # copy of self.stop() we can't call object methods in dealloc as it
1028 *         # might already be partially deleted
1029 *         if self.watch:             # <<<<<<<<<<<<<<
1030 *             zmq_stopwatch_stop(self.watch)
1031 *             self.watch = NULL
1032 */
1033  __pyx_t_1 = (__pyx_v_self->watch != 0);
1034  if (__pyx_t_1) {
1035
1036    /* "zmq/backend/cython/utils.pyx":79
1037 *         # might already be partially deleted
1038 *         if self.watch:
1039 *             zmq_stopwatch_stop(self.watch)             # <<<<<<<<<<<<<<
1040 *             self.watch = NULL
1041 *
1042 */
1043    zmq_stopwatch_stop(__pyx_v_self->watch);
1044
1045    /* "zmq/backend/cython/utils.pyx":80
1046 *         if self.watch:
1047 *             zmq_stopwatch_stop(self.watch)
1048 *             self.watch = NULL             # <<<<<<<<<<<<<<
1049 *
1050 *     def start(self):
1051 */
1052    __pyx_v_self->watch = NULL;
1053    goto __pyx_L3;
1054  }
1055  __pyx_L3:;
1056
1057  /* "zmq/backend/cython/utils.pyx":75
1058 *         self.watch = NULL
1059 *
1060 *     def __dealloc__(self):             # <<<<<<<<<<<<<<
1061 *         # copy of self.stop() we can't call object methods in dealloc as it
1062 *         # might already be partially deleted
1063 */
1064
1065  /* function exit code */
1066  __Pyx_RefNannyFinishContext();
1067}
1068
1069/* "zmq/backend/cython/utils.pyx":82
1070 *             self.watch = NULL
1071 *
1072 *     def start(self):             # <<<<<<<<<<<<<<
1073 *         """s.start()
1074 *
1075 */
1076
1077/* Python wrapper */
1078static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_5start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1079static char __pyx_doc_3zmq_7backend_6cython_5utils_9Stopwatch_4start[] = "s.start()\n\n        Start the stopwatch.\n        ";
1080static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_5start(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1081  PyObject *__pyx_r = 0;
1082  __Pyx_RefNannyDeclarations
1083  __Pyx_RefNannySetupContext("start (wrapper)", 0);
1084  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_4start(((struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *)__pyx_v_self));
1085
1086  /* function exit code */
1087  __Pyx_RefNannyFinishContext();
1088  return __pyx_r;
1089}
1090
1091static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_4start(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self) {
1092  PyObject *__pyx_r = NULL;
1093  __Pyx_RefNannyDeclarations
1094  int __pyx_t_1;
1095  PyObject *__pyx_t_2 = NULL;
1096  PyObject *__pyx_t_3 = NULL;
1097  int __pyx_lineno = 0;
1098  const char *__pyx_filename = NULL;
1099  int __pyx_clineno = 0;
1100  __Pyx_RefNannySetupContext("start", 0);
1101
1102  /* "zmq/backend/cython/utils.pyx":87
1103 *         Start the stopwatch.
1104 *         """
1105 *         if self.watch == NULL:             # <<<<<<<<<<<<<<
1106 *             self.watch = zmq_stopwatch_start()
1107 *         else:
1108 */
1109  __pyx_t_1 = ((__pyx_v_self->watch == NULL) != 0);
1110  if (__pyx_t_1) {
1111
1112    /* "zmq/backend/cython/utils.pyx":88
1113 *         """
1114 *         if self.watch == NULL:
1115 *             self.watch = zmq_stopwatch_start()             # <<<<<<<<<<<<<<
1116 *         else:
1117 *             raise ZMQError('Stopwatch is already running.')
1118 */
1119    __pyx_v_self->watch = zmq_stopwatch_start();
1120    goto __pyx_L3;
1121  }
1122  /*else*/ {
1123
1124    /* "zmq/backend/cython/utils.pyx":90
1125 *             self.watch = zmq_stopwatch_start()
1126 *         else:
1127 *             raise ZMQError('Stopwatch is already running.')             # <<<<<<<<<<<<<<
1128 *
1129 *     def stop(self):
1130 */
1131    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1132    __Pyx_GOTREF(__pyx_t_2);
1133    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1134    __Pyx_GOTREF(__pyx_t_3);
1135    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1136    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
1137    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1138    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1139  }
1140  __pyx_L3:;
1141
1142  /* "zmq/backend/cython/utils.pyx":82
1143 *             self.watch = NULL
1144 *
1145 *     def start(self):             # <<<<<<<<<<<<<<
1146 *         """s.start()
1147 *
1148 */
1149
1150  /* function exit code */
1151  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1152  goto __pyx_L0;
1153  __pyx_L1_error:;
1154  __Pyx_XDECREF(__pyx_t_2);
1155  __Pyx_XDECREF(__pyx_t_3);
1156  __Pyx_AddTraceback("zmq.backend.cython.utils.Stopwatch.start", __pyx_clineno, __pyx_lineno, __pyx_filename);
1157  __pyx_r = NULL;
1158  __pyx_L0:;
1159  __Pyx_XGIVEREF(__pyx_r);
1160  __Pyx_RefNannyFinishContext();
1161  return __pyx_r;
1162}
1163
1164/* "zmq/backend/cython/utils.pyx":92
1165 *             raise ZMQError('Stopwatch is already running.')
1166 *
1167 *     def stop(self):             # <<<<<<<<<<<<<<
1168 *         """s.stop()
1169 *
1170 */
1171
1172/* Python wrapper */
1173static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_7stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
1174static char __pyx_doc_3zmq_7backend_6cython_5utils_9Stopwatch_6stop[] = "s.stop()\n\n        Stop the stopwatch.\n        \n        Returns\n        -------\n        t : unsigned long int\n            the number of microseconds since ``start()`` was called.\n        ";
1175static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_7stop(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
1176  PyObject *__pyx_r = 0;
1177  __Pyx_RefNannyDeclarations
1178  __Pyx_RefNannySetupContext("stop (wrapper)", 0);
1179  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_6stop(((struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *)__pyx_v_self));
1180
1181  /* function exit code */
1182  __Pyx_RefNannyFinishContext();
1183  return __pyx_r;
1184}
1185
1186static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_6stop(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self) {
1187  unsigned long __pyx_v_time;
1188  PyObject *__pyx_r = NULL;
1189  __Pyx_RefNannyDeclarations
1190  int __pyx_t_1;
1191  PyObject *__pyx_t_2 = NULL;
1192  PyObject *__pyx_t_3 = NULL;
1193  int __pyx_lineno = 0;
1194  const char *__pyx_filename = NULL;
1195  int __pyx_clineno = 0;
1196  __Pyx_RefNannySetupContext("stop", 0);
1197
1198  /* "zmq/backend/cython/utils.pyx":103
1199 *         """
1200 *         cdef unsigned long time
1201 *         if self.watch == NULL:             # <<<<<<<<<<<<<<
1202 *             raise ZMQError('Must start the Stopwatch before calling stop.')
1203 *         else:
1204 */
1205  __pyx_t_1 = ((__pyx_v_self->watch == NULL) != 0);
1206  if (__pyx_t_1) {
1207
1208    /* "zmq/backend/cython/utils.pyx":104
1209 *         cdef unsigned long time
1210 *         if self.watch == NULL:
1211 *             raise ZMQError('Must start the Stopwatch before calling stop.')             # <<<<<<<<<<<<<<
1212 *         else:
1213 *             time = zmq_stopwatch_stop(self.watch)
1214 */
1215    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_ZMQError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1216    __Pyx_GOTREF(__pyx_t_2);
1217    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1218    __Pyx_GOTREF(__pyx_t_3);
1219    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1220    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
1221    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1222    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1223  }
1224  /*else*/ {
1225
1226    /* "zmq/backend/cython/utils.pyx":106
1227 *             raise ZMQError('Must start the Stopwatch before calling stop.')
1228 *         else:
1229 *             time = zmq_stopwatch_stop(self.watch)             # <<<<<<<<<<<<<<
1230 *             self.watch = NULL
1231 *             return time
1232 */
1233    __pyx_v_time = zmq_stopwatch_stop(__pyx_v_self->watch);
1234
1235    /* "zmq/backend/cython/utils.pyx":107
1236 *         else:
1237 *             time = zmq_stopwatch_stop(self.watch)
1238 *             self.watch = NULL             # <<<<<<<<<<<<<<
1239 *             return time
1240 *
1241 */
1242    __pyx_v_self->watch = NULL;
1243
1244    /* "zmq/backend/cython/utils.pyx":108
1245 *             time = zmq_stopwatch_stop(self.watch)
1246 *             self.watch = NULL
1247 *             return time             # <<<<<<<<<<<<<<
1248 *
1249 *     def sleep(self, int seconds):
1250 */
1251    __Pyx_XDECREF(__pyx_r);
1252    __pyx_t_3 = __Pyx_PyInt_From_unsigned_long(__pyx_v_time); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 108; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1253    __Pyx_GOTREF(__pyx_t_3);
1254    __pyx_r = __pyx_t_3;
1255    __pyx_t_3 = 0;
1256    goto __pyx_L0;
1257  }
1258
1259  /* "zmq/backend/cython/utils.pyx":92
1260 *             raise ZMQError('Stopwatch is already running.')
1261 *
1262 *     def stop(self):             # <<<<<<<<<<<<<<
1263 *         """s.stop()
1264 *
1265 */
1266
1267  /* function exit code */
1268  __pyx_L1_error:;
1269  __Pyx_XDECREF(__pyx_t_2);
1270  __Pyx_XDECREF(__pyx_t_3);
1271  __Pyx_AddTraceback("zmq.backend.cython.utils.Stopwatch.stop", __pyx_clineno, __pyx_lineno, __pyx_filename);
1272  __pyx_r = NULL;
1273  __pyx_L0:;
1274  __Pyx_XGIVEREF(__pyx_r);
1275  __Pyx_RefNannyFinishContext();
1276  return __pyx_r;
1277}
1278
1279/* "zmq/backend/cython/utils.pyx":110
1280 *             return time
1281 *
1282 *     def sleep(self, int seconds):             # <<<<<<<<<<<<<<
1283 *         """s.sleep(seconds)
1284 *
1285 */
1286
1287/* Python wrapper */
1288static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_9sleep(PyObject *__pyx_v_self, PyObject *__pyx_arg_seconds); /*proto*/
1289static char __pyx_doc_3zmq_7backend_6cython_5utils_9Stopwatch_8sleep[] = "s.sleep(seconds)\n\n        Sleep for an integer number of seconds.\n        ";
1290static PyObject *__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_9sleep(PyObject *__pyx_v_self, PyObject *__pyx_arg_seconds) {
1291  int __pyx_v_seconds;
1292  int __pyx_lineno = 0;
1293  const char *__pyx_filename = NULL;
1294  int __pyx_clineno = 0;
1295  PyObject *__pyx_r = 0;
1296  __Pyx_RefNannyDeclarations
1297  __Pyx_RefNannySetupContext("sleep (wrapper)", 0);
1298  assert(__pyx_arg_seconds); {
1299    __pyx_v_seconds = __Pyx_PyInt_As_int(__pyx_arg_seconds); if (unlikely((__pyx_v_seconds == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 110; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1300  }
1301  goto __pyx_L4_argument_unpacking_done;
1302  __pyx_L3_error:;
1303  __Pyx_AddTraceback("zmq.backend.cython.utils.Stopwatch.sleep", __pyx_clineno, __pyx_lineno, __pyx_filename);
1304  __Pyx_RefNannyFinishContext();
1305  return NULL;
1306  __pyx_L4_argument_unpacking_done:;
1307  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_8sleep(((struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *)__pyx_v_self), ((int)__pyx_v_seconds));
1308
1309  /* function exit code */
1310  __Pyx_RefNannyFinishContext();
1311  return __pyx_r;
1312}
1313
1314static PyObject *__pyx_pf_3zmq_7backend_6cython_5utils_9Stopwatch_8sleep(CYTHON_UNUSED struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch *__pyx_v_self, int __pyx_v_seconds) {
1315  PyObject *__pyx_r = NULL;
1316  __Pyx_RefNannyDeclarations
1317  __Pyx_RefNannySetupContext("sleep", 0);
1318
1319  /* "zmq/backend/cython/utils.pyx":115
1320 *         Sleep for an integer number of seconds.
1321 *         """
1322 *         with nogil:             # <<<<<<<<<<<<<<
1323 *             zmq_sleep(seconds)
1324 *
1325 */
1326  {
1327      #ifdef WITH_THREAD
1328      PyThreadState *_save;
1329      Py_UNBLOCK_THREADS
1330      #endif
1331      /*try:*/ {
1332
1333        /* "zmq/backend/cython/utils.pyx":116
1334 *         """
1335 *         with nogil:
1336 *             zmq_sleep(seconds)             # <<<<<<<<<<<<<<
1337 *
1338 *
1339 */
1340        zmq_sleep(__pyx_v_seconds);
1341      }
1342
1343      /* "zmq/backend/cython/utils.pyx":115
1344 *         Sleep for an integer number of seconds.
1345 *         """
1346 *         with nogil:             # <<<<<<<<<<<<<<
1347 *             zmq_sleep(seconds)
1348 *
1349 */
1350      /*finally:*/ {
1351        /*normal exit:*/{
1352          #ifdef WITH_THREAD
1353          Py_BLOCK_THREADS
1354          #endif
1355          goto __pyx_L5;
1356        }
1357        __pyx_L5:;
1358      }
1359  }
1360
1361  /* "zmq/backend/cython/utils.pyx":110
1362 *             return time
1363 *
1364 *     def sleep(self, int seconds):             # <<<<<<<<<<<<<<
1365 *         """s.sleep(seconds)
1366 *
1367 */
1368
1369  /* function exit code */
1370  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
1371  __Pyx_XGIVEREF(__pyx_r);
1372  __Pyx_RefNannyFinishContext();
1373  return __pyx_r;
1374}
1375
1376static PyObject *__pyx_tp_new_3zmq_7backend_6cython_5utils_Stopwatch(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
1377  PyObject *o;
1378  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
1379    o = (*t->tp_alloc)(t, 0);
1380  } else {
1381    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
1382  }
1383  if (unlikely(!o)) return 0;
1384  if (unlikely(__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_1__cinit__(o, __pyx_empty_tuple, NULL) < 0)) {
1385    Py_DECREF(o); o = 0;
1386  }
1387  return o;
1388}
1389
1390static void __pyx_tp_dealloc_3zmq_7backend_6cython_5utils_Stopwatch(PyObject *o) {
1391  #if PY_VERSION_HEX >= 0x030400a1
1392  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
1393    if (PyObject_CallFinalizerFromDealloc(o)) return;
1394  }
1395  #endif
1396  {
1397    PyObject *etype, *eval, *etb;
1398    PyErr_Fetch(&etype, &eval, &etb);
1399    ++Py_REFCNT(o);
1400    __pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_3__dealloc__(o);
1401    --Py_REFCNT(o);
1402    PyErr_Restore(etype, eval, etb);
1403  }
1404  (*Py_TYPE(o)->tp_free)(o);
1405}
1406
1407static PyMethodDef __pyx_methods_3zmq_7backend_6cython_5utils_Stopwatch[] = {
1408  {"start", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_5start, METH_NOARGS, __pyx_doc_3zmq_7backend_6cython_5utils_9Stopwatch_4start},
1409  {"stop", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_7stop, METH_NOARGS, __pyx_doc_3zmq_7backend_6cython_5utils_9Stopwatch_6stop},
1410  {"sleep", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_5utils_9Stopwatch_9sleep, METH_O, __pyx_doc_3zmq_7backend_6cython_5utils_9Stopwatch_8sleep},
1411  {0, 0, 0, 0}
1412};
1413
1414static PyTypeObject __pyx_type_3zmq_7backend_6cython_5utils_Stopwatch = {
1415  PyVarObject_HEAD_INIT(0, 0)
1416  "zmq.backend.cython.utils.Stopwatch", /*tp_name*/
1417  sizeof(struct __pyx_obj_3zmq_7backend_6cython_5utils_Stopwatch), /*tp_basicsize*/
1418  0, /*tp_itemsize*/
1419  __pyx_tp_dealloc_3zmq_7backend_6cython_5utils_Stopwatch, /*tp_dealloc*/
1420  0, /*tp_print*/
1421  0, /*tp_getattr*/
1422  0, /*tp_setattr*/
1423  #if PY_MAJOR_VERSION < 3
1424  0, /*tp_compare*/
1425  #else
1426  0, /*reserved*/
1427  #endif
1428  0, /*tp_repr*/
1429  0, /*tp_as_number*/
1430  0, /*tp_as_sequence*/
1431  0, /*tp_as_mapping*/
1432  0, /*tp_hash*/
1433  0, /*tp_call*/
1434  0, /*tp_str*/
1435  0, /*tp_getattro*/
1436  0, /*tp_setattro*/
1437  0, /*tp_as_buffer*/
1438  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
1439  "Stopwatch()\n\n    A simple stopwatch based on zmq_stopwatch_start/stop.\n\n    This class should be used for benchmarking and timing 0MQ code.\n    ", /*tp_doc*/
1440  0, /*tp_traverse*/
1441  0, /*tp_clear*/
1442  0, /*tp_richcompare*/
1443  0, /*tp_weaklistoffset*/
1444  0, /*tp_iter*/
1445  0, /*tp_iternext*/
1446  __pyx_methods_3zmq_7backend_6cython_5utils_Stopwatch, /*tp_methods*/
1447  0, /*tp_members*/
1448  0, /*tp_getset*/
1449  0, /*tp_base*/
1450  0, /*tp_dict*/
1451  0, /*tp_descr_get*/
1452  0, /*tp_descr_set*/
1453  0, /*tp_dictoffset*/
1454  0, /*tp_init*/
1455  0, /*tp_alloc*/
1456  __pyx_tp_new_3zmq_7backend_6cython_5utils_Stopwatch, /*tp_new*/
1457  0, /*tp_free*/
1458  0, /*tp_is_gc*/
1459  0, /*tp_bases*/
1460  0, /*tp_mro*/
1461  0, /*tp_cache*/
1462  0, /*tp_subclasses*/
1463  0, /*tp_weaklist*/
1464  0, /*tp_del*/
1465  0, /*tp_version_tag*/
1466  #if PY_VERSION_HEX >= 0x030400a1
1467  0, /*tp_finalize*/
1468  #endif
1469};
1470
1471static PyMethodDef __pyx_methods[] = {
1472  {0, 0, 0, 0}
1473};
1474
1475#if PY_MAJOR_VERSION >= 3
1476static struct PyModuleDef __pyx_moduledef = {
1477  #if PY_VERSION_HEX < 0x03020000
1478    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
1479  #else
1480    PyModuleDef_HEAD_INIT,
1481  #endif
1482    "utils",
1483    __pyx_k_0MQ_utils, /* m_doc */
1484    -1, /* m_size */
1485    __pyx_methods /* m_methods */,
1486    NULL, /* m_reload */
1487    NULL, /* m_traverse */
1488    NULL, /* m_clear */
1489    NULL /* m_free */
1490};
1491#endif
1492
1493static __Pyx_StringTabEntry __pyx_string_tab[] = {
1494  {&__pyx_kp_s_Must_start_the_Stopwatch_before, __pyx_k_Must_start_the_Stopwatch_before, sizeof(__pyx_k_Must_start_the_Stopwatch_before), 0, 0, 1, 0},
1495  {&__pyx_n_s_Stopwatch, __pyx_k_Stopwatch, sizeof(__pyx_k_Stopwatch), 0, 0, 1, 1},
1496  {&__pyx_kp_s_Stopwatch_is_already_running, __pyx_k_Stopwatch_is_already_running, sizeof(__pyx_k_Stopwatch_is_already_running), 0, 0, 1, 0},
1497  {&__pyx_n_s_ZMQError, __pyx_k_ZMQError, sizeof(__pyx_k_ZMQError), 0, 0, 1, 1},
1498  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
1499  {&__pyx_n_s_capability, __pyx_k_capability, sizeof(__pyx_k_capability), 0, 0, 1, 1},
1500  {&__pyx_n_s_ccap, __pyx_k_ccap, sizeof(__pyx_k_ccap), 0, 0, 1, 1},
1501  {&__pyx_n_s_check_rc, __pyx_k_check_rc, sizeof(__pyx_k_check_rc), 0, 0, 1, 1},
1502  {&__pyx_n_s_check_version, __pyx_k_check_version, sizeof(__pyx_k_check_version), 0, 0, 1, 1},
1503  {&__pyx_n_s_curve_keypair, __pyx_k_curve_keypair, sizeof(__pyx_k_curve_keypair), 0, 0, 1, 1},
1504  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
1505  {&__pyx_n_s_has, __pyx_k_has, sizeof(__pyx_k_has), 0, 0, 1, 1},
1506  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
1507  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
1508  {&__pyx_kp_s_private_tmp_pyzmq_release_zmq_b, __pyx_k_private_tmp_pyzmq_release_zmq_b, sizeof(__pyx_k_private_tmp_pyzmq_release_zmq_b), 0, 0, 1, 0},
1509  {&__pyx_n_s_public_key, __pyx_k_public_key, sizeof(__pyx_k_public_key), 0, 0, 1, 1},
1510  {&__pyx_n_s_rc, __pyx_k_rc, sizeof(__pyx_k_rc), 0, 0, 1, 1},
1511  {&__pyx_n_s_secret_key, __pyx_k_secret_key, sizeof(__pyx_k_secret_key), 0, 0, 1, 1},
1512  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
1513  {&__pyx_n_s_unicode, __pyx_k_unicode, sizeof(__pyx_k_unicode), 0, 0, 1, 1},
1514  {&__pyx_n_s_utf8, __pyx_k_utf8, sizeof(__pyx_k_utf8), 0, 0, 1, 1},
1515  {&__pyx_n_s_zmq_backend_cython_utils, __pyx_k_zmq_backend_cython_utils, sizeof(__pyx_k_zmq_backend_cython_utils), 0, 0, 1, 1},
1516  {&__pyx_n_s_zmq_error, __pyx_k_zmq_error, sizeof(__pyx_k_zmq_error), 0, 0, 1, 1},
1517  {&__pyx_kp_s_zmq_has, __pyx_k_zmq_has, sizeof(__pyx_k_zmq_has), 0, 0, 1, 0},
1518  {&__pyx_n_s_zmq_utils_strtypes, __pyx_k_zmq_utils_strtypes, sizeof(__pyx_k_zmq_utils_strtypes), 0, 0, 1, 1},
1519  {0, 0, 0, 0, 0, 0, 0}
1520};
1521static int __Pyx_InitCachedBuiltins(void) {
1522  return 0;
1523}
1524
1525static int __Pyx_InitCachedConstants(void) {
1526  __Pyx_RefNannyDeclarations
1527  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
1528
1529  /* "zmq/backend/cython/utils.pyx":35
1530 *     .. versionadded:: 14.1
1531 *     """
1532 *     _check_version((4,1), 'zmq.has')             # <<<<<<<<<<<<<<
1533 *     cdef bytes ccap
1534 *     if isinstance(capability, unicode):
1535 */
1536  __pyx_tuple_ = PyTuple_Pack(2, __pyx_int_4, __pyx_int_1); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1537  __Pyx_GOTREF(__pyx_tuple_);
1538  __Pyx_GIVEREF(__pyx_tuple_);
1539  __pyx_tuple__2 = PyTuple_Pack(2, __pyx_tuple_, __pyx_kp_s_zmq_has); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1540  __Pyx_GOTREF(__pyx_tuple__2);
1541  __Pyx_GIVEREF(__pyx_tuple__2);
1542
1543  /* "zmq/backend/cython/utils.pyx":38
1544 *     cdef bytes ccap
1545 *     if isinstance(capability, unicode):
1546 *         capability = capability.encode('utf8')             # <<<<<<<<<<<<<<
1547 *     ccap = capability
1548 *     return bool(zmq_has(ccap))
1549 */
1550  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_n_s_utf8); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 38; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1551  __Pyx_GOTREF(__pyx_tuple__3);
1552  __Pyx_GIVEREF(__pyx_tuple__3);
1553
1554  /* "zmq/backend/cython/utils.pyx":58
1555 *     cdef char[64] public_key
1556 *     cdef char[64] secret_key
1557 *     _check_version((4,0), "curve_keypair")             # <<<<<<<<<<<<<<
1558 *     rc = zmq_curve_keypair (public_key, secret_key)
1559 *     _check_rc(rc)
1560 */
1561  __pyx_tuple__4 = PyTuple_Pack(2, __pyx_int_4, __pyx_int_0); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1562  __Pyx_GOTREF(__pyx_tuple__4);
1563  __Pyx_GIVEREF(__pyx_tuple__4);
1564  __pyx_tuple__5 = PyTuple_Pack(2, __pyx_tuple__4, __pyx_n_s_curve_keypair); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1565  __Pyx_GOTREF(__pyx_tuple__5);
1566  __Pyx_GIVEREF(__pyx_tuple__5);
1567
1568  /* "zmq/backend/cython/utils.pyx":90
1569 *             self.watch = zmq_stopwatch_start()
1570 *         else:
1571 *             raise ZMQError('Stopwatch is already running.')             # <<<<<<<<<<<<<<
1572 *
1573 *     def stop(self):
1574 */
1575  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_kp_s_Stopwatch_is_already_running); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 90; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1576  __Pyx_GOTREF(__pyx_tuple__6);
1577  __Pyx_GIVEREF(__pyx_tuple__6);
1578
1579  /* "zmq/backend/cython/utils.pyx":104
1580 *         cdef unsigned long time
1581 *         if self.watch == NULL:
1582 *             raise ZMQError('Must start the Stopwatch before calling stop.')             # <<<<<<<<<<<<<<
1583 *         else:
1584 *             time = zmq_stopwatch_stop(self.watch)
1585 */
1586  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_kp_s_Must_start_the_Stopwatch_before); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1587  __Pyx_GOTREF(__pyx_tuple__7);
1588  __Pyx_GIVEREF(__pyx_tuple__7);
1589
1590  /* "zmq/backend/cython/utils.pyx":29
1591 * from zmq.utils.strtypes import unicode
1592 *
1593 * def has(capability):             # <<<<<<<<<<<<<<
1594 *     """Check for zmq capability by name (e.g. 'ipc', 'curve')
1595 *
1596 */
1597  __pyx_tuple__8 = PyTuple_Pack(2, __pyx_n_s_capability, __pyx_n_s_ccap); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1598  __Pyx_GOTREF(__pyx_tuple__8);
1599  __Pyx_GIVEREF(__pyx_tuple__8);
1600  __pyx_codeobj__9 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__8, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_pyzmq_release_zmq_b, __pyx_n_s_has, 29, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1601
1602  /* "zmq/backend/cython/utils.pyx":42
1603 *     return bool(zmq_has(ccap))
1604 *
1605 * def curve_keypair():             # <<<<<<<<<<<<<<
1606 *     """generate a Z85 keypair for use with zmq.CURVE security
1607 *
1608 */
1609  __pyx_tuple__10 = PyTuple_Pack(3, __pyx_n_s_rc, __pyx_n_s_public_key, __pyx_n_s_secret_key); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1610  __Pyx_GOTREF(__pyx_tuple__10);
1611  __Pyx_GIVEREF(__pyx_tuple__10);
1612  __pyx_codeobj__11 = (PyObject*)__Pyx_PyCode_New(0, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__10, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_pyzmq_release_zmq_b, __pyx_n_s_curve_keypair, 42, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1613  __Pyx_RefNannyFinishContext();
1614  return 0;
1615  __pyx_L1_error:;
1616  __Pyx_RefNannyFinishContext();
1617  return -1;
1618}
1619
1620static int __Pyx_InitGlobals(void) {
1621  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1622  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1623  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1624  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1625  return 0;
1626  __pyx_L1_error:;
1627  return -1;
1628}
1629
1630#if PY_MAJOR_VERSION < 3
1631PyMODINIT_FUNC initutils(void); /*proto*/
1632PyMODINIT_FUNC initutils(void)
1633#else
1634PyMODINIT_FUNC PyInit_utils(void); /*proto*/
1635PyMODINIT_FUNC PyInit_utils(void)
1636#endif
1637{
1638  PyObject *__pyx_t_1 = NULL;
1639  PyObject *__pyx_t_2 = NULL;
1640  int __pyx_lineno = 0;
1641  const char *__pyx_filename = NULL;
1642  int __pyx_clineno = 0;
1643  __Pyx_RefNannyDeclarations
1644  #if CYTHON_REFNANNY
1645  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
1646  if (!__Pyx_RefNanny) {
1647      PyErr_Clear();
1648      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
1649      if (!__Pyx_RefNanny)
1650          Py_FatalError("failed to import 'refnanny' module");
1651  }
1652  #endif
1653  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit_utils(void)", 0);
1654  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1655  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1656  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1657  #ifdef __Pyx_CyFunction_USED
1658  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1659  #endif
1660  #ifdef __Pyx_FusedFunction_USED
1661  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1662  #endif
1663  #ifdef __Pyx_Generator_USED
1664  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1665  #endif
1666  /*--- Library function declarations ---*/
1667  /*--- Threads initialization code ---*/
1668  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
1669  #ifdef WITH_THREAD /* Python build with threading support? */
1670  PyEval_InitThreads();
1671  #endif
1672  #endif
1673  /*--- Module creation code ---*/
1674  #if PY_MAJOR_VERSION < 3
1675  __pyx_m = Py_InitModule4("utils", __pyx_methods, __pyx_k_0MQ_utils, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
1676  #else
1677  __pyx_m = PyModule_Create(&__pyx_moduledef);
1678  #endif
1679  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1680  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1681  Py_INCREF(__pyx_d);
1682  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1683  #if CYTHON_COMPILING_IN_PYPY
1684  Py_INCREF(__pyx_b);
1685  #endif
1686  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1687  /*--- Initialize various global constants etc. ---*/
1688  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1689  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
1690  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1691  #endif
1692  if (__pyx_module_is_main_zmq__backend__cython__utils) {
1693    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1694  }
1695  #if PY_MAJOR_VERSION >= 3
1696  {
1697    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1698    if (!PyDict_GetItemString(modules, "zmq.backend.cython.utils")) {
1699      if (unlikely(PyDict_SetItemString(modules, "zmq.backend.cython.utils", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1700    }
1701  }
1702  #endif
1703  /*--- Builtin init code ---*/
1704  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1705  /*--- Constants init code ---*/
1706  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1707  /*--- Global init code ---*/
1708  /*--- Variable export code ---*/
1709  /*--- Function export code ---*/
1710  /*--- Type init code ---*/
1711  if (PyType_Ready(&__pyx_type_3zmq_7backend_6cython_5utils_Stopwatch) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1712  __pyx_type_3zmq_7backend_6cython_5utils_Stopwatch.tp_print = 0;
1713  if (PyObject_SetAttrString(__pyx_m, "Stopwatch", (PyObject *)&__pyx_type_3zmq_7backend_6cython_5utils_Stopwatch) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1714  __pyx_ptype_3zmq_7backend_6cython_5utils_Stopwatch = &__pyx_type_3zmq_7backend_6cython_5utils_Stopwatch;
1715  /*--- Type import code ---*/
1716  /*--- Variable import code ---*/
1717  /*--- Function import code ---*/
1718  /*--- Execution code ---*/
1719
1720  /* "zmq/backend/cython/utils.pyx":26
1721 *     zmq_has, const_char_ptr
1722 * )
1723 * from zmq.error import ZMQError, _check_rc, _check_version             # <<<<<<<<<<<<<<
1724 * from zmq.utils.strtypes import unicode
1725 *
1726 */
1727  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1728  __Pyx_GOTREF(__pyx_t_1);
1729  __Pyx_INCREF(__pyx_n_s_ZMQError);
1730  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_ZMQError);
1731  __Pyx_GIVEREF(__pyx_n_s_ZMQError);
1732  __Pyx_INCREF(__pyx_n_s_check_rc);
1733  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_check_rc);
1734  __Pyx_GIVEREF(__pyx_n_s_check_rc);
1735  __Pyx_INCREF(__pyx_n_s_check_version);
1736  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_check_version);
1737  __Pyx_GIVEREF(__pyx_n_s_check_version);
1738  __pyx_t_2 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_1, -1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1739  __Pyx_GOTREF(__pyx_t_2);
1740  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1741  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_ZMQError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1742  __Pyx_GOTREF(__pyx_t_1);
1743  if (PyDict_SetItem(__pyx_d, __pyx_n_s_ZMQError, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1744  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1745  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_check_rc); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1746  __Pyx_GOTREF(__pyx_t_1);
1747  if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_rc, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1748  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1749  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_check_version); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1750  __Pyx_GOTREF(__pyx_t_1);
1751  if (PyDict_SetItem(__pyx_d, __pyx_n_s_check_version, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1752  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1753  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1754
1755  /* "zmq/backend/cython/utils.pyx":27
1756 * )
1757 * from zmq.error import ZMQError, _check_rc, _check_version
1758 * from zmq.utils.strtypes import unicode             # <<<<<<<<<<<<<<
1759 *
1760 * def has(capability):
1761 */
1762  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1763  __Pyx_GOTREF(__pyx_t_2);
1764  __Pyx_INCREF(__pyx_n_s_unicode);
1765  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_unicode);
1766  __Pyx_GIVEREF(__pyx_n_s_unicode);
1767  __pyx_t_1 = __Pyx_Import(__pyx_n_s_zmq_utils_strtypes, __pyx_t_2, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1768  __Pyx_GOTREF(__pyx_t_1);
1769  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1770  __pyx_t_2 = __Pyx_ImportFrom(__pyx_t_1, __pyx_n_s_unicode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1771  __Pyx_GOTREF(__pyx_t_2);
1772  if (PyDict_SetItem(__pyx_d, __pyx_n_s_unicode, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 27; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1773  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
1774  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1775
1776  /* "zmq/backend/cython/utils.pyx":29
1777 * from zmq.utils.strtypes import unicode
1778 *
1779 * def has(capability):             # <<<<<<<<<<<<<<
1780 *     """Check for zmq capability by name (e.g. 'ipc', 'curve')
1781 *
1782 */
1783  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3zmq_7backend_6cython_5utils_1has, NULL, __pyx_n_s_zmq_backend_cython_utils); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1784  __Pyx_GOTREF(__pyx_t_1);
1785  if (PyDict_SetItem(__pyx_d, __pyx_n_s_has, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1786  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1787
1788  /* "zmq/backend/cython/utils.pyx":42
1789 *     return bool(zmq_has(ccap))
1790 *
1791 * def curve_keypair():             # <<<<<<<<<<<<<<
1792 *     """generate a Z85 keypair for use with zmq.CURVE security
1793 *
1794 */
1795  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_3zmq_7backend_6cython_5utils_3curve_keypair, NULL, __pyx_n_s_zmq_backend_cython_utils); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1796  __Pyx_GOTREF(__pyx_t_1);
1797  if (PyDict_SetItem(__pyx_d, __pyx_n_s_curve_keypair, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1798  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1799
1800  /* "zmq/backend/cython/utils.pyx":119
1801 *
1802 *
1803 * __all__ = ['has', 'curve_keypair', 'Stopwatch']             # <<<<<<<<<<<<<<
1804 */
1805  __pyx_t_1 = PyList_New(3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1806  __Pyx_GOTREF(__pyx_t_1);
1807  __Pyx_INCREF(__pyx_n_s_has);
1808  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_has);
1809  __Pyx_GIVEREF(__pyx_n_s_has);
1810  __Pyx_INCREF(__pyx_n_s_curve_keypair);
1811  PyList_SET_ITEM(__pyx_t_1, 1, __pyx_n_s_curve_keypair);
1812  __Pyx_GIVEREF(__pyx_n_s_curve_keypair);
1813  __Pyx_INCREF(__pyx_n_s_Stopwatch);
1814  PyList_SET_ITEM(__pyx_t_1, 2, __pyx_n_s_Stopwatch);
1815  __Pyx_GIVEREF(__pyx_n_s_Stopwatch);
1816  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1817  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1818
1819  /* "zmq/backend/cython/utils.pyx":1
1820 * """0MQ utils."""             # <<<<<<<<<<<<<<
1821 *
1822 * #
1823 */
1824  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1825  __Pyx_GOTREF(__pyx_t_1);
1826  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1827  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
1828
1829  /*--- Wrapped vars code ---*/
1830
1831  goto __pyx_L0;
1832  __pyx_L1_error:;
1833  __Pyx_XDECREF(__pyx_t_1);
1834  __Pyx_XDECREF(__pyx_t_2);
1835  if (__pyx_m) {
1836    if (__pyx_d) {
1837      __Pyx_AddTraceback("init zmq.backend.cython.utils", __pyx_clineno, __pyx_lineno, __pyx_filename);
1838    }
1839    Py_DECREF(__pyx_m); __pyx_m = 0;
1840  } else if (!PyErr_Occurred()) {
1841    PyErr_SetString(PyExc_ImportError, "init zmq.backend.cython.utils");
1842  }
1843  __pyx_L0:;
1844  __Pyx_RefNannyFinishContext();
1845  #if PY_MAJOR_VERSION < 3
1846  return;
1847  #else
1848  return __pyx_m;
1849  #endif
1850}
1851
1852/* Runtime support code */
1853#if CYTHON_REFNANNY
1854static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
1855    PyObject *m = NULL, *p = NULL;
1856    void *r = NULL;
1857    m = PyImport_ImportModule((char *)modname);
1858    if (!m) goto end;
1859    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
1860    if (!p) goto end;
1861    r = PyLong_AsVoidPtr(p);
1862end:
1863    Py_XDECREF(p);
1864    Py_XDECREF(m);
1865    return (__Pyx_RefNannyAPIStruct *)r;
1866}
1867#endif
1868
1869static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
1870    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
1871    if (unlikely(!result)) {
1872        PyErr_Format(PyExc_NameError,
1873#if PY_MAJOR_VERSION >= 3
1874            "name '%U' is not defined", name);
1875#else
1876            "name '%.200s' is not defined", PyString_AS_STRING(name));
1877#endif
1878    }
1879    return result;
1880}
1881
1882static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
1883    PyObject *result;
1884#if CYTHON_COMPILING_IN_CPYTHON
1885    result = PyDict_GetItem(__pyx_d, name);
1886    if (likely(result)) {
1887        Py_INCREF(result);
1888    } else {
1889#else
1890    result = PyObject_GetItem(__pyx_d, name);
1891    if (!result) {
1892        PyErr_Clear();
1893#endif
1894        result = __Pyx_GetBuiltinName(name);
1895    }
1896    return result;
1897}
1898
1899#if CYTHON_COMPILING_IN_CPYTHON
1900static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
1901    PyObject *result;
1902    ternaryfunc call = func->ob_type->tp_call;
1903    if (unlikely(!call))
1904        return PyObject_Call(func, arg, kw);
1905    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
1906        return NULL;
1907    result = (*call)(func, arg, kw);
1908    Py_LeaveRecursiveCall();
1909    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
1910        PyErr_SetString(
1911            PyExc_SystemError,
1912            "NULL result without error in PyObject_Call");
1913    }
1914    return result;
1915}
1916#endif
1917
1918#if CYTHON_COMPILING_IN_CPYTHON
1919static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
1920    PyObject *self, *result;
1921    PyCFunction cfunc;
1922    cfunc = PyCFunction_GET_FUNCTION(func);
1923    self = PyCFunction_GET_SELF(func);
1924    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
1925        return NULL;
1926    result = cfunc(self, arg);
1927    Py_LeaveRecursiveCall();
1928    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
1929        PyErr_SetString(
1930            PyExc_SystemError,
1931            "NULL result without error in PyObject_Call");
1932    }
1933    return result;
1934}
1935#endif
1936
1937#if CYTHON_COMPILING_IN_CPYTHON
1938static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
1939    PyObject *result;
1940    PyObject *args = PyTuple_New(1);
1941    if (unlikely(!args)) return NULL;
1942    Py_INCREF(arg);
1943    PyTuple_SET_ITEM(args, 0, arg);
1944    result = __Pyx_PyObject_Call(func, args, NULL);
1945    Py_DECREF(args);
1946    return result;
1947}
1948static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
1949#ifdef __Pyx_CyFunction_USED
1950    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
1951#else
1952    if (likely(PyCFunction_Check(func))) {
1953#endif
1954        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
1955            return __Pyx_PyObject_CallMethO(func, arg);
1956        }
1957    }
1958    return __Pyx__PyObject_CallOneArg(func, arg);
1959}
1960#else
1961static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
1962    PyObject* args = PyTuple_Pack(1, arg);
1963    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
1964}
1965#endif
1966
1967static void __Pyx_RaiseArgtupleInvalid(
1968    const char* func_name,
1969    int exact,
1970    Py_ssize_t num_min,
1971    Py_ssize_t num_max,
1972    Py_ssize_t num_found)
1973{
1974    Py_ssize_t num_expected;
1975    const char *more_or_less;
1976    if (num_found < num_min) {
1977        num_expected = num_min;
1978        more_or_less = "at least";
1979    } else {
1980        num_expected = num_max;
1981        more_or_less = "at most";
1982    }
1983    if (exact) {
1984        more_or_less = "exactly";
1985    }
1986    PyErr_Format(PyExc_TypeError,
1987                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
1988                 func_name, more_or_less, num_expected,
1989                 (num_expected == 1) ? "" : "s", num_found);
1990}
1991
1992static CYTHON_INLINE int __Pyx_CheckKeywordStrings(
1993    PyObject *kwdict,
1994    const char* function_name,
1995    int kw_allowed)
1996{
1997    PyObject* key = 0;
1998    Py_ssize_t pos = 0;
1999#if CYTHON_COMPILING_IN_PYPY
2000    if (!kw_allowed && PyDict_Next(kwdict, &pos, &key, 0))
2001        goto invalid_keyword;
2002    return 1;
2003#else
2004    while (PyDict_Next(kwdict, &pos, &key, 0)) {
2005        #if PY_MAJOR_VERSION < 3
2006        if (unlikely(!PyString_CheckExact(key)) && unlikely(!PyString_Check(key)))
2007        #endif
2008            if (unlikely(!PyUnicode_Check(key)))
2009                goto invalid_keyword_type;
2010    }
2011    if ((!kw_allowed) && unlikely(key))
2012        goto invalid_keyword;
2013    return 1;
2014invalid_keyword_type:
2015    PyErr_Format(PyExc_TypeError,
2016        "%.200s() keywords must be strings", function_name);
2017    return 0;
2018#endif
2019invalid_keyword:
2020    PyErr_Format(PyExc_TypeError,
2021    #if PY_MAJOR_VERSION < 3
2022        "%.200s() got an unexpected keyword argument '%.200s'",
2023        function_name, PyString_AsString(key));
2024    #else
2025        "%s() got an unexpected keyword argument '%U'",
2026        function_name, key);
2027    #endif
2028    return 0;
2029}
2030
2031static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
2032#if CYTHON_COMPILING_IN_CPYTHON
2033    PyObject *tmp_type, *tmp_value, *tmp_tb;
2034    PyThreadState *tstate = PyThreadState_GET();
2035    tmp_type = tstate->curexc_type;
2036    tmp_value = tstate->curexc_value;
2037    tmp_tb = tstate->curexc_traceback;
2038    tstate->curexc_type = type;
2039    tstate->curexc_value = value;
2040    tstate->curexc_traceback = tb;
2041    Py_XDECREF(tmp_type);
2042    Py_XDECREF(tmp_value);
2043    Py_XDECREF(tmp_tb);
2044#else
2045    PyErr_Restore(type, value, tb);
2046#endif
2047}
2048static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
2049#if CYTHON_COMPILING_IN_CPYTHON
2050    PyThreadState *tstate = PyThreadState_GET();
2051    *type = tstate->curexc_type;
2052    *value = tstate->curexc_value;
2053    *tb = tstate->curexc_traceback;
2054    tstate->curexc_type = 0;
2055    tstate->curexc_value = 0;
2056    tstate->curexc_traceback = 0;
2057#else
2058    PyErr_Fetch(type, value, tb);
2059#endif
2060}
2061
2062#if PY_MAJOR_VERSION < 3
2063static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
2064                        CYTHON_UNUSED PyObject *cause) {
2065    Py_XINCREF(type);
2066    if (!value || value == Py_None)
2067        value = NULL;
2068    else
2069        Py_INCREF(value);
2070    if (!tb || tb == Py_None)
2071        tb = NULL;
2072    else {
2073        Py_INCREF(tb);
2074        if (!PyTraceBack_Check(tb)) {
2075            PyErr_SetString(PyExc_TypeError,
2076                "raise: arg 3 must be a traceback or None");
2077            goto raise_error;
2078        }
2079    }
2080    if (PyType_Check(type)) {
2081#if CYTHON_COMPILING_IN_PYPY
2082        if (!value) {
2083            Py_INCREF(Py_None);
2084            value = Py_None;
2085        }
2086#endif
2087        PyErr_NormalizeException(&type, &value, &tb);
2088    } else {
2089        if (value) {
2090            PyErr_SetString(PyExc_TypeError,
2091                "instance exception may not have a separate value");
2092            goto raise_error;
2093        }
2094        value = type;
2095        type = (PyObject*) Py_TYPE(type);
2096        Py_INCREF(type);
2097        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
2098            PyErr_SetString(PyExc_TypeError,
2099                "raise: exception class must be a subclass of BaseException");
2100            goto raise_error;
2101        }
2102    }
2103    __Pyx_ErrRestore(type, value, tb);
2104    return;
2105raise_error:
2106    Py_XDECREF(value);
2107    Py_XDECREF(type);
2108    Py_XDECREF(tb);
2109    return;
2110}
2111#else
2112static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
2113    PyObject* owned_instance = NULL;
2114    if (tb == Py_None) {
2115        tb = 0;
2116    } else if (tb && !PyTraceBack_Check(tb)) {
2117        PyErr_SetString(PyExc_TypeError,
2118            "raise: arg 3 must be a traceback or None");
2119        goto bad;
2120    }
2121    if (value == Py_None)
2122        value = 0;
2123    if (PyExceptionInstance_Check(type)) {
2124        if (value) {
2125            PyErr_SetString(PyExc_TypeError,
2126                "instance exception may not have a separate value");
2127            goto bad;
2128        }
2129        value = type;
2130        type = (PyObject*) Py_TYPE(value);
2131    } else if (PyExceptionClass_Check(type)) {
2132        PyObject *instance_class = NULL;
2133        if (value && PyExceptionInstance_Check(value)) {
2134            instance_class = (PyObject*) Py_TYPE(value);
2135            if (instance_class != type) {
2136                if (PyObject_IsSubclass(instance_class, type)) {
2137                    type = instance_class;
2138                } else {
2139                    instance_class = NULL;
2140                }
2141            }
2142        }
2143        if (!instance_class) {
2144            PyObject *args;
2145            if (!value)
2146                args = PyTuple_New(0);
2147            else if (PyTuple_Check(value)) {
2148                Py_INCREF(value);
2149                args = value;
2150            } else
2151                args = PyTuple_Pack(1, value);
2152            if (!args)
2153                goto bad;
2154            owned_instance = PyObject_Call(type, args, NULL);
2155            Py_DECREF(args);
2156            if (!owned_instance)
2157                goto bad;
2158            value = owned_instance;
2159            if (!PyExceptionInstance_Check(value)) {
2160                PyErr_Format(PyExc_TypeError,
2161                             "calling %R should have returned an instance of "
2162                             "BaseException, not %R",
2163                             type, Py_TYPE(value));
2164                goto bad;
2165            }
2166        }
2167    } else {
2168        PyErr_SetString(PyExc_TypeError,
2169            "raise: exception class must be a subclass of BaseException");
2170        goto bad;
2171    }
2172#if PY_VERSION_HEX >= 0x03030000
2173    if (cause) {
2174#else
2175    if (cause && cause != Py_None) {
2176#endif
2177        PyObject *fixed_cause;
2178        if (cause == Py_None) {
2179            fixed_cause = NULL;
2180        } else if (PyExceptionClass_Check(cause)) {
2181            fixed_cause = PyObject_CallObject(cause, NULL);
2182            if (fixed_cause == NULL)
2183                goto bad;
2184        } else if (PyExceptionInstance_Check(cause)) {
2185            fixed_cause = cause;
2186            Py_INCREF(fixed_cause);
2187        } else {
2188            PyErr_SetString(PyExc_TypeError,
2189                            "exception causes must derive from "
2190                            "BaseException");
2191            goto bad;
2192        }
2193        PyException_SetCause(value, fixed_cause);
2194    }
2195    PyErr_SetObject(type, value);
2196    if (tb) {
2197#if CYTHON_COMPILING_IN_PYPY
2198        PyObject *tmp_type, *tmp_value, *tmp_tb;
2199        PyErr_Fetch(tmp_type, tmp_value, tmp_tb);
2200        Py_INCREF(tb);
2201        PyErr_Restore(tmp_type, tmp_value, tb);
2202        Py_XDECREF(tmp_tb);
2203#else
2204        PyThreadState *tstate = PyThreadState_GET();
2205        PyObject* tmp_tb = tstate->curexc_traceback;
2206        if (tb != tmp_tb) {
2207            Py_INCREF(tb);
2208            tstate->curexc_traceback = tb;
2209            Py_XDECREF(tmp_tb);
2210        }
2211#endif
2212    }
2213bad:
2214    Py_XDECREF(owned_instance);
2215    return;
2216}
2217#endif
2218
2219static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
2220    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
2221    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
2222        PyErr_Format(PyExc_ImportError,
2223        #if PY_MAJOR_VERSION < 3
2224            "cannot import name %.230s", PyString_AS_STRING(name));
2225        #else
2226            "cannot import name %S", name);
2227        #endif
2228    }
2229    return value;
2230}
2231
2232static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
2233    int start = 0, mid = 0, end = count - 1;
2234    if (end >= 0 && code_line > entries[end].code_line) {
2235        return count;
2236    }
2237    while (start < end) {
2238        mid = (start + end) / 2;
2239        if (code_line < entries[mid].code_line) {
2240            end = mid;
2241        } else if (code_line > entries[mid].code_line) {
2242             start = mid + 1;
2243        } else {
2244            return mid;
2245        }
2246    }
2247    if (code_line <= entries[mid].code_line) {
2248        return mid;
2249    } else {
2250        return mid + 1;
2251    }
2252}
2253static PyCodeObject *__pyx_find_code_object(int code_line) {
2254    PyCodeObject* code_object;
2255    int pos;
2256    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
2257        return NULL;
2258    }
2259    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2260    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
2261        return NULL;
2262    }
2263    code_object = __pyx_code_cache.entries[pos].code_object;
2264    Py_INCREF(code_object);
2265    return code_object;
2266}
2267static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
2268    int pos, i;
2269    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
2270    if (unlikely(!code_line)) {
2271        return;
2272    }
2273    if (unlikely(!entries)) {
2274        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
2275        if (likely(entries)) {
2276            __pyx_code_cache.entries = entries;
2277            __pyx_code_cache.max_count = 64;
2278            __pyx_code_cache.count = 1;
2279            entries[0].code_line = code_line;
2280            entries[0].code_object = code_object;
2281            Py_INCREF(code_object);
2282        }
2283        return;
2284    }
2285    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
2286    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
2287        PyCodeObject* tmp = entries[pos].code_object;
2288        entries[pos].code_object = code_object;
2289        Py_DECREF(tmp);
2290        return;
2291    }
2292    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
2293        int new_max = __pyx_code_cache.max_count + 64;
2294        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
2295            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
2296        if (unlikely(!entries)) {
2297            return;
2298        }
2299        __pyx_code_cache.entries = entries;
2300        __pyx_code_cache.max_count = new_max;
2301    }
2302    for (i=__pyx_code_cache.count; i>pos; i--) {
2303        entries[i] = entries[i-1];
2304    }
2305    entries[pos].code_line = code_line;
2306    entries[pos].code_object = code_object;
2307    __pyx_code_cache.count++;
2308    Py_INCREF(code_object);
2309}
2310
2311#include "compile.h"
2312#include "frameobject.h"
2313#include "traceback.h"
2314static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
2315            const char *funcname, int c_line,
2316            int py_line, const char *filename) {
2317    PyCodeObject *py_code = 0;
2318    PyObject *py_srcfile = 0;
2319    PyObject *py_funcname = 0;
2320    #if PY_MAJOR_VERSION < 3
2321    py_srcfile = PyString_FromString(filename);
2322    #else
2323    py_srcfile = PyUnicode_FromString(filename);
2324    #endif
2325    if (!py_srcfile) goto bad;
2326    if (c_line) {
2327        #if PY_MAJOR_VERSION < 3
2328        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2329        #else
2330        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
2331        #endif
2332    }
2333    else {
2334        #if PY_MAJOR_VERSION < 3
2335        py_funcname = PyString_FromString(funcname);
2336        #else
2337        py_funcname = PyUnicode_FromString(funcname);
2338        #endif
2339    }
2340    if (!py_funcname) goto bad;
2341    py_code = __Pyx_PyCode_New(
2342        0,
2343        0,
2344        0,
2345        0,
2346        0,
2347        __pyx_empty_bytes, /*PyObject *code,*/
2348        __pyx_empty_tuple, /*PyObject *consts,*/
2349        __pyx_empty_tuple, /*PyObject *names,*/
2350        __pyx_empty_tuple, /*PyObject *varnames,*/
2351        __pyx_empty_tuple, /*PyObject *freevars,*/
2352        __pyx_empty_tuple, /*PyObject *cellvars,*/
2353        py_srcfile,   /*PyObject *filename,*/
2354        py_funcname,  /*PyObject *name,*/
2355        py_line,
2356        __pyx_empty_bytes  /*PyObject *lnotab*/
2357    );
2358    Py_DECREF(py_srcfile);
2359    Py_DECREF(py_funcname);
2360    return py_code;
2361bad:
2362    Py_XDECREF(py_srcfile);
2363    Py_XDECREF(py_funcname);
2364    return NULL;
2365}
2366static void __Pyx_AddTraceback(const char *funcname, int c_line,
2367                               int py_line, const char *filename) {
2368    PyCodeObject *py_code = 0;
2369    PyFrameObject *py_frame = 0;
2370    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
2371    if (!py_code) {
2372        py_code = __Pyx_CreateCodeObjectForTraceback(
2373            funcname, c_line, py_line, filename);
2374        if (!py_code) goto bad;
2375        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
2376    }
2377    py_frame = PyFrame_New(
2378        PyThreadState_GET(), /*PyThreadState *tstate,*/
2379        py_code,             /*PyCodeObject *code,*/
2380        __pyx_d,      /*PyObject *globals,*/
2381        0                    /*PyObject *locals*/
2382    );
2383    if (!py_frame) goto bad;
2384    py_frame->f_lineno = py_line;
2385    PyTraceBack_Here(py_frame);
2386bad:
2387    Py_XDECREF(py_code);
2388    Py_XDECREF(py_frame);
2389}
2390
2391static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
2392    PyObject *empty_list = 0;
2393    PyObject *module = 0;
2394    PyObject *global_dict = 0;
2395    PyObject *empty_dict = 0;
2396    PyObject *list;
2397    #if PY_VERSION_HEX < 0x03030000
2398    PyObject *py_import;
2399    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
2400    if (!py_import)
2401        goto bad;
2402    #endif
2403    if (from_list)
2404        list = from_list;
2405    else {
2406        empty_list = PyList_New(0);
2407        if (!empty_list)
2408            goto bad;
2409        list = empty_list;
2410    }
2411    global_dict = PyModule_GetDict(__pyx_m);
2412    if (!global_dict)
2413        goto bad;
2414    empty_dict = PyDict_New();
2415    if (!empty_dict)
2416        goto bad;
2417    {
2418        #if PY_MAJOR_VERSION >= 3
2419        if (level == -1) {
2420            if (strchr(__Pyx_MODULE_NAME, '.')) {
2421                #if PY_VERSION_HEX < 0x03030000
2422                PyObject *py_level = PyInt_FromLong(1);
2423                if (!py_level)
2424                    goto bad;
2425                module = PyObject_CallFunctionObjArgs(py_import,
2426                    name, global_dict, empty_dict, list, py_level, NULL);
2427                Py_DECREF(py_level);
2428                #else
2429                module = PyImport_ImportModuleLevelObject(
2430                    name, global_dict, empty_dict, list, 1);
2431                #endif
2432                if (!module) {
2433                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
2434                        goto bad;
2435                    PyErr_Clear();
2436                }
2437            }
2438            level = 0;
2439        }
2440        #endif
2441        if (!module) {
2442            #if PY_VERSION_HEX < 0x03030000
2443            PyObject *py_level = PyInt_FromLong(level);
2444            if (!py_level)
2445                goto bad;
2446            module = PyObject_CallFunctionObjArgs(py_import,
2447                name, global_dict, empty_dict, list, py_level, NULL);
2448            Py_DECREF(py_level);
2449            #else
2450            module = PyImport_ImportModuleLevelObject(
2451                name, global_dict, empty_dict, list, level);
2452            #endif
2453        }
2454    }
2455bad:
2456    #if PY_VERSION_HEX < 0x03030000
2457    Py_XDECREF(py_import);
2458    #endif
2459    Py_XDECREF(empty_list);
2460    Py_XDECREF(empty_dict);
2461    return module;
2462}
2463
2464#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
2465    {                                                                     \
2466        func_type value = func_value;                                     \
2467        if (sizeof(target_type) < sizeof(func_type)) {                    \
2468            if (unlikely(value != (func_type) (target_type) value)) {     \
2469                func_type zero = 0;                                       \
2470                if (is_unsigned && unlikely(value < zero))                \
2471                    goto raise_neg_overflow;                              \
2472                else                                                      \
2473                    goto raise_overflow;                                  \
2474            }                                                             \
2475        }                                                                 \
2476        return (target_type) value;                                       \
2477    }
2478
2479#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
2480 #if CYTHON_USE_PYLONG_INTERNALS
2481  #include "longintrepr.h"
2482 #endif
2483#endif
2484
2485static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
2486    const int neg_one = (int) -1, const_zero = 0;
2487    const int is_unsigned = neg_one > const_zero;
2488#if PY_MAJOR_VERSION < 3
2489    if (likely(PyInt_Check(x))) {
2490        if (sizeof(int) < sizeof(long)) {
2491            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
2492        } else {
2493            long val = PyInt_AS_LONG(x);
2494            if (is_unsigned && unlikely(val < 0)) {
2495                goto raise_neg_overflow;
2496            }
2497            return (int) val;
2498        }
2499    } else
2500#endif
2501    if (likely(PyLong_Check(x))) {
2502        if (is_unsigned) {
2503#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
2504 #if CYTHON_USE_PYLONG_INTERNALS
2505            switch (Py_SIZE(x)) {
2506                case  0: return 0;
2507                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
2508            }
2509 #endif
2510#endif
2511            if (unlikely(Py_SIZE(x) < 0)) {
2512                goto raise_neg_overflow;
2513            }
2514            if (sizeof(int) <= sizeof(unsigned long)) {
2515                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
2516            } else if (sizeof(int) <= sizeof(unsigned long long)) {
2517                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong(x))
2518            }
2519        } else {
2520#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
2521 #if CYTHON_USE_PYLONG_INTERNALS
2522            switch (Py_SIZE(x)) {
2523                case  0: return 0;
2524                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
2525                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
2526            }
2527 #endif
2528#endif
2529            if (sizeof(int) <= sizeof(long)) {
2530                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
2531            } else if (sizeof(int) <= sizeof(long long)) {
2532                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong(x))
2533            }
2534        }
2535        {
2536#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
2537            PyErr_SetString(PyExc_RuntimeError,
2538                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
2539#else
2540            int val;
2541            PyObject *v = __Pyx_PyNumber_Int(x);
2542 #if PY_MAJOR_VERSION < 3
2543            if (likely(v) && !PyLong_Check(v)) {
2544                PyObject *tmp = v;
2545                v = PyNumber_Long(tmp);
2546                Py_DECREF(tmp);
2547            }
2548 #endif
2549            if (likely(v)) {
2550                int one = 1; int is_little = (int)*(unsigned char *)&one;
2551                unsigned char *bytes = (unsigned char *)&val;
2552                int ret = _PyLong_AsByteArray((PyLongObject *)v,
2553                                              bytes, sizeof(val),
2554                                              is_little, !is_unsigned);
2555                Py_DECREF(v);
2556                if (likely(!ret))
2557                    return val;
2558            }
2559#endif
2560            return (int) -1;
2561        }
2562    } else {
2563        int val;
2564        PyObject *tmp = __Pyx_PyNumber_Int(x);
2565        if (!tmp) return (int) -1;
2566        val = __Pyx_PyInt_As_int(tmp);
2567        Py_DECREF(tmp);
2568        return val;
2569    }
2570raise_overflow:
2571    PyErr_SetString(PyExc_OverflowError,
2572        "value too large to convert to int");
2573    return (int) -1;
2574raise_neg_overflow:
2575    PyErr_SetString(PyExc_OverflowError,
2576        "can't convert negative value to int");
2577    return (int) -1;
2578}
2579
2580static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
2581    const int neg_one = (int) -1, const_zero = 0;
2582    const int is_unsigned = neg_one > const_zero;
2583    if (is_unsigned) {
2584        if (sizeof(int) < sizeof(long)) {
2585            return PyInt_FromLong((long) value);
2586        } else if (sizeof(int) <= sizeof(unsigned long)) {
2587            return PyLong_FromUnsignedLong((unsigned long) value);
2588        } else if (sizeof(int) <= sizeof(unsigned long long)) {
2589            return PyLong_FromUnsignedLongLong((unsigned long long) value);
2590        }
2591    } else {
2592        if (sizeof(int) <= sizeof(long)) {
2593            return PyInt_FromLong((long) value);
2594        } else if (sizeof(int) <= sizeof(long long)) {
2595            return PyLong_FromLongLong((long long) value);
2596        }
2597    }
2598    {
2599        int one = 1; int little = (int)*(unsigned char *)&one;
2600        unsigned char *bytes = (unsigned char *)&value;
2601        return _PyLong_FromByteArray(bytes, sizeof(int),
2602                                     little, !is_unsigned);
2603    }
2604}
2605
2606static CYTHON_INLINE PyObject* __Pyx_PyInt_From_unsigned_long(unsigned long value) {
2607    const unsigned long neg_one = (unsigned long) -1, const_zero = 0;
2608    const int is_unsigned = neg_one > const_zero;
2609    if (is_unsigned) {
2610        if (sizeof(unsigned long) < sizeof(long)) {
2611            return PyInt_FromLong((long) value);
2612        } else if (sizeof(unsigned long) <= sizeof(unsigned long)) {
2613            return PyLong_FromUnsignedLong((unsigned long) value);
2614        } else if (sizeof(unsigned long) <= sizeof(unsigned long long)) {
2615            return PyLong_FromUnsignedLongLong((unsigned long long) value);
2616        }
2617    } else {
2618        if (sizeof(unsigned long) <= sizeof(long)) {
2619            return PyInt_FromLong((long) value);
2620        } else if (sizeof(unsigned long) <= sizeof(long long)) {
2621            return PyLong_FromLongLong((long long) value);
2622        }
2623    }
2624    {
2625        int one = 1; int little = (int)*(unsigned char *)&one;
2626        unsigned char *bytes = (unsigned char *)&value;
2627        return _PyLong_FromByteArray(bytes, sizeof(unsigned long),
2628                                     little, !is_unsigned);
2629    }
2630}
2631
2632static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
2633    const long neg_one = (long) -1, const_zero = 0;
2634    const int is_unsigned = neg_one > const_zero;
2635    if (is_unsigned) {
2636        if (sizeof(long) < sizeof(long)) {
2637            return PyInt_FromLong((long) value);
2638        } else if (sizeof(long) <= sizeof(unsigned long)) {
2639            return PyLong_FromUnsignedLong((unsigned long) value);
2640        } else if (sizeof(long) <= sizeof(unsigned long long)) {
2641            return PyLong_FromUnsignedLongLong((unsigned long long) value);
2642        }
2643    } else {
2644        if (sizeof(long) <= sizeof(long)) {
2645            return PyInt_FromLong((long) value);
2646        } else if (sizeof(long) <= sizeof(long long)) {
2647            return PyLong_FromLongLong((long long) value);
2648        }
2649    }
2650    {
2651        int one = 1; int little = (int)*(unsigned char *)&one;
2652        unsigned char *bytes = (unsigned char *)&value;
2653        return _PyLong_FromByteArray(bytes, sizeof(long),
2654                                     little, !is_unsigned);
2655    }
2656}
2657
2658static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
2659    const long neg_one = (long) -1, const_zero = 0;
2660    const int is_unsigned = neg_one > const_zero;
2661#if PY_MAJOR_VERSION < 3
2662    if (likely(PyInt_Check(x))) {
2663        if (sizeof(long) < sizeof(long)) {
2664            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
2665        } else {
2666            long val = PyInt_AS_LONG(x);
2667            if (is_unsigned && unlikely(val < 0)) {
2668                goto raise_neg_overflow;
2669            }
2670            return (long) val;
2671        }
2672    } else
2673#endif
2674    if (likely(PyLong_Check(x))) {
2675        if (is_unsigned) {
2676#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
2677 #if CYTHON_USE_PYLONG_INTERNALS
2678            switch (Py_SIZE(x)) {
2679                case  0: return 0;
2680                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
2681            }
2682 #endif
2683#endif
2684            if (unlikely(Py_SIZE(x) < 0)) {
2685                goto raise_neg_overflow;
2686            }
2687            if (sizeof(long) <= sizeof(unsigned long)) {
2688                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
2689            } else if (sizeof(long) <= sizeof(unsigned long long)) {
2690                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong(x))
2691            }
2692        } else {
2693#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
2694 #if CYTHON_USE_PYLONG_INTERNALS
2695            switch (Py_SIZE(x)) {
2696                case  0: return 0;
2697                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
2698                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
2699            }
2700 #endif
2701#endif
2702            if (sizeof(long) <= sizeof(long)) {
2703                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
2704            } else if (sizeof(long) <= sizeof(long long)) {
2705                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong(x))
2706            }
2707        }
2708        {
2709#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
2710            PyErr_SetString(PyExc_RuntimeError,
2711                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
2712#else
2713            long val;
2714            PyObject *v = __Pyx_PyNumber_Int(x);
2715 #if PY_MAJOR_VERSION < 3
2716            if (likely(v) && !PyLong_Check(v)) {
2717                PyObject *tmp = v;
2718                v = PyNumber_Long(tmp);
2719                Py_DECREF(tmp);
2720            }
2721 #endif
2722            if (likely(v)) {
2723                int one = 1; int is_little = (int)*(unsigned char *)&one;
2724                unsigned char *bytes = (unsigned char *)&val;
2725                int ret = _PyLong_AsByteArray((PyLongObject *)v,
2726                                              bytes, sizeof(val),
2727                                              is_little, !is_unsigned);
2728                Py_DECREF(v);
2729                if (likely(!ret))
2730                    return val;
2731            }
2732#endif
2733            return (long) -1;
2734        }
2735    } else {
2736        long val;
2737        PyObject *tmp = __Pyx_PyNumber_Int(x);
2738        if (!tmp) return (long) -1;
2739        val = __Pyx_PyInt_As_long(tmp);
2740        Py_DECREF(tmp);
2741        return val;
2742    }
2743raise_overflow:
2744    PyErr_SetString(PyExc_OverflowError,
2745        "value too large to convert to long");
2746    return (long) -1;
2747raise_neg_overflow:
2748    PyErr_SetString(PyExc_OverflowError,
2749        "can't convert negative value to long");
2750    return (long) -1;
2751}
2752
2753static int __Pyx_check_binary_version(void) {
2754    char ctversion[4], rtversion[4];
2755    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
2756    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
2757    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
2758        char message[200];
2759        PyOS_snprintf(message, sizeof(message),
2760                      "compiletime version %s of module '%.100s' "
2761                      "does not match runtime version %s",
2762                      ctversion, __Pyx_MODULE_NAME, rtversion);
2763        return PyErr_WarnEx(NULL, message, 1);
2764    }
2765    return 0;
2766}
2767
2768static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
2769    while (t->p) {
2770        #if PY_MAJOR_VERSION < 3
2771        if (t->is_unicode) {
2772            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
2773        } else if (t->intern) {
2774            *t->p = PyString_InternFromString(t->s);
2775        } else {
2776            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
2777        }
2778        #else
2779        if (t->is_unicode | t->is_str) {
2780            if (t->intern) {
2781                *t->p = PyUnicode_InternFromString(t->s);
2782            } else if (t->encoding) {
2783                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
2784            } else {
2785                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
2786            }
2787        } else {
2788            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
2789        }
2790        #endif
2791        if (!*t->p)
2792            return -1;
2793        ++t;
2794    }
2795    return 0;
2796}
2797
2798static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
2799    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
2800}
2801static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
2802    Py_ssize_t ignore;
2803    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
2804}
2805static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
2806#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
2807    if (
2808#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
2809            __Pyx_sys_getdefaultencoding_not_ascii &&
2810#endif
2811            PyUnicode_Check(o)) {
2812#if PY_VERSION_HEX < 0x03030000
2813        char* defenc_c;
2814        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
2815        if (!defenc) return NULL;
2816        defenc_c = PyBytes_AS_STRING(defenc);
2817#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
2818        {
2819            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
2820            char* c;
2821            for (c = defenc_c; c < end; c++) {
2822                if ((unsigned char) (*c) >= 128) {
2823                    PyUnicode_AsASCIIString(o);
2824                    return NULL;
2825                }
2826            }
2827        }
2828#endif
2829        *length = PyBytes_GET_SIZE(defenc);
2830        return defenc_c;
2831#else
2832        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
2833#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
2834        if (PyUnicode_IS_ASCII(o)) {
2835            *length = PyUnicode_GET_LENGTH(o);
2836            return PyUnicode_AsUTF8(o);
2837        } else {
2838            PyUnicode_AsASCIIString(o);
2839            return NULL;
2840        }
2841#else
2842        return PyUnicode_AsUTF8AndSize(o, length);
2843#endif
2844#endif
2845    } else
2846#endif
2847#if !CYTHON_COMPILING_IN_PYPY
2848    if (PyByteArray_Check(o)) {
2849        *length = PyByteArray_GET_SIZE(o);
2850        return PyByteArray_AS_STRING(o);
2851    } else
2852#endif
2853    {
2854        char* result;
2855        int r = PyBytes_AsStringAndSize(o, &result, length);
2856        if (unlikely(r < 0)) {
2857            return NULL;
2858        } else {
2859            return result;
2860        }
2861    }
2862}
2863static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
2864   int is_true = x == Py_True;
2865   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
2866   else return PyObject_IsTrue(x);
2867}
2868static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
2869  PyNumberMethods *m;
2870  const char *name = NULL;
2871  PyObject *res = NULL;
2872#if PY_MAJOR_VERSION < 3
2873  if (PyInt_Check(x) || PyLong_Check(x))
2874#else
2875  if (PyLong_Check(x))
2876#endif
2877    return Py_INCREF(x), x;
2878  m = Py_TYPE(x)->tp_as_number;
2879#if PY_MAJOR_VERSION < 3
2880  if (m && m->nb_int) {
2881    name = "int";
2882    res = PyNumber_Int(x);
2883  }
2884  else if (m && m->nb_long) {
2885    name = "long";
2886    res = PyNumber_Long(x);
2887  }
2888#else
2889  if (m && m->nb_int) {
2890    name = "int";
2891    res = PyNumber_Long(x);
2892  }
2893#endif
2894  if (res) {
2895#if PY_MAJOR_VERSION < 3
2896    if (!PyInt_Check(res) && !PyLong_Check(res)) {
2897#else
2898    if (!PyLong_Check(res)) {
2899#endif
2900      PyErr_Format(PyExc_TypeError,
2901                   "__%.4s__ returned non-%.4s (type %.200s)",
2902                   name, name, Py_TYPE(res)->tp_name);
2903      Py_DECREF(res);
2904      return NULL;
2905    }
2906  }
2907  else if (!PyErr_Occurred()) {
2908    PyErr_SetString(PyExc_TypeError,
2909                    "an integer is required");
2910  }
2911  return res;
2912}
2913static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
2914  Py_ssize_t ival;
2915  PyObject *x;
2916#if PY_MAJOR_VERSION < 3
2917  if (likely(PyInt_CheckExact(b)))
2918      return PyInt_AS_LONG(b);
2919#endif
2920  if (likely(PyLong_CheckExact(b))) {
2921    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
2922     #if CYTHON_USE_PYLONG_INTERNALS
2923       switch (Py_SIZE(b)) {
2924       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
2925       case  0: return 0;
2926       case  1: return ((PyLongObject*)b)->ob_digit[0];
2927       }
2928     #endif
2929    #endif
2930    return PyLong_AsSsize_t(b);
2931  }
2932  x = PyNumber_Index(b);
2933  if (!x) return -1;
2934  ival = PyInt_AsSsize_t(x);
2935  Py_DECREF(x);
2936  return ival;
2937}
2938static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
2939    return PyInt_FromSize_t(ival);
2940}
2941
2942
2943#endif /* Py_PYTHON_H */
2944