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___poll
235#define __PYX_HAVE_API__zmq__backend__cython___poll
236#include "string.h"
237#include "stdlib.h"
238#include "zmq_compat.h"
239#include "zmq.h"
240#include "zmq_utils.h"
241#include "errno.h"
242#include "stdio.h"
243#include "pythread.h"
244#ifdef _OPENMP
245#include <omp.h>
246#endif /* _OPENMP */
247
248#ifdef PYREX_WITHOUT_ASSERTIONS
249#define CYTHON_WITHOUT_ASSERTIONS
250#endif
251
252#ifndef CYTHON_UNUSED
253# if defined(__GNUC__)
254#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
255#     define CYTHON_UNUSED __attribute__ ((__unused__))
256#   else
257#     define CYTHON_UNUSED
258#   endif
259# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
260#   define CYTHON_UNUSED __attribute__ ((__unused__))
261# else
262#   define CYTHON_UNUSED
263# endif
264#endif
265typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
266                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
267
268#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
269#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
270#define __PYX_DEFAULT_STRING_ENCODING ""
271#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
272#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
273#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
274    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
275    (sizeof(type) > sizeof(Py_ssize_t) &&               \
276          likely(v < (type)PY_SSIZE_T_MAX ||            \
277                 v == (type)PY_SSIZE_T_MAX)  &&         \
278          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
279                                v == (type)PY_SSIZE_T_MIN)))  ||  \
280    (sizeof(type) == sizeof(Py_ssize_t) &&              \
281          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
282                               v == (type)PY_SSIZE_T_MAX)))  )
283static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
284static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
285#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
286#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
287#define __Pyx_PyBytes_FromString        PyBytes_FromString
288#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
289static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
290#if PY_MAJOR_VERSION < 3
291    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
292    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
293#else
294    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
295    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
296#endif
297#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
298#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
299#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((const char*)s)
300#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((const char*)s)
301#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((const char*)s)
302#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((const char*)s)
303#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s)
304#if PY_MAJOR_VERSION < 3
305static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
306{
307    const Py_UNICODE *u_end = u;
308    while (*u_end++) ;
309    return (size_t)(u_end - u - 1);
310}
311#else
312#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
313#endif
314#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
315#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
316#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
317#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
318#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
319static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
320static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
321static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
322static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
323#if CYTHON_COMPILING_IN_CPYTHON
324#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
325#else
326#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
327#endif
328#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
329#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
330static int __Pyx_sys_getdefaultencoding_not_ascii;
331static int __Pyx_init_sys_getdefaultencoding_params(void) {
332    PyObject* sys;
333    PyObject* default_encoding = NULL;
334    PyObject* ascii_chars_u = NULL;
335    PyObject* ascii_chars_b = NULL;
336    const char* default_encoding_c;
337    sys = PyImport_ImportModule("sys");
338    if (!sys) goto bad;
339    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
340    Py_DECREF(sys);
341    if (!default_encoding) goto bad;
342    default_encoding_c = PyBytes_AsString(default_encoding);
343    if (!default_encoding_c) goto bad;
344    if (strcmp(default_encoding_c, "ascii") == 0) {
345        __Pyx_sys_getdefaultencoding_not_ascii = 0;
346    } else {
347        char ascii_chars[128];
348        int c;
349        for (c = 0; c < 128; c++) {
350            ascii_chars[c] = c;
351        }
352        __Pyx_sys_getdefaultencoding_not_ascii = 1;
353        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
354        if (!ascii_chars_u) goto bad;
355        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
356        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
357            PyErr_Format(
358                PyExc_ValueError,
359                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
360                default_encoding_c);
361            goto bad;
362        }
363        Py_DECREF(ascii_chars_u);
364        Py_DECREF(ascii_chars_b);
365    }
366    Py_DECREF(default_encoding);
367    return 0;
368bad:
369    Py_XDECREF(default_encoding);
370    Py_XDECREF(ascii_chars_u);
371    Py_XDECREF(ascii_chars_b);
372    return -1;
373}
374#endif
375#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
376#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
377#else
378#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
379#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
380static char* __PYX_DEFAULT_STRING_ENCODING;
381static int __Pyx_init_sys_getdefaultencoding_params(void) {
382    PyObject* sys;
383    PyObject* default_encoding = NULL;
384    char* default_encoding_c;
385    sys = PyImport_ImportModule("sys");
386    if (!sys) goto bad;
387    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
388    Py_DECREF(sys);
389    if (!default_encoding) goto bad;
390    default_encoding_c = PyBytes_AsString(default_encoding);
391    if (!default_encoding_c) goto bad;
392    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
393    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
394    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
395    Py_DECREF(default_encoding);
396    return 0;
397bad:
398    Py_XDECREF(default_encoding);
399    return -1;
400}
401#endif
402#endif
403
404
405/* Test for GCC > 2.95 */
406#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
407  #define likely(x)   __builtin_expect(!!(x), 1)
408  #define unlikely(x) __builtin_expect(!!(x), 0)
409#else /* !__GNUC__ or GCC < 2.95 */
410  #define likely(x)   (x)
411  #define unlikely(x) (x)
412#endif /* __GNUC__ */
413
414static PyObject *__pyx_m;
415static PyObject *__pyx_d;
416static PyObject *__pyx_b;
417static PyObject *__pyx_empty_tuple;
418static PyObject *__pyx_empty_bytes;
419static int __pyx_lineno;
420static int __pyx_clineno = 0;
421static const char * __pyx_cfilenm= __FILE__;
422static const char *__pyx_filename;
423
424
425static const char *__pyx_f[] = {
426  "zmq/backend/cython/_poll.pyx",
427  "zmq/backend/cython/checkrc.pxd",
428  "zmq/backend/cython/context.pxd",
429  "zmq/backend/cython/socket.pxd",
430  "type.pxd",
431  "bool.pxd",
432  "complex.pxd",
433};
434
435/*--- Type declarations ---*/
436struct __pyx_obj_3zmq_7backend_6cython_7context_Context;
437struct __pyx_obj_3zmq_7backend_6cython_6socket_Socket;
438struct __pyx_opt_args_3zmq_7backend_6cython_6socket_6Socket_send;
439struct __pyx_opt_args_3zmq_7backend_6cython_6socket_6Socket_recv;
440
441/* "socket.pxd":45
442 *
443 *     # cpdef methods for direct-cython access:
444 *     cpdef object send(self, object data, int flags=*, copy=*, track=*)             # <<<<<<<<<<<<<<
445 *     cpdef object recv(self, int flags=*, copy=*, track=*)
446 *
447 */
448struct __pyx_opt_args_3zmq_7backend_6cython_6socket_6Socket_send {
449  int __pyx_n;
450  int flags;
451  PyObject *copy;
452  PyObject *track;
453};
454
455/* "socket.pxd":46
456 *     # cpdef methods for direct-cython access:
457 *     cpdef object send(self, object data, int flags=*, copy=*, track=*)
458 *     cpdef object recv(self, int flags=*, copy=*, track=*)             # <<<<<<<<<<<<<<
459 *
460 */
461struct __pyx_opt_args_3zmq_7backend_6cython_6socket_6Socket_recv {
462  int __pyx_n;
463  int flags;
464  PyObject *copy;
465  PyObject *track;
466};
467
468/* "context.pxd":26
469 * #-----------------------------------------------------------------------------
470 *
471 * cdef class Context:             # <<<<<<<<<<<<<<
472 *
473 *     cdef object __weakref__     # enable weakref
474 */
475struct __pyx_obj_3zmq_7backend_6cython_7context_Context {
476  PyObject_HEAD
477  struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context *__pyx_vtab;
478  PyObject *__weakref__;
479  void *handle;
480  int _shadow;
481  void **_sockets;
482  size_t _n_sockets;
483  size_t _max_sockets;
484  int _pid;
485  int closed;
486};
487
488
489/* "socket.pxd":33
490 *
491 *
492 * cdef class Socket:             # <<<<<<<<<<<<<<
493 *
494 *     cdef object __weakref__     # enable weakref
495 */
496struct __pyx_obj_3zmq_7backend_6cython_6socket_Socket {
497  PyObject_HEAD
498  struct __pyx_vtabstruct_3zmq_7backend_6cython_6socket_Socket *__pyx_vtab;
499  PyObject *__weakref__;
500  void *handle;
501  int _shadow;
502  struct __pyx_obj_3zmq_7backend_6cython_7context_Context *context;
503  int _closed;
504  int _pid;
505};
506
507
508
509/* "context.pxd":26
510 * #-----------------------------------------------------------------------------
511 *
512 * cdef class Context:             # <<<<<<<<<<<<<<
513 *
514 *     cdef object __weakref__     # enable weakref
515 */
516
517struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context {
518  int (*_term)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *);
519  void (*_add_socket)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *);
520  void (*_remove_socket)(struct __pyx_obj_3zmq_7backend_6cython_7context_Context *, void *);
521};
522static struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context *__pyx_vtabptr_3zmq_7backend_6cython_7context_Context;
523
524
525/* "socket.pxd":33
526 *
527 *
528 * cdef class Socket:             # <<<<<<<<<<<<<<
529 *
530 *     cdef object __weakref__     # enable weakref
531 */
532
533struct __pyx_vtabstruct_3zmq_7backend_6cython_6socket_Socket {
534  PyObject *(*send)(struct __pyx_obj_3zmq_7backend_6cython_6socket_Socket *, PyObject *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_7backend_6cython_6socket_6Socket_send *__pyx_optional_args);
535  PyObject *(*recv)(struct __pyx_obj_3zmq_7backend_6cython_6socket_Socket *, int __pyx_skip_dispatch, struct __pyx_opt_args_3zmq_7backend_6cython_6socket_6Socket_recv *__pyx_optional_args);
536};
537static struct __pyx_vtabstruct_3zmq_7backend_6cython_6socket_Socket *__pyx_vtabptr_3zmq_7backend_6cython_6socket_Socket;
538#ifndef CYTHON_REFNANNY
539  #define CYTHON_REFNANNY 0
540#endif
541#if CYTHON_REFNANNY
542  typedef struct {
543    void (*INCREF)(void*, PyObject*, int);
544    void (*DECREF)(void*, PyObject*, int);
545    void (*GOTREF)(void*, PyObject*, int);
546    void (*GIVEREF)(void*, PyObject*, int);
547    void* (*SetupContext)(const char*, int, const char*);
548    void (*FinishContext)(void**);
549  } __Pyx_RefNannyAPIStruct;
550  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
551  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
552  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
553#ifdef WITH_THREAD
554  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
555          if (acquire_gil) { \
556              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
557              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
558              PyGILState_Release(__pyx_gilstate_save); \
559          } else { \
560              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
561          }
562#else
563  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
564          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
565#endif
566  #define __Pyx_RefNannyFinishContext() \
567          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
568  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
569  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
570  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
571  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
572  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
573  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
574  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
575  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
576#else
577  #define __Pyx_RefNannyDeclarations
578  #define __Pyx_RefNannySetupContext(name, acquire_gil)
579  #define __Pyx_RefNannyFinishContext()
580  #define __Pyx_INCREF(r) Py_INCREF(r)
581  #define __Pyx_DECREF(r) Py_DECREF(r)
582  #define __Pyx_GOTREF(r)
583  #define __Pyx_GIVEREF(r)
584  #define __Pyx_XINCREF(r) Py_XINCREF(r)
585  #define __Pyx_XDECREF(r) Py_XDECREF(r)
586  #define __Pyx_XGOTREF(r)
587  #define __Pyx_XGIVEREF(r)
588#endif
589#define __Pyx_XDECREF_SET(r, v) do {                            \
590        PyObject *tmp = (PyObject *) r;                         \
591        r = v; __Pyx_XDECREF(tmp);                              \
592    } while (0)
593#define __Pyx_DECREF_SET(r, v) do {                             \
594        PyObject *tmp = (PyObject *) r;                         \
595        r = v; __Pyx_DECREF(tmp);                               \
596    } while (0)
597#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
598#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
599
600#if CYTHON_COMPILING_IN_CPYTHON
601static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
602    PyTypeObject* tp = Py_TYPE(obj);
603    if (likely(tp->tp_getattro))
604        return tp->tp_getattro(obj, attr_name);
605#if PY_MAJOR_VERSION < 3
606    if (likely(tp->tp_getattr))
607        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
608#endif
609    return PyObject_GetAttr(obj, attr_name);
610}
611#else
612#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
613#endif
614
615static PyObject *__Pyx_GetBuiltinName(PyObject *name);
616
617static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
618
619static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
620    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
621    const char* function_name);
622
623static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
624    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
625
626#if CYTHON_COMPILING_IN_CPYTHON
627static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
628#else
629#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
630#endif
631
632static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
633static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
634
635static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
636
637#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
638    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
639    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
640    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
641               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
642#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
643    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
644    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
645    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
646static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
647                                                              int wraparound, int boundscheck);
648#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
649    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
650    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
651    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
652static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
653                                                              int wraparound, int boundscheck);
654static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
655static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
656                                                     int is_list, int wraparound, int boundscheck);
657
658static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
659
660static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
661
662static CYTHON_INLINE int __Pyx_IterFinish(void);
663
664static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
665
666static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
667
668#if CYTHON_COMPILING_IN_CPYTHON
669static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
670#endif
671
672static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
673
674#if CYTHON_COMPILING_IN_CPYTHON
675static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
676#else
677#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
678#endif
679
680static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb);
681static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb);
682
683static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb);
684
685#if CYTHON_COMPILING_IN_CPYTHON
686static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
687    PyListObject* L = (PyListObject*) list;
688    Py_ssize_t len = Py_SIZE(list);
689    if (likely(L->allocated > len) & likely(len > (L->allocated >> 1))) {
690        Py_INCREF(x);
691        PyList_SET_ITEM(list, len, x);
692        Py_SIZE(list) = len+1;
693        return 0;
694    }
695    return PyList_Append(list, x);
696}
697#else
698#define __Pyx_PyList_Append(L,x) PyList_Append(L,x)
699#endif
700
701static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
702
703static void* __Pyx_GetVtable(PyObject *dict);
704
705typedef struct {
706    int code_line;
707    PyCodeObject* code_object;
708} __Pyx_CodeObjectCacheEntry;
709struct __Pyx_CodeObjectCache {
710    int count;
711    int max_count;
712    __Pyx_CodeObjectCacheEntry* entries;
713};
714static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
715static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
716static PyCodeObject *__pyx_find_code_object(int code_line);
717static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
718
719static void __Pyx_AddTraceback(const char *funcname, int c_line,
720                               int py_line, const char *filename);
721
722static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
723
724static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
725
726static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
727
728static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
729
730static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
731
732static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *);
733
734#ifndef __PYX_FORCE_INIT_THREADS
735  #define __PYX_FORCE_INIT_THREADS 0
736#endif
737
738static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value);
739
740static int __Pyx_check_binary_version(void);
741
742#if !defined(__Pyx_PyIdentifier_FromString)
743#if PY_MAJOR_VERSION < 3
744  #define __Pyx_PyIdentifier_FromString(s) PyString_FromString(s)
745#else
746  #define __Pyx_PyIdentifier_FromString(s) PyUnicode_FromString(s)
747#endif
748#endif
749
750static PyObject *__Pyx_ImportModule(const char *name);
751
752static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name, size_t size, int strict);
753
754static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
755
756
757/* Module declarations from 'libc.string' */
758
759/* Module declarations from 'libc.stdlib' */
760
761/* Module declarations from 'zmq.backend.cython.libzmq' */
762
763/* Module declarations from 'zmq.backend.cython.context' */
764static PyTypeObject *__pyx_ptype_3zmq_7backend_6cython_7context_Context = 0;
765
766/* Module declarations from 'zmq.backend.cython.socket' */
767static PyTypeObject *__pyx_ptype_3zmq_7backend_6cython_6socket_Socket = 0;
768
769/* Module declarations from 'libc.errno' */
770
771/* Module declarations from 'cpython.version' */
772
773/* Module declarations from 'cpython.ref' */
774
775/* Module declarations from 'cpython.exc' */
776
777/* Module declarations from 'cpython.module' */
778
779/* Module declarations from 'cpython.mem' */
780
781/* Module declarations from 'cpython.tuple' */
782
783/* Module declarations from 'cpython.list' */
784
785/* Module declarations from 'libc.stdio' */
786
787/* Module declarations from 'cpython.object' */
788
789/* Module declarations from 'cpython.sequence' */
790
791/* Module declarations from 'cpython.mapping' */
792
793/* Module declarations from 'cpython.iterator' */
794
795/* Module declarations from '__builtin__' */
796
797/* Module declarations from 'cpython.type' */
798static PyTypeObject *__pyx_ptype_7cpython_4type_type = 0;
799
800/* Module declarations from 'cpython.number' */
801
802/* Module declarations from 'cpython.int' */
803
804/* Module declarations from '__builtin__' */
805
806/* Module declarations from 'cpython.bool' */
807static PyTypeObject *__pyx_ptype_7cpython_4bool_bool = 0;
808
809/* Module declarations from 'cpython.long' */
810
811/* Module declarations from 'cpython.float' */
812
813/* Module declarations from '__builtin__' */
814
815/* Module declarations from 'cpython.complex' */
816static PyTypeObject *__pyx_ptype_7cpython_7complex_complex = 0;
817
818/* Module declarations from 'cpython.string' */
819
820/* Module declarations from 'cpython.unicode' */
821
822/* Module declarations from 'cpython.dict' */
823
824/* Module declarations from 'cpython.instance' */
825
826/* Module declarations from 'cpython.function' */
827
828/* Module declarations from 'cpython.method' */
829
830/* Module declarations from 'cpython.weakref' */
831
832/* Module declarations from 'cpython.getargs' */
833
834/* Module declarations from 'cpython.pythread' */
835
836/* Module declarations from 'cpython.pystate' */
837
838/* Module declarations from 'cpython.cobject' */
839
840/* Module declarations from 'cpython.oldbuffer' */
841
842/* Module declarations from 'cpython.set' */
843
844/* Module declarations from 'cpython.buffer' */
845
846/* Module declarations from 'cpython.bytes' */
847
848/* Module declarations from 'cpython.pycapsule' */
849
850/* Module declarations from 'cpython' */
851
852/* Module declarations from 'zmq.backend.cython.checkrc' */
853static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(int); /*proto*/
854
855/* Module declarations from 'zmq.backend.cython._poll' */
856#define __Pyx_MODULE_NAME "zmq.backend.cython._poll"
857int __pyx_module_is_main_zmq__backend__cython___poll = 0;
858
859/* Implementation of 'zmq.backend.cython._poll' */
860static PyObject *__pyx_builtin_MemoryError;
861static PyObject *__pyx_builtin_range;
862static PyObject *__pyx_builtin_ValueError;
863static PyObject *__pyx_builtin_TypeError;
864static PyObject *__pyx_pf_3zmq_7backend_6cython_5_poll_zmq_poll(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sockets, long __pyx_v_timeout); /* proto */
865static char __pyx_k_i[] = "i";
866static char __pyx_k_s[] = "s";
867static char __pyx_k_rc[] = "rc";
868static char __pyx_k_all[] = "__all__";
869static char __pyx_k_sys[] = "sys";
870static char __pyx_k_main[] = "__main__";
871static char __pyx_k_test[] = "__test__";
872static char __pyx_k_Again[] = "Again";
873static char __pyx_k_int_t[] = "int_t";
874static char __pyx_k_range[] = "range";
875static char __pyx_k_events[] = "events";
876static char __pyx_k_fileno[] = "fileno";
877static char __pyx_k_import[] = "__import__";
878static char __pyx_k_results[] = "results";
879static char __pyx_k_revents[] = "revents";
880static char __pyx_k_sockets[] = "sockets";
881static char __pyx_k_timeout[] = "timeout";
882static char __pyx_k_ZMQError[] = "ZMQError";
883static char __pyx_k_nsockets[] = "nsockets";
884static char __pyx_k_zmq_poll[] = "zmq_poll";
885static char __pyx_k_TypeError[] = "TypeError";
886static char __pyx_k_pollitems[] = "pollitems";
887static char __pyx_k_zmq_error[] = "zmq.error";
888static char __pyx_k_ValueError[] = "ValueError";
889static char __pyx_k_pyx_vtable[] = "__pyx_vtable__";
890static char __pyx_k_MemoryError[] = "MemoryError";
891static char __pyx_k_version_info[] = "version_info";
892static char __pyx_k_current_socket[] = "current_socket";
893static char __pyx_k_ContextTerminated[] = "ContextTerminated";
894static char __pyx_k_zmq_backend_cython__poll[] = "zmq.backend.cython._poll";
895static char __pyx_k_Could_not_allocate_poll_items[] = "Could not allocate poll items";
896static char __pyx_k_private_tmp_pyzmq_release_zmq_b[] = "/private/tmp/pyzmq-release/zmq/backend/cython/_poll.pyx";
897static char __pyx_k_0MQ_polling_related_functions_an[] = "0MQ polling related functions and classes.";
898static char __pyx_k_Socket_must_be_a_0MQ_socket_an_i[] = "Socket must be a 0MQ socket, an integer fd or have a fileno() method: %r";
899static char __pyx_k_fileno_must_return_a_valid_integ[] = "fileno() must return a valid integer fd";
900static PyObject *__pyx_n_s_Again;
901static PyObject *__pyx_n_s_ContextTerminated;
902static PyObject *__pyx_kp_s_Could_not_allocate_poll_items;
903static PyObject *__pyx_n_s_MemoryError;
904static PyObject *__pyx_kp_s_Socket_must_be_a_0MQ_socket_an_i;
905static PyObject *__pyx_n_s_TypeError;
906static PyObject *__pyx_n_s_ValueError;
907static PyObject *__pyx_n_s_ZMQError;
908static PyObject *__pyx_n_s_all;
909static PyObject *__pyx_n_s_current_socket;
910static PyObject *__pyx_n_s_events;
911static PyObject *__pyx_n_s_fileno;
912static PyObject *__pyx_kp_s_fileno_must_return_a_valid_integ;
913static PyObject *__pyx_n_s_i;
914static PyObject *__pyx_n_s_import;
915static PyObject *__pyx_n_s_int_t;
916static PyObject *__pyx_n_s_main;
917static PyObject *__pyx_n_s_nsockets;
918static PyObject *__pyx_n_s_pollitems;
919static PyObject *__pyx_kp_s_private_tmp_pyzmq_release_zmq_b;
920static PyObject *__pyx_n_s_pyx_vtable;
921static PyObject *__pyx_n_s_range;
922static PyObject *__pyx_n_s_rc;
923static PyObject *__pyx_n_s_results;
924static PyObject *__pyx_n_s_revents;
925static PyObject *__pyx_n_s_s;
926static PyObject *__pyx_n_s_sockets;
927static PyObject *__pyx_n_s_sys;
928static PyObject *__pyx_n_s_test;
929static PyObject *__pyx_n_s_timeout;
930static PyObject *__pyx_n_s_version_info;
931static PyObject *__pyx_n_s_zmq_backend_cython__poll;
932static PyObject *__pyx_n_s_zmq_error;
933static PyObject *__pyx_n_s_zmq_poll;
934static PyObject *__pyx_int_3;
935static PyObject *__pyx_tuple_;
936static PyObject *__pyx_tuple__2;
937static PyObject *__pyx_tuple__3;
938static PyObject *__pyx_codeobj__4;
939
940/* "zmq/backend/cython/_poll.pyx":47
941 *
942 *
943 * def zmq_poll(sockets, long timeout=-1):             # <<<<<<<<<<<<<<
944 *     """zmq_poll(sockets, timeout=-1)
945 *
946 */
947
948/* Python wrapper */
949static PyObject *__pyx_pw_3zmq_7backend_6cython_5_poll_1zmq_poll(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
950static char __pyx_doc_3zmq_7backend_6cython_5_poll_zmq_poll[] = "zmq_poll(sockets, timeout=-1)\n\n    Poll a set of 0MQ sockets, native file descs. or sockets.\n\n    Parameters\n    ----------\n    sockets : list of tuples of (socket, flags)\n        Each element of this list is a two-tuple containing a socket\n        and a flags. The socket may be a 0MQ socket or any object with\n        a ``fileno()`` method. The flags can be zmq.POLLIN (for detecting\n        for incoming messages), zmq.POLLOUT (for detecting that send is OK)\n        or zmq.POLLIN|zmq.POLLOUT for detecting both.\n    timeout : int\n        The number of milliseconds to poll for. Negative means no timeout.\n    ";
951static PyMethodDef __pyx_mdef_3zmq_7backend_6cython_5_poll_1zmq_poll = {"zmq_poll", (PyCFunction)__pyx_pw_3zmq_7backend_6cython_5_poll_1zmq_poll, METH_VARARGS|METH_KEYWORDS, __pyx_doc_3zmq_7backend_6cython_5_poll_zmq_poll};
952static PyObject *__pyx_pw_3zmq_7backend_6cython_5_poll_1zmq_poll(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
953  PyObject *__pyx_v_sockets = 0;
954  long __pyx_v_timeout;
955  int __pyx_lineno = 0;
956  const char *__pyx_filename = NULL;
957  int __pyx_clineno = 0;
958  PyObject *__pyx_r = 0;
959  __Pyx_RefNannyDeclarations
960  __Pyx_RefNannySetupContext("zmq_poll (wrapper)", 0);
961  {
962    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_sockets,&__pyx_n_s_timeout,0};
963    PyObject* values[2] = {0,0};
964    if (unlikely(__pyx_kwds)) {
965      Py_ssize_t kw_args;
966      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
967      switch (pos_args) {
968        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
969        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
970        case  0: break;
971        default: goto __pyx_L5_argtuple_error;
972      }
973      kw_args = PyDict_Size(__pyx_kwds);
974      switch (pos_args) {
975        case  0:
976        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sockets)) != 0)) kw_args--;
977        else goto __pyx_L5_argtuple_error;
978        case  1:
979        if (kw_args > 0) {
980          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_timeout);
981          if (value) { values[1] = value; kw_args--; }
982        }
983      }
984      if (unlikely(kw_args > 0)) {
985        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "zmq_poll") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
986      }
987    } else {
988      switch (PyTuple_GET_SIZE(__pyx_args)) {
989        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
990        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
991        break;
992        default: goto __pyx_L5_argtuple_error;
993      }
994    }
995    __pyx_v_sockets = values[0];
996    if (values[1]) {
997      __pyx_v_timeout = __Pyx_PyInt_As_long(values[1]); if (unlikely((__pyx_v_timeout == (long)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
998    } else {
999      __pyx_v_timeout = ((long)-1);
1000    }
1001  }
1002  goto __pyx_L4_argument_unpacking_done;
1003  __pyx_L5_argtuple_error:;
1004  __Pyx_RaiseArgtupleInvalid("zmq_poll", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
1005  __pyx_L3_error:;
1006  __Pyx_AddTraceback("zmq.backend.cython._poll.zmq_poll", __pyx_clineno, __pyx_lineno, __pyx_filename);
1007  __Pyx_RefNannyFinishContext();
1008  return NULL;
1009  __pyx_L4_argument_unpacking_done:;
1010  __pyx_r = __pyx_pf_3zmq_7backend_6cython_5_poll_zmq_poll(__pyx_self, __pyx_v_sockets, __pyx_v_timeout);
1011
1012  /* function exit code */
1013  __Pyx_RefNannyFinishContext();
1014  return __pyx_r;
1015}
1016
1017static PyObject *__pyx_pf_3zmq_7backend_6cython_5_poll_zmq_poll(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_sockets, long __pyx_v_timeout) {
1018  int __pyx_v_rc;
1019  int __pyx_v_i;
1020  zmq_pollitem_t *__pyx_v_pollitems;
1021  int __pyx_v_nsockets;
1022  PyObject *__pyx_v_s = NULL;
1023  PyObject *__pyx_v_events = NULL;
1024  PyObject *__pyx_v_fileno = NULL;
1025  PyObject *__pyx_v_results = NULL;
1026  short __pyx_v_revents;
1027  PyObject *__pyx_r = NULL;
1028  __Pyx_RefNannyDeclarations
1029  Py_ssize_t __pyx_t_1;
1030  int __pyx_t_2;
1031  PyObject *__pyx_t_3 = NULL;
1032  int __pyx_t_4;
1033  int __pyx_t_5;
1034  PyObject *__pyx_t_6 = NULL;
1035  PyObject *__pyx_t_7 = NULL;
1036  PyObject *__pyx_t_8 = NULL;
1037  PyObject *(*__pyx_t_9)(PyObject *);
1038  int __pyx_t_10;
1039  void *__pyx_t_11;
1040  short __pyx_t_12;
1041  int __pyx_t_13;
1042  PyObject *__pyx_t_14 = NULL;
1043  PyObject *__pyx_t_15 = NULL;
1044  PyObject *__pyx_t_16 = NULL;
1045  int __pyx_t_17;
1046  int __pyx_lineno = 0;
1047  const char *__pyx_filename = NULL;
1048  int __pyx_clineno = 0;
1049  __Pyx_RefNannySetupContext("zmq_poll", 0);
1050
1051  /* "zmq/backend/cython/_poll.pyx":64
1052 *     """
1053 *     cdef int rc, i
1054 *     cdef zmq_pollitem_t *pollitems = NULL             # <<<<<<<<<<<<<<
1055 *     cdef int nsockets = <int>len(sockets)
1056 *     cdef Socket current_socket
1057 */
1058  __pyx_v_pollitems = NULL;
1059
1060  /* "zmq/backend/cython/_poll.pyx":65
1061 *     cdef int rc, i
1062 *     cdef zmq_pollitem_t *pollitems = NULL
1063 *     cdef int nsockets = <int>len(sockets)             # <<<<<<<<<<<<<<
1064 *     cdef Socket current_socket
1065 *
1066 */
1067  __pyx_t_1 = PyObject_Length(__pyx_v_sockets); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1068  __pyx_v_nsockets = ((int)__pyx_t_1);
1069
1070  /* "zmq/backend/cython/_poll.pyx":68
1071 *     cdef Socket current_socket
1072 *
1073 *     if nsockets == 0:             # <<<<<<<<<<<<<<
1074 *         return []
1075 *
1076 */
1077  __pyx_t_2 = ((__pyx_v_nsockets == 0) != 0);
1078  if (__pyx_t_2) {
1079
1080    /* "zmq/backend/cython/_poll.pyx":69
1081 *
1082 *     if nsockets == 0:
1083 *         return []             # <<<<<<<<<<<<<<
1084 *
1085 *     pollitems = <zmq_pollitem_t *>malloc(nsockets*sizeof(zmq_pollitem_t))
1086 */
1087    __Pyx_XDECREF(__pyx_r);
1088    __pyx_t_3 = PyList_New(0); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1089    __Pyx_GOTREF(__pyx_t_3);
1090    __pyx_r = __pyx_t_3;
1091    __pyx_t_3 = 0;
1092    goto __pyx_L0;
1093  }
1094
1095  /* "zmq/backend/cython/_poll.pyx":71
1096 *         return []
1097 *
1098 *     pollitems = <zmq_pollitem_t *>malloc(nsockets*sizeof(zmq_pollitem_t))             # <<<<<<<<<<<<<<
1099 *     if pollitems == NULL:
1100 *         raise MemoryError("Could not allocate poll items")
1101 */
1102  __pyx_v_pollitems = ((zmq_pollitem_t *)malloc((__pyx_v_nsockets * (sizeof(zmq_pollitem_t)))));
1103
1104  /* "zmq/backend/cython/_poll.pyx":72
1105 *
1106 *     pollitems = <zmq_pollitem_t *>malloc(nsockets*sizeof(zmq_pollitem_t))
1107 *     if pollitems == NULL:             # <<<<<<<<<<<<<<
1108 *         raise MemoryError("Could not allocate poll items")
1109 *
1110 */
1111  __pyx_t_2 = ((__pyx_v_pollitems == NULL) != 0);
1112  if (__pyx_t_2) {
1113
1114    /* "zmq/backend/cython/_poll.pyx":73
1115 *     pollitems = <zmq_pollitem_t *>malloc(nsockets*sizeof(zmq_pollitem_t))
1116 *     if pollitems == NULL:
1117 *         raise MemoryError("Could not allocate poll items")             # <<<<<<<<<<<<<<
1118 *
1119 *     if ZMQ_VERSION_MAJOR < 3:
1120 */
1121    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_MemoryError, __pyx_tuple_, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1122    __Pyx_GOTREF(__pyx_t_3);
1123    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
1124    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1125    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1126  }
1127
1128  /* "zmq/backend/cython/_poll.pyx":75
1129 *         raise MemoryError("Could not allocate poll items")
1130 *
1131 *     if ZMQ_VERSION_MAJOR < 3:             # <<<<<<<<<<<<<<
1132 *         # timeout is us in 2.x, ms in 3.x
1133 *         # expected input is ms (matches 3.x)
1134 */
1135  __pyx_t_2 = ((ZMQ_VERSION_MAJOR < 3) != 0);
1136  if (__pyx_t_2) {
1137
1138    /* "zmq/backend/cython/_poll.pyx":78
1139 *         # timeout is us in 2.x, ms in 3.x
1140 *         # expected input is ms (matches 3.x)
1141 *         timeout = 1000*timeout             # <<<<<<<<<<<<<<
1142 *
1143 *     for i in range(nsockets):
1144 */
1145    __pyx_v_timeout = (1000 * __pyx_v_timeout);
1146    goto __pyx_L5;
1147  }
1148  __pyx_L5:;
1149
1150  /* "zmq/backend/cython/_poll.pyx":80
1151 *         timeout = 1000*timeout
1152 *
1153 *     for i in range(nsockets):             # <<<<<<<<<<<<<<
1154 *         s, events = sockets[i]
1155 *         if isinstance(s, Socket):
1156 */
1157  __pyx_t_4 = __pyx_v_nsockets;
1158  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
1159    __pyx_v_i = __pyx_t_5;
1160
1161    /* "zmq/backend/cython/_poll.pyx":81
1162 *
1163 *     for i in range(nsockets):
1164 *         s, events = sockets[i]             # <<<<<<<<<<<<<<
1165 *         if isinstance(s, Socket):
1166 *             pollitems[i].socket = (<Socket>s).handle
1167 */
1168    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_sockets, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1169    __Pyx_GOTREF(__pyx_t_3);
1170    if ((likely(PyTuple_CheckExact(__pyx_t_3))) || (PyList_CheckExact(__pyx_t_3))) {
1171      PyObject* sequence = __pyx_t_3;
1172      #if CYTHON_COMPILING_IN_CPYTHON
1173      Py_ssize_t size = Py_SIZE(sequence);
1174      #else
1175      Py_ssize_t size = PySequence_Size(sequence);
1176      #endif
1177      if (unlikely(size != 2)) {
1178        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
1179        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
1180        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1181      }
1182      #if CYTHON_COMPILING_IN_CPYTHON
1183      if (likely(PyTuple_CheckExact(sequence))) {
1184        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 0);
1185        __pyx_t_7 = PyTuple_GET_ITEM(sequence, 1);
1186      } else {
1187        __pyx_t_6 = PyList_GET_ITEM(sequence, 0);
1188        __pyx_t_7 = PyList_GET_ITEM(sequence, 1);
1189      }
1190      __Pyx_INCREF(__pyx_t_6);
1191      __Pyx_INCREF(__pyx_t_7);
1192      #else
1193      __pyx_t_6 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1194      __Pyx_GOTREF(__pyx_t_6);
1195      __pyx_t_7 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1196      __Pyx_GOTREF(__pyx_t_7);
1197      #endif
1198      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1199    } else {
1200      Py_ssize_t index = -1;
1201      __pyx_t_8 = PyObject_GetIter(__pyx_t_3); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1202      __Pyx_GOTREF(__pyx_t_8);
1203      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1204      __pyx_t_9 = Py_TYPE(__pyx_t_8)->tp_iternext;
1205      index = 0; __pyx_t_6 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_6)) goto __pyx_L8_unpacking_failed;
1206      __Pyx_GOTREF(__pyx_t_6);
1207      index = 1; __pyx_t_7 = __pyx_t_9(__pyx_t_8); if (unlikely(!__pyx_t_7)) goto __pyx_L8_unpacking_failed;
1208      __Pyx_GOTREF(__pyx_t_7);
1209      if (__Pyx_IternextUnpackEndCheck(__pyx_t_9(__pyx_t_8), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1210      __pyx_t_9 = NULL;
1211      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1212      goto __pyx_L9_unpacking_done;
1213      __pyx_L8_unpacking_failed:;
1214      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1215      __pyx_t_9 = NULL;
1216      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
1217      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1218      __pyx_L9_unpacking_done:;
1219    }
1220    __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_6);
1221    __pyx_t_6 = 0;
1222    __Pyx_XDECREF_SET(__pyx_v_events, __pyx_t_7);
1223    __pyx_t_7 = 0;
1224
1225    /* "zmq/backend/cython/_poll.pyx":82
1226 *     for i in range(nsockets):
1227 *         s, events = sockets[i]
1228 *         if isinstance(s, Socket):             # <<<<<<<<<<<<<<
1229 *             pollitems[i].socket = (<Socket>s).handle
1230 *             pollitems[i].events = events
1231 */
1232    __pyx_t_2 = __Pyx_TypeCheck(__pyx_v_s, ((PyObject*)__pyx_ptype_3zmq_7backend_6cython_6socket_Socket));
1233    __pyx_t_10 = (__pyx_t_2 != 0);
1234    if (__pyx_t_10) {
1235
1236      /* "zmq/backend/cython/_poll.pyx":83
1237 *         s, events = sockets[i]
1238 *         if isinstance(s, Socket):
1239 *             pollitems[i].socket = (<Socket>s).handle             # <<<<<<<<<<<<<<
1240 *             pollitems[i].events = events
1241 *             pollitems[i].revents = 0
1242 */
1243      __pyx_t_11 = ((struct __pyx_obj_3zmq_7backend_6cython_6socket_Socket *)__pyx_v_s)->handle;
1244      (__pyx_v_pollitems[__pyx_v_i]).socket = __pyx_t_11;
1245
1246      /* "zmq/backend/cython/_poll.pyx":84
1247 *         if isinstance(s, Socket):
1248 *             pollitems[i].socket = (<Socket>s).handle
1249 *             pollitems[i].events = events             # <<<<<<<<<<<<<<
1250 *             pollitems[i].revents = 0
1251 *         elif isinstance(s, int_t):
1252 */
1253      __pyx_t_12 = __Pyx_PyInt_As_short(__pyx_v_events); if (unlikely((__pyx_t_12 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1254      (__pyx_v_pollitems[__pyx_v_i]).events = __pyx_t_12;
1255
1256      /* "zmq/backend/cython/_poll.pyx":85
1257 *             pollitems[i].socket = (<Socket>s).handle
1258 *             pollitems[i].events = events
1259 *             pollitems[i].revents = 0             # <<<<<<<<<<<<<<
1260 *         elif isinstance(s, int_t):
1261 *             pollitems[i].socket = NULL
1262 */
1263      (__pyx_v_pollitems[__pyx_v_i]).revents = 0;
1264      goto __pyx_L10;
1265    }
1266
1267    /* "zmq/backend/cython/_poll.pyx":86
1268 *             pollitems[i].events = events
1269 *             pollitems[i].revents = 0
1270 *         elif isinstance(s, int_t):             # <<<<<<<<<<<<<<
1271 *             pollitems[i].socket = NULL
1272 *             pollitems[i].fd = s
1273 */
1274    __pyx_t_3 = __Pyx_GetModuleGlobalName(__pyx_n_s_int_t); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1275    __Pyx_GOTREF(__pyx_t_3);
1276    __pyx_t_10 = PyObject_IsInstance(__pyx_v_s, __pyx_t_3); if (unlikely(__pyx_t_10 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 86; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1277    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1278    __pyx_t_2 = (__pyx_t_10 != 0);
1279    if (__pyx_t_2) {
1280
1281      /* "zmq/backend/cython/_poll.pyx":87
1282 *             pollitems[i].revents = 0
1283 *         elif isinstance(s, int_t):
1284 *             pollitems[i].socket = NULL             # <<<<<<<<<<<<<<
1285 *             pollitems[i].fd = s
1286 *             pollitems[i].events = events
1287 */
1288      (__pyx_v_pollitems[__pyx_v_i]).socket = NULL;
1289
1290      /* "zmq/backend/cython/_poll.pyx":88
1291 *         elif isinstance(s, int_t):
1292 *             pollitems[i].socket = NULL
1293 *             pollitems[i].fd = s             # <<<<<<<<<<<<<<
1294 *             pollitems[i].events = events
1295 *             pollitems[i].revents = 0
1296 */
1297      __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_s); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1298      (__pyx_v_pollitems[__pyx_v_i]).fd = __pyx_t_13;
1299
1300      /* "zmq/backend/cython/_poll.pyx":89
1301 *             pollitems[i].socket = NULL
1302 *             pollitems[i].fd = s
1303 *             pollitems[i].events = events             # <<<<<<<<<<<<<<
1304 *             pollitems[i].revents = 0
1305 *         elif hasattr(s, 'fileno'):
1306 */
1307      __pyx_t_12 = __Pyx_PyInt_As_short(__pyx_v_events); if (unlikely((__pyx_t_12 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1308      (__pyx_v_pollitems[__pyx_v_i]).events = __pyx_t_12;
1309
1310      /* "zmq/backend/cython/_poll.pyx":90
1311 *             pollitems[i].fd = s
1312 *             pollitems[i].events = events
1313 *             pollitems[i].revents = 0             # <<<<<<<<<<<<<<
1314 *         elif hasattr(s, 'fileno'):
1315 *             try:
1316 */
1317      (__pyx_v_pollitems[__pyx_v_i]).revents = 0;
1318      goto __pyx_L10;
1319    }
1320
1321    /* "zmq/backend/cython/_poll.pyx":91
1322 *             pollitems[i].events = events
1323 *             pollitems[i].revents = 0
1324 *         elif hasattr(s, 'fileno'):             # <<<<<<<<<<<<<<
1325 *             try:
1326 *                 fileno = int(s.fileno())
1327 */
1328    __pyx_t_2 = PyObject_HasAttr(__pyx_v_s, __pyx_n_s_fileno); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1329    __pyx_t_10 = (__pyx_t_2 != 0);
1330    if (__pyx_t_10) {
1331
1332      /* "zmq/backend/cython/_poll.pyx":92
1333 *             pollitems[i].revents = 0
1334 *         elif hasattr(s, 'fileno'):
1335 *             try:             # <<<<<<<<<<<<<<
1336 *                 fileno = int(s.fileno())
1337 *             except:
1338 */
1339      {
1340        __Pyx_ExceptionSave(&__pyx_t_14, &__pyx_t_15, &__pyx_t_16);
1341        __Pyx_XGOTREF(__pyx_t_14);
1342        __Pyx_XGOTREF(__pyx_t_15);
1343        __Pyx_XGOTREF(__pyx_t_16);
1344        /*try:*/ {
1345
1346          /* "zmq/backend/cython/_poll.pyx":93
1347 *         elif hasattr(s, 'fileno'):
1348 *             try:
1349 *                 fileno = int(s.fileno())             # <<<<<<<<<<<<<<
1350 *             except:
1351 *                 free(pollitems)
1352 */
1353          __pyx_t_7 = __Pyx_PyObject_GetAttrStr(__pyx_v_s, __pyx_n_s_fileno); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
1354          __Pyx_GOTREF(__pyx_t_7);
1355          __pyx_t_6 = NULL;
1356          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_7))) {
1357            __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
1358            if (likely(__pyx_t_6)) {
1359              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
1360              __Pyx_INCREF(__pyx_t_6);
1361              __Pyx_INCREF(function);
1362              __Pyx_DECREF_SET(__pyx_t_7, function);
1363            }
1364          }
1365          if (__pyx_t_6) {
1366            __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_6); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
1367            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1368          } else {
1369            __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_t_7); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
1370          }
1371          __Pyx_GOTREF(__pyx_t_3);
1372          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1373          __pyx_t_7 = PyNumber_Int(__pyx_t_3); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 93; __pyx_clineno = __LINE__; goto __pyx_L11_error;}
1374          __Pyx_GOTREF(__pyx_t_7);
1375          __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1376          __Pyx_XDECREF_SET(__pyx_v_fileno, __pyx_t_7);
1377          __pyx_t_7 = 0;
1378        }
1379        /*else:*/ {
1380
1381          /* "zmq/backend/cython/_poll.pyx":98
1382 *                 raise ValueError('fileno() must return a valid integer fd')
1383 *             else:
1384 *                 pollitems[i].socket = NULL             # <<<<<<<<<<<<<<
1385 *                 pollitems[i].fd = fileno
1386 *                 pollitems[i].events = events
1387 */
1388          (__pyx_v_pollitems[__pyx_v_i]).socket = NULL;
1389
1390          /* "zmq/backend/cython/_poll.pyx":99
1391 *             else:
1392 *                 pollitems[i].socket = NULL
1393 *                 pollitems[i].fd = fileno             # <<<<<<<<<<<<<<
1394 *                 pollitems[i].events = events
1395 *                 pollitems[i].revents = 0
1396 */
1397          __pyx_t_13 = __Pyx_PyInt_As_int(__pyx_v_fileno); if (unlikely((__pyx_t_13 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 99; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
1398          (__pyx_v_pollitems[__pyx_v_i]).fd = __pyx_t_13;
1399
1400          /* "zmq/backend/cython/_poll.pyx":100
1401 *                 pollitems[i].socket = NULL
1402 *                 pollitems[i].fd = fileno
1403 *                 pollitems[i].events = events             # <<<<<<<<<<<<<<
1404 *                 pollitems[i].revents = 0
1405 *         else:
1406 */
1407          __pyx_t_12 = __Pyx_PyInt_As_short(__pyx_v_events); if (unlikely((__pyx_t_12 == (short)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 100; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
1408          (__pyx_v_pollitems[__pyx_v_i]).events = __pyx_t_12;
1409
1410          /* "zmq/backend/cython/_poll.pyx":101
1411 *                 pollitems[i].fd = fileno
1412 *                 pollitems[i].events = events
1413 *                 pollitems[i].revents = 0             # <<<<<<<<<<<<<<
1414 *         else:
1415 *             free(pollitems)
1416 */
1417          (__pyx_v_pollitems[__pyx_v_i]).revents = 0;
1418        }
1419        __Pyx_XDECREF(__pyx_t_14); __pyx_t_14 = 0;
1420        __Pyx_XDECREF(__pyx_t_15); __pyx_t_15 = 0;
1421        __Pyx_XDECREF(__pyx_t_16); __pyx_t_16 = 0;
1422        goto __pyx_L18_try_end;
1423        __pyx_L11_error:;
1424        __Pyx_XDECREF(__pyx_t_8); __pyx_t_8 = 0;
1425        __Pyx_XDECREF(__pyx_t_6); __pyx_t_6 = 0;
1426        __Pyx_XDECREF(__pyx_t_3); __pyx_t_3 = 0;
1427        __Pyx_XDECREF(__pyx_t_7); __pyx_t_7 = 0;
1428
1429        /* "zmq/backend/cython/_poll.pyx":94
1430 *             try:
1431 *                 fileno = int(s.fileno())
1432 *             except:             # <<<<<<<<<<<<<<
1433 *                 free(pollitems)
1434 *                 raise ValueError('fileno() must return a valid integer fd')
1435 */
1436        /*except:*/ {
1437          __Pyx_AddTraceback("zmq.backend.cython._poll.zmq_poll", __pyx_clineno, __pyx_lineno, __pyx_filename);
1438          if (__Pyx_GetException(&__pyx_t_7, &__pyx_t_3, &__pyx_t_6) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
1439          __Pyx_GOTREF(__pyx_t_7);
1440          __Pyx_GOTREF(__pyx_t_3);
1441          __Pyx_GOTREF(__pyx_t_6);
1442
1443          /* "zmq/backend/cython/_poll.pyx":95
1444 *                 fileno = int(s.fileno())
1445 *             except:
1446 *                 free(pollitems)             # <<<<<<<<<<<<<<
1447 *                 raise ValueError('fileno() must return a valid integer fd')
1448 *             else:
1449 */
1450          free(__pyx_v_pollitems);
1451
1452          /* "zmq/backend/cython/_poll.pyx":96
1453 *             except:
1454 *                 free(pollitems)
1455 *                 raise ValueError('fileno() must return a valid integer fd')             # <<<<<<<<<<<<<<
1456 *             else:
1457 *                 pollitems[i].socket = NULL
1458 */
1459          __pyx_t_8 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
1460          __Pyx_GOTREF(__pyx_t_8);
1461          __Pyx_Raise(__pyx_t_8, 0, 0, 0);
1462          __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
1463          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L13_except_error;}
1464        }
1465        __pyx_L13_except_error:;
1466        __Pyx_XGIVEREF(__pyx_t_14);
1467        __Pyx_XGIVEREF(__pyx_t_15);
1468        __Pyx_XGIVEREF(__pyx_t_16);
1469        __Pyx_ExceptionReset(__pyx_t_14, __pyx_t_15, __pyx_t_16);
1470        goto __pyx_L1_error;
1471        __pyx_L18_try_end:;
1472      }
1473      goto __pyx_L10;
1474    }
1475    /*else*/ {
1476
1477      /* "zmq/backend/cython/_poll.pyx":103
1478 *                 pollitems[i].revents = 0
1479 *         else:
1480 *             free(pollitems)             # <<<<<<<<<<<<<<
1481 *             raise TypeError(
1482 *                 "Socket must be a 0MQ socket, an integer fd or have "
1483 */
1484      free(__pyx_v_pollitems);
1485
1486      /* "zmq/backend/cython/_poll.pyx":106
1487 *             raise TypeError(
1488 *                 "Socket must be a 0MQ socket, an integer fd or have "
1489 *                 "a fileno() method: %r" % s             # <<<<<<<<<<<<<<
1490 *             )
1491 *
1492 */
1493      __pyx_t_6 = __Pyx_PyString_Format(__pyx_kp_s_Socket_must_be_a_0MQ_socket_an_i, __pyx_v_s); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 106; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1494      __Pyx_GOTREF(__pyx_t_6);
1495
1496      /* "zmq/backend/cython/_poll.pyx":104
1497 *         else:
1498 *             free(pollitems)
1499 *             raise TypeError(             # <<<<<<<<<<<<<<
1500 *                 "Socket must be a 0MQ socket, an integer fd or have "
1501 *                 "a fileno() method: %r" % s
1502 */
1503      __pyx_t_3 = PyTuple_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1504      __Pyx_GOTREF(__pyx_t_3);
1505      PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_6);
1506      __Pyx_GIVEREF(__pyx_t_6);
1507      __pyx_t_6 = 0;
1508      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_TypeError, __pyx_t_3, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1509      __Pyx_GOTREF(__pyx_t_6);
1510      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1511      __Pyx_Raise(__pyx_t_6, 0, 0, 0);
1512      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1513      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1514    }
1515    __pyx_L10:;
1516  }
1517
1518  /* "zmq/backend/cython/_poll.pyx":110
1519 *
1520 *
1521 *     with nogil:             # <<<<<<<<<<<<<<
1522 *         rc = zmq_poll_c(pollitems, nsockets, timeout)
1523 *
1524 */
1525  {
1526      #ifdef WITH_THREAD
1527      PyThreadState *_save;
1528      Py_UNBLOCK_THREADS
1529      #endif
1530      /*try:*/ {
1531
1532        /* "zmq/backend/cython/_poll.pyx":111
1533 *
1534 *     with nogil:
1535 *         rc = zmq_poll_c(pollitems, nsockets, timeout)             # <<<<<<<<<<<<<<
1536 *
1537 *     if rc < 0:
1538 */
1539        __pyx_v_rc = zmq_poll(__pyx_v_pollitems, __pyx_v_nsockets, __pyx_v_timeout);
1540      }
1541
1542      /* "zmq/backend/cython/_poll.pyx":110
1543 *
1544 *
1545 *     with nogil:             # <<<<<<<<<<<<<<
1546 *         rc = zmq_poll_c(pollitems, nsockets, timeout)
1547 *
1548 */
1549      /*finally:*/ {
1550        /*normal exit:*/{
1551          #ifdef WITH_THREAD
1552          Py_BLOCK_THREADS
1553          #endif
1554          goto __pyx_L23;
1555        }
1556        __pyx_L23:;
1557      }
1558  }
1559
1560  /* "zmq/backend/cython/_poll.pyx":113
1561 *         rc = zmq_poll_c(pollitems, nsockets, timeout)
1562 *
1563 *     if rc < 0:             # <<<<<<<<<<<<<<
1564 *         free(pollitems)
1565 *         _check_rc(rc)
1566 */
1567  __pyx_t_10 = ((__pyx_v_rc < 0) != 0);
1568  if (__pyx_t_10) {
1569
1570    /* "zmq/backend/cython/_poll.pyx":114
1571 *
1572 *     if rc < 0:
1573 *         free(pollitems)             # <<<<<<<<<<<<<<
1574 *         _check_rc(rc)
1575 *
1576 */
1577    free(__pyx_v_pollitems);
1578
1579    /* "zmq/backend/cython/_poll.pyx":115
1580 *     if rc < 0:
1581 *         free(pollitems)
1582 *         _check_rc(rc)             # <<<<<<<<<<<<<<
1583 *
1584 *     results = []
1585 */
1586    __pyx_t_4 = __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(__pyx_v_rc); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1587    goto __pyx_L24;
1588  }
1589  __pyx_L24:;
1590
1591  /* "zmq/backend/cython/_poll.pyx":117
1592 *         _check_rc(rc)
1593 *
1594 *     results = []             # <<<<<<<<<<<<<<
1595 *     for i in range(nsockets):
1596 *         revents = pollitems[i].revents
1597 */
1598  __pyx_t_6 = PyList_New(0); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1599  __Pyx_GOTREF(__pyx_t_6);
1600  __pyx_v_results = ((PyObject*)__pyx_t_6);
1601  __pyx_t_6 = 0;
1602
1603  /* "zmq/backend/cython/_poll.pyx":118
1604 *
1605 *     results = []
1606 *     for i in range(nsockets):             # <<<<<<<<<<<<<<
1607 *         revents = pollitems[i].revents
1608 *         # for compatibility with select.poll:
1609 */
1610  __pyx_t_4 = __pyx_v_nsockets;
1611  for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
1612    __pyx_v_i = __pyx_t_5;
1613
1614    /* "zmq/backend/cython/_poll.pyx":119
1615 *     results = []
1616 *     for i in range(nsockets):
1617 *         revents = pollitems[i].revents             # <<<<<<<<<<<<<<
1618 *         # for compatibility with select.poll:
1619 *         # - only return sockets with non-zero status
1620 */
1621    __pyx_t_12 = (__pyx_v_pollitems[__pyx_v_i]).revents;
1622    __pyx_v_revents = __pyx_t_12;
1623
1624    /* "zmq/backend/cython/_poll.pyx":123
1625 *         # - only return sockets with non-zero status
1626 *         # - return the fd for plain sockets
1627 *         if revents > 0:             # <<<<<<<<<<<<<<
1628 *             if pollitems[i].socket != NULL:
1629 *                 s = sockets[i][0]
1630 */
1631    __pyx_t_10 = ((__pyx_v_revents > 0) != 0);
1632    if (__pyx_t_10) {
1633
1634      /* "zmq/backend/cython/_poll.pyx":124
1635 *         # - return the fd for plain sockets
1636 *         if revents > 0:
1637 *             if pollitems[i].socket != NULL:             # <<<<<<<<<<<<<<
1638 *                 s = sockets[i][0]
1639 *             else:
1640 */
1641      __pyx_t_10 = (((__pyx_v_pollitems[__pyx_v_i]).socket != NULL) != 0);
1642      if (__pyx_t_10) {
1643
1644        /* "zmq/backend/cython/_poll.pyx":125
1645 *         if revents > 0:
1646 *             if pollitems[i].socket != NULL:
1647 *                 s = sockets[i][0]             # <<<<<<<<<<<<<<
1648 *             else:
1649 *                 s = pollitems[i].fd
1650 */
1651        __pyx_t_6 = __Pyx_GetItemInt(__pyx_v_sockets, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1652        __Pyx_GOTREF(__pyx_t_6);
1653        __pyx_t_3 = __Pyx_GetItemInt(__pyx_t_6, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 125; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
1654        __Pyx_GOTREF(__pyx_t_3);
1655        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1656        __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
1657        __pyx_t_3 = 0;
1658        goto __pyx_L28;
1659      }
1660      /*else*/ {
1661
1662        /* "zmq/backend/cython/_poll.pyx":127
1663 *                 s = sockets[i][0]
1664 *             else:
1665 *                 s = pollitems[i].fd             # <<<<<<<<<<<<<<
1666 *             results.append((s, revents))
1667 *
1668 */
1669        __pyx_t_3 = __Pyx_PyInt_From_int((__pyx_v_pollitems[__pyx_v_i]).fd); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 127; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1670        __Pyx_GOTREF(__pyx_t_3);
1671        __Pyx_XDECREF_SET(__pyx_v_s, __pyx_t_3);
1672        __pyx_t_3 = 0;
1673      }
1674      __pyx_L28:;
1675
1676      /* "zmq/backend/cython/_poll.pyx":128
1677 *             else:
1678 *                 s = pollitems[i].fd
1679 *             results.append((s, revents))             # <<<<<<<<<<<<<<
1680 *
1681 *     free(pollitems)
1682 */
1683      __pyx_t_3 = __Pyx_PyInt_From_short(__pyx_v_revents); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1684      __Pyx_GOTREF(__pyx_t_3);
1685      __pyx_t_6 = PyTuple_New(2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1686      __Pyx_GOTREF(__pyx_t_6);
1687      __Pyx_INCREF(__pyx_v_s);
1688      PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_v_s);
1689      __Pyx_GIVEREF(__pyx_v_s);
1690      PyTuple_SET_ITEM(__pyx_t_6, 1, __pyx_t_3);
1691      __Pyx_GIVEREF(__pyx_t_3);
1692      __pyx_t_3 = 0;
1693      __pyx_t_17 = __Pyx_PyList_Append(__pyx_v_results, __pyx_t_6); if (unlikely(__pyx_t_17 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1694      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1695      goto __pyx_L27;
1696    }
1697    __pyx_L27:;
1698  }
1699
1700  /* "zmq/backend/cython/_poll.pyx":130
1701 *             results.append((s, revents))
1702 *
1703 *     free(pollitems)             # <<<<<<<<<<<<<<
1704 *     return results
1705 *
1706 */
1707  free(__pyx_v_pollitems);
1708
1709  /* "zmq/backend/cython/_poll.pyx":131
1710 *
1711 *     free(pollitems)
1712 *     return results             # <<<<<<<<<<<<<<
1713 *
1714 * #-----------------------------------------------------------------------------
1715 */
1716  __Pyx_XDECREF(__pyx_r);
1717  __Pyx_INCREF(__pyx_v_results);
1718  __pyx_r = __pyx_v_results;
1719  goto __pyx_L0;
1720
1721  /* "zmq/backend/cython/_poll.pyx":47
1722 *
1723 *
1724 * def zmq_poll(sockets, long timeout=-1):             # <<<<<<<<<<<<<<
1725 *     """zmq_poll(sockets, timeout=-1)
1726 *
1727 */
1728
1729  /* function exit code */
1730  __pyx_L1_error:;
1731  __Pyx_XDECREF(__pyx_t_3);
1732  __Pyx_XDECREF(__pyx_t_6);
1733  __Pyx_XDECREF(__pyx_t_7);
1734  __Pyx_XDECREF(__pyx_t_8);
1735  __Pyx_AddTraceback("zmq.backend.cython._poll.zmq_poll", __pyx_clineno, __pyx_lineno, __pyx_filename);
1736  __pyx_r = NULL;
1737  __pyx_L0:;
1738  __Pyx_XDECREF(__pyx_v_s);
1739  __Pyx_XDECREF(__pyx_v_events);
1740  __Pyx_XDECREF(__pyx_v_fileno);
1741  __Pyx_XDECREF(__pyx_v_results);
1742  __Pyx_XGIVEREF(__pyx_r);
1743  __Pyx_RefNannyFinishContext();
1744  return __pyx_r;
1745}
1746
1747/* "zmq/backend/cython/checkrc.pxd":5
1748 * from libzmq cimport zmq_errno, ZMQ_ETERM
1749 *
1750 * cdef inline int _check_rc(int rc) except -1:             # <<<<<<<<<<<<<<
1751 *     """internal utility for checking zmq return condition
1752 *
1753 */
1754
1755static CYTHON_INLINE int __pyx_f_3zmq_7backend_6cython_7checkrc__check_rc(int __pyx_v_rc) {
1756  int __pyx_v_errno;
1757  PyObject *__pyx_v_Again = NULL;
1758  PyObject *__pyx_v_ContextTerminated = NULL;
1759  PyObject *__pyx_v_ZMQError = NULL;
1760  int __pyx_r;
1761  __Pyx_RefNannyDeclarations
1762  int __pyx_t_1;
1763  int __pyx_t_2;
1764  PyObject *__pyx_t_3 = NULL;
1765  PyObject *__pyx_t_4 = NULL;
1766  PyObject *__pyx_t_5 = NULL;
1767  PyObject *__pyx_t_6 = NULL;
1768  PyObject *__pyx_t_7 = NULL;
1769  int __pyx_lineno = 0;
1770  const char *__pyx_filename = NULL;
1771  int __pyx_clineno = 0;
1772  __Pyx_RefNannySetupContext("_check_rc", 0);
1773
1774  /* "zmq/backend/cython/checkrc.pxd":10
1775 *     and raising the appropriate Exception class
1776 *     """
1777 *     cdef int errno = zmq_errno()             # <<<<<<<<<<<<<<
1778 *     PyErr_CheckSignals()
1779 *     if rc < 0:
1780 */
1781  __pyx_v_errno = zmq_errno();
1782
1783  /* "zmq/backend/cython/checkrc.pxd":11
1784 *     """
1785 *     cdef int errno = zmq_errno()
1786 *     PyErr_CheckSignals()             # <<<<<<<<<<<<<<
1787 *     if rc < 0:
1788 *         if errno == EAGAIN:
1789 */
1790  __pyx_t_1 = PyErr_CheckSignals(); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 11; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1791
1792  /* "zmq/backend/cython/checkrc.pxd":12
1793 *     cdef int errno = zmq_errno()
1794 *     PyErr_CheckSignals()
1795 *     if rc < 0:             # <<<<<<<<<<<<<<
1796 *         if errno == EAGAIN:
1797 *             from zmq.error import Again
1798 */
1799  __pyx_t_2 = ((__pyx_v_rc < 0) != 0);
1800  if (__pyx_t_2) {
1801
1802    /* "zmq/backend/cython/checkrc.pxd":16
1803 *             from zmq.error import Again
1804 *             raise Again(errno)
1805 *         elif errno == ZMQ_ETERM:             # <<<<<<<<<<<<<<
1806 *             from zmq.error import ContextTerminated
1807 *             raise ContextTerminated(errno)
1808 */
1809    switch (__pyx_v_errno) {
1810
1811      /* "zmq/backend/cython/checkrc.pxd":13
1812 *     PyErr_CheckSignals()
1813 *     if rc < 0:
1814 *         if errno == EAGAIN:             # <<<<<<<<<<<<<<
1815 *             from zmq.error import Again
1816 *             raise Again(errno)
1817 */
1818      case EAGAIN:
1819
1820      /* "zmq/backend/cython/checkrc.pxd":14
1821 *     if rc < 0:
1822 *         if errno == EAGAIN:
1823 *             from zmq.error import Again             # <<<<<<<<<<<<<<
1824 *             raise Again(errno)
1825 *         elif errno == ZMQ_ETERM:
1826 */
1827      __pyx_t_3 = PyList_New(1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1828      __Pyx_GOTREF(__pyx_t_3);
1829      __Pyx_INCREF(__pyx_n_s_Again);
1830      PyList_SET_ITEM(__pyx_t_3, 0, __pyx_n_s_Again);
1831      __Pyx_GIVEREF(__pyx_n_s_Again);
1832      __pyx_t_4 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_3, -1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1833      __Pyx_GOTREF(__pyx_t_4);
1834      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1835      __pyx_t_3 = __Pyx_ImportFrom(__pyx_t_4, __pyx_n_s_Again); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 14; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1836      __Pyx_GOTREF(__pyx_t_3);
1837      __Pyx_INCREF(__pyx_t_3);
1838      __pyx_v_Again = __pyx_t_3;
1839      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1840      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1841
1842      /* "zmq/backend/cython/checkrc.pxd":15
1843 *         if errno == EAGAIN:
1844 *             from zmq.error import Again
1845 *             raise Again(errno)             # <<<<<<<<<<<<<<
1846 *         elif errno == ZMQ_ETERM:
1847 *             from zmq.error import ContextTerminated
1848 */
1849      __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_errno); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1850      __Pyx_GOTREF(__pyx_t_3);
1851      __Pyx_INCREF(__pyx_v_Again);
1852      __pyx_t_5 = __pyx_v_Again; __pyx_t_6 = NULL;
1853      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
1854        __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
1855        if (likely(__pyx_t_6)) {
1856          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
1857          __Pyx_INCREF(__pyx_t_6);
1858          __Pyx_INCREF(function);
1859          __Pyx_DECREF_SET(__pyx_t_5, function);
1860        }
1861      }
1862      if (!__pyx_t_6) {
1863        __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1864        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
1865        __Pyx_GOTREF(__pyx_t_4);
1866      } else {
1867        __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1868        __Pyx_GOTREF(__pyx_t_7);
1869        PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __Pyx_GIVEREF(__pyx_t_6); __pyx_t_6 = NULL;
1870        PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_t_3);
1871        __Pyx_GIVEREF(__pyx_t_3);
1872        __pyx_t_3 = 0;
1873        __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1874        __Pyx_GOTREF(__pyx_t_4);
1875        __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1876      }
1877      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1878      __Pyx_Raise(__pyx_t_4, 0, 0, 0);
1879      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1880      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1881      break;
1882
1883      /* "zmq/backend/cython/checkrc.pxd":16
1884 *             from zmq.error import Again
1885 *             raise Again(errno)
1886 *         elif errno == ZMQ_ETERM:             # <<<<<<<<<<<<<<
1887 *             from zmq.error import ContextTerminated
1888 *             raise ContextTerminated(errno)
1889 */
1890      case ETERM:
1891
1892      /* "zmq/backend/cython/checkrc.pxd":17
1893 *             raise Again(errno)
1894 *         elif errno == ZMQ_ETERM:
1895 *             from zmq.error import ContextTerminated             # <<<<<<<<<<<<<<
1896 *             raise ContextTerminated(errno)
1897 *         else:
1898 */
1899      __pyx_t_4 = PyList_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1900      __Pyx_GOTREF(__pyx_t_4);
1901      __Pyx_INCREF(__pyx_n_s_ContextTerminated);
1902      PyList_SET_ITEM(__pyx_t_4, 0, __pyx_n_s_ContextTerminated);
1903      __Pyx_GIVEREF(__pyx_n_s_ContextTerminated);
1904      __pyx_t_5 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_4, -1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1905      __Pyx_GOTREF(__pyx_t_5);
1906      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1907      __pyx_t_4 = __Pyx_ImportFrom(__pyx_t_5, __pyx_n_s_ContextTerminated); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 17; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1908      __Pyx_GOTREF(__pyx_t_4);
1909      __Pyx_INCREF(__pyx_t_4);
1910      __pyx_v_ContextTerminated = __pyx_t_4;
1911      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1912      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1913
1914      /* "zmq/backend/cython/checkrc.pxd":18
1915 *         elif errno == ZMQ_ETERM:
1916 *             from zmq.error import ContextTerminated
1917 *             raise ContextTerminated(errno)             # <<<<<<<<<<<<<<
1918 *         else:
1919 *             from zmq.error import ZMQError
1920 */
1921      __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_errno); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1922      __Pyx_GOTREF(__pyx_t_4);
1923      __Pyx_INCREF(__pyx_v_ContextTerminated);
1924      __pyx_t_7 = __pyx_v_ContextTerminated; __pyx_t_3 = NULL;
1925      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
1926        __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_7);
1927        if (likely(__pyx_t_3)) {
1928          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
1929          __Pyx_INCREF(__pyx_t_3);
1930          __Pyx_INCREF(function);
1931          __Pyx_DECREF_SET(__pyx_t_7, function);
1932        }
1933      }
1934      if (!__pyx_t_3) {
1935        __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1936        __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
1937        __Pyx_GOTREF(__pyx_t_5);
1938      } else {
1939        __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1940        __Pyx_GOTREF(__pyx_t_6);
1941        PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_3); __Pyx_GIVEREF(__pyx_t_3); __pyx_t_3 = NULL;
1942        PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_t_4);
1943        __Pyx_GIVEREF(__pyx_t_4);
1944        __pyx_t_4 = 0;
1945        __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1946        __Pyx_GOTREF(__pyx_t_5);
1947        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
1948      }
1949      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1950      __Pyx_Raise(__pyx_t_5, 0, 0, 0);
1951      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1952      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 18; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1953      break;
1954      default:
1955
1956      /* "zmq/backend/cython/checkrc.pxd":20
1957 *             raise ContextTerminated(errno)
1958 *         else:
1959 *             from zmq.error import ZMQError             # <<<<<<<<<<<<<<
1960 *             raise ZMQError(errno)
1961 *         # return -1
1962 */
1963      __pyx_t_5 = PyList_New(1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1964      __Pyx_GOTREF(__pyx_t_5);
1965      __Pyx_INCREF(__pyx_n_s_ZMQError);
1966      PyList_SET_ITEM(__pyx_t_5, 0, __pyx_n_s_ZMQError);
1967      __Pyx_GIVEREF(__pyx_n_s_ZMQError);
1968      __pyx_t_7 = __Pyx_Import(__pyx_n_s_zmq_error, __pyx_t_5, -1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1969      __Pyx_GOTREF(__pyx_t_7);
1970      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1971      __pyx_t_5 = __Pyx_ImportFrom(__pyx_t_7, __pyx_n_s_ZMQError); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1972      __Pyx_GOTREF(__pyx_t_5);
1973      __Pyx_INCREF(__pyx_t_5);
1974      __pyx_v_ZMQError = __pyx_t_5;
1975      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
1976      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
1977
1978      /* "zmq/backend/cython/checkrc.pxd":21
1979 *         else:
1980 *             from zmq.error import ZMQError
1981 *             raise ZMQError(errno)             # <<<<<<<<<<<<<<
1982 *         # return -1
1983 *     return 0
1984 */
1985      __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_errno); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
1986      __Pyx_GOTREF(__pyx_t_5);
1987      __Pyx_INCREF(__pyx_v_ZMQError);
1988      __pyx_t_6 = __pyx_v_ZMQError; __pyx_t_4 = NULL;
1989      if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
1990        __pyx_t_4 = PyMethod_GET_SELF(__pyx_t_6);
1991        if (likely(__pyx_t_4)) {
1992          PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
1993          __Pyx_INCREF(__pyx_t_4);
1994          __Pyx_INCREF(function);
1995          __Pyx_DECREF_SET(__pyx_t_6, function);
1996        }
1997      }
1998      if (!__pyx_t_4) {
1999        __pyx_t_7 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2000        __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
2001        __Pyx_GOTREF(__pyx_t_7);
2002      } else {
2003        __pyx_t_3 = PyTuple_New(1+1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2004        __Pyx_GOTREF(__pyx_t_3);
2005        PyTuple_SET_ITEM(__pyx_t_3, 0, __pyx_t_4); __Pyx_GIVEREF(__pyx_t_4); __pyx_t_4 = NULL;
2006        PyTuple_SET_ITEM(__pyx_t_3, 0+1, __pyx_t_5);
2007        __Pyx_GIVEREF(__pyx_t_5);
2008        __pyx_t_5 = 0;
2009        __pyx_t_7 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_3, NULL); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2010        __Pyx_GOTREF(__pyx_t_7);
2011        __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
2012      }
2013      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
2014      __Pyx_Raise(__pyx_t_7, 0, 0, 0);
2015      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
2016      {__pyx_filename = __pyx_f[1]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2017      break;
2018    }
2019  }
2020
2021  /* "zmq/backend/cython/checkrc.pxd":23
2022 *             raise ZMQError(errno)
2023 *         # return -1
2024 *     return 0             # <<<<<<<<<<<<<<
2025 */
2026  __pyx_r = 0;
2027  goto __pyx_L0;
2028
2029  /* "zmq/backend/cython/checkrc.pxd":5
2030 * from libzmq cimport zmq_errno, ZMQ_ETERM
2031 *
2032 * cdef inline int _check_rc(int rc) except -1:             # <<<<<<<<<<<<<<
2033 *     """internal utility for checking zmq return condition
2034 *
2035 */
2036
2037  /* function exit code */
2038  __pyx_L1_error:;
2039  __Pyx_XDECREF(__pyx_t_3);
2040  __Pyx_XDECREF(__pyx_t_4);
2041  __Pyx_XDECREF(__pyx_t_5);
2042  __Pyx_XDECREF(__pyx_t_6);
2043  __Pyx_XDECREF(__pyx_t_7);
2044  __Pyx_AddTraceback("zmq.backend.cython.checkrc._check_rc", __pyx_clineno, __pyx_lineno, __pyx_filename);
2045  __pyx_r = -1;
2046  __pyx_L0:;
2047  __Pyx_XDECREF(__pyx_v_Again);
2048  __Pyx_XDECREF(__pyx_v_ContextTerminated);
2049  __Pyx_XDECREF(__pyx_v_ZMQError);
2050  __Pyx_RefNannyFinishContext();
2051  return __pyx_r;
2052}
2053
2054static PyMethodDef __pyx_methods[] = {
2055  {0, 0, 0, 0}
2056};
2057
2058#if PY_MAJOR_VERSION >= 3
2059static struct PyModuleDef __pyx_moduledef = {
2060  #if PY_VERSION_HEX < 0x03020000
2061    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
2062  #else
2063    PyModuleDef_HEAD_INIT,
2064  #endif
2065    "_poll",
2066    __pyx_k_0MQ_polling_related_functions_an, /* m_doc */
2067    -1, /* m_size */
2068    __pyx_methods /* m_methods */,
2069    NULL, /* m_reload */
2070    NULL, /* m_traverse */
2071    NULL, /* m_clear */
2072    NULL /* m_free */
2073};
2074#endif
2075
2076static __Pyx_StringTabEntry __pyx_string_tab[] = {
2077  {&__pyx_n_s_Again, __pyx_k_Again, sizeof(__pyx_k_Again), 0, 0, 1, 1},
2078  {&__pyx_n_s_ContextTerminated, __pyx_k_ContextTerminated, sizeof(__pyx_k_ContextTerminated), 0, 0, 1, 1},
2079  {&__pyx_kp_s_Could_not_allocate_poll_items, __pyx_k_Could_not_allocate_poll_items, sizeof(__pyx_k_Could_not_allocate_poll_items), 0, 0, 1, 0},
2080  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
2081  {&__pyx_kp_s_Socket_must_be_a_0MQ_socket_an_i, __pyx_k_Socket_must_be_a_0MQ_socket_an_i, sizeof(__pyx_k_Socket_must_be_a_0MQ_socket_an_i), 0, 0, 1, 0},
2082  {&__pyx_n_s_TypeError, __pyx_k_TypeError, sizeof(__pyx_k_TypeError), 0, 0, 1, 1},
2083  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
2084  {&__pyx_n_s_ZMQError, __pyx_k_ZMQError, sizeof(__pyx_k_ZMQError), 0, 0, 1, 1},
2085  {&__pyx_n_s_all, __pyx_k_all, sizeof(__pyx_k_all), 0, 0, 1, 1},
2086  {&__pyx_n_s_current_socket, __pyx_k_current_socket, sizeof(__pyx_k_current_socket), 0, 0, 1, 1},
2087  {&__pyx_n_s_events, __pyx_k_events, sizeof(__pyx_k_events), 0, 0, 1, 1},
2088  {&__pyx_n_s_fileno, __pyx_k_fileno, sizeof(__pyx_k_fileno), 0, 0, 1, 1},
2089  {&__pyx_kp_s_fileno_must_return_a_valid_integ, __pyx_k_fileno_must_return_a_valid_integ, sizeof(__pyx_k_fileno_must_return_a_valid_integ), 0, 0, 1, 0},
2090  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
2091  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
2092  {&__pyx_n_s_int_t, __pyx_k_int_t, sizeof(__pyx_k_int_t), 0, 0, 1, 1},
2093  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
2094  {&__pyx_n_s_nsockets, __pyx_k_nsockets, sizeof(__pyx_k_nsockets), 0, 0, 1, 1},
2095  {&__pyx_n_s_pollitems, __pyx_k_pollitems, sizeof(__pyx_k_pollitems), 0, 0, 1, 1},
2096  {&__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},
2097  {&__pyx_n_s_pyx_vtable, __pyx_k_pyx_vtable, sizeof(__pyx_k_pyx_vtable), 0, 0, 1, 1},
2098  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
2099  {&__pyx_n_s_rc, __pyx_k_rc, sizeof(__pyx_k_rc), 0, 0, 1, 1},
2100  {&__pyx_n_s_results, __pyx_k_results, sizeof(__pyx_k_results), 0, 0, 1, 1},
2101  {&__pyx_n_s_revents, __pyx_k_revents, sizeof(__pyx_k_revents), 0, 0, 1, 1},
2102  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
2103  {&__pyx_n_s_sockets, __pyx_k_sockets, sizeof(__pyx_k_sockets), 0, 0, 1, 1},
2104  {&__pyx_n_s_sys, __pyx_k_sys, sizeof(__pyx_k_sys), 0, 0, 1, 1},
2105  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
2106  {&__pyx_n_s_timeout, __pyx_k_timeout, sizeof(__pyx_k_timeout), 0, 0, 1, 1},
2107  {&__pyx_n_s_version_info, __pyx_k_version_info, sizeof(__pyx_k_version_info), 0, 0, 1, 1},
2108  {&__pyx_n_s_zmq_backend_cython__poll, __pyx_k_zmq_backend_cython__poll, sizeof(__pyx_k_zmq_backend_cython__poll), 0, 0, 1, 1},
2109  {&__pyx_n_s_zmq_error, __pyx_k_zmq_error, sizeof(__pyx_k_zmq_error), 0, 0, 1, 1},
2110  {&__pyx_n_s_zmq_poll, __pyx_k_zmq_poll, sizeof(__pyx_k_zmq_poll), 0, 0, 1, 1},
2111  {0, 0, 0, 0, 0, 0, 0}
2112};
2113static int __Pyx_InitCachedBuiltins(void) {
2114  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2115  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2116  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2117  __pyx_builtin_TypeError = __Pyx_GetBuiltinName(__pyx_n_s_TypeError); if (!__pyx_builtin_TypeError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 104; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2118  return 0;
2119  __pyx_L1_error:;
2120  return -1;
2121}
2122
2123static int __Pyx_InitCachedConstants(void) {
2124  __Pyx_RefNannyDeclarations
2125  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
2126
2127  /* "zmq/backend/cython/_poll.pyx":73
2128 *     pollitems = <zmq_pollitem_t *>malloc(nsockets*sizeof(zmq_pollitem_t))
2129 *     if pollitems == NULL:
2130 *         raise MemoryError("Could not allocate poll items")             # <<<<<<<<<<<<<<
2131 *
2132 *     if ZMQ_VERSION_MAJOR < 3:
2133 */
2134  __pyx_tuple_ = PyTuple_Pack(1, __pyx_kp_s_Could_not_allocate_poll_items); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2135  __Pyx_GOTREF(__pyx_tuple_);
2136  __Pyx_GIVEREF(__pyx_tuple_);
2137
2138  /* "zmq/backend/cython/_poll.pyx":96
2139 *             except:
2140 *                 free(pollitems)
2141 *                 raise ValueError('fileno() must return a valid integer fd')             # <<<<<<<<<<<<<<
2142 *             else:
2143 *                 pollitems[i].socket = NULL
2144 */
2145  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_s_fileno_must_return_a_valid_integ); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 96; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2146  __Pyx_GOTREF(__pyx_tuple__2);
2147  __Pyx_GIVEREF(__pyx_tuple__2);
2148
2149  /* "zmq/backend/cython/_poll.pyx":47
2150 *
2151 *
2152 * def zmq_poll(sockets, long timeout=-1):             # <<<<<<<<<<<<<<
2153 *     """zmq_poll(sockets, timeout=-1)
2154 *
2155 */
2156  __pyx_tuple__3 = PyTuple_Pack(12, __pyx_n_s_sockets, __pyx_n_s_timeout, __pyx_n_s_rc, __pyx_n_s_i, __pyx_n_s_pollitems, __pyx_n_s_nsockets, __pyx_n_s_current_socket, __pyx_n_s_s, __pyx_n_s_events, __pyx_n_s_fileno, __pyx_n_s_results, __pyx_n_s_revents); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2157  __Pyx_GOTREF(__pyx_tuple__3);
2158  __Pyx_GIVEREF(__pyx_tuple__3);
2159  __pyx_codeobj__4 = (PyObject*)__Pyx_PyCode_New(2, 0, 12, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__3, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_private_tmp_pyzmq_release_zmq_b, __pyx_n_s_zmq_poll, 47, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2160  __Pyx_RefNannyFinishContext();
2161  return 0;
2162  __pyx_L1_error:;
2163  __Pyx_RefNannyFinishContext();
2164  return -1;
2165}
2166
2167static int __Pyx_InitGlobals(void) {
2168  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
2169  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2170  return 0;
2171  __pyx_L1_error:;
2172  return -1;
2173}
2174
2175#if PY_MAJOR_VERSION < 3
2176PyMODINIT_FUNC init_poll(void); /*proto*/
2177PyMODINIT_FUNC init_poll(void)
2178#else
2179PyMODINIT_FUNC PyInit__poll(void); /*proto*/
2180PyMODINIT_FUNC PyInit__poll(void)
2181#endif
2182{
2183  PyObject *__pyx_t_1 = NULL;
2184  PyObject *__pyx_t_2 = NULL;
2185  int __pyx_t_3;
2186  int __pyx_lineno = 0;
2187  const char *__pyx_filename = NULL;
2188  int __pyx_clineno = 0;
2189  __Pyx_RefNannyDeclarations
2190  #if CYTHON_REFNANNY
2191  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
2192  if (!__Pyx_RefNanny) {
2193      PyErr_Clear();
2194      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
2195      if (!__Pyx_RefNanny)
2196          Py_FatalError("failed to import 'refnanny' module");
2197  }
2198  #endif
2199  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__poll(void)", 0);
2200  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2201  __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;}
2202  __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;}
2203  #ifdef __Pyx_CyFunction_USED
2204  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2205  #endif
2206  #ifdef __Pyx_FusedFunction_USED
2207  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2208  #endif
2209  #ifdef __Pyx_Generator_USED
2210  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2211  #endif
2212  /*--- Library function declarations ---*/
2213  /*--- Threads initialization code ---*/
2214  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
2215  #ifdef WITH_THREAD /* Python build with threading support? */
2216  PyEval_InitThreads();
2217  #endif
2218  #endif
2219  /*--- Module creation code ---*/
2220  #if PY_MAJOR_VERSION < 3
2221  __pyx_m = Py_InitModule4("_poll", __pyx_methods, __pyx_k_0MQ_polling_related_functions_an, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
2222  #else
2223  __pyx_m = PyModule_Create(&__pyx_moduledef);
2224  #endif
2225  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2226  __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;}
2227  Py_INCREF(__pyx_d);
2228  __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;}
2229  #if CYTHON_COMPILING_IN_PYPY
2230  Py_INCREF(__pyx_b);
2231  #endif
2232  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
2233  /*--- Initialize various global constants etc. ---*/
2234  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2235  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
2236  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2237  #endif
2238  if (__pyx_module_is_main_zmq__backend__cython___poll) {
2239    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;};
2240  }
2241  #if PY_MAJOR_VERSION >= 3
2242  {
2243    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2244    if (!PyDict_GetItemString(modules, "zmq.backend.cython._poll")) {
2245      if (unlikely(PyDict_SetItemString(modules, "zmq.backend.cython._poll", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2246    }
2247  }
2248  #endif
2249  /*--- Builtin init code ---*/
2250  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2251  /*--- Constants init code ---*/
2252  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2253  /*--- Global init code ---*/
2254  /*--- Variable export code ---*/
2255  /*--- Function export code ---*/
2256  /*--- Type init code ---*/
2257  /*--- Type import code ---*/
2258  __pyx_ptype_3zmq_7backend_6cython_7context_Context = __Pyx_ImportType("zmq.backend.cython.context", "Context", sizeof(struct __pyx_obj_3zmq_7backend_6cython_7context_Context), 1); if (unlikely(!__pyx_ptype_3zmq_7backend_6cython_7context_Context)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2259  __pyx_vtabptr_3zmq_7backend_6cython_7context_Context = (struct __pyx_vtabstruct_3zmq_7backend_6cython_7context_Context*)__Pyx_GetVtable(__pyx_ptype_3zmq_7backend_6cython_7context_Context->tp_dict); if (unlikely(!__pyx_vtabptr_3zmq_7backend_6cython_7context_Context)) {__pyx_filename = __pyx_f[2]; __pyx_lineno = 26; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2260  __pyx_ptype_3zmq_7backend_6cython_6socket_Socket = __Pyx_ImportType("zmq.backend.cython.socket", "Socket", sizeof(struct __pyx_obj_3zmq_7backend_6cython_6socket_Socket), 1); if (unlikely(!__pyx_ptype_3zmq_7backend_6cython_6socket_Socket)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2261  __pyx_vtabptr_3zmq_7backend_6cython_6socket_Socket = (struct __pyx_vtabstruct_3zmq_7backend_6cython_6socket_Socket*)__Pyx_GetVtable(__pyx_ptype_3zmq_7backend_6cython_6socket_Socket->tp_dict); if (unlikely(!__pyx_vtabptr_3zmq_7backend_6cython_6socket_Socket)) {__pyx_filename = __pyx_f[3]; __pyx_lineno = 33; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2262  __pyx_ptype_7cpython_4type_type = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "type",
2263  #if CYTHON_COMPILING_IN_PYPY
2264  sizeof(PyTypeObject),
2265  #else
2266  sizeof(PyHeapTypeObject),
2267  #endif
2268  0); if (unlikely(!__pyx_ptype_7cpython_4type_type)) {__pyx_filename = __pyx_f[4]; __pyx_lineno = 9; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2269  __pyx_ptype_7cpython_4bool_bool = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "bool", sizeof(PyBoolObject), 0); if (unlikely(!__pyx_ptype_7cpython_4bool_bool)) {__pyx_filename = __pyx_f[5]; __pyx_lineno = 8; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2270  __pyx_ptype_7cpython_7complex_complex = __Pyx_ImportType(__Pyx_BUILTIN_MODULE_NAME, "complex", sizeof(PyComplexObject), 0); if (unlikely(!__pyx_ptype_7cpython_7complex_complex)) {__pyx_filename = __pyx_f[6]; __pyx_lineno = 15; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2271  /*--- Variable import code ---*/
2272  /*--- Function import code ---*/
2273  /*--- Execution code ---*/
2274
2275  /* "zmq/backend/cython/_poll.pyx":32
2276 * from socket cimport Socket
2277 *
2278 * import sys             # <<<<<<<<<<<<<<
2279 *
2280 * from zmq.backend.cython.checkrc cimport _check_rc
2281 */
2282  __pyx_t_1 = __Pyx_Import(__pyx_n_s_sys, 0, -1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2283  __Pyx_GOTREF(__pyx_t_1);
2284  if (PyDict_SetItem(__pyx_d, __pyx_n_s_sys, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2285  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2286
2287  /* "zmq/backend/cython/_poll.pyx":41
2288 *
2289 * # version-independent typecheck for int/long
2290 * if sys.version_info[0] >= 3:             # <<<<<<<<<<<<<<
2291 *     int_t = int
2292 * else:
2293 */
2294  __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_sys); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2295  __Pyx_GOTREF(__pyx_t_1);
2296  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_t_1, __pyx_n_s_version_info); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2297  __Pyx_GOTREF(__pyx_t_2);
2298  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2299  __pyx_t_1 = __Pyx_GetItemInt(__pyx_t_2, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
2300  __Pyx_GOTREF(__pyx_t_1);
2301  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2302  __pyx_t_2 = PyObject_RichCompare(__pyx_t_1, __pyx_int_3, Py_GE); __Pyx_XGOTREF(__pyx_t_2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2303  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
2304  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2305  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2306  if (__pyx_t_3) {
2307
2308    /* "zmq/backend/cython/_poll.pyx":42
2309 * # version-independent typecheck for int/long
2310 * if sys.version_info[0] >= 3:
2311 *     int_t = int             # <<<<<<<<<<<<<<
2312 * else:
2313 *     int_t = (int,long)
2314 */
2315    if (PyDict_SetItem(__pyx_d, __pyx_n_s_int_t, ((PyObject *)((PyObject*)(&PyInt_Type)))) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2316    goto __pyx_L2;
2317  }
2318  /*else*/ {
2319
2320    /* "zmq/backend/cython/_poll.pyx":44
2321 *     int_t = int
2322 * else:
2323 *     int_t = (int,long)             # <<<<<<<<<<<<<<
2324 *
2325 *
2326 */
2327    __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2328    __Pyx_GOTREF(__pyx_t_2);
2329    __Pyx_INCREF(((PyObject *)((PyObject*)(&PyInt_Type))));
2330    PyTuple_SET_ITEM(__pyx_t_2, 0, ((PyObject *)((PyObject*)(&PyInt_Type))));
2331    __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyInt_Type))));
2332    __Pyx_INCREF(((PyObject *)((PyObject*)(&PyLong_Type))));
2333    PyTuple_SET_ITEM(__pyx_t_2, 1, ((PyObject *)((PyObject*)(&PyLong_Type))));
2334    __Pyx_GIVEREF(((PyObject *)((PyObject*)(&PyLong_Type))));
2335    if (PyDict_SetItem(__pyx_d, __pyx_n_s_int_t, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2336    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2337  }
2338  __pyx_L2:;
2339
2340  /* "zmq/backend/cython/_poll.pyx":47
2341 *
2342 *
2343 * def zmq_poll(sockets, long timeout=-1):             # <<<<<<<<<<<<<<
2344 *     """zmq_poll(sockets, timeout=-1)
2345 *
2346 */
2347  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_3zmq_7backend_6cython_5_poll_1zmq_poll, NULL, __pyx_n_s_zmq_backend_cython__poll); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2348  __Pyx_GOTREF(__pyx_t_2);
2349  if (PyDict_SetItem(__pyx_d, __pyx_n_s_zmq_poll, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 47; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2350  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2351
2352  /* "zmq/backend/cython/_poll.pyx":137
2353 * #-----------------------------------------------------------------------------
2354 *
2355 * __all__ = [ 'zmq_poll' ]             # <<<<<<<<<<<<<<
2356 */
2357  __pyx_t_2 = PyList_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2358  __Pyx_GOTREF(__pyx_t_2);
2359  __Pyx_INCREF(__pyx_n_s_zmq_poll);
2360  PyList_SET_ITEM(__pyx_t_2, 0, __pyx_n_s_zmq_poll);
2361  __Pyx_GIVEREF(__pyx_n_s_zmq_poll);
2362  if (PyDict_SetItem(__pyx_d, __pyx_n_s_all, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 137; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2363  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2364
2365  /* "zmq/backend/cython/_poll.pyx":1
2366 * """0MQ polling related functions and classes."""             # <<<<<<<<<<<<<<
2367 *
2368 * #
2369 */
2370  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2371  __Pyx_GOTREF(__pyx_t_2);
2372  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
2373  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
2374
2375  /* "zmq/backend/cython/checkrc.pxd":5
2376 * from libzmq cimport zmq_errno, ZMQ_ETERM
2377 *
2378 * cdef inline int _check_rc(int rc) except -1:             # <<<<<<<<<<<<<<
2379 *     """internal utility for checking zmq return condition
2380 *
2381 */
2382
2383  /*--- Wrapped vars code ---*/
2384
2385  goto __pyx_L0;
2386  __pyx_L1_error:;
2387  __Pyx_XDECREF(__pyx_t_1);
2388  __Pyx_XDECREF(__pyx_t_2);
2389  if (__pyx_m) {
2390    if (__pyx_d) {
2391      __Pyx_AddTraceback("init zmq.backend.cython._poll", __pyx_clineno, __pyx_lineno, __pyx_filename);
2392    }
2393    Py_DECREF(__pyx_m); __pyx_m = 0;
2394  } else if (!PyErr_Occurred()) {
2395    PyErr_SetString(PyExc_ImportError, "init zmq.backend.cython._poll");
2396  }
2397  __pyx_L0:;
2398  __Pyx_RefNannyFinishContext();
2399  #if PY_MAJOR_VERSION < 3
2400  return;
2401  #else
2402  return __pyx_m;
2403  #endif
2404}
2405
2406/* Runtime support code */
2407#if CYTHON_REFNANNY
2408static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
2409    PyObject *m = NULL, *p = NULL;
2410    void *r = NULL;
2411    m = PyImport_ImportModule((char *)modname);
2412    if (!m) goto end;
2413    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
2414    if (!p) goto end;
2415    r = PyLong_AsVoidPtr(p);
2416end:
2417    Py_XDECREF(p);
2418    Py_XDECREF(m);
2419    return (__Pyx_RefNannyAPIStruct *)r;
2420}
2421#endif
2422
2423static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
2424    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
2425    if (unlikely(!result)) {
2426        PyErr_Format(PyExc_NameError,
2427#if PY_MAJOR_VERSION >= 3
2428            "name '%U' is not defined", name);
2429#else
2430            "name '%.200s' is not defined", PyString_AS_STRING(name));
2431#endif
2432    }
2433    return result;
2434}
2435
2436static void __Pyx_RaiseDoubleKeywordsError(
2437    const char* func_name,
2438    PyObject* kw_name)
2439{
2440    PyErr_Format(PyExc_TypeError,
2441        #if PY_MAJOR_VERSION >= 3
2442        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
2443        #else
2444        "%s() got multiple values for keyword argument '%s'", func_name,
2445        PyString_AsString(kw_name));
2446        #endif
2447}
2448
2449static int __Pyx_ParseOptionalKeywords(
2450    PyObject *kwds,
2451    PyObject **argnames[],
2452    PyObject *kwds2,
2453    PyObject *values[],
2454    Py_ssize_t num_pos_args,
2455    const char* function_name)
2456{
2457    PyObject *key = 0, *value = 0;
2458    Py_ssize_t pos = 0;
2459    PyObject*** name;
2460    PyObject*** first_kw_arg = argnames + num_pos_args;
2461    while (PyDict_Next(kwds, &pos, &key, &value)) {
2462        name = first_kw_arg;
2463        while (*name && (**name != key)) name++;
2464        if (*name) {
2465            values[name-argnames] = value;
2466            continue;
2467        }
2468        name = first_kw_arg;
2469        #if PY_MAJOR_VERSION < 3
2470        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
2471            while (*name) {
2472                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
2473                        && _PyString_Eq(**name, key)) {
2474                    values[name-argnames] = value;
2475                    break;
2476                }
2477                name++;
2478            }
2479            if (*name) continue;
2480            else {
2481                PyObject*** argname = argnames;
2482                while (argname != first_kw_arg) {
2483                    if ((**argname == key) || (
2484                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
2485                             && _PyString_Eq(**argname, key))) {
2486                        goto arg_passed_twice;
2487                    }
2488                    argname++;
2489                }
2490            }
2491        } else
2492        #endif
2493        if (likely(PyUnicode_Check(key))) {
2494            while (*name) {
2495                int cmp = (**name == key) ? 0 :
2496                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2497                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
2498                #endif
2499                    PyUnicode_Compare(**name, key);
2500                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2501                if (cmp == 0) {
2502                    values[name-argnames] = value;
2503                    break;
2504                }
2505                name++;
2506            }
2507            if (*name) continue;
2508            else {
2509                PyObject*** argname = argnames;
2510                while (argname != first_kw_arg) {
2511                    int cmp = (**argname == key) ? 0 :
2512                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
2513                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
2514                    #endif
2515                        PyUnicode_Compare(**argname, key);
2516                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
2517                    if (cmp == 0) goto arg_passed_twice;
2518                    argname++;
2519                }
2520            }
2521        } else
2522            goto invalid_keyword_type;
2523        if (kwds2) {
2524            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
2525        } else {
2526            goto invalid_keyword;
2527        }
2528    }
2529    return 0;
2530arg_passed_twice:
2531    __Pyx_RaiseDoubleKeywordsError(function_name, key);
2532    goto bad;
2533invalid_keyword_type:
2534    PyErr_Format(PyExc_TypeError,
2535        "%.200s() keywords must be strings", function_name);
2536    goto bad;
2537invalid_keyword:
2538    PyErr_Format(PyExc_TypeError,
2539    #if PY_MAJOR_VERSION < 3
2540        "%.200s() got an unexpected keyword argument '%.200s'",
2541        function_name, PyString_AsString(key));
2542    #else
2543        "%s() got an unexpected keyword argument '%U'",
2544        function_name, key);
2545    #endif
2546bad:
2547    return -1;
2548}
2549
2550static void __Pyx_RaiseArgtupleInvalid(
2551    const char* func_name,
2552    int exact,
2553    Py_ssize_t num_min,
2554    Py_ssize_t num_max,
2555    Py_ssize_t num_found)
2556{
2557    Py_ssize_t num_expected;
2558    const char *more_or_less;
2559    if (num_found < num_min) {
2560        num_expected = num_min;
2561        more_or_less = "at least";
2562    } else {
2563        num_expected = num_max;
2564        more_or_less = "at most";
2565    }
2566    if (exact) {
2567        more_or_less = "exactly";
2568    }
2569    PyErr_Format(PyExc_TypeError,
2570                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
2571                 func_name, more_or_less, num_expected,
2572                 (num_expected == 1) ? "" : "s", num_found);
2573}
2574
2575#if CYTHON_COMPILING_IN_CPYTHON
2576static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
2577    PyObject *result;
2578    ternaryfunc call = func->ob_type->tp_call;
2579    if (unlikely(!call))
2580        return PyObject_Call(func, arg, kw);
2581    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2582        return NULL;
2583    result = (*call)(func, arg, kw);
2584    Py_LeaveRecursiveCall();
2585    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2586        PyErr_SetString(
2587            PyExc_SystemError,
2588            "NULL result without error in PyObject_Call");
2589    }
2590    return result;
2591}
2592#endif
2593
2594static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
2595#if CYTHON_COMPILING_IN_CPYTHON
2596    PyObject *tmp_type, *tmp_value, *tmp_tb;
2597    PyThreadState *tstate = PyThreadState_GET();
2598    tmp_type = tstate->curexc_type;
2599    tmp_value = tstate->curexc_value;
2600    tmp_tb = tstate->curexc_traceback;
2601    tstate->curexc_type = type;
2602    tstate->curexc_value = value;
2603    tstate->curexc_traceback = tb;
2604    Py_XDECREF(tmp_type);
2605    Py_XDECREF(tmp_value);
2606    Py_XDECREF(tmp_tb);
2607#else
2608    PyErr_Restore(type, value, tb);
2609#endif
2610}
2611static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
2612#if CYTHON_COMPILING_IN_CPYTHON
2613    PyThreadState *tstate = PyThreadState_GET();
2614    *type = tstate->curexc_type;
2615    *value = tstate->curexc_value;
2616    *tb = tstate->curexc_traceback;
2617    tstate->curexc_type = 0;
2618    tstate->curexc_value = 0;
2619    tstate->curexc_traceback = 0;
2620#else
2621    PyErr_Fetch(type, value, tb);
2622#endif
2623}
2624
2625#if PY_MAJOR_VERSION < 3
2626static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
2627                        CYTHON_UNUSED PyObject *cause) {
2628    Py_XINCREF(type);
2629    if (!value || value == Py_None)
2630        value = NULL;
2631    else
2632        Py_INCREF(value);
2633    if (!tb || tb == Py_None)
2634        tb = NULL;
2635    else {
2636        Py_INCREF(tb);
2637        if (!PyTraceBack_Check(tb)) {
2638            PyErr_SetString(PyExc_TypeError,
2639                "raise: arg 3 must be a traceback or None");
2640            goto raise_error;
2641        }
2642    }
2643    if (PyType_Check(type)) {
2644#if CYTHON_COMPILING_IN_PYPY
2645        if (!value) {
2646            Py_INCREF(Py_None);
2647            value = Py_None;
2648        }
2649#endif
2650        PyErr_NormalizeException(&type, &value, &tb);
2651    } else {
2652        if (value) {
2653            PyErr_SetString(PyExc_TypeError,
2654                "instance exception may not have a separate value");
2655            goto raise_error;
2656        }
2657        value = type;
2658        type = (PyObject*) Py_TYPE(type);
2659        Py_INCREF(type);
2660        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
2661            PyErr_SetString(PyExc_TypeError,
2662                "raise: exception class must be a subclass of BaseException");
2663            goto raise_error;
2664        }
2665    }
2666    __Pyx_ErrRestore(type, value, tb);
2667    return;
2668raise_error:
2669    Py_XDECREF(value);
2670    Py_XDECREF(type);
2671    Py_XDECREF(tb);
2672    return;
2673}
2674#else
2675static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
2676    PyObject* owned_instance = NULL;
2677    if (tb == Py_None) {
2678        tb = 0;
2679    } else if (tb && !PyTraceBack_Check(tb)) {
2680        PyErr_SetString(PyExc_TypeError,
2681            "raise: arg 3 must be a traceback or None");
2682        goto bad;
2683    }
2684    if (value == Py_None)
2685        value = 0;
2686    if (PyExceptionInstance_Check(type)) {
2687        if (value) {
2688            PyErr_SetString(PyExc_TypeError,
2689                "instance exception may not have a separate value");
2690            goto bad;
2691        }
2692        value = type;
2693        type = (PyObject*) Py_TYPE(value);
2694    } else if (PyExceptionClass_Check(type)) {
2695        PyObject *instance_class = NULL;
2696        if (value && PyExceptionInstance_Check(value)) {
2697            instance_class = (PyObject*) Py_TYPE(value);
2698            if (instance_class != type) {
2699                if (PyObject_IsSubclass(instance_class, type)) {
2700                    type = instance_class;
2701                } else {
2702                    instance_class = NULL;
2703                }
2704            }
2705        }
2706        if (!instance_class) {
2707            PyObject *args;
2708            if (!value)
2709                args = PyTuple_New(0);
2710            else if (PyTuple_Check(value)) {
2711                Py_INCREF(value);
2712                args = value;
2713            } else
2714                args = PyTuple_Pack(1, value);
2715            if (!args)
2716                goto bad;
2717            owned_instance = PyObject_Call(type, args, NULL);
2718            Py_DECREF(args);
2719            if (!owned_instance)
2720                goto bad;
2721            value = owned_instance;
2722            if (!PyExceptionInstance_Check(value)) {
2723                PyErr_Format(PyExc_TypeError,
2724                             "calling %R should have returned an instance of "
2725                             "BaseException, not %R",
2726                             type, Py_TYPE(value));
2727                goto bad;
2728            }
2729        }
2730    } else {
2731        PyErr_SetString(PyExc_TypeError,
2732            "raise: exception class must be a subclass of BaseException");
2733        goto bad;
2734    }
2735#if PY_VERSION_HEX >= 0x03030000
2736    if (cause) {
2737#else
2738    if (cause && cause != Py_None) {
2739#endif
2740        PyObject *fixed_cause;
2741        if (cause == Py_None) {
2742            fixed_cause = NULL;
2743        } else if (PyExceptionClass_Check(cause)) {
2744            fixed_cause = PyObject_CallObject(cause, NULL);
2745            if (fixed_cause == NULL)
2746                goto bad;
2747        } else if (PyExceptionInstance_Check(cause)) {
2748            fixed_cause = cause;
2749            Py_INCREF(fixed_cause);
2750        } else {
2751            PyErr_SetString(PyExc_TypeError,
2752                            "exception causes must derive from "
2753                            "BaseException");
2754            goto bad;
2755        }
2756        PyException_SetCause(value, fixed_cause);
2757    }
2758    PyErr_SetObject(type, value);
2759    if (tb) {
2760#if CYTHON_COMPILING_IN_PYPY
2761        PyObject *tmp_type, *tmp_value, *tmp_tb;
2762        PyErr_Fetch(tmp_type, tmp_value, tmp_tb);
2763        Py_INCREF(tb);
2764        PyErr_Restore(tmp_type, tmp_value, tb);
2765        Py_XDECREF(tmp_tb);
2766#else
2767        PyThreadState *tstate = PyThreadState_GET();
2768        PyObject* tmp_tb = tstate->curexc_traceback;
2769        if (tb != tmp_tb) {
2770            Py_INCREF(tb);
2771            tstate->curexc_traceback = tb;
2772            Py_XDECREF(tmp_tb);
2773        }
2774#endif
2775    }
2776bad:
2777    Py_XDECREF(owned_instance);
2778    return;
2779}
2780#endif
2781
2782static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
2783    PyObject *r;
2784    if (!j) return NULL;
2785    r = PyObject_GetItem(o, j);
2786    Py_DECREF(j);
2787    return r;
2788}
2789static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
2790                                                              int wraparound, int boundscheck) {
2791#if CYTHON_COMPILING_IN_CPYTHON
2792    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
2793    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
2794        PyObject *r = PyList_GET_ITEM(o, i);
2795        Py_INCREF(r);
2796        return r;
2797    }
2798    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2799#else
2800    return PySequence_GetItem(o, i);
2801#endif
2802}
2803static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
2804                                                              int wraparound, int boundscheck) {
2805#if CYTHON_COMPILING_IN_CPYTHON
2806    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
2807    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
2808        PyObject *r = PyTuple_GET_ITEM(o, i);
2809        Py_INCREF(r);
2810        return r;
2811    }
2812    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2813#else
2814    return PySequence_GetItem(o, i);
2815#endif
2816}
2817static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
2818                                                     int is_list, int wraparound, int boundscheck) {
2819#if CYTHON_COMPILING_IN_CPYTHON
2820    if (is_list || PyList_CheckExact(o)) {
2821        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
2822        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
2823            PyObject *r = PyList_GET_ITEM(o, n);
2824            Py_INCREF(r);
2825            return r;
2826        }
2827    }
2828    else if (PyTuple_CheckExact(o)) {
2829        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
2830        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
2831            PyObject *r = PyTuple_GET_ITEM(o, n);
2832            Py_INCREF(r);
2833            return r;
2834        }
2835    } else {
2836        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
2837        if (likely(m && m->sq_item)) {
2838            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
2839                Py_ssize_t l = m->sq_length(o);
2840                if (likely(l >= 0)) {
2841                    i += l;
2842                } else {
2843                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
2844                        PyErr_Clear();
2845                    else
2846                        return NULL;
2847                }
2848            }
2849            return m->sq_item(o, i);
2850        }
2851    }
2852#else
2853    if (is_list || PySequence_Check(o)) {
2854        return PySequence_GetItem(o, i);
2855    }
2856#endif
2857    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
2858}
2859
2860static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
2861    PyErr_Format(PyExc_ValueError,
2862                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
2863}
2864
2865static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
2866    PyErr_Format(PyExc_ValueError,
2867                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
2868                 index, (index == 1) ? "" : "s");
2869}
2870
2871static CYTHON_INLINE int __Pyx_IterFinish(void) {
2872#if CYTHON_COMPILING_IN_CPYTHON
2873    PyThreadState *tstate = PyThreadState_GET();
2874    PyObject* exc_type = tstate->curexc_type;
2875    if (unlikely(exc_type)) {
2876        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
2877            PyObject *exc_value, *exc_tb;
2878            exc_value = tstate->curexc_value;
2879            exc_tb = tstate->curexc_traceback;
2880            tstate->curexc_type = 0;
2881            tstate->curexc_value = 0;
2882            tstate->curexc_traceback = 0;
2883            Py_DECREF(exc_type);
2884            Py_XDECREF(exc_value);
2885            Py_XDECREF(exc_tb);
2886            return 0;
2887        } else {
2888            return -1;
2889        }
2890    }
2891    return 0;
2892#else
2893    if (unlikely(PyErr_Occurred())) {
2894        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
2895            PyErr_Clear();
2896            return 0;
2897        } else {
2898            return -1;
2899        }
2900    }
2901    return 0;
2902#endif
2903}
2904
2905static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
2906    if (unlikely(retval)) {
2907        Py_DECREF(retval);
2908        __Pyx_RaiseTooManyValuesError(expected);
2909        return -1;
2910    } else {
2911        return __Pyx_IterFinish();
2912    }
2913    return 0;
2914}
2915
2916static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
2917    PyObject *result;
2918#if CYTHON_COMPILING_IN_CPYTHON
2919    result = PyDict_GetItem(__pyx_d, name);
2920    if (likely(result)) {
2921        Py_INCREF(result);
2922    } else {
2923#else
2924    result = PyObject_GetItem(__pyx_d, name);
2925    if (!result) {
2926        PyErr_Clear();
2927#endif
2928        result = __Pyx_GetBuiltinName(name);
2929    }
2930    return result;
2931}
2932
2933#if CYTHON_COMPILING_IN_CPYTHON
2934static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
2935    PyObject *self, *result;
2936    PyCFunction cfunc;
2937    cfunc = PyCFunction_GET_FUNCTION(func);
2938    self = PyCFunction_GET_SELF(func);
2939    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
2940        return NULL;
2941    result = cfunc(self, arg);
2942    Py_LeaveRecursiveCall();
2943    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
2944        PyErr_SetString(
2945            PyExc_SystemError,
2946            "NULL result without error in PyObject_Call");
2947    }
2948    return result;
2949}
2950#endif
2951
2952#if CYTHON_COMPILING_IN_CPYTHON
2953static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2954    PyObject *result;
2955    PyObject *args = PyTuple_New(1);
2956    if (unlikely(!args)) return NULL;
2957    Py_INCREF(arg);
2958    PyTuple_SET_ITEM(args, 0, arg);
2959    result = __Pyx_PyObject_Call(func, args, NULL);
2960    Py_DECREF(args);
2961    return result;
2962}
2963static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2964#ifdef __Pyx_CyFunction_USED
2965    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
2966#else
2967    if (likely(PyCFunction_Check(func))) {
2968#endif
2969        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
2970            return __Pyx_PyObject_CallMethO(func, arg);
2971        }
2972    }
2973    return __Pyx__PyObject_CallOneArg(func, arg);
2974}
2975#else
2976static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
2977    PyObject* args = PyTuple_Pack(1, arg);
2978    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
2979}
2980#endif
2981
2982#if CYTHON_COMPILING_IN_CPYTHON
2983static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
2984#ifdef __Pyx_CyFunction_USED
2985    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
2986#else
2987    if (likely(PyCFunction_Check(func))) {
2988#endif
2989        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
2990            return __Pyx_PyObject_CallMethO(func, NULL);
2991        }
2992    }
2993    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
2994}
2995#endif
2996
2997static CYTHON_INLINE void __Pyx_ExceptionSave(PyObject **type, PyObject **value, PyObject **tb) {
2998#if CYTHON_COMPILING_IN_CPYTHON
2999    PyThreadState *tstate = PyThreadState_GET();
3000    *type = tstate->exc_type;
3001    *value = tstate->exc_value;
3002    *tb = tstate->exc_traceback;
3003    Py_XINCREF(*type);
3004    Py_XINCREF(*value);
3005    Py_XINCREF(*tb);
3006#else
3007    PyErr_GetExcInfo(type, value, tb);
3008#endif
3009}
3010static void __Pyx_ExceptionReset(PyObject *type, PyObject *value, PyObject *tb) {
3011#if CYTHON_COMPILING_IN_CPYTHON
3012    PyObject *tmp_type, *tmp_value, *tmp_tb;
3013    PyThreadState *tstate = PyThreadState_GET();
3014    tmp_type = tstate->exc_type;
3015    tmp_value = tstate->exc_value;
3016    tmp_tb = tstate->exc_traceback;
3017    tstate->exc_type = type;
3018    tstate->exc_value = value;
3019    tstate->exc_traceback = tb;
3020    Py_XDECREF(tmp_type);
3021    Py_XDECREF(tmp_value);
3022    Py_XDECREF(tmp_tb);
3023#else
3024    PyErr_SetExcInfo(type, value, tb);
3025#endif
3026}
3027
3028static int __Pyx_GetException(PyObject **type, PyObject **value, PyObject **tb) {
3029    PyObject *local_type, *local_value, *local_tb;
3030#if CYTHON_COMPILING_IN_CPYTHON
3031    PyObject *tmp_type, *tmp_value, *tmp_tb;
3032    PyThreadState *tstate = PyThreadState_GET();
3033    local_type = tstate->curexc_type;
3034    local_value = tstate->curexc_value;
3035    local_tb = tstate->curexc_traceback;
3036    tstate->curexc_type = 0;
3037    tstate->curexc_value = 0;
3038    tstate->curexc_traceback = 0;
3039#else
3040    PyErr_Fetch(&local_type, &local_value, &local_tb);
3041#endif
3042    PyErr_NormalizeException(&local_type, &local_value, &local_tb);
3043#if CYTHON_COMPILING_IN_CPYTHON
3044    if (unlikely(tstate->curexc_type))
3045#else
3046    if (unlikely(PyErr_Occurred()))
3047#endif
3048        goto bad;
3049    #if PY_MAJOR_VERSION >= 3
3050    if (local_tb) {
3051        if (unlikely(PyException_SetTraceback(local_value, local_tb) < 0))
3052            goto bad;
3053    }
3054    #endif
3055    Py_XINCREF(local_tb);
3056    Py_XINCREF(local_type);
3057    Py_XINCREF(local_value);
3058    *type = local_type;
3059    *value = local_value;
3060    *tb = local_tb;
3061#if CYTHON_COMPILING_IN_CPYTHON
3062    tmp_type = tstate->exc_type;
3063    tmp_value = tstate->exc_value;
3064    tmp_tb = tstate->exc_traceback;
3065    tstate->exc_type = local_type;
3066    tstate->exc_value = local_value;
3067    tstate->exc_traceback = local_tb;
3068    Py_XDECREF(tmp_type);
3069    Py_XDECREF(tmp_value);
3070    Py_XDECREF(tmp_tb);
3071#else
3072    PyErr_SetExcInfo(local_type, local_value, local_tb);
3073#endif
3074    return 0;
3075bad:
3076    *type = 0;
3077    *value = 0;
3078    *tb = 0;
3079    Py_XDECREF(local_type);
3080    Py_XDECREF(local_value);
3081    Py_XDECREF(local_tb);
3082    return -1;
3083}
3084
3085static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
3086    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
3087    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
3088        PyErr_Format(PyExc_ImportError,
3089        #if PY_MAJOR_VERSION < 3
3090            "cannot import name %.230s", PyString_AS_STRING(name));
3091        #else
3092            "cannot import name %S", name);
3093        #endif
3094    }
3095    return value;
3096}
3097
3098static void* __Pyx_GetVtable(PyObject *dict) {
3099    void* ptr;
3100    PyObject *ob = PyObject_GetItem(dict, __pyx_n_s_pyx_vtable);
3101    if (!ob)
3102        goto bad;
3103#if PY_VERSION_HEX >= 0x02070000
3104    ptr = PyCapsule_GetPointer(ob, 0);
3105#else
3106    ptr = PyCObject_AsVoidPtr(ob);
3107#endif
3108    if (!ptr && !PyErr_Occurred())
3109        PyErr_SetString(PyExc_RuntimeError, "invalid vtable found for imported type");
3110    Py_DECREF(ob);
3111    return ptr;
3112bad:
3113    Py_XDECREF(ob);
3114    return NULL;
3115}
3116
3117static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
3118    int start = 0, mid = 0, end = count - 1;
3119    if (end >= 0 && code_line > entries[end].code_line) {
3120        return count;
3121    }
3122    while (start < end) {
3123        mid = (start + end) / 2;
3124        if (code_line < entries[mid].code_line) {
3125            end = mid;
3126        } else if (code_line > entries[mid].code_line) {
3127             start = mid + 1;
3128        } else {
3129            return mid;
3130        }
3131    }
3132    if (code_line <= entries[mid].code_line) {
3133        return mid;
3134    } else {
3135        return mid + 1;
3136    }
3137}
3138static PyCodeObject *__pyx_find_code_object(int code_line) {
3139    PyCodeObject* code_object;
3140    int pos;
3141    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
3142        return NULL;
3143    }
3144    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3145    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
3146        return NULL;
3147    }
3148    code_object = __pyx_code_cache.entries[pos].code_object;
3149    Py_INCREF(code_object);
3150    return code_object;
3151}
3152static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
3153    int pos, i;
3154    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
3155    if (unlikely(!code_line)) {
3156        return;
3157    }
3158    if (unlikely(!entries)) {
3159        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
3160        if (likely(entries)) {
3161            __pyx_code_cache.entries = entries;
3162            __pyx_code_cache.max_count = 64;
3163            __pyx_code_cache.count = 1;
3164            entries[0].code_line = code_line;
3165            entries[0].code_object = code_object;
3166            Py_INCREF(code_object);
3167        }
3168        return;
3169    }
3170    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
3171    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
3172        PyCodeObject* tmp = entries[pos].code_object;
3173        entries[pos].code_object = code_object;
3174        Py_DECREF(tmp);
3175        return;
3176    }
3177    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
3178        int new_max = __pyx_code_cache.max_count + 64;
3179        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
3180            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
3181        if (unlikely(!entries)) {
3182            return;
3183        }
3184        __pyx_code_cache.entries = entries;
3185        __pyx_code_cache.max_count = new_max;
3186    }
3187    for (i=__pyx_code_cache.count; i>pos; i--) {
3188        entries[i] = entries[i-1];
3189    }
3190    entries[pos].code_line = code_line;
3191    entries[pos].code_object = code_object;
3192    __pyx_code_cache.count++;
3193    Py_INCREF(code_object);
3194}
3195
3196#include "compile.h"
3197#include "frameobject.h"
3198#include "traceback.h"
3199static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
3200            const char *funcname, int c_line,
3201            int py_line, const char *filename) {
3202    PyCodeObject *py_code = 0;
3203    PyObject *py_srcfile = 0;
3204    PyObject *py_funcname = 0;
3205    #if PY_MAJOR_VERSION < 3
3206    py_srcfile = PyString_FromString(filename);
3207    #else
3208    py_srcfile = PyUnicode_FromString(filename);
3209    #endif
3210    if (!py_srcfile) goto bad;
3211    if (c_line) {
3212        #if PY_MAJOR_VERSION < 3
3213        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3214        #else
3215        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
3216        #endif
3217    }
3218    else {
3219        #if PY_MAJOR_VERSION < 3
3220        py_funcname = PyString_FromString(funcname);
3221        #else
3222        py_funcname = PyUnicode_FromString(funcname);
3223        #endif
3224    }
3225    if (!py_funcname) goto bad;
3226    py_code = __Pyx_PyCode_New(
3227        0,
3228        0,
3229        0,
3230        0,
3231        0,
3232        __pyx_empty_bytes, /*PyObject *code,*/
3233        __pyx_empty_tuple, /*PyObject *consts,*/
3234        __pyx_empty_tuple, /*PyObject *names,*/
3235        __pyx_empty_tuple, /*PyObject *varnames,*/
3236        __pyx_empty_tuple, /*PyObject *freevars,*/
3237        __pyx_empty_tuple, /*PyObject *cellvars,*/
3238        py_srcfile,   /*PyObject *filename,*/
3239        py_funcname,  /*PyObject *name,*/
3240        py_line,
3241        __pyx_empty_bytes  /*PyObject *lnotab*/
3242    );
3243    Py_DECREF(py_srcfile);
3244    Py_DECREF(py_funcname);
3245    return py_code;
3246bad:
3247    Py_XDECREF(py_srcfile);
3248    Py_XDECREF(py_funcname);
3249    return NULL;
3250}
3251static void __Pyx_AddTraceback(const char *funcname, int c_line,
3252                               int py_line, const char *filename) {
3253    PyCodeObject *py_code = 0;
3254    PyFrameObject *py_frame = 0;
3255    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
3256    if (!py_code) {
3257        py_code = __Pyx_CreateCodeObjectForTraceback(
3258            funcname, c_line, py_line, filename);
3259        if (!py_code) goto bad;
3260        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
3261    }
3262    py_frame = PyFrame_New(
3263        PyThreadState_GET(), /*PyThreadState *tstate,*/
3264        py_code,             /*PyCodeObject *code,*/
3265        __pyx_d,      /*PyObject *globals,*/
3266        0                    /*PyObject *locals*/
3267    );
3268    if (!py_frame) goto bad;
3269    py_frame->f_lineno = py_line;
3270    PyTraceBack_Here(py_frame);
3271bad:
3272    Py_XDECREF(py_code);
3273    Py_XDECREF(py_frame);
3274}
3275
3276static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
3277    PyObject *empty_list = 0;
3278    PyObject *module = 0;
3279    PyObject *global_dict = 0;
3280    PyObject *empty_dict = 0;
3281    PyObject *list;
3282    #if PY_VERSION_HEX < 0x03030000
3283    PyObject *py_import;
3284    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
3285    if (!py_import)
3286        goto bad;
3287    #endif
3288    if (from_list)
3289        list = from_list;
3290    else {
3291        empty_list = PyList_New(0);
3292        if (!empty_list)
3293            goto bad;
3294        list = empty_list;
3295    }
3296    global_dict = PyModule_GetDict(__pyx_m);
3297    if (!global_dict)
3298        goto bad;
3299    empty_dict = PyDict_New();
3300    if (!empty_dict)
3301        goto bad;
3302    {
3303        #if PY_MAJOR_VERSION >= 3
3304        if (level == -1) {
3305            if (strchr(__Pyx_MODULE_NAME, '.')) {
3306                #if PY_VERSION_HEX < 0x03030000
3307                PyObject *py_level = PyInt_FromLong(1);
3308                if (!py_level)
3309                    goto bad;
3310                module = PyObject_CallFunctionObjArgs(py_import,
3311                    name, global_dict, empty_dict, list, py_level, NULL);
3312                Py_DECREF(py_level);
3313                #else
3314                module = PyImport_ImportModuleLevelObject(
3315                    name, global_dict, empty_dict, list, 1);
3316                #endif
3317                if (!module) {
3318                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
3319                        goto bad;
3320                    PyErr_Clear();
3321                }
3322            }
3323            level = 0;
3324        }
3325        #endif
3326        if (!module) {
3327            #if PY_VERSION_HEX < 0x03030000
3328            PyObject *py_level = PyInt_FromLong(level);
3329            if (!py_level)
3330                goto bad;
3331            module = PyObject_CallFunctionObjArgs(py_import,
3332                name, global_dict, empty_dict, list, py_level, NULL);
3333            Py_DECREF(py_level);
3334            #else
3335            module = PyImport_ImportModuleLevelObject(
3336                name, global_dict, empty_dict, list, level);
3337            #endif
3338        }
3339    }
3340bad:
3341    #if PY_VERSION_HEX < 0x03030000
3342    Py_XDECREF(py_import);
3343    #endif
3344    Py_XDECREF(empty_list);
3345    Py_XDECREF(empty_dict);
3346    return module;
3347}
3348
3349static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
3350    const long neg_one = (long) -1, const_zero = 0;
3351    const int is_unsigned = neg_one > const_zero;
3352    if (is_unsigned) {
3353        if (sizeof(long) < sizeof(long)) {
3354            return PyInt_FromLong((long) value);
3355        } else if (sizeof(long) <= sizeof(unsigned long)) {
3356            return PyLong_FromUnsignedLong((unsigned long) value);
3357        } else if (sizeof(long) <= sizeof(unsigned long long)) {
3358            return PyLong_FromUnsignedLongLong((unsigned long long) value);
3359        }
3360    } else {
3361        if (sizeof(long) <= sizeof(long)) {
3362            return PyInt_FromLong((long) value);
3363        } else if (sizeof(long) <= sizeof(long long)) {
3364            return PyLong_FromLongLong((long long) value);
3365        }
3366    }
3367    {
3368        int one = 1; int little = (int)*(unsigned char *)&one;
3369        unsigned char *bytes = (unsigned char *)&value;
3370        return _PyLong_FromByteArray(bytes, sizeof(long),
3371                                     little, !is_unsigned);
3372    }
3373}
3374
3375#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
3376    {                                                                     \
3377        func_type value = func_value;                                     \
3378        if (sizeof(target_type) < sizeof(func_type)) {                    \
3379            if (unlikely(value != (func_type) (target_type) value)) {     \
3380                func_type zero = 0;                                       \
3381                if (is_unsigned && unlikely(value < zero))                \
3382                    goto raise_neg_overflow;                              \
3383                else                                                      \
3384                    goto raise_overflow;                                  \
3385            }                                                             \
3386        }                                                                 \
3387        return (target_type) value;                                       \
3388    }
3389
3390#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3391 #if CYTHON_USE_PYLONG_INTERNALS
3392  #include "longintrepr.h"
3393 #endif
3394#endif
3395
3396static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
3397    const long neg_one = (long) -1, const_zero = 0;
3398    const int is_unsigned = neg_one > const_zero;
3399#if PY_MAJOR_VERSION < 3
3400    if (likely(PyInt_Check(x))) {
3401        if (sizeof(long) < sizeof(long)) {
3402            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
3403        } else {
3404            long val = PyInt_AS_LONG(x);
3405            if (is_unsigned && unlikely(val < 0)) {
3406                goto raise_neg_overflow;
3407            }
3408            return (long) val;
3409        }
3410    } else
3411#endif
3412    if (likely(PyLong_Check(x))) {
3413        if (is_unsigned) {
3414#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3415 #if CYTHON_USE_PYLONG_INTERNALS
3416            switch (Py_SIZE(x)) {
3417                case  0: return 0;
3418                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
3419            }
3420 #endif
3421#endif
3422            if (unlikely(Py_SIZE(x) < 0)) {
3423                goto raise_neg_overflow;
3424            }
3425            if (sizeof(long) <= sizeof(unsigned long)) {
3426                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
3427            } else if (sizeof(long) <= sizeof(unsigned long long)) {
3428                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong(x))
3429            }
3430        } else {
3431#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3432 #if CYTHON_USE_PYLONG_INTERNALS
3433            switch (Py_SIZE(x)) {
3434                case  0: return 0;
3435                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
3436                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
3437            }
3438 #endif
3439#endif
3440            if (sizeof(long) <= sizeof(long)) {
3441                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
3442            } else if (sizeof(long) <= sizeof(long long)) {
3443                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong(x))
3444            }
3445        }
3446        {
3447#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3448            PyErr_SetString(PyExc_RuntimeError,
3449                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3450#else
3451            long val;
3452            PyObject *v = __Pyx_PyNumber_Int(x);
3453 #if PY_MAJOR_VERSION < 3
3454            if (likely(v) && !PyLong_Check(v)) {
3455                PyObject *tmp = v;
3456                v = PyNumber_Long(tmp);
3457                Py_DECREF(tmp);
3458            }
3459 #endif
3460            if (likely(v)) {
3461                int one = 1; int is_little = (int)*(unsigned char *)&one;
3462                unsigned char *bytes = (unsigned char *)&val;
3463                int ret = _PyLong_AsByteArray((PyLongObject *)v,
3464                                              bytes, sizeof(val),
3465                                              is_little, !is_unsigned);
3466                Py_DECREF(v);
3467                if (likely(!ret))
3468                    return val;
3469            }
3470#endif
3471            return (long) -1;
3472        }
3473    } else {
3474        long val;
3475        PyObject *tmp = __Pyx_PyNumber_Int(x);
3476        if (!tmp) return (long) -1;
3477        val = __Pyx_PyInt_As_long(tmp);
3478        Py_DECREF(tmp);
3479        return val;
3480    }
3481raise_overflow:
3482    PyErr_SetString(PyExc_OverflowError,
3483        "value too large to convert to long");
3484    return (long) -1;
3485raise_neg_overflow:
3486    PyErr_SetString(PyExc_OverflowError,
3487        "can't convert negative value to long");
3488    return (long) -1;
3489}
3490
3491static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
3492    const int neg_one = (int) -1, const_zero = 0;
3493    const int is_unsigned = neg_one > const_zero;
3494    if (is_unsigned) {
3495        if (sizeof(int) < sizeof(long)) {
3496            return PyInt_FromLong((long) value);
3497        } else if (sizeof(int) <= sizeof(unsigned long)) {
3498            return PyLong_FromUnsignedLong((unsigned long) value);
3499        } else if (sizeof(int) <= sizeof(unsigned long long)) {
3500            return PyLong_FromUnsignedLongLong((unsigned long long) value);
3501        }
3502    } else {
3503        if (sizeof(int) <= sizeof(long)) {
3504            return PyInt_FromLong((long) value);
3505        } else if (sizeof(int) <= sizeof(long long)) {
3506            return PyLong_FromLongLong((long long) value);
3507        }
3508    }
3509    {
3510        int one = 1; int little = (int)*(unsigned char *)&one;
3511        unsigned char *bytes = (unsigned char *)&value;
3512        return _PyLong_FromByteArray(bytes, sizeof(int),
3513                                     little, !is_unsigned);
3514    }
3515}
3516
3517static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
3518    const int neg_one = (int) -1, const_zero = 0;
3519    const int is_unsigned = neg_one > const_zero;
3520#if PY_MAJOR_VERSION < 3
3521    if (likely(PyInt_Check(x))) {
3522        if (sizeof(int) < sizeof(long)) {
3523            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
3524        } else {
3525            long val = PyInt_AS_LONG(x);
3526            if (is_unsigned && unlikely(val < 0)) {
3527                goto raise_neg_overflow;
3528            }
3529            return (int) val;
3530        }
3531    } else
3532#endif
3533    if (likely(PyLong_Check(x))) {
3534        if (is_unsigned) {
3535#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3536 #if CYTHON_USE_PYLONG_INTERNALS
3537            switch (Py_SIZE(x)) {
3538                case  0: return 0;
3539                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
3540            }
3541 #endif
3542#endif
3543            if (unlikely(Py_SIZE(x) < 0)) {
3544                goto raise_neg_overflow;
3545            }
3546            if (sizeof(int) <= sizeof(unsigned long)) {
3547                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
3548            } else if (sizeof(int) <= sizeof(unsigned long long)) {
3549                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong(x))
3550            }
3551        } else {
3552#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3553 #if CYTHON_USE_PYLONG_INTERNALS
3554            switch (Py_SIZE(x)) {
3555                case  0: return 0;
3556                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
3557                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
3558            }
3559 #endif
3560#endif
3561            if (sizeof(int) <= sizeof(long)) {
3562                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
3563            } else if (sizeof(int) <= sizeof(long long)) {
3564                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong(x))
3565            }
3566        }
3567        {
3568#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3569            PyErr_SetString(PyExc_RuntimeError,
3570                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3571#else
3572            int val;
3573            PyObject *v = __Pyx_PyNumber_Int(x);
3574 #if PY_MAJOR_VERSION < 3
3575            if (likely(v) && !PyLong_Check(v)) {
3576                PyObject *tmp = v;
3577                v = PyNumber_Long(tmp);
3578                Py_DECREF(tmp);
3579            }
3580 #endif
3581            if (likely(v)) {
3582                int one = 1; int is_little = (int)*(unsigned char *)&one;
3583                unsigned char *bytes = (unsigned char *)&val;
3584                int ret = _PyLong_AsByteArray((PyLongObject *)v,
3585                                              bytes, sizeof(val),
3586                                              is_little, !is_unsigned);
3587                Py_DECREF(v);
3588                if (likely(!ret))
3589                    return val;
3590            }
3591#endif
3592            return (int) -1;
3593        }
3594    } else {
3595        int val;
3596        PyObject *tmp = __Pyx_PyNumber_Int(x);
3597        if (!tmp) return (int) -1;
3598        val = __Pyx_PyInt_As_int(tmp);
3599        Py_DECREF(tmp);
3600        return val;
3601    }
3602raise_overflow:
3603    PyErr_SetString(PyExc_OverflowError,
3604        "value too large to convert to int");
3605    return (int) -1;
3606raise_neg_overflow:
3607    PyErr_SetString(PyExc_OverflowError,
3608        "can't convert negative value to int");
3609    return (int) -1;
3610}
3611
3612static CYTHON_INLINE short __Pyx_PyInt_As_short(PyObject *x) {
3613    const short neg_one = (short) -1, const_zero = 0;
3614    const int is_unsigned = neg_one > const_zero;
3615#if PY_MAJOR_VERSION < 3
3616    if (likely(PyInt_Check(x))) {
3617        if (sizeof(short) < sizeof(long)) {
3618            __PYX_VERIFY_RETURN_INT(short, long, PyInt_AS_LONG(x))
3619        } else {
3620            long val = PyInt_AS_LONG(x);
3621            if (is_unsigned && unlikely(val < 0)) {
3622                goto raise_neg_overflow;
3623            }
3624            return (short) val;
3625        }
3626    } else
3627#endif
3628    if (likely(PyLong_Check(x))) {
3629        if (is_unsigned) {
3630#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3631 #if CYTHON_USE_PYLONG_INTERNALS
3632            switch (Py_SIZE(x)) {
3633                case  0: return 0;
3634                case  1: __PYX_VERIFY_RETURN_INT(short, digit, ((PyLongObject*)x)->ob_digit[0]);
3635            }
3636 #endif
3637#endif
3638            if (unlikely(Py_SIZE(x) < 0)) {
3639                goto raise_neg_overflow;
3640            }
3641            if (sizeof(short) <= sizeof(unsigned long)) {
3642                __PYX_VERIFY_RETURN_INT(short, unsigned long, PyLong_AsUnsignedLong(x))
3643            } else if (sizeof(short) <= sizeof(unsigned long long)) {
3644                __PYX_VERIFY_RETURN_INT(short, unsigned long long, PyLong_AsUnsignedLongLong(x))
3645            }
3646        } else {
3647#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3648 #if CYTHON_USE_PYLONG_INTERNALS
3649            switch (Py_SIZE(x)) {
3650                case  0: return 0;
3651                case  1: __PYX_VERIFY_RETURN_INT(short,  digit, +(((PyLongObject*)x)->ob_digit[0]));
3652                case -1: __PYX_VERIFY_RETURN_INT(short, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
3653            }
3654 #endif
3655#endif
3656            if (sizeof(short) <= sizeof(long)) {
3657                __PYX_VERIFY_RETURN_INT(short, long, PyLong_AsLong(x))
3658            } else if (sizeof(short) <= sizeof(long long)) {
3659                __PYX_VERIFY_RETURN_INT(short, long long, PyLong_AsLongLong(x))
3660            }
3661        }
3662        {
3663#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
3664            PyErr_SetString(PyExc_RuntimeError,
3665                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
3666#else
3667            short val;
3668            PyObject *v = __Pyx_PyNumber_Int(x);
3669 #if PY_MAJOR_VERSION < 3
3670            if (likely(v) && !PyLong_Check(v)) {
3671                PyObject *tmp = v;
3672                v = PyNumber_Long(tmp);
3673                Py_DECREF(tmp);
3674            }
3675 #endif
3676            if (likely(v)) {
3677                int one = 1; int is_little = (int)*(unsigned char *)&one;
3678                unsigned char *bytes = (unsigned char *)&val;
3679                int ret = _PyLong_AsByteArray((PyLongObject *)v,
3680                                              bytes, sizeof(val),
3681                                              is_little, !is_unsigned);
3682                Py_DECREF(v);
3683                if (likely(!ret))
3684                    return val;
3685            }
3686#endif
3687            return (short) -1;
3688        }
3689    } else {
3690        short val;
3691        PyObject *tmp = __Pyx_PyNumber_Int(x);
3692        if (!tmp) return (short) -1;
3693        val = __Pyx_PyInt_As_short(tmp);
3694        Py_DECREF(tmp);
3695        return val;
3696    }
3697raise_overflow:
3698    PyErr_SetString(PyExc_OverflowError,
3699        "value too large to convert to short");
3700    return (short) -1;
3701raise_neg_overflow:
3702    PyErr_SetString(PyExc_OverflowError,
3703        "can't convert negative value to short");
3704    return (short) -1;
3705}
3706
3707static CYTHON_INLINE PyObject* __Pyx_PyInt_From_short(short value) {
3708    const short neg_one = (short) -1, const_zero = 0;
3709    const int is_unsigned = neg_one > const_zero;
3710    if (is_unsigned) {
3711        if (sizeof(short) < sizeof(long)) {
3712            return PyInt_FromLong((long) value);
3713        } else if (sizeof(short) <= sizeof(unsigned long)) {
3714            return PyLong_FromUnsignedLong((unsigned long) value);
3715        } else if (sizeof(short) <= sizeof(unsigned long long)) {
3716            return PyLong_FromUnsignedLongLong((unsigned long long) value);
3717        }
3718    } else {
3719        if (sizeof(short) <= sizeof(long)) {
3720            return PyInt_FromLong((long) value);
3721        } else if (sizeof(short) <= sizeof(long long)) {
3722            return PyLong_FromLongLong((long long) value);
3723        }
3724    }
3725    {
3726        int one = 1; int little = (int)*(unsigned char *)&one;
3727        unsigned char *bytes = (unsigned char *)&value;
3728        return _PyLong_FromByteArray(bytes, sizeof(short),
3729                                     little, !is_unsigned);
3730    }
3731}
3732
3733static int __Pyx_check_binary_version(void) {
3734    char ctversion[4], rtversion[4];
3735    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
3736    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
3737    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
3738        char message[200];
3739        PyOS_snprintf(message, sizeof(message),
3740                      "compiletime version %s of module '%.100s' "
3741                      "does not match runtime version %s",
3742                      ctversion, __Pyx_MODULE_NAME, rtversion);
3743        return PyErr_WarnEx(NULL, message, 1);
3744    }
3745    return 0;
3746}
3747
3748#ifndef __PYX_HAVE_RT_ImportModule
3749#define __PYX_HAVE_RT_ImportModule
3750static PyObject *__Pyx_ImportModule(const char *name) {
3751    PyObject *py_name = 0;
3752    PyObject *py_module = 0;
3753    py_name = __Pyx_PyIdentifier_FromString(name);
3754    if (!py_name)
3755        goto bad;
3756    py_module = PyImport_Import(py_name);
3757    Py_DECREF(py_name);
3758    return py_module;
3759bad:
3760    Py_XDECREF(py_name);
3761    return 0;
3762}
3763#endif
3764
3765#ifndef __PYX_HAVE_RT_ImportType
3766#define __PYX_HAVE_RT_ImportType
3767static PyTypeObject *__Pyx_ImportType(const char *module_name, const char *class_name,
3768    size_t size, int strict)
3769{
3770    PyObject *py_module = 0;
3771    PyObject *result = 0;
3772    PyObject *py_name = 0;
3773    char warning[200];
3774    Py_ssize_t basicsize;
3775#ifdef Py_LIMITED_API
3776    PyObject *py_basicsize;
3777#endif
3778    py_module = __Pyx_ImportModule(module_name);
3779    if (!py_module)
3780        goto bad;
3781    py_name = __Pyx_PyIdentifier_FromString(class_name);
3782    if (!py_name)
3783        goto bad;
3784    result = PyObject_GetAttr(py_module, py_name);
3785    Py_DECREF(py_name);
3786    py_name = 0;
3787    Py_DECREF(py_module);
3788    py_module = 0;
3789    if (!result)
3790        goto bad;
3791    if (!PyType_Check(result)) {
3792        PyErr_Format(PyExc_TypeError,
3793            "%.200s.%.200s is not a type object",
3794            module_name, class_name);
3795        goto bad;
3796    }
3797#ifndef Py_LIMITED_API
3798    basicsize = ((PyTypeObject *)result)->tp_basicsize;
3799#else
3800    py_basicsize = PyObject_GetAttrString(result, "__basicsize__");
3801    if (!py_basicsize)
3802        goto bad;
3803    basicsize = PyLong_AsSsize_t(py_basicsize);
3804    Py_DECREF(py_basicsize);
3805    py_basicsize = 0;
3806    if (basicsize == (Py_ssize_t)-1 && PyErr_Occurred())
3807        goto bad;
3808#endif
3809    if (!strict && (size_t)basicsize > size) {
3810        PyOS_snprintf(warning, sizeof(warning),
3811            "%s.%s size changed, may indicate binary incompatibility",
3812            module_name, class_name);
3813        if (PyErr_WarnEx(NULL, warning, 0) < 0) goto bad;
3814    }
3815    else if ((size_t)basicsize != size) {
3816        PyErr_Format(PyExc_ValueError,
3817            "%.200s.%.200s has the wrong size, try recompiling",
3818            module_name, class_name);
3819        goto bad;
3820    }
3821    return (PyTypeObject *)result;
3822bad:
3823    Py_XDECREF(py_module);
3824    Py_XDECREF(result);
3825    return NULL;
3826}
3827#endif
3828
3829static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
3830    while (t->p) {
3831        #if PY_MAJOR_VERSION < 3
3832        if (t->is_unicode) {
3833            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
3834        } else if (t->intern) {
3835            *t->p = PyString_InternFromString(t->s);
3836        } else {
3837            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
3838        }
3839        #else
3840        if (t->is_unicode | t->is_str) {
3841            if (t->intern) {
3842                *t->p = PyUnicode_InternFromString(t->s);
3843            } else if (t->encoding) {
3844                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
3845            } else {
3846                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
3847            }
3848        } else {
3849            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
3850        }
3851        #endif
3852        if (!*t->p)
3853            return -1;
3854        ++t;
3855    }
3856    return 0;
3857}
3858
3859static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
3860    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
3861}
3862static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
3863    Py_ssize_t ignore;
3864    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
3865}
3866static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
3867#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
3868    if (
3869#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3870            __Pyx_sys_getdefaultencoding_not_ascii &&
3871#endif
3872            PyUnicode_Check(o)) {
3873#if PY_VERSION_HEX < 0x03030000
3874        char* defenc_c;
3875        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
3876        if (!defenc) return NULL;
3877        defenc_c = PyBytes_AS_STRING(defenc);
3878#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3879        {
3880            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
3881            char* c;
3882            for (c = defenc_c; c < end; c++) {
3883                if ((unsigned char) (*c) >= 128) {
3884                    PyUnicode_AsASCIIString(o);
3885                    return NULL;
3886                }
3887            }
3888        }
3889#endif
3890        *length = PyBytes_GET_SIZE(defenc);
3891        return defenc_c;
3892#else
3893        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
3894#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
3895        if (PyUnicode_IS_ASCII(o)) {
3896            *length = PyUnicode_GET_LENGTH(o);
3897            return PyUnicode_AsUTF8(o);
3898        } else {
3899            PyUnicode_AsASCIIString(o);
3900            return NULL;
3901        }
3902#else
3903        return PyUnicode_AsUTF8AndSize(o, length);
3904#endif
3905#endif
3906    } else
3907#endif
3908#if !CYTHON_COMPILING_IN_PYPY
3909    if (PyByteArray_Check(o)) {
3910        *length = PyByteArray_GET_SIZE(o);
3911        return PyByteArray_AS_STRING(o);
3912    } else
3913#endif
3914    {
3915        char* result;
3916        int r = PyBytes_AsStringAndSize(o, &result, length);
3917        if (unlikely(r < 0)) {
3918            return NULL;
3919        } else {
3920            return result;
3921        }
3922    }
3923}
3924static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
3925   int is_true = x == Py_True;
3926   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
3927   else return PyObject_IsTrue(x);
3928}
3929static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
3930  PyNumberMethods *m;
3931  const char *name = NULL;
3932  PyObject *res = NULL;
3933#if PY_MAJOR_VERSION < 3
3934  if (PyInt_Check(x) || PyLong_Check(x))
3935#else
3936  if (PyLong_Check(x))
3937#endif
3938    return Py_INCREF(x), x;
3939  m = Py_TYPE(x)->tp_as_number;
3940#if PY_MAJOR_VERSION < 3
3941  if (m && m->nb_int) {
3942    name = "int";
3943    res = PyNumber_Int(x);
3944  }
3945  else if (m && m->nb_long) {
3946    name = "long";
3947    res = PyNumber_Long(x);
3948  }
3949#else
3950  if (m && m->nb_int) {
3951    name = "int";
3952    res = PyNumber_Long(x);
3953  }
3954#endif
3955  if (res) {
3956#if PY_MAJOR_VERSION < 3
3957    if (!PyInt_Check(res) && !PyLong_Check(res)) {
3958#else
3959    if (!PyLong_Check(res)) {
3960#endif
3961      PyErr_Format(PyExc_TypeError,
3962                   "__%.4s__ returned non-%.4s (type %.200s)",
3963                   name, name, Py_TYPE(res)->tp_name);
3964      Py_DECREF(res);
3965      return NULL;
3966    }
3967  }
3968  else if (!PyErr_Occurred()) {
3969    PyErr_SetString(PyExc_TypeError,
3970                    "an integer is required");
3971  }
3972  return res;
3973}
3974static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
3975  Py_ssize_t ival;
3976  PyObject *x;
3977#if PY_MAJOR_VERSION < 3
3978  if (likely(PyInt_CheckExact(b)))
3979      return PyInt_AS_LONG(b);
3980#endif
3981  if (likely(PyLong_CheckExact(b))) {
3982    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
3983     #if CYTHON_USE_PYLONG_INTERNALS
3984       switch (Py_SIZE(b)) {
3985       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
3986       case  0: return 0;
3987       case  1: return ((PyLongObject*)b)->ob_digit[0];
3988       }
3989     #endif
3990    #endif
3991    return PyLong_AsSsize_t(b);
3992  }
3993  x = PyNumber_Index(b);
3994  if (!x) return -1;
3995  ival = PyInt_AsSsize_t(x);
3996  Py_DECREF(x);
3997  return ival;
3998}
3999static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
4000    return PyInt_FromSize_t(ival);
4001}
4002
4003
4004#endif /* Py_PYTHON_H */
4005