summaryrefslogtreecommitdiffstats
path: root/scripts/external_libs/zmq/utils
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/external_libs/zmq/utils')
-rw-r--r--scripts/external_libs/zmq/utils/__init__.py0
-rw-r--r--scripts/external_libs/zmq/utils/buffers.pxd313
-rw-r--r--scripts/external_libs/zmq/utils/compiler.json24
-rw-r--r--scripts/external_libs/zmq/utils/config.json10
-rw-r--r--scripts/external_libs/zmq/utils/constant_names.py365
-rw-r--r--scripts/external_libs/zmq/utils/garbage.py180
-rw-r--r--scripts/external_libs/zmq/utils/getpid_compat.h6
-rw-r--r--scripts/external_libs/zmq/utils/interop.py33
-rw-r--r--scripts/external_libs/zmq/utils/ipcmaxlen.h21
-rw-r--r--scripts/external_libs/zmq/utils/jsonapi.py59
-rw-r--r--scripts/external_libs/zmq/utils/monitor.py68
-rw-r--r--scripts/external_libs/zmq/utils/pyversion_compat.h25
-rw-r--r--scripts/external_libs/zmq/utils/sixcerpt.py52
-rw-r--r--scripts/external_libs/zmq/utils/strtypes.py45
-rw-r--r--scripts/external_libs/zmq/utils/win32.py132
-rw-r--r--scripts/external_libs/zmq/utils/z85.py56
-rw-r--r--scripts/external_libs/zmq/utils/zmq_compat.h80
-rw-r--r--scripts/external_libs/zmq/utils/zmq_constants.h622
18 files changed, 2091 insertions, 0 deletions
diff --git a/scripts/external_libs/zmq/utils/__init__.py b/scripts/external_libs/zmq/utils/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/__init__.py
diff --git a/scripts/external_libs/zmq/utils/buffers.pxd b/scripts/external_libs/zmq/utils/buffers.pxd
new file mode 100644
index 00000000..998aa551
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/buffers.pxd
@@ -0,0 +1,313 @@
+"""Python version-independent methods for C/Python buffers.
+
+This file was copied and adapted from mpi4py.
+
+Authors
+-------
+* MinRK
+"""
+
+#-----------------------------------------------------------------------------
+# Copyright (c) 2010 Lisandro Dalcin
+# All rights reserved.
+# Used under BSD License: http://www.opensource.org/licenses/bsd-license.php
+#
+# Retrieval:
+# Jul 23, 2010 18:00 PST (r539)
+# http://code.google.com/p/mpi4py/source/browse/trunk/src/MPI/asbuffer.pxi
+#
+# Modifications from original:
+# Copyright (c) 2010-2012 Brian Granger, Min Ragan-Kelley
+#
+# Distributed under the terms of the New BSD License. The full license is in
+# the file COPYING.BSD, distributed as part of this software.
+#-----------------------------------------------------------------------------
+
+
+#-----------------------------------------------------------------------------
+# Python includes.
+#-----------------------------------------------------------------------------
+
+# get version-independent aliases:
+cdef extern from "pyversion_compat.h":
+ pass
+
+# Python 3 buffer interface (PEP 3118)
+cdef extern from "Python.h":
+ int PY_MAJOR_VERSION
+ int PY_MINOR_VERSION
+ ctypedef int Py_ssize_t
+ ctypedef struct PyMemoryViewObject:
+ pass
+ ctypedef struct Py_buffer:
+ void *buf
+ Py_ssize_t len
+ int readonly
+ char *format
+ int ndim
+ Py_ssize_t *shape
+ Py_ssize_t *strides
+ Py_ssize_t *suboffsets
+ Py_ssize_t itemsize
+ void *internal
+ cdef enum:
+ PyBUF_SIMPLE
+ PyBUF_WRITABLE
+ PyBUF_FORMAT
+ PyBUF_ANY_CONTIGUOUS
+ int PyObject_CheckBuffer(object)
+ int PyObject_GetBuffer(object, Py_buffer *, int) except -1
+ void PyBuffer_Release(Py_buffer *)
+
+ int PyBuffer_FillInfo(Py_buffer *view, object obj, void *buf,
+ Py_ssize_t len, int readonly, int infoflags) except -1
+ object PyMemoryView_FromBuffer(Py_buffer *info)
+
+ object PyMemoryView_FromObject(object)
+
+# Python 2 buffer interface (legacy)
+cdef extern from "Python.h":
+ ctypedef void const_void "const void"
+ Py_ssize_t Py_END_OF_BUFFER
+ int PyObject_CheckReadBuffer(object)
+ int PyObject_AsReadBuffer (object, const_void **, Py_ssize_t *) except -1
+ int PyObject_AsWriteBuffer(object, void **, Py_ssize_t *) except -1
+
+ object PyBuffer_FromMemory(void *ptr, Py_ssize_t s)
+ object PyBuffer_FromReadWriteMemory(void *ptr, Py_ssize_t s)
+
+ object PyBuffer_FromObject(object, Py_ssize_t offset, Py_ssize_t size)
+ object PyBuffer_FromReadWriteObject(object, Py_ssize_t offset, Py_ssize_t size)
+
+
+#-----------------------------------------------------------------------------
+# asbuffer: C buffer from python object
+#-----------------------------------------------------------------------------
+
+
+cdef inline int memoryview_available():
+ return PY_MAJOR_VERSION >= 3 or (PY_MAJOR_VERSION >=2 and PY_MINOR_VERSION >= 7)
+
+cdef inline int oldstyle_available():
+ return PY_MAJOR_VERSION < 3
+
+
+cdef inline int check_buffer(object ob):
+ """Version independent check for whether an object is a buffer.
+
+ Parameters
+ ----------
+ object : object
+ Any Python object
+
+ Returns
+ -------
+ int : 0 if no buffer interface, 3 if newstyle buffer interface, 2 if oldstyle.
+ """
+ if PyObject_CheckBuffer(ob):
+ return 3
+ if oldstyle_available():
+ return PyObject_CheckReadBuffer(ob) and 2
+ return 0
+
+
+cdef inline object asbuffer(object ob, int writable, int format,
+ void **base, Py_ssize_t *size,
+ Py_ssize_t *itemsize):
+ """Turn an object into a C buffer in a Python version-independent way.
+
+ Parameters
+ ----------
+ ob : object
+ The object to be turned into a buffer.
+ Must provide a Python Buffer interface
+ writable : int
+ Whether the resulting buffer should be allowed to write
+ to the object.
+ format : int
+ The format of the buffer. See Python buffer docs.
+ base : void **
+ The pointer that will be used to store the resulting C buffer.
+ size : Py_ssize_t *
+ The size of the buffer(s).
+ itemsize : Py_ssize_t *
+ The size of an item, if the buffer is non-contiguous.
+
+ Returns
+ -------
+ An object describing the buffer format. Generally a str, such as 'B'.
+ """
+
+ cdef void *bptr = NULL
+ cdef Py_ssize_t blen = 0, bitemlen = 0
+ cdef Py_buffer view
+ cdef int flags = PyBUF_SIMPLE
+ cdef int mode = 0
+
+ bfmt = None
+
+ mode = check_buffer(ob)
+ if mode == 0:
+ raise TypeError("%r does not provide a buffer interface."%ob)
+
+ if mode == 3:
+ flags = PyBUF_ANY_CONTIGUOUS
+ if writable:
+ flags |= PyBUF_WRITABLE
+ if format:
+ flags |= PyBUF_FORMAT
+ PyObject_GetBuffer(ob, &view, flags)
+ bptr = view.buf
+ blen = view.len
+ if format:
+ if view.format != NULL:
+ bfmt = view.format
+ bitemlen = view.itemsize
+ PyBuffer_Release(&view)
+ else: # oldstyle
+ if writable:
+ PyObject_AsWriteBuffer(ob, &bptr, &blen)
+ else:
+ PyObject_AsReadBuffer(ob, <const_void **>&bptr, &blen)
+ if format:
+ try: # numpy.ndarray
+ dtype = ob.dtype
+ bfmt = dtype.char
+ bitemlen = dtype.itemsize
+ except AttributeError:
+ try: # array.array
+ bfmt = ob.typecode
+ bitemlen = ob.itemsize
+ except AttributeError:
+ if isinstance(ob, bytes):
+ bfmt = b"B"
+ bitemlen = 1
+ else:
+ # nothing found
+ bfmt = None
+ bitemlen = 0
+ if base: base[0] = <void *>bptr
+ if size: size[0] = <Py_ssize_t>blen
+ if itemsize: itemsize[0] = <Py_ssize_t>bitemlen
+
+ if PY_MAJOR_VERSION >= 3 and bfmt is not None:
+ return bfmt.decode('ascii')
+ return bfmt
+
+
+cdef inline object asbuffer_r(object ob, void **base, Py_ssize_t *size):
+ """Wrapper for standard calls to asbuffer with a readonly buffer."""
+ asbuffer(ob, 0, 0, base, size, NULL)
+ return ob
+
+
+cdef inline object asbuffer_w(object ob, void **base, Py_ssize_t *size):
+ """Wrapper for standard calls to asbuffer with a writable buffer."""
+ asbuffer(ob, 1, 0, base, size, NULL)
+ return ob
+
+#------------------------------------------------------------------------------
+# frombuffer: python buffer/view from C buffer
+#------------------------------------------------------------------------------
+
+
+cdef inline object frombuffer_3(void *ptr, Py_ssize_t s, int readonly):
+ """Python 3 version of frombuffer.
+
+ This is the Python 3 model, but will work on Python >= 2.6. Currently,
+ we use it only on >= 3.0.
+ """
+ cdef Py_buffer pybuf
+ cdef Py_ssize_t *shape = [s]
+ cdef str astr=""
+ PyBuffer_FillInfo(&pybuf, astr, ptr, s, readonly, PyBUF_SIMPLE)
+ pybuf.format = "B"
+ pybuf.shape = shape
+ return PyMemoryView_FromBuffer(&pybuf)
+
+
+cdef inline object frombuffer_2(void *ptr, Py_ssize_t s, int readonly):
+ """Python 2 version of frombuffer.
+
+ This must be used for Python <= 2.6, but we use it for all Python < 3.
+ """
+
+ if oldstyle_available():
+ if readonly:
+ return PyBuffer_FromMemory(ptr, s)
+ else:
+ return PyBuffer_FromReadWriteMemory(ptr, s)
+ else:
+ raise NotImplementedError("Old style buffers not available.")
+
+
+cdef inline object frombuffer(void *ptr, Py_ssize_t s, int readonly):
+ """Create a Python Buffer/View of a C array.
+
+ Parameters
+ ----------
+ ptr : void *
+ Pointer to the array to be copied.
+ s : size_t
+ Length of the buffer.
+ readonly : int
+ whether the resulting object should be allowed to write to the buffer.
+
+ Returns
+ -------
+ Python Buffer/View of the C buffer.
+ """
+ # oldstyle first priority for now
+ if oldstyle_available():
+ return frombuffer_2(ptr, s, readonly)
+ else:
+ return frombuffer_3(ptr, s, readonly)
+
+
+cdef inline object frombuffer_r(void *ptr, Py_ssize_t s):
+ """Wrapper for readonly view frombuffer."""
+ return frombuffer(ptr, s, 1)
+
+
+cdef inline object frombuffer_w(void *ptr, Py_ssize_t s):
+ """Wrapper for writable view frombuffer."""
+ return frombuffer(ptr, s, 0)
+
+#------------------------------------------------------------------------------
+# viewfromobject: python buffer/view from python object, refcounts intact
+# frombuffer(asbuffer(obj)) would lose track of refs
+#------------------------------------------------------------------------------
+
+cdef inline object viewfromobject(object obj, int readonly):
+ """Construct a Python Buffer/View object from another Python object.
+
+ This work in a Python version independent manner.
+
+ Parameters
+ ----------
+ obj : object
+ The input object to be cast as a buffer
+ readonly : int
+ Whether the result should be prevented from overwriting the original.
+
+ Returns
+ -------
+ Buffer/View of the original object.
+ """
+ if not memoryview_available():
+ if readonly:
+ return PyBuffer_FromObject(obj, 0, Py_END_OF_BUFFER)
+ else:
+ return PyBuffer_FromReadWriteObject(obj, 0, Py_END_OF_BUFFER)
+ else:
+ return PyMemoryView_FromObject(obj)
+
+
+cdef inline object viewfromobject_r(object obj):
+ """Wrapper for readonly viewfromobject."""
+ return viewfromobject(obj, 1)
+
+
+cdef inline object viewfromobject_w(object obj):
+ """Wrapper for writable viewfromobject."""
+ return viewfromobject(obj, 0)
diff --git a/scripts/external_libs/zmq/utils/compiler.json b/scripts/external_libs/zmq/utils/compiler.json
new file mode 100644
index 00000000..e58fc130
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/compiler.json
@@ -0,0 +1,24 @@
+{
+ "extra_link_args": [],
+ "define_macros": [
+ [
+ "HAVE_SYS_UN_H",
+ 1
+ ]
+ ],
+ "runtime_library_dirs": [
+ "$ORIGIN/.."
+ ],
+ "libraries": [
+ "zmq"
+ ],
+ "library_dirs": [
+ "zmq"
+ ],
+ "include_dirs": [
+ "/auto/srg-sce-swinfra-usr/emb/users/hhaim/work/depot/asr1k/emb/private/bpsim/main/src/zmq/include",
+ "zmq/utils",
+ "zmq/backend/cython",
+ "zmq/devices"
+ ]
+} \ No newline at end of file
diff --git a/scripts/external_libs/zmq/utils/config.json b/scripts/external_libs/zmq/utils/config.json
new file mode 100644
index 00000000..1e4611f9
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/config.json
@@ -0,0 +1,10 @@
+{
+ "have_sys_un_h": true,
+ "zmq_prefix": "/auto/srg-sce-swinfra-usr/emb/users/hhaim/work/depot/asr1k/emb/private/bpsim/main/src/zmq",
+ "no_libzmq_extension": true,
+ "libzmq_extension": false,
+ "easy_install": {},
+ "bdist_egg": {},
+ "skip_check_zmq": false,
+ "build_ext": {}
+} \ No newline at end of file
diff --git a/scripts/external_libs/zmq/utils/constant_names.py b/scripts/external_libs/zmq/utils/constant_names.py
new file mode 100644
index 00000000..47da9dc2
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/constant_names.py
@@ -0,0 +1,365 @@
+"""0MQ Constant names"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+# dictionaries of constants new or removed in particular versions
+
+new_in = {
+ (2,2,0) : [
+ 'RCVTIMEO',
+ 'SNDTIMEO',
+ ],
+ (3,2,2) : [
+ # errnos
+ 'EMSGSIZE',
+ 'EAFNOSUPPORT',
+ 'ENETUNREACH',
+ 'ECONNABORTED',
+ 'ECONNRESET',
+ 'ENOTCONN',
+ 'ETIMEDOUT',
+ 'EHOSTUNREACH',
+ 'ENETRESET',
+
+ # ctx opts
+ 'IO_THREADS',
+ 'MAX_SOCKETS',
+ 'IO_THREADS_DFLT',
+ 'MAX_SOCKETS_DFLT',
+
+ # socket opts
+ 'ROUTER_BEHAVIOR',
+ 'ROUTER_MANDATORY',
+ 'FAIL_UNROUTABLE',
+ 'TCP_KEEPALIVE',
+ 'TCP_KEEPALIVE_CNT',
+ 'TCP_KEEPALIVE_IDLE',
+ 'TCP_KEEPALIVE_INTVL',
+ 'DELAY_ATTACH_ON_CONNECT',
+ 'XPUB_VERBOSE',
+
+ # msg opts
+ 'MORE',
+
+ 'EVENT_CONNECTED',
+ 'EVENT_CONNECT_DELAYED',
+ 'EVENT_CONNECT_RETRIED',
+ 'EVENT_LISTENING',
+ 'EVENT_BIND_FAILED',
+ 'EVENT_ACCEPTED',
+ 'EVENT_ACCEPT_FAILED',
+ 'EVENT_CLOSED',
+ 'EVENT_CLOSE_FAILED',
+ 'EVENT_DISCONNECTED',
+ 'EVENT_ALL',
+ ],
+ (4,0,0) : [
+ # socket types
+ 'STREAM',
+
+ # socket opts
+ 'IMMEDIATE',
+ 'ROUTER_RAW',
+ 'IPV6',
+ 'MECHANISM',
+ 'PLAIN_SERVER',
+ 'PLAIN_USERNAME',
+ 'PLAIN_PASSWORD',
+ 'CURVE_SERVER',
+ 'CURVE_PUBLICKEY',
+ 'CURVE_SECRETKEY',
+ 'CURVE_SERVERKEY',
+ 'PROBE_ROUTER',
+ 'REQ_RELAXED',
+ 'REQ_CORRELATE',
+ 'CONFLATE',
+ 'ZAP_DOMAIN',
+
+ # security
+ 'NULL',
+ 'PLAIN',
+ 'CURVE',
+
+ # events
+ 'EVENT_MONITOR_STOPPED',
+ ],
+ (4,1,0) : [
+ # ctx opts
+ 'SOCKET_LIMIT',
+ 'THREAD_PRIORITY',
+ 'THREAD_PRIORITY_DFLT',
+ 'THREAD_SCHED_POLICY',
+ 'THREAD_SCHED_POLICY_DFLT',
+
+ # socket opts
+ 'ROUTER_HANDOVER',
+ 'TOS',
+ 'IPC_FILTER_PID',
+ 'IPC_FILTER_UID',
+ 'IPC_FILTER_GID',
+ 'CONNECT_RID',
+ 'GSSAPI_SERVER',
+ 'GSSAPI_PRINCIPAL',
+ 'GSSAPI_SERVICE_PRINCIPAL',
+ 'GSSAPI_PLAINTEXT',
+ 'HANDSHAKE_IVL',
+ 'IDENTITY_FD',
+ 'XPUB_NODROP',
+ 'SOCKS_PROXY',
+
+ # msg opts
+ 'SRCFD',
+ 'SHARED',
+
+ # security
+ 'GSSAPI',
+
+ ],
+}
+
+
+removed_in = {
+ (3,2,2) : [
+ 'UPSTREAM',
+ 'DOWNSTREAM',
+
+ 'HWM',
+ 'SWAP',
+ 'MCAST_LOOP',
+ 'RECOVERY_IVL_MSEC',
+ ]
+}
+
+# collections of zmq constant names based on their role
+# base names have no specific use
+# opt names are validated in get/set methods of various objects
+
+base_names = [
+ # base
+ 'VERSION',
+ 'VERSION_MAJOR',
+ 'VERSION_MINOR',
+ 'VERSION_PATCH',
+ 'NOBLOCK',
+ 'DONTWAIT',
+
+ 'POLLIN',
+ 'POLLOUT',
+ 'POLLERR',
+
+ 'SNDMORE',
+
+ 'STREAMER',
+ 'FORWARDER',
+ 'QUEUE',
+
+ 'IO_THREADS_DFLT',
+ 'MAX_SOCKETS_DFLT',
+ 'POLLITEMS_DFLT',
+ 'THREAD_PRIORITY_DFLT',
+ 'THREAD_SCHED_POLICY_DFLT',
+
+ # socktypes
+ 'PAIR',
+ 'PUB',
+ 'SUB',
+ 'REQ',
+ 'REP',
+ 'DEALER',
+ 'ROUTER',
+ 'XREQ',
+ 'XREP',
+ 'PULL',
+ 'PUSH',
+ 'XPUB',
+ 'XSUB',
+ 'UPSTREAM',
+ 'DOWNSTREAM',
+ 'STREAM',
+
+ # events
+ 'EVENT_CONNECTED',
+ 'EVENT_CONNECT_DELAYED',
+ 'EVENT_CONNECT_RETRIED',
+ 'EVENT_LISTENING',
+ 'EVENT_BIND_FAILED',
+ 'EVENT_ACCEPTED',
+ 'EVENT_ACCEPT_FAILED',
+ 'EVENT_CLOSED',
+ 'EVENT_CLOSE_FAILED',
+ 'EVENT_DISCONNECTED',
+ 'EVENT_ALL',
+ 'EVENT_MONITOR_STOPPED',
+
+ # security
+ 'NULL',
+ 'PLAIN',
+ 'CURVE',
+ 'GSSAPI',
+
+ ## ERRNO
+ # Often used (these are alse in errno.)
+ 'EAGAIN',
+ 'EINVAL',
+ 'EFAULT',
+ 'ENOMEM',
+ 'ENODEV',
+ 'EMSGSIZE',
+ 'EAFNOSUPPORT',
+ 'ENETUNREACH',
+ 'ECONNABORTED',
+ 'ECONNRESET',
+ 'ENOTCONN',
+ 'ETIMEDOUT',
+ 'EHOSTUNREACH',
+ 'ENETRESET',
+
+ # For Windows compatability
+ 'HAUSNUMERO',
+ 'ENOTSUP',
+ 'EPROTONOSUPPORT',
+ 'ENOBUFS',
+ 'ENETDOWN',
+ 'EADDRINUSE',
+ 'EADDRNOTAVAIL',
+ 'ECONNREFUSED',
+ 'EINPROGRESS',
+ 'ENOTSOCK',
+
+ # 0MQ Native
+ 'EFSM',
+ 'ENOCOMPATPROTO',
+ 'ETERM',
+ 'EMTHREAD',
+]
+
+int64_sockopt_names = [
+ 'AFFINITY',
+ 'MAXMSGSIZE',
+
+ # sockopts removed in 3.0.0
+ 'HWM',
+ 'SWAP',
+ 'MCAST_LOOP',
+ 'RECOVERY_IVL_MSEC',
+]
+
+bytes_sockopt_names = [
+ 'IDENTITY',
+ 'SUBSCRIBE',
+ 'UNSUBSCRIBE',
+ 'LAST_ENDPOINT',
+ 'TCP_ACCEPT_FILTER',
+
+ 'PLAIN_USERNAME',
+ 'PLAIN_PASSWORD',
+
+ 'CURVE_PUBLICKEY',
+ 'CURVE_SECRETKEY',
+ 'CURVE_SERVERKEY',
+ 'ZAP_DOMAIN',
+ 'CONNECT_RID',
+ 'GSSAPI_PRINCIPAL',
+ 'GSSAPI_SERVICE_PRINCIPAL',
+ 'SOCKS_PROXY',
+]
+
+fd_sockopt_names = [
+ 'FD',
+ 'IDENTITY_FD',
+]
+
+int_sockopt_names = [
+ # sockopts
+ 'RECONNECT_IVL_MAX',
+
+ # sockopts new in 2.2.0
+ 'SNDTIMEO',
+ 'RCVTIMEO',
+
+ # new in 3.x
+ 'SNDHWM',
+ 'RCVHWM',
+ 'MULTICAST_HOPS',
+ 'IPV4ONLY',
+
+ 'ROUTER_BEHAVIOR',
+ 'TCP_KEEPALIVE',
+ 'TCP_KEEPALIVE_CNT',
+ 'TCP_KEEPALIVE_IDLE',
+ 'TCP_KEEPALIVE_INTVL',
+ 'DELAY_ATTACH_ON_CONNECT',
+ 'XPUB_VERBOSE',
+
+ 'EVENTS',
+ 'TYPE',
+ 'LINGER',
+ 'RECONNECT_IVL',
+ 'BACKLOG',
+
+ 'ROUTER_MANDATORY',
+ 'FAIL_UNROUTABLE',
+
+ 'ROUTER_RAW',
+ 'IMMEDIATE',
+ 'IPV6',
+ 'MECHANISM',
+ 'PLAIN_SERVER',
+ 'CURVE_SERVER',
+ 'PROBE_ROUTER',
+ 'REQ_RELAXED',
+ 'REQ_CORRELATE',
+ 'CONFLATE',
+ 'ROUTER_HANDOVER',
+ 'TOS',
+ 'IPC_FILTER_PID',
+ 'IPC_FILTER_UID',
+ 'IPC_FILTER_GID',
+ 'GSSAPI_SERVER',
+ 'GSSAPI_PLAINTEXT',
+ 'HANDSHAKE_IVL',
+ 'XPUB_NODROP',
+]
+
+switched_sockopt_names = [
+ 'RATE',
+ 'RECOVERY_IVL',
+ 'SNDBUF',
+ 'RCVBUF',
+ 'RCVMORE',
+]
+
+ctx_opt_names = [
+ 'IO_THREADS',
+ 'MAX_SOCKETS',
+ 'SOCKET_LIMIT',
+ 'THREAD_PRIORITY',
+ 'THREAD_SCHED_POLICY',
+]
+
+msg_opt_names = [
+ 'MORE',
+ 'SRCFD',
+ 'SHARED',
+]
+
+from itertools import chain
+
+all_names = list(chain(
+ base_names,
+ ctx_opt_names,
+ bytes_sockopt_names,
+ fd_sockopt_names,
+ int_sockopt_names,
+ int64_sockopt_names,
+ switched_sockopt_names,
+ msg_opt_names,
+))
+
+del chain
+
+def no_prefix(name):
+ """does the given constant have a ZMQ_ prefix?"""
+ return name.startswith('E') and not name.startswith('EVENT')
+
diff --git a/scripts/external_libs/zmq/utils/garbage.py b/scripts/external_libs/zmq/utils/garbage.py
new file mode 100644
index 00000000..80a8725a
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/garbage.py
@@ -0,0 +1,180 @@
+"""Garbage collection thread for representing zmq refcount of Python objects
+used in zero-copy sends.
+"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+
+import atexit
+import struct
+
+from os import getpid
+from collections import namedtuple
+from threading import Thread, Event, Lock
+import warnings
+
+import zmq
+
+
+gcref = namedtuple('gcref', ['obj', 'event'])
+
+class GarbageCollectorThread(Thread):
+ """Thread in which garbage collection actually happens."""
+ def __init__(self, gc):
+ super(GarbageCollectorThread, self).__init__()
+ self.gc = gc
+ self.daemon = True
+ self.pid = getpid()
+ self.ready = Event()
+
+ def run(self):
+ # detect fork at begining of the thread
+ if getpid is None or getpid() != self.pid:
+ self.ready.set()
+ return
+ try:
+ s = self.gc.context.socket(zmq.PULL)
+ s.linger = 0
+ s.bind(self.gc.url)
+ finally:
+ self.ready.set()
+
+ while True:
+ # detect fork
+ if getpid is None or getpid() != self.pid:
+ return
+ msg = s.recv()
+ if msg == b'DIE':
+ break
+ fmt = 'L' if len(msg) == 4 else 'Q'
+ key = struct.unpack(fmt, msg)[0]
+ tup = self.gc.refs.pop(key, None)
+ if tup and tup.event:
+ tup.event.set()
+ del tup
+ s.close()
+
+
+class GarbageCollector(object):
+ """PyZMQ Garbage Collector
+
+ Used for representing the reference held by libzmq during zero-copy sends.
+ This object holds a dictionary, keyed by Python id,
+ of the Python objects whose memory are currently in use by zeromq.
+
+ When zeromq is done with the memory, it sends a message on an inproc PUSH socket
+ containing the packed size_t (32 or 64-bit unsigned int),
+ which is the key in the dict.
+ When the PULL socket in the gc thread receives that message,
+ the reference is popped from the dict,
+ and any tracker events that should be signaled fire.
+ """
+
+ refs = None
+ _context = None
+ _lock = None
+ url = "inproc://pyzmq.gc.01"
+
+ def __init__(self, context=None):
+ super(GarbageCollector, self).__init__()
+ self.refs = {}
+ self.pid = None
+ self.thread = None
+ self._context = context
+ self._lock = Lock()
+ self._stay_down = False
+ atexit.register(self._atexit)
+
+ @property
+ def context(self):
+ if self._context is None:
+ self._context = zmq.Context()
+ return self._context
+
+ @context.setter
+ def context(self, ctx):
+ if self.is_alive():
+ if self.refs:
+ warnings.warn("Replacing gc context while gc is running", RuntimeWarning)
+ self.stop()
+ self._context = ctx
+
+ def _atexit(self):
+ """atexit callback
+
+ sets _stay_down flag so that gc doesn't try to start up again in other atexit handlers
+ """
+ self._stay_down = True
+ self.stop()
+
+ def stop(self):
+ """stop the garbage-collection thread"""
+ if not self.is_alive():
+ return
+ self._stop()
+
+ def _stop(self):
+ push = self.context.socket(zmq.PUSH)
+ push.connect(self.url)
+ push.send(b'DIE')
+ push.close()
+ self.thread.join()
+ self.context.term()
+ self.refs.clear()
+ self.context = None
+
+ def start(self):
+ """Start a new garbage collection thread.
+
+ Creates a new zmq Context used for garbage collection.
+ Under most circumstances, this will only be called once per process.
+ """
+ if self.thread is not None and self.pid != getpid():
+ # It's re-starting, must free earlier thread's context
+ # since a fork probably broke it
+ self._stop()
+ self.pid = getpid()
+ self.refs = {}
+ self.thread = GarbageCollectorThread(self)
+ self.thread.start()
+ self.thread.ready.wait()
+
+ def is_alive(self):
+ """Is the garbage collection thread currently running?
+
+ Includes checks for process shutdown or fork.
+ """
+ if (getpid is None or
+ getpid() != self.pid or
+ self.thread is None or
+ not self.thread.is_alive()
+ ):
+ return False
+ return True
+
+ def store(self, obj, event=None):
+ """store an object and (optionally) event for zero-copy"""
+ if not self.is_alive():
+ if self._stay_down:
+ return 0
+ # safely start the gc thread
+ # use lock and double check,
+ # so we don't start multiple threads
+ with self._lock:
+ if not self.is_alive():
+ self.start()
+ tup = gcref(obj, event)
+ theid = id(tup)
+ self.refs[theid] = tup
+ return theid
+
+ def __del__(self):
+ if not self.is_alive():
+ return
+ try:
+ self.stop()
+ except Exception as e:
+ raise (e)
+
+gc = GarbageCollector()
diff --git a/scripts/external_libs/zmq/utils/getpid_compat.h b/scripts/external_libs/zmq/utils/getpid_compat.h
new file mode 100644
index 00000000..47ce90fa
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/getpid_compat.h
@@ -0,0 +1,6 @@
+#ifdef _WIN32
+ #include <process.h>
+ #define getpid _getpid
+#else
+ #include <unistd.h>
+#endif
diff --git a/scripts/external_libs/zmq/utils/interop.py b/scripts/external_libs/zmq/utils/interop.py
new file mode 100644
index 00000000..26c01969
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/interop.py
@@ -0,0 +1,33 @@
+"""Utils for interoperability with other libraries.
+
+Just CFFI pointer casting for now.
+"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+
+try:
+ long
+except NameError:
+ long = int # Python 3
+
+
+def cast_int_addr(n):
+ """Cast an address to a Python int
+
+ This could be a Python integer or a CFFI pointer
+ """
+ if isinstance(n, (int, long)):
+ return n
+ try:
+ import cffi
+ except ImportError:
+ pass
+ else:
+ # from pyzmq, this is an FFI void *
+ ffi = cffi.FFI()
+ if isinstance(n, ffi.CData):
+ return int(ffi.cast("size_t", n))
+
+ raise ValueError("Cannot cast %r to int" % n)
diff --git a/scripts/external_libs/zmq/utils/ipcmaxlen.h b/scripts/external_libs/zmq/utils/ipcmaxlen.h
new file mode 100644
index 00000000..7218db78
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/ipcmaxlen.h
@@ -0,0 +1,21 @@
+/*
+
+Platform-independant detection of IPC path max length
+
+Copyright (c) 2012 Godefroid Chapelle
+
+Distributed under the terms of the New BSD License. The full license is in
+the file COPYING.BSD, distributed as part of this software.
+ */
+
+#if defined(HAVE_SYS_UN_H)
+#include "sys/un.h"
+int get_ipc_path_max_len(void) {
+ struct sockaddr_un *dummy;
+ return sizeof(dummy->sun_path) - 1;
+}
+#else
+int get_ipc_path_max_len(void) {
+ return 0;
+}
+#endif
diff --git a/scripts/external_libs/zmq/utils/jsonapi.py b/scripts/external_libs/zmq/utils/jsonapi.py
new file mode 100644
index 00000000..865ca6d5
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/jsonapi.py
@@ -0,0 +1,59 @@
+"""Priority based json library imports.
+
+Always serializes to bytes instead of unicode for zeromq compatibility
+on Python 2 and 3.
+
+Use ``jsonapi.loads()`` and ``jsonapi.dumps()`` for guaranteed symmetry.
+
+Priority: ``simplejson`` > ``jsonlib2`` > stdlib ``json``
+
+``jsonapi.loads/dumps`` provide kwarg-compatibility with stdlib json.
+
+``jsonapi.jsonmod`` will be the module of the actual underlying implementation.
+"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+from zmq.utils.strtypes import bytes, unicode
+
+jsonmod = None
+
+priority = ['simplejson', 'jsonlib2', 'json']
+for mod in priority:
+ try:
+ jsonmod = __import__(mod)
+ except ImportError:
+ pass
+ else:
+ break
+
+def dumps(o, **kwargs):
+ """Serialize object to JSON bytes (utf-8).
+
+ See jsonapi.jsonmod.dumps for details on kwargs.
+ """
+
+ if 'separators' not in kwargs:
+ kwargs['separators'] = (',', ':')
+
+ s = jsonmod.dumps(o, **kwargs)
+
+ if isinstance(s, unicode):
+ s = s.encode('utf8')
+
+ return s
+
+def loads(s, **kwargs):
+ """Load object from JSON bytes (utf-8).
+
+ See jsonapi.jsonmod.loads for details on kwargs.
+ """
+
+ if str is unicode and isinstance(s, bytes):
+ s = s.decode('utf8')
+
+ return jsonmod.loads(s, **kwargs)
+
+__all__ = ['jsonmod', 'dumps', 'loads']
+
diff --git a/scripts/external_libs/zmq/utils/monitor.py b/scripts/external_libs/zmq/utils/monitor.py
new file mode 100644
index 00000000..734d54b1
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/monitor.py
@@ -0,0 +1,68 @@
+# -*- coding: utf-8 -*-
+"""Module holding utility and convenience functions for zmq event monitoring."""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+import struct
+import zmq
+from zmq.error import _check_version
+
+def parse_monitor_message(msg):
+ """decode zmq_monitor event messages.
+
+ Parameters
+ ----------
+ msg : list(bytes)
+ zmq multipart message that has arrived on a monitor PAIR socket.
+
+ First frame is::
+
+ 16 bit event id
+ 32 bit event value
+ no padding
+
+ Second frame is the endpoint as a bytestring
+
+ Returns
+ -------
+ event : dict
+ event description as dict with the keys `event`, `value`, and `endpoint`.
+ """
+
+ if len(msg) != 2 or len(msg[0]) != 6:
+ raise RuntimeError("Invalid event message format: %s" % msg)
+ event = {}
+ event['event'], event['value'] = struct.unpack("=hi", msg[0])
+ event['endpoint'] = msg[1]
+ return event
+
+def recv_monitor_message(socket, flags=0):
+ """Receive and decode the given raw message from the monitoring socket and return a dict.
+
+ Requires libzmq ≥ 4.0
+
+ The returned dict will have the following entries:
+ event : int, the event id as described in libzmq.zmq_socket_monitor
+ value : int, the event value associated with the event, see libzmq.zmq_socket_monitor
+ endpoint : string, the affected endpoint
+
+ Parameters
+ ----------
+ socket : zmq PAIR socket
+ The PAIR socket (created by other.get_monitor_socket()) on which to recv the message
+ flags : bitfield (int)
+ standard zmq recv flags
+
+ Returns
+ -------
+ event : dict
+ event description as dict with the keys `event`, `value`, and `endpoint`.
+ """
+ _check_version((4,0), 'libzmq event API')
+ # will always return a list
+ msg = socket.recv_multipart(flags)
+ # 4.0-style event API
+ return parse_monitor_message(msg)
+
+__all__ = ['parse_monitor_message', 'recv_monitor_message']
diff --git a/scripts/external_libs/zmq/utils/pyversion_compat.h b/scripts/external_libs/zmq/utils/pyversion_compat.h
new file mode 100644
index 00000000..fac09046
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/pyversion_compat.h
@@ -0,0 +1,25 @@
+#include "Python.h"
+
+#if PY_VERSION_HEX < 0x02070000
+ #define PyMemoryView_FromBuffer(info) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), (PyObject *)NULL)
+ #define PyMemoryView_FromObject(object) (PyErr_SetString(PyExc_NotImplementedError, \
+ "new buffer interface is not available"), (PyObject *)NULL)
+#endif
+
+#if PY_VERSION_HEX >= 0x03000000
+ // for buffers
+ #define Py_END_OF_BUFFER ((Py_ssize_t) 0)
+
+ #define PyObject_CheckReadBuffer(object) (0)
+
+ #define PyBuffer_FromMemory(ptr, s) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+ #define PyBuffer_FromReadWriteMemory(ptr, s) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+ #define PyBuffer_FromObject(object, offset, size) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+ #define PyBuffer_FromReadWriteObject(object, offset, size) (PyErr_SetString(PyExc_NotImplementedError, \
+ "old buffer interface is not available"), (PyObject *)NULL)
+
+#endif
diff --git a/scripts/external_libs/zmq/utils/sixcerpt.py b/scripts/external_libs/zmq/utils/sixcerpt.py
new file mode 100644
index 00000000..5492fd59
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/sixcerpt.py
@@ -0,0 +1,52 @@
+"""Excerpts of six.py"""
+
+# Copyright (C) 2010-2014 Benjamin Peterson
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in all
+# copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+# SOFTWARE.
+
+import sys
+
+# Useful for very coarse version differentiation.
+PY2 = sys.version_info[0] == 2
+PY3 = sys.version_info[0] == 3
+
+if PY3:
+
+ def reraise(tp, value, tb=None):
+ if value.__traceback__ is not tb:
+ raise value.with_traceback(tb)
+ raise value
+
+else:
+ def exec_(_code_, _globs_=None, _locs_=None):
+ """Execute code in a namespace."""
+ if _globs_ is None:
+ frame = sys._getframe(1)
+ _globs_ = frame.f_globals
+ if _locs_ is None:
+ _locs_ = frame.f_locals
+ del frame
+ elif _locs_ is None:
+ _locs_ = _globs_
+ exec("""exec _code_ in _globs_, _locs_""")
+
+
+ exec_("""def reraise(tp, value, tb=None):
+ raise tp, value, tb
+""")
diff --git a/scripts/external_libs/zmq/utils/strtypes.py b/scripts/external_libs/zmq/utils/strtypes.py
new file mode 100644
index 00000000..548410dc
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/strtypes.py
@@ -0,0 +1,45 @@
+"""Declare basic string types unambiguously for various Python versions.
+
+Authors
+-------
+* MinRK
+"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+import sys
+
+if sys.version_info[0] >= 3:
+ bytes = bytes
+ unicode = str
+ basestring = (bytes, unicode)
+else:
+ unicode = unicode
+ bytes = str
+ basestring = basestring
+
+def cast_bytes(s, encoding='utf8', errors='strict'):
+ """cast unicode or bytes to bytes"""
+ if isinstance(s, bytes):
+ return s
+ elif isinstance(s, unicode):
+ return s.encode(encoding, errors)
+ else:
+ raise TypeError("Expected unicode or bytes, got %r" % s)
+
+def cast_unicode(s, encoding='utf8', errors='strict'):
+ """cast bytes or unicode to unicode"""
+ if isinstance(s, bytes):
+ return s.decode(encoding, errors)
+ elif isinstance(s, unicode):
+ return s
+ else:
+ raise TypeError("Expected unicode or bytes, got %r" % s)
+
+# give short 'b' alias for cast_bytes, so that we can use fake b('stuff')
+# to simulate b'stuff'
+b = asbytes = cast_bytes
+u = cast_unicode
+
+__all__ = ['asbytes', 'bytes', 'unicode', 'basestring', 'b', 'u', 'cast_bytes', 'cast_unicode']
diff --git a/scripts/external_libs/zmq/utils/win32.py b/scripts/external_libs/zmq/utils/win32.py
new file mode 100644
index 00000000..ea758299
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/win32.py
@@ -0,0 +1,132 @@
+"""Win32 compatibility utilities."""
+
+#-----------------------------------------------------------------------------
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+#-----------------------------------------------------------------------------
+
+import os
+
+# No-op implementation for other platforms.
+class _allow_interrupt(object):
+ """Utility for fixing CTRL-C events on Windows.
+
+ On Windows, the Python interpreter intercepts CTRL-C events in order to
+ translate them into ``KeyboardInterrupt`` exceptions. It (presumably)
+ does this by setting a flag in its "control control handler" and
+ checking it later at a convenient location in the interpreter.
+
+ However, when the Python interpreter is blocked waiting for the ZMQ
+ poll operation to complete, it must wait for ZMQ's ``select()``
+ operation to complete before translating the CTRL-C event into the
+ ``KeyboardInterrupt`` exception.
+
+ The only way to fix this seems to be to add our own "console control
+ handler" and perform some application-defined operation that will
+ unblock the ZMQ polling operation in order to force ZMQ to pass control
+ back to the Python interpreter.
+
+ This context manager performs all that Windows-y stuff, providing you
+ with a hook that is called when a CTRL-C event is intercepted. This
+ hook allows you to unblock your ZMQ poll operation immediately, which
+ will then result in the expected ``KeyboardInterrupt`` exception.
+
+ Without this context manager, your ZMQ-based application will not
+ respond normally to CTRL-C events on Windows. If a CTRL-C event occurs
+ while blocked on ZMQ socket polling, the translation to a
+ ``KeyboardInterrupt`` exception will be delayed until the I/O completes
+ and control returns to the Python interpreter (this may never happen if
+ you use an infinite timeout).
+
+ A no-op implementation is provided on non-Win32 systems to avoid the
+ application from having to conditionally use it.
+
+ Example usage:
+
+ .. sourcecode:: python
+
+ def stop_my_application():
+ # ...
+
+ with allow_interrupt(stop_my_application):
+ # main polling loop.
+
+ In a typical ZMQ application, you would use the "self pipe trick" to
+ send message to a ``PAIR`` socket in order to interrupt your blocking
+ socket polling operation.
+
+ In a Tornado event loop, you can use the ``IOLoop.stop`` method to
+ unblock your I/O loop.
+ """
+
+ def __init__(self, action=None):
+ """Translate ``action`` into a CTRL-C handler.
+
+ ``action`` is a callable that takes no arguments and returns no
+ value (returned value is ignored). It must *NEVER* raise an
+ exception.
+
+ If unspecified, a no-op will be used.
+ """
+ self._init_action(action)
+
+ def _init_action(self, action):
+ pass
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, *args):
+ return
+
+if os.name == 'nt':
+ from ctypes import WINFUNCTYPE, windll
+ from ctypes.wintypes import BOOL, DWORD
+
+ kernel32 = windll.LoadLibrary('kernel32')
+
+ # <http://msdn.microsoft.com/en-us/library/ms686016.aspx>
+ PHANDLER_ROUTINE = WINFUNCTYPE(BOOL, DWORD)
+ SetConsoleCtrlHandler = kernel32.SetConsoleCtrlHandler
+ SetConsoleCtrlHandler.argtypes = (PHANDLER_ROUTINE, BOOL)
+ SetConsoleCtrlHandler.restype = BOOL
+
+ class allow_interrupt(_allow_interrupt):
+ __doc__ = _allow_interrupt.__doc__
+
+ def _init_action(self, action):
+ if action is None:
+ action = lambda: None
+ self.action = action
+ @PHANDLER_ROUTINE
+ def handle(event):
+ if event == 0: # CTRL_C_EVENT
+ action()
+ # Typical C implementations would return 1 to indicate that
+ # the event was processed and other control handlers in the
+ # stack should not be executed. However, that would
+ # prevent the Python interpreter's handler from translating
+ # CTRL-C to a `KeyboardInterrupt` exception, so we pretend
+ # that we didn't handle it.
+ return 0
+ self.handle = handle
+
+ def __enter__(self):
+ """Install the custom CTRL-C handler."""
+ result = SetConsoleCtrlHandler(self.handle, 1)
+ if result == 0:
+ # Have standard library automatically call `GetLastError()` and
+ # `FormatMessage()` into a nice exception object :-)
+ raise WindowsError()
+
+ def __exit__(self, *args):
+ """Remove the custom CTRL-C handler."""
+ result = SetConsoleCtrlHandler(self.handle, 0)
+ if result == 0:
+ # Have standard library automatically call `GetLastError()` and
+ # `FormatMessage()` into a nice exception object :-)
+ raise WindowsError()
+else:
+ class allow_interrupt(_allow_interrupt):
+ __doc__ = _allow_interrupt.__doc__
+ pass
diff --git a/scripts/external_libs/zmq/utils/z85.py b/scripts/external_libs/zmq/utils/z85.py
new file mode 100644
index 00000000..1bb1784e
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/z85.py
@@ -0,0 +1,56 @@
+"""Python implementation of Z85 85-bit encoding
+
+Z85 encoding is a plaintext encoding for a bytestring interpreted as 32bit integers.
+Since the chunks are 32bit, a bytestring must be a multiple of 4 bytes.
+See ZMQ RFC 32 for details.
+
+
+"""
+
+# Copyright (C) PyZMQ Developers
+# Distributed under the terms of the Modified BSD License.
+
+import sys
+import struct
+
+PY3 = sys.version_info[0] >= 3
+# Z85CHARS is the base 85 symbol table
+Z85CHARS = b"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ.-:+=^!/*?&<>()[]{}@%$#"
+# Z85MAP maps integers in [0,84] to the appropriate character in Z85CHARS
+Z85MAP = dict([(c, idx) for idx, c in enumerate(Z85CHARS)])
+
+_85s = [ 85**i for i in range(5) ][::-1]
+
+def encode(rawbytes):
+ """encode raw bytes into Z85"""
+ # Accepts only byte arrays bounded to 4 bytes
+ if len(rawbytes) % 4:
+ raise ValueError("length must be multiple of 4, not %i" % len(rawbytes))
+
+ nvalues = len(rawbytes) / 4
+
+ values = struct.unpack('>%dI' % nvalues, rawbytes)
+ encoded = []
+ for v in values:
+ for offset in _85s:
+ encoded.append(Z85CHARS[(v // offset) % 85])
+
+ # In Python 3, encoded is a list of integers (obviously?!)
+ if PY3:
+ return bytes(encoded)
+ else:
+ return b''.join(encoded)
+
+def decode(z85bytes):
+ """decode Z85 bytes to raw bytes"""
+ if len(z85bytes) % 5:
+ raise ValueError("Z85 length must be multiple of 5, not %i" % len(z85bytes))
+
+ nvalues = len(z85bytes) / 5
+ values = []
+ for i in range(0, len(z85bytes), 5):
+ value = 0
+ for j, offset in enumerate(_85s):
+ value += Z85MAP[z85bytes[i+j]] * offset
+ values.append(value)
+ return struct.pack('>%dI' % nvalues, *values)
diff --git a/scripts/external_libs/zmq/utils/zmq_compat.h b/scripts/external_libs/zmq/utils/zmq_compat.h
new file mode 100644
index 00000000..81c57b69
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/zmq_compat.h
@@ -0,0 +1,80 @@
+//-----------------------------------------------------------------------------
+// Copyright (c) 2010 Brian Granger, Min Ragan-Kelley
+//
+// Distributed under the terms of the New BSD License. The full license is in
+// the file COPYING.BSD, distributed as part of this software.
+//-----------------------------------------------------------------------------
+
+#if defined(_MSC_VER)
+#define pyzmq_int64_t __int64
+#else
+#include <stdint.h>
+#define pyzmq_int64_t int64_t
+#endif
+
+
+#include "zmq.h"
+// version compatibility for constants:
+#include "zmq_constants.h"
+
+#define _missing (-1)
+
+
+// define fd type (from libzmq's fd.hpp)
+#ifdef _WIN32
+ #ifdef _MSC_VER && _MSC_VER <= 1400
+ #define ZMQ_FD_T UINT_PTR
+ #else
+ #define ZMQ_FD_T SOCKET
+ #endif
+#else
+ #define ZMQ_FD_T int
+#endif
+
+// use unambiguous aliases for zmq_send/recv functions
+
+#if ZMQ_VERSION_MAJOR >= 4
+// nothing to remove
+#else
+ #define zmq_curve_keypair(z85_public_key, z85_secret_key) _missing
+#endif
+
+#if ZMQ_VERSION_MAJOR >= 4 && ZMQ_VERSION_MINOR >= 1
+// nothing to remove
+#else
+ #define zmq_msg_gets(msg, prop) _missing
+ #define zmq_has(capability) _missing
+#endif
+
+#if ZMQ_VERSION_MAJOR >= 3
+ #define zmq_sendbuf zmq_send
+ #define zmq_recvbuf zmq_recv
+
+ // 3.x deprecations - these symbols haven't been removed,
+ // but let's protect against their planned removal
+ #define zmq_device(device_type, isocket, osocket) _missing
+ #define zmq_init(io_threads) ((void*)NULL)
+ #define zmq_term zmq_ctx_destroy
+#else
+ #define zmq_ctx_set(ctx, opt, val) _missing
+ #define zmq_ctx_get(ctx, opt) _missing
+ #define zmq_ctx_destroy zmq_term
+ #define zmq_ctx_new() ((void*)NULL)
+
+ #define zmq_proxy(a,b,c) _missing
+
+ #define zmq_disconnect(s, addr) _missing
+ #define zmq_unbind(s, addr) _missing
+
+ #define zmq_msg_more(msg) _missing
+ #define zmq_msg_get(msg, opt) _missing
+ #define zmq_msg_set(msg, opt, val) _missing
+ #define zmq_msg_send(msg, s, flags) zmq_send(s, msg, flags)
+ #define zmq_msg_recv(msg, s, flags) zmq_recv(s, msg, flags)
+
+ #define zmq_sendbuf(s, buf, len, flags) _missing
+ #define zmq_recvbuf(s, buf, len, flags) _missing
+
+ #define zmq_socket_monitor(s, addr, flags) _missing
+
+#endif
diff --git a/scripts/external_libs/zmq/utils/zmq_constants.h b/scripts/external_libs/zmq/utils/zmq_constants.h
new file mode 100644
index 00000000..97683022
--- /dev/null
+++ b/scripts/external_libs/zmq/utils/zmq_constants.h
@@ -0,0 +1,622 @@
+#ifndef _PYZMQ_CONSTANT_DEFS
+#define _PYZMQ_CONSTANT_DEFS
+
+#define _PYZMQ_UNDEFINED (-9999)
+#ifndef ZMQ_VERSION
+ #define ZMQ_VERSION (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_VERSION_MAJOR
+ #define ZMQ_VERSION_MAJOR (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_VERSION_MINOR
+ #define ZMQ_VERSION_MINOR (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_VERSION_PATCH
+ #define ZMQ_VERSION_PATCH (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_NOBLOCK
+ #define ZMQ_NOBLOCK (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_DONTWAIT
+ #define ZMQ_DONTWAIT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_POLLIN
+ #define ZMQ_POLLIN (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_POLLOUT
+ #define ZMQ_POLLOUT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_POLLERR
+ #define ZMQ_POLLERR (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SNDMORE
+ #define ZMQ_SNDMORE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_STREAMER
+ #define ZMQ_STREAMER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_FORWARDER
+ #define ZMQ_FORWARDER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_QUEUE
+ #define ZMQ_QUEUE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IO_THREADS_DFLT
+ #define ZMQ_IO_THREADS_DFLT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MAX_SOCKETS_DFLT
+ #define ZMQ_MAX_SOCKETS_DFLT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_POLLITEMS_DFLT
+ #define ZMQ_POLLITEMS_DFLT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_THREAD_PRIORITY_DFLT
+ #define ZMQ_THREAD_PRIORITY_DFLT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_THREAD_SCHED_POLICY_DFLT
+ #define ZMQ_THREAD_SCHED_POLICY_DFLT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PAIR
+ #define ZMQ_PAIR (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PUB
+ #define ZMQ_PUB (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SUB
+ #define ZMQ_SUB (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_REQ
+ #define ZMQ_REQ (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_REP
+ #define ZMQ_REP (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_DEALER
+ #define ZMQ_DEALER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_ROUTER
+ #define ZMQ_ROUTER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_XREQ
+ #define ZMQ_XREQ (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_XREP
+ #define ZMQ_XREP (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PULL
+ #define ZMQ_PULL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PUSH
+ #define ZMQ_PUSH (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_XPUB
+ #define ZMQ_XPUB (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_XSUB
+ #define ZMQ_XSUB (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_UPSTREAM
+ #define ZMQ_UPSTREAM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_DOWNSTREAM
+ #define ZMQ_DOWNSTREAM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_STREAM
+ #define ZMQ_STREAM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_CONNECTED
+ #define ZMQ_EVENT_CONNECTED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_CONNECT_DELAYED
+ #define ZMQ_EVENT_CONNECT_DELAYED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_CONNECT_RETRIED
+ #define ZMQ_EVENT_CONNECT_RETRIED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_LISTENING
+ #define ZMQ_EVENT_LISTENING (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_BIND_FAILED
+ #define ZMQ_EVENT_BIND_FAILED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_ACCEPTED
+ #define ZMQ_EVENT_ACCEPTED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_ACCEPT_FAILED
+ #define ZMQ_EVENT_ACCEPT_FAILED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_CLOSED
+ #define ZMQ_EVENT_CLOSED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_CLOSE_FAILED
+ #define ZMQ_EVENT_CLOSE_FAILED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_DISCONNECTED
+ #define ZMQ_EVENT_DISCONNECTED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_ALL
+ #define ZMQ_EVENT_ALL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENT_MONITOR_STOPPED
+ #define ZMQ_EVENT_MONITOR_STOPPED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_NULL
+ #define ZMQ_NULL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PLAIN
+ #define ZMQ_PLAIN (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CURVE
+ #define ZMQ_CURVE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_GSSAPI
+ #define ZMQ_GSSAPI (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EAGAIN
+ #define EAGAIN (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EINVAL
+ #define EINVAL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EFAULT
+ #define EFAULT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENOMEM
+ #define ENOMEM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENODEV
+ #define ENODEV (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EMSGSIZE
+ #define EMSGSIZE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EAFNOSUPPORT
+ #define EAFNOSUPPORT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENETUNREACH
+ #define ENETUNREACH (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ECONNABORTED
+ #define ECONNABORTED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ECONNRESET
+ #define ECONNRESET (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENOTCONN
+ #define ENOTCONN (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ETIMEDOUT
+ #define ETIMEDOUT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EHOSTUNREACH
+ #define EHOSTUNREACH (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENETRESET
+ #define ENETRESET (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_HAUSNUMERO
+ #define ZMQ_HAUSNUMERO (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENOTSUP
+ #define ENOTSUP (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EPROTONOSUPPORT
+ #define EPROTONOSUPPORT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENOBUFS
+ #define ENOBUFS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENETDOWN
+ #define ENETDOWN (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EADDRINUSE
+ #define EADDRINUSE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EADDRNOTAVAIL
+ #define EADDRNOTAVAIL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ECONNREFUSED
+ #define ECONNREFUSED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EINPROGRESS
+ #define EINPROGRESS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENOTSOCK
+ #define ENOTSOCK (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EFSM
+ #define EFSM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ENOCOMPATPROTO
+ #define ENOCOMPATPROTO (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ETERM
+ #define ETERM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef EMTHREAD
+ #define EMTHREAD (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IO_THREADS
+ #define ZMQ_IO_THREADS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MAX_SOCKETS
+ #define ZMQ_MAX_SOCKETS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SOCKET_LIMIT
+ #define ZMQ_SOCKET_LIMIT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_THREAD_PRIORITY
+ #define ZMQ_THREAD_PRIORITY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_THREAD_SCHED_POLICY
+ #define ZMQ_THREAD_SCHED_POLICY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IDENTITY
+ #define ZMQ_IDENTITY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SUBSCRIBE
+ #define ZMQ_SUBSCRIBE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_UNSUBSCRIBE
+ #define ZMQ_UNSUBSCRIBE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_LAST_ENDPOINT
+ #define ZMQ_LAST_ENDPOINT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TCP_ACCEPT_FILTER
+ #define ZMQ_TCP_ACCEPT_FILTER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PLAIN_USERNAME
+ #define ZMQ_PLAIN_USERNAME (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PLAIN_PASSWORD
+ #define ZMQ_PLAIN_PASSWORD (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CURVE_PUBLICKEY
+ #define ZMQ_CURVE_PUBLICKEY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CURVE_SECRETKEY
+ #define ZMQ_CURVE_SECRETKEY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CURVE_SERVERKEY
+ #define ZMQ_CURVE_SERVERKEY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_ZAP_DOMAIN
+ #define ZMQ_ZAP_DOMAIN (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CONNECT_RID
+ #define ZMQ_CONNECT_RID (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_GSSAPI_PRINCIPAL
+ #define ZMQ_GSSAPI_PRINCIPAL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_GSSAPI_SERVICE_PRINCIPAL
+ #define ZMQ_GSSAPI_SERVICE_PRINCIPAL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SOCKS_PROXY
+ #define ZMQ_SOCKS_PROXY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_FD
+ #define ZMQ_FD (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IDENTITY_FD
+ #define ZMQ_IDENTITY_FD (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RECONNECT_IVL_MAX
+ #define ZMQ_RECONNECT_IVL_MAX (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SNDTIMEO
+ #define ZMQ_SNDTIMEO (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RCVTIMEO
+ #define ZMQ_RCVTIMEO (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SNDHWM
+ #define ZMQ_SNDHWM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RCVHWM
+ #define ZMQ_RCVHWM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MULTICAST_HOPS
+ #define ZMQ_MULTICAST_HOPS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IPV4ONLY
+ #define ZMQ_IPV4ONLY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_ROUTER_BEHAVIOR
+ #define ZMQ_ROUTER_BEHAVIOR (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TCP_KEEPALIVE
+ #define ZMQ_TCP_KEEPALIVE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TCP_KEEPALIVE_CNT
+ #define ZMQ_TCP_KEEPALIVE_CNT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TCP_KEEPALIVE_IDLE
+ #define ZMQ_TCP_KEEPALIVE_IDLE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TCP_KEEPALIVE_INTVL
+ #define ZMQ_TCP_KEEPALIVE_INTVL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_DELAY_ATTACH_ON_CONNECT
+ #define ZMQ_DELAY_ATTACH_ON_CONNECT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_XPUB_VERBOSE
+ #define ZMQ_XPUB_VERBOSE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_EVENTS
+ #define ZMQ_EVENTS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TYPE
+ #define ZMQ_TYPE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_LINGER
+ #define ZMQ_LINGER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RECONNECT_IVL
+ #define ZMQ_RECONNECT_IVL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_BACKLOG
+ #define ZMQ_BACKLOG (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_ROUTER_MANDATORY
+ #define ZMQ_ROUTER_MANDATORY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_FAIL_UNROUTABLE
+ #define ZMQ_FAIL_UNROUTABLE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_ROUTER_RAW
+ #define ZMQ_ROUTER_RAW (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IMMEDIATE
+ #define ZMQ_IMMEDIATE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IPV6
+ #define ZMQ_IPV6 (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MECHANISM
+ #define ZMQ_MECHANISM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PLAIN_SERVER
+ #define ZMQ_PLAIN_SERVER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CURVE_SERVER
+ #define ZMQ_CURVE_SERVER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_PROBE_ROUTER
+ #define ZMQ_PROBE_ROUTER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_REQ_RELAXED
+ #define ZMQ_REQ_RELAXED (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_REQ_CORRELATE
+ #define ZMQ_REQ_CORRELATE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_CONFLATE
+ #define ZMQ_CONFLATE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_ROUTER_HANDOVER
+ #define ZMQ_ROUTER_HANDOVER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_TOS
+ #define ZMQ_TOS (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IPC_FILTER_PID
+ #define ZMQ_IPC_FILTER_PID (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IPC_FILTER_UID
+ #define ZMQ_IPC_FILTER_UID (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_IPC_FILTER_GID
+ #define ZMQ_IPC_FILTER_GID (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_GSSAPI_SERVER
+ #define ZMQ_GSSAPI_SERVER (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_GSSAPI_PLAINTEXT
+ #define ZMQ_GSSAPI_PLAINTEXT (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_HANDSHAKE_IVL
+ #define ZMQ_HANDSHAKE_IVL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_XPUB_NODROP
+ #define ZMQ_XPUB_NODROP (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_AFFINITY
+ #define ZMQ_AFFINITY (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MAXMSGSIZE
+ #define ZMQ_MAXMSGSIZE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_HWM
+ #define ZMQ_HWM (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SWAP
+ #define ZMQ_SWAP (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MCAST_LOOP
+ #define ZMQ_MCAST_LOOP (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RECOVERY_IVL_MSEC
+ #define ZMQ_RECOVERY_IVL_MSEC (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RATE
+ #define ZMQ_RATE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RECOVERY_IVL
+ #define ZMQ_RECOVERY_IVL (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SNDBUF
+ #define ZMQ_SNDBUF (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RCVBUF
+ #define ZMQ_RCVBUF (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_RCVMORE
+ #define ZMQ_RCVMORE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_MORE
+ #define ZMQ_MORE (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SRCFD
+ #define ZMQ_SRCFD (_PYZMQ_UNDEFINED)
+#endif
+
+#ifndef ZMQ_SHARED
+ #define ZMQ_SHARED (_PYZMQ_UNDEFINED)
+#endif
+
+
+#endif // ifndef _PYZMQ_CONSTANT_DEFS