code
stringlengths
0
56.1M
repo_name
stringclasses
515 values
path
stringlengths
2
147
language
stringclasses
447 values
license
stringclasses
7 values
size
int64
0
56.8M
= zmq_atomic_counter_value(3) == NAME zmq_atomic_counter_value - return value of atomic counter == SYNOPSIS *int zmq_atomic_counter_value (void *counter);* == DESCRIPTION The _zmq_atomic_counter_value_ function returns the value of an atomic counter created by _zmq_atomic_counter_new()_. This function uses platform specific atomic operations. == RETURN VALUE The _zmq_atomic_counter_value()_ function returns the value of the atomic counter. If _counter_ does not point to an atomic counter created by _zmq_atomic_counter_new()_, the behaviour is undefined. == EXAMPLE .Test code for atomic counters ---- void *counter = zmq_atomic_counter_new (); assert (zmq_atomic_counter_value (counter) == 0); assert (zmq_atomic_counter_inc (counter) == 0); assert (zmq_atomic_counter_inc (counter) == 1); assert (zmq_atomic_counter_inc (counter) == 2); assert (zmq_atomic_counter_value (counter) == 3); assert (zmq_atomic_counter_dec (counter) == 1); assert (zmq_atomic_counter_dec (counter) == 1); assert (zmq_atomic_counter_dec (counter) == 0); zmq_atomic_counter_set (counter, 2); assert (zmq_atomic_counter_dec (counter) == 1); assert (zmq_atomic_counter_dec (counter) == 0); zmq_atomic_counter_destroy (&counter); return 0; ---- == SEE ALSO * xref:zmq_atomic_counter_new.adoc[zmq_atomic_counter_new] * xref:zmq_atomic_counter_set.adoc[zmq_atomic_counter_set] * xref:zmq_atomic_counter_inc.adoc[zmq_atomic_counter_inc] * xref:zmq_atomic_counter_dec.adoc[zmq_atomic_counter_dec] * xref:zmq_atomic_counter_destroy.adoc[zmq_atomic_counter_destroy] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_atomic_counter_value.adoc
AsciiDoc
gpl-3.0
1,712
= zmq_bind(3) == NAME zmq_bind - accept incoming connections on a socket == SYNOPSIS *int zmq_bind (void '*socket', const char '*endpoint');* == DESCRIPTION The _zmq_bind()_ function binds the 'socket' to a local 'endpoint' and then accepts incoming connections on that endpoint. The 'endpoint' is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to bind to. 0MQ provides the the following transports: 'tcp':: unicast transport using TCP, see xref:zmq_tcp.adoc[zmq_tcp] 'ipc':: local inter-process communication transport, see xref:zmq_ipc.adoc[zmq_ipc] 'inproc':: local in-process (inter-thread) communication transport, see xref:zmq_inproc.adoc[zmq_inproc] 'pgm', 'epgm':: reliable multicast transport using PGM, see xref:zmq_pgm.adoc[zmq_pgm] 'vmci':: virtual machine communications interface (VMCI), see xref:zmq_vmci.adoc[zmq_vmci] 'udp':: unreliable unicast and multicast using UDP, see xref:zmq_udp.adoc[zmq_udp] Every 0MQ socket type except 'ZMQ_PAIR' and 'ZMQ_CHANNEL' supports one-to-many and many-to-one semantics. The precise semantics depend on the socket type and are defined in xref:zmq_socket.adoc[zmq_socket] The 'ipc', 'tcp', 'vmci' and 'udp' transports accept wildcard addresses: see xref:zmq_ipc.adoc[zmq_ipc], xref:zmq_tcp.adoc[zmq_tcp], xref:zmq_vmci.adoc[zmq_vmci] and xref:zmq_udp.adoc[zmq_udp] for details. NOTE: the address syntax may be different for _zmq_bind()_ and _zmq_connect()_ especially for the 'tcp', 'pgm' and 'epgm' transports. NOTE: following a _zmq_bind()_, the socket enters a 'mute' state unless or until at least one incoming or outgoing connection is made, at which point the socket enters a 'ready' state. In the mute state, the socket blocks or drops messages according to the socket type, as defined in xref:zmq_socket.adoc[zmq_socket] By contrast, following a libzmq:zmq_connect, the socket enters the 'ready' state. == RETURN VALUE The _zmq_bind()_ function returns zero if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The endpoint supplied is invalid. *EPROTONOSUPPORT*:: The requested 'transport' protocol is not supported. *ENOCOMPATPROTO*:: The requested 'transport' protocol is not compatible with the socket type. *EADDRINUSE*:: The requested 'address' is already in use. *EADDRNOTAVAIL*:: The requested 'address' was not local. *ENODEV*:: The requested 'address' specifies a nonexistent interface. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EMTHREAD*:: No I/O thread is available to accomplish the task. == EXAMPLE .Binding a publisher socket to an in-process and a TCP transport ---- /* Create a ZMQ_PUB socket */ void *socket = zmq_socket (context, ZMQ_PUB); assert (socket); /* Bind it to a in-process transport with the address 'my_publisher' */ int rc = zmq_bind (socket, "inproc://my_publisher"); assert (rc == 0); /* Bind it to a TCP transport on port 5555 of the 'eth0' interface */ rc = zmq_bind (socket, "tcp://eth0:5555"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_bind.adoc
AsciiDoc
gpl-3.0
3,485
= zmq_close(3) == NAME zmq_close - close 0MQ socket == SYNOPSIS *int zmq_close (void '*socket');* == DESCRIPTION The _zmq_close()_ function shall destroy the socket referenced by the 'socket' argument. Any outstanding messages physically received from the network but not yet received by the application with _zmq_recv()_ shall be discarded. The behaviour for discarding messages sent by the application with _zmq_send()_ but not yet physically transferred to the network depends on the value of the _ZMQ_LINGER_ socket option for the specified 'socket'. _zmq_close()_ must be called exactly once for each socket. If it is never called, _zmq_ctx_term()_ will block forever. If it is called multiple times for the same socket or if 'socket' does not point to a socket, the behaviour is undefined. NOTE: The default setting of _ZMQ_LINGER_ does not discard unsent messages; this behaviour may cause the application to block when calling _zmq_ctx_term()_. For details refer to xref:zmq_setsockopt.adoc[zmq_setsockopt] and xref:zmq_ctx_term.adoc[zmq_ctx_term] NOTE: This API will complete asynchronously, so not everything will be deallocated after it returns. See above for details about linger. == RETURN VALUE The _zmq_close()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ENOTSOCK*:: The provided 'socket' was NULL. == SEE ALSO * xref:zmq_socket.adoc[zmq_socket] * xref:zmq_ctx_term.adoc[zmq_ctx_term] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_close.adoc
AsciiDoc
gpl-3.0
1,731
= zmq_connect(3) == NAME zmq_connect - create outgoing connection from socket == SYNOPSIS *int zmq_connect (void '*socket', const char '*endpoint');* == DESCRIPTION The _zmq_connect()_ function connects the 'socket' to an 'endpoint' and then accepts incoming connections on that endpoint. The 'endpoint' is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. 0MQ provides the the following transports: 'tcp':: unicast transport using TCP, see xref:zmq_tcp.adoc[zmq_tcp] 'ipc':: local inter-process communication transport, see xref:zmq_ipc.adoc[zmq_ipc] 'inproc':: local in-process (inter-thread) communication transport, see xref:zmq_inproc.adoc[zmq_inproc] 'pgm', 'epgm':: reliable multicast transport using PGM, see xref:zmq_pgm.adoc[zmq_pgm] 'vmci':: virtual machine communications interface (VMCI), see xref:zmq_vmci.adoc[zmq_vmci] 'udp':: unreliable unicast and multicast using UDP, see xref:zmq_udp.adoc[zmq_udp] Every 0MQ socket type except 'ZMQ_PAIR' and 'ZMQ_CHANNEL' supports one-to-many and many-to-one semantics. The precise semantics depend on the socket type and are defined in xref:zmq_socket.adoc[zmq_socket] NOTE: for most transports and socket types the connection is not performed immediately but as needed by 0MQ. Thus a successful call to _zmq_connect()_ does not mean that the connection was or could actually be established. Because of this, for most transports and socket types the order in which a 'server' socket is bound and a 'client' socket is connected to it does not matter. The _ZMQ_PAIR_ and _ZMQ_CHANNEL_ sockets are an exception, as they do not automatically reconnect to endpoints. NOTE: following a _zmq_connect()_, for socket types except for ZMQ_ROUTER, the socket enters its normal 'ready' state. By contrast, following a _zmq_bind()_ alone, the socket enters a 'mute' state in which the socket blocks or drops messages according to the socket type, as defined in xref:zmq_socket.adoc[zmq_socket] A ZMQ_ROUTER socket enters its normal 'ready' state for a specific peer only when handshaking is complete for that peer, which may take an arbitrary time. NOTE: for some socket types, multiple connections to the same endpoint don't really make sense (see https://github.com/zeromq/libzmq/issues/788). For those socket types, any attempt to connect to an already connected endpoint is silently ignored (i.e., returns zero). This behavior applies to ZMQ_DEALER, ZMQ_SUB, ZMQ_PUB, and ZMQ_REQ socket types. == RETURN VALUE The _zmq_connect()_ function returns zero if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The endpoint supplied is invalid. *EPROTONOSUPPORT*:: The requested 'transport' protocol is not supported. *ENOCOMPATPROTO*:: The requested 'transport' protocol is not compatible with the socket type. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EMTHREAD*:: No I/O thread is available to accomplish the task. == EXAMPLE .Connecting a subscriber socket to an in-process and a TCP transport ---- /* Create a ZMQ_SUB socket */ void *socket = zmq_socket (context, ZMQ_SUB); assert (socket); /* Connect it to an in-process transport with the address 'my_publisher' */ int rc = zmq_connect (socket, "inproc://my_publisher"); assert (rc == 0); /* Connect it to the host server001, port 5555 using a TCP transport */ rc = zmq_connect (socket, "tcp://server001:5555"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_connect.adoc
AsciiDoc
gpl-3.0
3,908
= zmq_connect_peer(3) == NAME zmq_connect_peer - create outgoing connection from socket and return the connection routing id in thread-safe and atomic way. == SYNOPSIS *uint32_t zmq_connect_peer (void '*socket', const char '*endpoint');* == DESCRIPTION The _zmq_connect_peer()_ function connects a 'ZMQ_PEER' socket to an 'endpoint' and then returns the endpoint 'routing_id'. The 'endpoint' is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. The function is supported only on the 'ZMQ_PEER' socket type and would return `0` with 'errno' set to 'ENOTSUP' otherwise. The _zmq_connect_peer()_ support the following transports: 'tcp':: unicast transport using TCP, see xref:zmq_tcp.adoc[zmq_tcp] 'ipc':: local inter-process communication transport, see xref:zmq_ipc.adoc[zmq_ipc] 'inproc':: local in-process (inter-thread) communication transport, see xref:zmq_inproc.adoc[zmq_inproc] 'ws':: unicast transport using WebSockets, see xref:zmq_ws.adoc[zmq_ws] 'wss':: unicast transport using WebSockets over TLS, see xref:zmq_wss.adoc[zmq_wss] == RETURN VALUE The _zmq_connect_peer()_ function returns the peer 'routing_id' if successful. Otherwise it returns `0` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The endpoint supplied is invalid. *EPROTONOSUPPORT*:: The requested 'transport' protocol is not supported with 'ZMQ_PEER'. *ENOCOMPATPROTO*:: The requested 'transport' protocol is not compatible with the socket type. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EMTHREAD*:: No I/O thread is available to accomplish the task. *ENOTSUP*:: The socket is not of type 'ZMQ_PEER'. *EFAULT*:: The 'ZMQ_IMMEDIATE' option is set on the socket. == EXAMPLE .Connecting a peer socket to a TCP transport and sending a message ---- /* Create a ZMQ_SUB socket */ void *socket = zmq_socket (context, ZMQ_PEER); assert (socket); /* Connect it to the host server001, port 5555 using a TCP transport */ uint32_t routing_id = zmq_connect (socket, "tcp://server001:5555"); assert (routing_id == 0); /* Sending a message to the peer */ zmq_msg_t msg; int rc = zmq_msg_init_data (&msg, "HELLO", 5, NULL, NULL); assert (rc == 0); rc = zmq_msg_set_routing_id (&msg, routing_id); assert (rc == 0); rc = zmq_msg_send (&msg, socket, 0); assert (rc == 5); rc = zmq_msg_close (&msg); assert (rc == 0); ---- == SEE ALSO * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_connect_peer.adoc
AsciiDoc
gpl-3.0
2,855
= zmq_ctx_get(3) == NAME zmq_ctx_get - get context options == SYNOPSIS *int zmq_ctx_get (void '*context', int 'option_name');* == DESCRIPTION The _zmq_ctx_get()_ function shall return the option specified by the 'option_name' argument. The _zmq_ctx_get()_ function accepts the following option names: ZMQ_IO_THREADS: Get number of I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_IO_THREADS' argument returns the size of the 0MQ thread pool for this context. ZMQ_MAX_SOCKETS: Get maximum number of sockets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MAX_SOCKETS' argument returns the maximum number of sockets allowed for this context. ZMQ_MAX_MSGSZ: Get maximum message size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MAX_MSGSZ' argument returns the maximum size of a message allowed for this context. Default value is INT_MAX. ZMQ_ZERO_COPY_RECV: Get message decoding strategy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_ZERO_COPY_RECV' argument return whether message decoder uses a zero copy strategy when receiving messages. Default value is 1. NOTE: in DRAFT state, not yet available in stable releases. ZMQ_SOCKET_LIMIT: Get largest configurable number of sockets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SOCKET_LIMIT' argument returns the largest number of sockets that xref:zmq_ctx_set.adoc[zmq_ctx_set] will accept. ZMQ_IPV6: Set IPv6 option ~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_IPV6' argument returns the IPv6 option for the context. ZMQ_BLOCKY: Get blocky setting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_BLOCKY' argument returns 1 if the context will block on terminate, zero if the "block forever on context termination" gambit was disabled by setting ZMQ_BLOCKY to false on all new contexts. ZMQ_THREAD_SCHED_POLICY: Get scheduling policy for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_SCHED_POLICY' argument returns the scheduling policy for internal context's thread pool. ZMQ_THREAD_NAME_PREFIX: Get name prefix for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_NAME_PREFIX' argument gets the numeric prefix of each thread created for the internal context's thread pool. ZMQ_MSG_T_SIZE: Get the zmq_msg_t size at runtime ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MSG_T_SIZE' argument returns the size of the zmq_msg_t structure at runtime, as defined in the include/zmq.h public header. This is useful for example for FFI bindings that can't simply do a sizeof(). == RETURN VALUE The _zmq_ctx_get()_ function returns a value of 0 or greater if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested option _option_name_ is unknown. *EFAULT*:: The provided 'context' is invalid. == EXAMPLE .Setting a limit on the number of sockets ---- void *context = zmq_ctx_new (); zmq_ctx_set (context, ZMQ_MAX_SOCKETS, 256); int max_sockets = zmq_ctx_get (context, ZMQ_MAX_SOCKETS); assert (max_sockets == 256); ---- .Switching off the context deadlock gambit ---- zmq_ctx_set (ctx, ZMQ_BLOCKY, false); ---- == SEE ALSO * xref:zmq_ctx_set.adoc[zmq_ctx_set] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_get.adoc
AsciiDoc
gpl-3.0
3,424
= zmq_ctx_get_ext(3) == NAME zmq_ctx_get_ext - get extended context options == SYNOPSIS *int zmq_ctx_get_ext (void '*context', int 'option_name', void '*option_value', size_t '*option_len');* == DESCRIPTION The _zmq_ctx_get()_ function shall retrieve the value for the option specified by the 'option_name' argument and store it in the buffer pointed to by the 'option_value' argument. The 'option_len' argument is the size in bytes of the buffer pointed to by 'option_value'; upon successful completion _zmq_ctx_get_ext()_ shall modify the 'option_len' argument to indicate the actual size of the option value stored in the buffer. The _zmq_ctx_get_ext()_ function accepts all the option names accepted by _zmq_ctx_get()_. Options that make most sense to retrieve using _zmq_ctx_get_ext()_ instead of _zmq_ctx_get()_ are: ZMQ_THREAD_NAME_PREFIX: Get name prefix for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_NAME_PREFIX' argument gets the string prefix of each thread created for the internal context's thread pool. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: empty string == RETURN VALUE The _zmq_ctx_get_ext()_ function returns a value of 0 or greater if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested option _option_name_ is unknown. *EFAULT*:: The provided 'context' is invalid. == EXAMPLE .Setting a prefix on internal ZMQ thread names: ---- void *context = zmq_ctx_new (); const char prefix[] = "MyApp"; size_t prefixLen = sizeof(prefix); zmq_ctx_set (context, ZMQ_THREAD_NAME_PREFIX, &prefix, &prefixLen); char buff[256]; size_t buffLen = sizeof(buff); int rc = zmq_ctx_get (context, ZMQ_THREAD_NAME_PREFIX, &buff, &buffLen); assert (rc == 0); assert (buffLen == prefixLen); ---- == SEE ALSO * xref:zmq_ctx_get.adoc[zmq_ctx_get] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_get_ext.adoc
AsciiDoc
gpl-3.0
2,104
= zmq_ctx_new(3) == NAME zmq_ctx_new - create new 0MQ context == SYNOPSIS *void *zmq_ctx_new ();* == DESCRIPTION The _zmq_ctx_new()_ function creates a new 0MQ 'context'. This function replaces the deprecated function xref:zmq_init.adoc[zmq_init] .Thread safety A 0MQ 'context' is thread safe and may be shared among as many application threads as necessary, without any additional locking required on the part of the caller. == RETURN VALUE The _zmq_ctx_new()_ function shall return an opaque handle to the newly created 'context' if successful. Otherwise it shall return NULL and set 'errno' to one of the values defined below. == ERRORS *EMFILE*:: The limit on the total number of open files has been reached and it wasn't possible to create a new context. *EMFILE*:: The limit on the total number of open files in system has been reached and it wasn't possible to create a new context. == SEE ALSO * xref:zmq.adoc[zmq] * xref:zmq_ctx_set.adoc[zmq_ctx_set] * xref:zmq_ctx_get.adoc[zmq_ctx_get] * xref:zmq_ctx_term.adoc[zmq_ctx_term] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_new.adoc
AsciiDoc
gpl-3.0
1,208
= zmq_ctx_set(3) == NAME zmq_ctx_set - set context options == SYNOPSIS *int zmq_ctx_set (void '*context', int 'option_name', int 'option_value');* == DESCRIPTION The _zmq_ctx_set()_ function shall set the option specified by the 'option_name' argument to the value of the 'option_value' argument. The _zmq_ctx_set()_ function accepts the following options: ZMQ_BLOCKY: Fix blocky behavior ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default the context will block, forever, on a zmq_ctx_term call. The assumption behind this behavior is that abrupt termination will cause message loss. Most real applications use some form of handshaking to ensure applications receive termination messages, and then terminate the context with 'ZMQ_LINGER' set to zero on all sockets. This setting is an easier way to get the same result. When 'ZMQ_BLOCKY' is set to false, all new sockets are given a linger timeout of zero. You must still close all sockets before calling zmq_ctx_term. [horizontal] Default value:: true (old behavior) ZMQ_IO_THREADS: Set number of I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_IO_THREADS' argument specifies the size of the 0MQ thread pool to handle I/O operations. If your application is using only the 'inproc' transport for messaging you may set this to zero, otherwise set it to at least one. This option only applies before creating any sockets on the context. [horizontal] Default value:: 1 ZMQ_THREAD_SCHED_POLICY: Set scheduling policy for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_SCHED_POLICY' argument sets the scheduling policy for internal context's thread pool. This option is not available on windows. Supported values for this option can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. This option only applies before creating any sockets on the context. [horizontal] Default value:: -1 ZMQ_THREAD_PRIORITY: Set scheduling priority for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_PRIORITY' argument sets scheduling priority for internal context's thread pool. This option is not available on windows. Supported values for this option depend on chosen scheduling policy. On Linux, when the scheduler policy is SCHED_OTHER, SCHED_IDLE or SCHED_BATCH, the OS scheduler will not use the thread priority but rather the thread "nice value"; in such cases, if 'ZMQ_THREAD_PRIORITY' is set to a strictly positive value, the system call "nice" will be used to set the nice value to -20 (max priority) instead of adjusting the thread priority (which must be zero for those scheduling policies). Details can be found in sched.h file, or at http://man7.org/linux/man-pages/man2/sched_setscheduler.2.html. This option only applies before creating any sockets on the context. [horizontal] Default value:: -1 ZMQ_THREAD_AFFINITY_CPU_ADD: Add a CPU to list of affinity for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_AFFINITY_CPU_ADD' argument adds a specific CPU to the affinity list for the internal context's thread pool. This option is only supported on Linux. This option only applies before creating any sockets on the context. The default affinity list is empty and means that no explicit CPU-affinity will be set on internal context's threads. [horizontal] Default value:: -1 ZMQ_THREAD_AFFINITY_CPU_REMOVE: Remove a CPU to list of affinity for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_AFFINITY_CPU_REMOVE' argument removes a specific CPU to the affinity list for the internal context's thread pool. This option is only supported on Linux. This option only applies before creating any sockets on the context. The default affinity list is empty and means that no explicit CPU-affinity will be set on internal context's threads. [horizontal] Default value:: -1 ZMQ_THREAD_NAME_PREFIX: Set name prefix for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_NAME_PREFIX' argument sets a numeric prefix to each thread created for the internal context's thread pool. This option is only supported on Linux. This option is useful to help debugging done via "top -H" or "gdb"; in case multiple processes on the system are using ZeroMQ it is useful to provide through this context option an application-specific prefix to distinguish ZeroMQ background threads that belong to different processes. This option only applies before creating any sockets on the context. [horizontal] Default value:: -1 ZMQ_MAX_MSGSZ: Set maximum message size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MAX_MSGSZ' argument sets the maximum allowed size of a message sent in the context. You can query the maximal allowed value with xref:zmq_ctx_get.adoc[zmq_ctx_get] using the 'ZMQ_MAX_MSGSZ' option. [horizontal] Default value:: INT_MAX Maximum value:: INT_MAX ZMQ_ZERO_COPY_RECV: Specify message decoding strategy ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_ZERO_COPY_RECV' argument specifies whether the message decoder should use a zero copy strategy when receiving messages. The zero copy strategy can lead to increased memory usage in some cases. This option allows you to use the older copying strategy. You can query the value of this option with xref:zmq_ctx_get.adoc[zmq_ctx_get] using the 'ZMQ_ZERO_COPY_RECV' option. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Default value:: 1 ZMQ_MAX_SOCKETS: Set maximum number of sockets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MAX_SOCKETS' argument sets the maximum number of sockets allowed on the context. You can query the maximal allowed value with xref:zmq_ctx_get.adoc[zmq_ctx_get] using the 'ZMQ_SOCKET_LIMIT' option. [horizontal] Default value:: 1023 ZMQ_IPV6: Set IPv6 option ~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_IPV6' argument sets the IPv6 value for all sockets created in the context from this point onwards. A value of `1` means IPv6 is enabled, while `0` means the socket will use only IPv4. When IPv6 is enabled, a socket will connect to, or accept connections from, both IPv4 and IPv6 hosts. [horizontal] Default value:: 0 == RETURN VALUE The _zmq_ctx_set()_ function returns zero if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested option _option_name_ is unknown. == EXAMPLE .Setting a limit on the number of sockets ---- void *context = zmq_ctx_new (); zmq_ctx_set (context, ZMQ_MAX_SOCKETS, 256); int max_sockets = zmq_ctx_get (context, ZMQ_MAX_SOCKETS); assert (max_sockets == 256); ---- == SEE ALSO * xref:zmq_ctx_get.adoc[zmq_ctx_get] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_set.adoc
AsciiDoc
gpl-3.0
6,988
= zmq_ctx_set_ext(3) == NAME zmq_ctx_set_ext - set extended context options == SYNOPSIS *int zmq_ctx_set_ext (void '*context', int 'option_name', const void '*option_value', size_t 'option_len');* == DESCRIPTION The _zmq_ctx_set_ext()_ function shall set the option specified by the 'option_name' argument to the value pointed to by the 'option_value' argument for the 0MQ context pointed to by the 'context' argument. The 'option_len' argument is the size of the option value in bytes. For options taking a value of type "character string", the provided byte data should either contain no zero bytes, or end in a single zero byte (terminating ASCII NUL character). The _zmq_ctx_set_ext()_ function accepts all the option names accepted by _zmq_ctx_set()_. Options that make most sense to set using _zmq_ctx_set_ext()_ instead of _zmq_ctx_set()_ are the following options: ZMQ_THREAD_NAME_PREFIX: Set name prefix for I/O threads ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_NAME_PREFIX' argument sets a string prefix to each thread created for the internal context's thread pool. This option is only supported on Linux. This option is useful to help debugging done via "top -H" or "gdb"; in case multiple processes on the system are using ZeroMQ it is useful to provide through this context option an application-specific prefix to distinguish ZeroMQ background threads that belong to different processes. This option only applies before creating any sockets on the context. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: empty string == RETURN VALUE The _zmq_ctx_set_ext()_ function returns zero if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested option _option_name_ is unknown. *EFAULT*:: The provided 'context' is invalid. == EXAMPLE .Setting a prefix on internal ZMQ thread names: ---- void *context = zmq_ctx_new (); const char prefix[] = "MyApp"; size_t prefixLen = sizeof(prefix); zmq_ctx_set (context, ZMQ_THREAD_NAME_PREFIX, &prefix, &prefixLen); char buff[256]; size_t buffLen = sizeof(buff); int rc = zmq_ctx_get (context, ZMQ_THREAD_NAME_PREFIX, &buff, &buffLen); assert (rc == 0); assert (buffLen == prefixLen); ---- == SEE ALSO * xref:zmq_ctx_set.adoc[zmq_ctx_set] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_set_ext.adoc
AsciiDoc
gpl-3.0
2,529
= zmq_ctx_shutdown(3) == NAME zmq_ctx_shutdown - shutdown a 0MQ context == SYNOPSIS *int zmq_ctx_shutdown (void '*context');* == DESCRIPTION The _zmq_ctx_shutdown()_ function shall shutdown the 0MQ context 'context'. Context shutdown will cause any blocking operations currently in progress on sockets open within 'context' to return immediately with an error code of ETERM. With the exception of _zmq_close()_, any further operations on sockets open within 'context' shall fail with an error code of ETERM. No further sockets can be created using _zmq_socket()_ on a context for which _zmq_ctx_shutdown()_ has been called, it will return and set errno to ETERM. This function is optional, client code is still required to call the xref:zmq_ctx_term.adoc[zmq_ctx_term] function to free all resources allocated by zeromq. == RETURN VALUE The _zmq_ctx_shutdown()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EFAULT*:: The provided 'context' was invalid. == SEE ALSO * xref:zmq.adoc[zmq] * xref:zmq_init.adoc[zmq_init] * xref:zmq_ctx_term.adoc[zmq_ctx_term] * xref:zmq_close.adoc[zmq_close] * xref:zmq_setsockopt.adoc[zmq_setsockopt] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_shutdown.adoc
AsciiDoc
gpl-3.0
1,396
= zmq_ctx_term(3) == NAME zmq_ctx_term - terminate a 0MQ context == SYNOPSIS *int zmq_ctx_term (void '*context');* == DESCRIPTION The _zmq_ctx_term()_ function shall destroy the 0MQ context 'context'. Context termination is performed in the following steps: 1. Any blocking operations currently in progress on sockets open within 'context' shall return immediately with an error code of ETERM. With the exception of _zmq_close()_, any further operations on sockets open within 'context' shall fail with an error code of ETERM. 2. After interrupting all blocking calls, _zmq_ctx_term()_ shall _block_ until the following conditions are satisfied: * All sockets open within 'context' have been closed with _zmq_close()_. * For each socket within 'context', all messages sent by the application with _zmq_send()_ have either been physically transferred to a network peer, or the socket's linger period set with the _ZMQ_LINGER_ socket option has expired. For further details regarding socket linger behaviour refer to the _ZMQ_LINGER_ option in xref:zmq_setsockopt.adoc[zmq_setsockopt] This function replaces the deprecated functions xref:zmq_term.adoc[zmq_term] and xref:zmq_ctx_destroy.adoc[zmq_ctx_destroy] == RETURN VALUE The _zmq_ctx_term()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EFAULT*:: The provided 'context' was invalid. *EINTR*:: Termination was interrupted by a signal. It can be restarted if needed. == SEE ALSO * xref:zmq.adoc[zmq] * xref:zmq_init.adoc[zmq_init] * xref:zmq_close.adoc[zmq_close] * xref:zmq_setsockopt.adoc[zmq_setsockopt] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ctx_term.adoc
AsciiDoc
gpl-3.0
1,859
= zmq_curve(7) == NAME zmq_curve - secure authentication and confidentiality == SYNOPSIS The CURVE mechanism defines a mechanism for secure authentication and confidentiality for communications between a client and a server. CURVE is intended for use on public networks. The CURVE mechanism is defined by this document: <http://rfc.zeromq.org/spec:25>. == CLIENT AND SERVER ROLES A socket using CURVE can be either client or server, at any moment, but not both. The role is independent of bind/connect direction. A socket can change roles at any point by setting new options. The role affects all zmq_connect and zmq_bind calls that follow it. To become a CURVE server, the application sets the ZMQ_CURVE_SERVER option on the socket, and then sets the ZMQ_CURVE_SECRETKEY option to provide the socket with its long-term secret key. The application does not provide the socket with its long-term public key, which is used only by clients. To become a CURVE client, the application sets the ZMQ_CURVE_SERVERKEY option with the long-term public key of the server it intends to connect to, or accept connections from, next. The application then sets the ZMQ_CURVE_PUBLICKEY and ZMQ_CURVE_SECRETKEY options with its client long-term key pair. If the server does authentication it will be based on the client's long term public key. == KEY ENCODING The standard representation for keys in source code is either 32 bytes of base 256 (binary) data, or 40 characters of base 85 data encoded using the Z85 algorithm defined by http://rfc.zeromq.org/spec:32. The Z85 algorithm is designed to produce printable key strings for use in configuration files, the command line, and code. There is a reference implementation in C at https://github.com/zeromq/rfc/tree/master/src. == TEST KEY VALUES For test cases, the client shall use this long-term key pair (specified as hexadecimal and in Z85): ---- public: BB88471D65E2659B30C55A5321CEBB5AAB2B70A398645C26DCA2B2FCB43FC518 Yne@$w-vo<fVvi]a<NY6T1ed:M$fCG*[IaLV{hID secret: 7BB864B489AFA3671FBE69101F94B38972F24816DFB01B51656B3FEC8DFD0888 D:)Q[IlAW!ahhC2ac:9*A}h:p?([4%wOTJ%JR%cs ---- And the server shall use this long-term key pair (specified as hexadecimal and in Z85): ---- public: 54FCBA24E93249969316FB617C872BB0C1D1FF14800427C594CBFACF1BC2D652 rq:rM>}U?@Lns47E1%kR.o@n%FcmmsL/@{H8]yf7 secret: 8E0BDD697628B91D8F245587EE95C5B04D48963F79259877B49CD9063AEAD3B7 JTKVSB%%)wK0E.X)V>+}o?pNmC{O&4W4b!Ni{Lh6 ---- == SEE ALSO * xref:zmq_z85_encode.adoc[zmq_z85_encode] * xref:zmq_z85_decode.adoc[zmq_z85_decode] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_null.adoc[zmq_null] * xref:zmq_plain.adoc[zmq_plain] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_curve.adoc
AsciiDoc
gpl-3.0
2,897
= zmq_curve_keypair(3) == NAME zmq_curve_keypair - generate a new CURVE keypair == SYNOPSIS *int zmq_curve_keypair (char *z85_public_key, char *z85_secret_key);* == DESCRIPTION The _zmq_curve_keypair()_ function shall return a newly generated random keypair consisting of a public key and a secret key. The caller provides two buffers, each at least 41 octets large, in which this method will store the keys. The keys are encoded using xref:zmq_z85_encode.adoc[zmq_z85_encode]. == RETURN VALUE The _zmq_curve_keypair()_ function shall return 0 if successful, else it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ENOTSUP*:: The libzmq library was not built with cryptographic support (libsodium). == EXAMPLE .Generating a new CURVE keypair ---- char public_key [41]; char secret_key [41]; int rc = zmq_curve_keypair (public_key, secret_key); assert (rc == 0); ---- == SEE ALSO * xref:zmq_z85_encode.adoc[zmq_z85_encode] * xref:zmq_z85_decode.adoc[zmq_z85_decode] * xref:zmq_curve.adoc[zmq_curve] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_curve_keypair.adoc
AsciiDoc
gpl-3.0
1,203
= zmq_curve_public(3) == NAME zmq_curve_public - derive the public key from a private key == SYNOPSIS *int zmq_curve_public (char *z85_public_key, char *z85_secret_key);* == DESCRIPTION The _zmq_curve_public()_ function shall derive the public key from a private key. The caller provides two buffers, each at least 41 octets large. In z85_secret_key the caller shall provide the private key, and the function will store the public key in z85_public_key. The keys are encoded using xref:zmq_z85_encode.adoc[zmq_z85_encode]. == RETURN VALUE The _zmq_curve_public()_ function shall return 0 if successful, else it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ENOTSUP*:: The libzmq library was not built with cryptographic support (libsodium). == EXAMPLE .Deriving the public key from a CURVE private key ---- char public_key [41]; char secret_key [41]; int rc = zmq_curve_keypair (public_key, secret_key); assert (rc == 0); char derived_public[41]; rc = zmq_curve_public (derived_public, secret_key); assert (rc == 0); assert (!strcmp (derived_public, public_key)); ---- == SEE ALSO * xref:zmq_z85_encode.adoc[zmq_z85_encode] * xref:zmq_z85_decode.adoc[zmq_z85_decode] * xref:zmq_curve_keypair.adoc[zmq_curve_keypair] * xref:zmq_curve.adoc[zmq_curve] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_curve_public.adoc
AsciiDoc
gpl-3.0
1,456
= zmq_disconnect(3) == NAME zmq_disconnect - Disconnect a socket from an endpoint == SYNOPSIS *int zmq_disconnect (void '*socket', const char '*endpoint');* == DESCRIPTION The _zmq_disconnect()_ function shall disconnect a socket specified by the 'socket' argument from the endpoint specified by the 'endpoint' argument. Note the actual disconnect system call might occur at a later time. Upon disconnection the will also stop receiving messages originating from this endpoint. Moreover, the socket will no longer be able to queue outgoing messages to this endpoint. The outgoing message queue associated with the endpoint will be discarded. However, if the socket's linger period is non-zero, libzmq will still attempt to transmit these discarded messages, until the linger period expires. The 'endpoint' argument is as described in xref:zmq_connect.adoc[zmq_connect] NOTE: The default setting of _ZMQ_LINGER_ does not discard unsent messages; this behaviour may cause the application to block when calling _zmq_ctx_term()_. For details refer to xref:zmq_setsockopt.adoc[zmq_setsockopt] and xref:zmq_ctx_term.adoc[zmq_ctx_term] == RETURN VALUE The _zmq_disconnect()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The endpoint supplied is invalid. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *ENOENT*:: The provided endpoint is not in use by the socket. == EXAMPLE .Connecting a subscriber socket to an in-process and a TCP transport ---- /* Create a ZMQ_SUB socket */ void *socket = zmq_socket (context, ZMQ_SUB); assert (socket); /* Connect it to the host server001, port 5555 using a TCP transport */ rc = zmq_connect (socket, "tcp://server001:5555"); assert (rc == 0); /* Disconnect from the previously connected endpoint */ rc = zmq_disconnect (socket, "tcp://server001:5555"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_disconnect.adoc
AsciiDoc
gpl-3.0
2,270
= zmq_errno(3) == NAME zmq_errno - retrieve value of errno for the calling thread == SYNOPSIS *int zmq_errno (void);* == DESCRIPTION The _zmq_errno()_ function shall retrieve the value of the 'errno' variable for the calling thread. The _zmq_errno()_ function is provided to assist users on non-POSIX systems who are experiencing issues with retrieving the correct value of 'errno' directly. Specifically, users on Win32 systems whose application is using a different C run-time library from the C run-time library in use by 0MQ will need to use _zmq_errno()_ for correct operation. IMPORTANT: Users not experiencing issues with retrieving the correct value of 'errno' should not use this function and should instead access the 'errno' variable directly. == RETURN VALUE The _zmq_errno()_ function shall return the value of the 'errno' variable for the calling thread. == ERRORS No errors are defined. == SEE ALSO * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_errno.adoc
AsciiDoc
gpl-3.0
1,107
= zmq_getsockopt(3) == NAME zmq_getsockopt - get 0MQ socket options == SYNOPSIS *int zmq_getsockopt (void '*socket', int 'option_name', void '*option_value', size_t '*option_len');* == DESCRIPTION The _zmq_getsockopt()_ function shall retrieve the value for the option specified by the 'option_name' argument for the 0MQ socket pointed to by the 'socket' argument, and store it in the buffer pointed to by the 'option_value' argument. The 'option_len' argument is the size in bytes of the buffer pointed to by 'option_value'; upon successful completion _zmq_getsockopt()_ shall modify the 'option_len' argument to indicate the actual size of the option value stored in the buffer. The following options can be retrieved with the _zmq_getsockopt()_ function: ZMQ_AFFINITY: Retrieve I/O thread affinity ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_AFFINITY' option shall retrieve the I/O thread affinity for newly created connections on the specified 'socket'. Affinity determines which threads from the 0MQ I/O thread pool associated with the socket's _context_ shall handle newly created connections. A value of zero specifies no affinity, meaning that work shall be distributed fairly among all 0MQ I/O threads in the thread pool. For non-zero values, the lowest bit corresponds to thread 1, second lowest bit to thread 2 and so on. For example, a value of 3 specifies that subsequent connections on 'socket' shall be handled exclusively by I/O threads 1 and 2. See also xref:zmq_init.adoc[zmq_init] for details on allocating the number of I/O threads for a specific _context_. [horizontal] Option value type:: uint64_t Option value unit:: N/A (bitmap) Default value:: 0 Applicable socket types:: N/A ZMQ_BACKLOG: Retrieve maximum length of the queue of outstanding connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_BACKLOG' option shall retrieve the maximum length of the queue of outstanding peer connections for the specified 'socket'; this only applies to connection-oriented transports. For details refer to your operating system documentation for the 'listen' function. [horizontal] Option value type:: int Option value unit:: connections Default value:: 100 Applicable socket types:: all, only for connection-oriented transports ZMQ_BINDTODEVICE: Retrieve name of device the socket is bound to ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_BINDTODEVICE' option retrieves the name of the device this socket is bound to, eg. an interface or VRF. If a socket is bound to an interface, only packets received from that interface are processed by the socket. If device is a VRF device, then subsequent binds/connects to that socket use addresses in the VRF routing table. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP or UDP transports. ZMQ_CONNECT_TIMEOUT: Retrieve connect() timeout ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieves how long to wait before timing-out a connect() system call. The connect() system call normally takes a long time before it returns a time out error. Setting this option allows the library to time out the call at an earlier interval. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 (disabled) Applicable socket types:: all, when using TCP transports. ZMQ_CURVE_PUBLICKEY: Retrieve current CURVE public key ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieves the current long term public key for the socket. You can provide either a 32 byte buffer, to retrieve the binary key value, or a 41 byte buffer, to retrieve the key in a printable Z85 format. NOTE: to fetch a printable key, the buffer must be 41 bytes large to hold the 40-char key value and one null byte. [horizontal] Option value type:: binary data or Z85 text string Option value size:: 32 or 41 Default value:: null Applicable socket types:: all, when using TCP transport ZMQ_CURVE_SECRETKEY: Retrieve current CURVE secret key ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieves the current long term secret key for the socket. You can provide either a 32 byte buffer, to retrieve the binary key value, or a 41 byte buffer, to retrieve the key in a printable Z85 format. NOTE: to fetch a printable key, the buffer must be 41 bytes large to hold the 40-char key value and one null byte. [horizontal] Option value type:: binary data or Z85 text string Option value size:: 32 or 41 Default value:: null Applicable socket types:: all, when using TCP transport ZMQ_CURVE_SERVERKEY: Retrieve current CURVE server key ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieves the current server key for the client socket. You can provide either a 32 byte buffer, to retrieve the binary key value, or a 41-byte buffer, to retrieve the key in a printable Z85 format. NOTE: to fetch a printable key, the buffer must be 41 bytes large to hold the 40-char key value and one null byte. [horizontal] Option value type:: binary data or Z85 text string Option value size:: 32 or 41 Default value:: null Applicable socket types:: all, when using TCP transport ZMQ_EVENTS: Retrieve socket event state ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_EVENTS' option shall retrieve the event state for the specified 'socket'. The returned value is a bit mask constructed by OR'ing a combination of the following event flags: *ZMQ_POLLIN*:: Indicates that at least one message may be received from the specified socket without blocking. *ZMQ_POLLOUT*:: Indicates that at least one message may be sent to the specified socket without blocking. The combination of a file descriptor returned by the 'ZMQ_FD' option being ready for reading but no actual events returned by a subsequent retrieval of the 'ZMQ_EVENTS' option is valid; applications should simply ignore this case and restart their polling operation/event loop. [horizontal] Option value type:: int Option value unit:: N/A (flags) Default value:: N/A Applicable socket types:: all ZMQ_FD: Retrieve file descriptor associated with the socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_FD' option shall retrieve the file descriptor associated with the specified 'socket'. The returned file descriptor can be used to integrate the socket into an existing event loop; the 0MQ library shall signal any pending events on the socket in an _edge-triggered_ fashion by making the file descriptor become ready for reading. NOTE: The ability to read from the returned file descriptor does not necessarily indicate that messages are available to be read from, or can be written to, the underlying socket; applications must retrieve the actual event state with a subsequent retrieval of the 'ZMQ_EVENTS' option. NOTE: The returned file descriptor is also used internally by the 'zmq_send' and 'zmq_recv' functions. As the descriptor is edge triggered, applications must update the state of 'ZMQ_EVENTS' after each invocation of 'zmq_send' or 'zmq_recv'.To be more explicit: after calling 'zmq_send' the socket may become readable (and vice versa) without triggering a read event on the file descriptor. CAUTION: The returned file descriptor is intended for use with a 'poll' or similar system call only. Applications must never attempt to read or write data to it directly, neither should they try to close it. [horizontal] Option value type:: int on POSIX systems, SOCKET on Windows Option value unit:: N/A Default value:: N/A Applicable socket types:: all ZMQ_GSSAPI_PLAINTEXT: Retrieve GSSAPI plaintext or encrypted status ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns the 'ZMQ_GSSAPI_PLAINTEXT' option, if any, previously set on the socket. A value of '1' means that communications will be plaintext. A value of '0' means communications will be encrypted. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 (false) Applicable socket types:: all, when using TCP or IPC transports ZMQ_GSSAPI_PRINCIPAL: Retrieve the name of the GSSAPI principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_GSSAPI_PRINCIPAL' option shall retrieve the principal name set for the GSSAPI security mechanism. The returned value shall be a NULL-terminated string and MAY be empty. The returned size SHALL include the terminating null byte. [horizontal] Option value type:: NULL-terminated character string Option value unit:: N/A Default value:: null string Applicable socket types:: all, when using TCP or IPC transports ZMQ_GSSAPI_SERVER: Retrieve current GSSAPI server role ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns the 'ZMQ_GSSAPI_SERVER' option, if any, previously set on the socket. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 (false) Applicable socket types:: all, when using TCP or IPC transports ZMQ_GSSAPI_SERVICE_PRINCIPAL: Retrieve the name of the GSSAPI service principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_GSSAPI_SERVICE_PRINCIPAL' option shall retrieve the principal name of the GSSAPI server to which a GSSAPI client socket intends to connect. The returned value shall be a NULL-terminated string and MAY be empty. The returned size SHALL include the terminating null byte. [horizontal] Option value type:: NULL-terminated character string Option value unit:: N/A Default value:: null string Applicable socket types:: all, when using TCP or IPC transports ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE: Retrieve nametype for service principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns the 'ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE' option, if any, previously set on the socket. A value of 'ZMQ_GSSAPI_NT_HOSTBASED' (0) means the name specified with 'ZMQ_GSSAPI_SERVICE_PRINCIPAL' is interpreted as a host based name. A value of 'ZMQ_GSSAPI_NT_USER_NAME' (1) means it is interpreted as a local user name. A value of 'ZMQ_GSSAPI_NT_KRB5_PRINCIPAL' (2) means it is interpreted as an unparsed principal name string (valid only with the krb5 GSSAPI mechanism). [horizontal] Option value type:: int Option value unit:: 0, 1, 2 Default value:: 0 (ZMQ_GSSAPI_NT_HOSTBASED) Applicable socket types:: all, when using TCP or IPC transports ZMQ_GSSAPI_PRINCIPAL_NAMETYPE: Retrieve nametype for service principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns the 'ZMQ_GSSAPI_PRINCIPAL_NAMETYPE' option, if any, previously set on the socket. A value of 'ZMQ_GSSAPI_NT_HOSTBASED' (0) means the name specified with 'ZMQ_GSSAPI_PRINCIPAL' is interpreted as a host based name. A value of 'ZMQ_GSSAPI_NT_USER_NAME' (1) means it is interpreted as a local user name. A value of 'ZMQ_GSSAPI_NT_KRB5_PRINCIPAL' (2) means it is interpreted as an unparsed principal name string (valid only with the krb5 GSSAPI mechanism). [horizontal] Option value type:: int Option value unit:: 0, 1, 2 Default value:: 0 (ZMQ_GSSAPI_NT_HOSTBASED) Applicable socket types:: all, when using TCP or IPC transports ZMQ_HANDSHAKE_IVL: Retrieve maximum handshake interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_HANDSHAKE_IVL' option shall retrieve the maximum handshake interval for the specified 'socket'. Handshaking is the exchange of socket configuration information (socket type, routing id, security) that occurs when a connection is first opened, only for connection-oriented transports. If handshaking does not complete within the configured time, the connection shall be closed. The value 0 means no handshake time limit. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 30000 Applicable socket types:: all but ZMQ_STREAM, only for connection-oriented transports ZMQ_IDENTITY: Retrieve socket identity ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This option name is now deprecated. Use ZMQ_ROUTING_ID instead. ZMQ_IDENTITY remains as an alias for now. ZMQ_IMMEDIATE: Retrieve attach-on-connect value ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the state of the attach on connect value. If set to `1`, will delay the attachment of a pipe on connect until the underlying connection has completed. This will cause the socket to block if there are no other connections, but will prevent queues from filling on pipes awaiting connection. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: all, primarily when using TCP/IPC transports. ZMQ_INVERT_MATCHING: Retrieve inverted filtering status ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns the value of the 'ZMQ_INVERT_MATCHING' option. A value of `1` means the socket uses inverted prefix matching. On 'PUB' and 'XPUB' sockets, this causes messages to be sent to all connected sockets 'except' those subscribed to a prefix that matches the message. On 'SUB' sockets, this causes only incoming messages that do 'not' match any of the socket's subscriptions to be received by the user. Whenever 'ZMQ_INVERT_MATCHING' is set to 1 on a 'PUB' socket, all 'SUB' sockets connecting to it must also have the option set to 1. Failure to do so will have the 'SUB' sockets reject everything the 'PUB' socket sends them. 'XSUB' sockets do not need to do this because they do not filter incoming messages. [horizontal] Option value type:: int Option value unit:: 0,1 Default value:: 0 Applicable socket types:: ZMQ_PUB, ZMQ_XPUB, ZMQ_SUB ZMQ_IPV4ONLY: Retrieve IPv4-only socket override status ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the IPv4-only option for the socket. This option is deprecated. Please use the ZMQ_IPV6 option. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 1 (true) Applicable socket types:: all, when using TCP transports. ZMQ_IPV6: Retrieve IPv6 socket status ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the IPv6 option for the socket. A value of `1` means IPv6 is enabled on the socket, while `0` means the socket will use only IPv4. When IPv6 is enabled the socket will connect to, or accept connections from, both IPv4 and IPv6 hosts. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: all, when using TCP transports. ZMQ_LAST_ENDPOINT: Retrieve the last endpoint set ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_LAST_ENDPOINT' option shall retrieve the last endpoint bound for TCP and IPC transports. The returned value will be a string in the form of a ZMQ DSN. Note that if the TCP host is INADDR_ANY, indicated by a *, then the returned address will be 0.0.0.0 (for IPv4). Note: not supported on GNU/Hurd with IPC due to non-working getsockname(). [horizontal] Option value type:: NULL-terminated character string Option value unit:: N/A Default value:: NULL Applicable socket types:: all, when binding TCP or IPC transports ZMQ_LINGER: Retrieve linger period for socket shutdown ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_LINGER' option shall retrieve the linger period for the specified 'socket'. The linger period determines how long pending messages which have yet to be sent to a peer shall linger in memory after a socket is closed with xref:zmq_close.adoc[zmq_close], and further affects the termination of the socket's context with xref:zmq_ctx_term.adoc[zmq_ctx_term] The following outlines the different behaviours: * The default value of '-1' specifies an infinite linger period. Pending messages shall not be discarded after a call to _zmq_close()_; attempting to terminate the socket's context with _zmq_ctx_term()_ shall block until all pending messages have been sent to a peer. * The value of '0' specifies no linger period. Pending messages shall be discarded immediately when the socket is closed with _zmq_close()_. * Positive values specify an upper bound for the linger period in milliseconds. Pending messages shall not be discarded after a call to _zmq_close()_; attempting to terminate the socket's context with _zmq_ctx_term()_ shall block until either all pending messages have been sent to a peer, or the linger period expires, after which any pending messages shall be discarded. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 (infinite) Applicable socket types:: all ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The option shall retrieve limit for the inbound messages. If a peer sends a message larger than ZMQ_MAXMSGSIZE it is disconnected. Value of -1 means 'no limit'. [horizontal] Option value type:: int64_t Option value unit:: bytes Default value:: -1 Applicable socket types:: all ZMQ_MECHANISM: Retrieve current security mechanism ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MECHANISM' option shall retrieve the current security mechanism for the socket. [horizontal] Option value type:: int Option value unit:: ZMQ_NULL, ZMQ_PLAIN, ZMQ_CURVE, or ZMQ_GSSAPI Default value:: ZMQ_NULL Applicable socket types:: all, when using TCP or IPC transports ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The option shall retrieve time-to-live used for outbound multicast packets. The default of 1 means that the multicast packets don't leave the local network. [horizontal] Option value type:: int Option value unit:: network hops Default value:: 1 Applicable socket types:: all, when using multicast transports ZMQ_MULTICAST_MAXTPDU: Maximum transport data unit size for multicast packets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_MULTICAST_MAXTPDU' option shall retrieve the maximum transport data unit size used for outbound multicast packets. This must be set at or below the minimum Maximum Transmission Unit (MTU) for all network paths over which multicast reception is required. [horizontal] Option value type:: int Option value unit:: bytes Default value:: 1500 Applicable socket types:: all, when using multicast transports ZMQ_PLAIN_PASSWORD: Retrieve current password ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_PLAIN_PASSWORD' option shall retrieve the last password set for the PLAIN security mechanism. The returned value shall be a NULL-terminated string and MAY be empty. The returned size SHALL include the terminating null byte. [horizontal] Option value type:: NULL-terminated character string Option value unit:: N/A Default value:: null string Applicable socket types:: all, when using TCP or IPC transports ZMQ_PLAIN_SERVER: Retrieve current PLAIN server role ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Returns the 'ZMQ_PLAIN_SERVER' option, if any, previously set on the socket. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: int Applicable socket types:: all, when using TCP or IPC transports ZMQ_PLAIN_USERNAME: Retrieve current PLAIN username ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_PLAIN_USERNAME' option shall retrieve the last username set for the PLAIN security mechanism. The returned value shall be a NULL-terminated string and MAY be empty. The returned size SHALL include the terminating null byte. [horizontal] Option value type:: NULL-terminated character string Option value unit:: N/A Default value:: null string Applicable socket types:: all, when using TCP or IPC transports ZMQ_USE_FD: Retrieve the pre-allocated socket file descriptor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_USE_FD' option shall retrieve the pre-allocated file descriptor that has been assigned to a ZMQ socket, if any. -1 shall be returned if a pre-allocated file descriptor was not set for the socket. [horizontal] Option value type:: int Option value unit:: file descriptor Default value:: -1 Applicable socket types:: all bound sockets, when using IPC or TCP transport ZMQ_PRIORITY: Retrieve the Priority on socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the protocol-defined priority for all packets to be sent on this socket, where supported by the OS. [horizontal] Option value type:: int Option value unit:: >0 Default value:: 0 Applicable socket types:: all, only for connection-oriented transports ZMQ_RATE: Retrieve multicast data rate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RATE' option shall retrieve the maximum send or receive data rate for multicast transports using the specified 'socket'. [horizontal] Option value type:: int Option value unit:: kilobits per second Default value:: 100 Applicable socket types:: all, when using multicast transports ZMQ_RCVBUF: Retrieve kernel receive buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RCVBUF' option shall retrieve the underlying kernel receive buffer size for the specified 'socket'. For details refer to your operating system documentation for the 'SO_RCVBUF' socket option. [horizontal] Option value type:: int Option value unit:: bytes Default value:: 8192 Applicable socket types:: all ZMQ_RCVHWM: Retrieve high water mark for inbound messages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RCVHWM' option shall return the high water mark for inbound messages on the specified 'socket'. The high water mark is a hard limit on the maximum number of outstanding messages 0MQ shall queue in memory for any single peer that the specified 'socket' is communicating with. A value of zero means no limit. If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, 0MQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in xref:zmq_socket.adoc[zmq_socket] for details on the exact action taken for each socket type. [horizontal] Option value type:: int Option value unit:: messages Default value:: 1000 Applicable socket types:: all ZMQ_RCVMORE: More message data parts to follow ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RCVMORE' option shall return True (1) if the message part last received from the 'socket' was a data part with more parts to follow. If there are no data parts to follow, this option shall return False (0). Refer to xref:zmq_send.adoc[zmq_send] and xref:zmq_recv.adoc[zmq_recv] for a detailed description of multi-part messages. [horizontal] Option value type:: int Option value unit:: boolean Default value:: N/A Applicable socket types:: all ZMQ_RCVTIMEO: Maximum time before a socket operation returns with EAGAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the timeout for recv operation on the socket. If the value is `0`, _zmq_recv(3)_ will return immediately, with a EAGAIN error if there is no message to receive. If the value is `-1`, it will block until a message is available. For all other values, it will wait for a message for that amount of time before returning with an EAGAIN error. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 (infinite) Applicable socket types:: all ZMQ_RECONNECT_IVL: Retrieve reconnection interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECONNECT_IVL' option shall retrieve the initial reconnection interval for the specified 'socket'. The reconnection interval is the period 0MQ shall wait between attempts to reconnect disconnected peers when using connection-oriented transports. The value -1 means no reconnection. NOTE: The reconnection interval may be randomized by 0MQ to prevent reconnection storms in topologies with a large number of peers per socket. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 100 Applicable socket types:: all, only for connection-oriented transports ZMQ_RECONNECT_IVL_MAX: Retrieve max reconnection interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECONNECT_IVL_MAX' option shall retrieve the max reconnection interval for the specified 'socket'. 0MQ shall wait at most the configured interval between reconnection attempts. The interval grows exponentionally (i.e.: it is doubled) with each attempt until it reaches ZMQ_RECONNECT_IVL_MAX. Default value means that the reconnect interval is based exclusively on ZMQ_RECONNECT_IVL and no exponential backoff is performed. NOTE: Value has to be greater or equal than ZMQ_RECONNECT_IVL, or else it will be ignored. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 (ZMQ_RECONNECT_IVL will be used) Applicable socket types:: all, only for connection-oriented transport ZMQ_RECONNECT_STOP: Retrieve condition where reconnection will stop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECONNECT_STOP' option shall retrieve the conditions under which automatic reconnection will stop. The 'ZMQ_RECONNECT_STOP_CONN_REFUSED' option will stop reconnection when 0MQ receives the ECONNREFUSED return code from the connect. This indicates that there is no code bound to the specified endpoint. [horizontal] Option value type:: int Option value unit:: 'ZMQ_RECONNECT_STOP_CONN_REFUSED' Default value:: 0 Applicable socket types:: all, only for connection-oriented transports ZMQ_RECOVERY_IVL: Get multicast recovery interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECOVERY_IVL' option shall retrieve the recovery interval for multicast transports using the specified 'socket'. The recovery interval determines the maximum time in milliseconds that a receiver can be absent from a multicast group before unrecoverable data loss will occur. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 10000 Applicable socket types:: all, when using multicast transports ZMQ_ROUTING_ID: Retrieve socket routing id ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_ROUTING_ID' option shall retrieve the routing id of the specified 'socket'. Routing ids are used only by the request/reply pattern. Specifically, it can be used in tandem with ROUTER socket to route messages to the peer with a specific routing id. A routing id must be at least one byte and at most 255 bytes long. Identities starting with a zero byte are reserved for use by the 0MQ infrastructure. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_REP, ZMQ_REQ, ZMQ_ROUTER, ZMQ_DEALER. ZMQ_SNDBUF: Retrieve kernel transmit buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SNDBUF' option shall retrieve the underlying kernel transmit buffer size for the specified 'socket'. For details refer to your operating system documentation for the 'SO_SNDBUF' socket option. [horizontal] Option value type:: int Option value unit:: bytes Default value:: 8192 Applicable socket types:: all ZMQ_SNDHWM: Retrieves high water mark for outbound messages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SNDHWM' option shall return the high water mark for outbound messages on the specified 'socket'. The high water mark is a hard limit on the maximum number of outstanding messages 0MQ shall queue in memory for any single peer that the specified 'socket' is communicating with. A value of zero means no limit. If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, 0MQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in xref:zmq_socket.adoc[zmq_socket] for details on the exact action taken for each socket type. [horizontal] Option value type:: int Option value unit:: messages Default value:: 1000 Applicable socket types:: all ZMQ_SNDTIMEO: Maximum time before a socket operation returns with EAGAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the timeout for send operation on the socket. If the value is `0`, _zmq_send(3)_ will return immediately, with a EAGAIN error if the message cannot be sent. If the value is `-1`, it will block until the message is sent. For all other values, it will try to send the message for that amount of time before returning with an EAGAIN error. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 (infinite) Applicable socket types:: all ZMQ_SOCKS_PROXY: Retrieve SOCKS5 proxy address ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SOCKS_PROXY' option shall retrieve the SOCKS5 proxy address in string format. The returned value shall be a NULL-terminated string and MAY be empty. The returned size SHALL include the terminating null byte. [horizontal] Option value type:: NULL-terminated character string Option value unit:: N/A Default value:: null string Applicable socket types:: all, when using TCP transports ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'SO_KEEPALIVE' socket option(where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,0,1 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'TCP_KEEPCNT' socket option(where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,>0 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPIDLE (or TCP_KEEPALIVE on some OS) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'TCP_KEEPIDLE'(or 'TCP_KEEPALIVE' on some OS) socket option (where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,>0 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'TCP_KEEPINTVL' socket option(where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,>0 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_MAXRT: Retrieve Max TCP Retransmit Timeout ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On OSes where it is supported, retrieves how long before an unacknowledged TCP retransmit times out. The system normally attempts many TCP retransmits following an exponential backoff strategy. This means that after a network outage, it may take a long time before the session can be re-established. Setting this option allows the timeout to happen at a shorter interval. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_THREAD_SAFE: Retrieve socket thread safety ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_THREAD_SAFE' option shall retrieve a boolean value indicating whether or not the socket is threadsafe. See xref:zmq_socket.adoc[zmq_socket] for which sockets are thread-safe. [horizontal] Option value type:: int Option value unit:: boolean Applicable socket types:: all ZMQ_TOS: Retrieve the Type-of-Service socket override status ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the IP_TOS option for the socket. [horizontal] Option value type:: int Option value unit:: >0 Default value:: 0 Applicable socket types:: all, only for connection-oriented transports ZMQ_TYPE: Retrieve socket type ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_TYPE' option shall retrieve the socket type for the specified 'socket'. The socket type is specified at socket creation time and cannot be modified afterwards. [horizontal] Option value type:: int Option value unit:: N/A Default value:: N/A Applicable socket types:: all ZMQ_ZAP_DOMAIN: Retrieve RFC 27 authentication domain ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_ZAP_DOMAIN' option shall retrieve the last ZAP domain set for the socket. The returned value shall be a NULL-terminated string and MAY be empty. An empty string means that ZAP authentication is disabled. The returned size SHALL include the terminating null byte. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_ZAP_ENFORCE_DOMAIN: Retrieve ZAP domain handling mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_ZAP_ENFORCE_DOMAIN' option shall retrieve the flag that determines whether a ZAP domain is strictly required or not. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: all, when using ZAP ZMQ_VMCI_BUFFER_SIZE: Retrieve buffer size of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_BUFFER_SIZE` option shall retrieve the size of the underlying buffer for the socket. Used during negotiation before the connection is established. [horizontal] Option value type:: uint64_t Option value unit:: bytes Default value:: 65546 Applicable socket types:: all, when using VMCI transport ZMQ_VMCI_BUFFER_MIN_SIZE: Retrieve min buffer size of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_BUFFER_MIN_SIZE` option shall retrieve the min size of the underlying buffer for the socket. Used during negotiation before the connection is established. [horizontal] Option value type:: uint64_t Option value unit:: bytes Default value:: 128 Applicable socket types:: all, when using VMCI transport ZMQ_VMCI_BUFFER_MAX_SIZE: Retrieve max buffer size of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_BUFFER_MAX_SIZE` option shall retrieve the max size of the underlying buffer for the socket. Used during negotiation before the connection is established. [horizontal] Option value type:: uint64_t Option value unit:: bytes Default value:: 262144 Applicable socket types:: all, when using VMCI transport ZMQ_VMCI_CONNECT_TIMEOUT: Retrieve connection timeout of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_CONNECT_TIMEOUT` option shall retrieve connection timeout for the socket. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 Applicable socket types:: all, when using VMCI transport ZMQ_MULTICAST_LOOP: Retrieve multicast local loopback configuration ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the current multicast loopback configuration. A value of `1` means that the multicast packets sent on this socket will be looped back to local listening interface. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 1 Applicable socket types:: ZMQ_RADIO, when using UDP multicast transport ZMQ_ROUTER_NOTIFY: Retrieve router socket notification settings ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieve the current notification settings of a router socket. The returned value is a bitmask composed of ZMQ_NOTIFY_CONNECT and ZMQ_NOTIFY_DISCONNECT flags, meaning connect and disconnect notifications are enabled, respectively. A value of '0' means the notifications are off. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, ZMQ_NOTIFY_CONNECT, ZMQ_NOTIFY_DISCONNECT, ZMQ_NOTIFY_CONNECT | ZMQ_NOTIFY_DISCONNECT Default value:: 0 Applicable socket types:: ZMQ_ROUTER ZMQ_IN_BATCH_SIZE: Maximal receive batch size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the maximal amount of messages that can be received in a single 'recv' system call. Cannot be zero. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: messages Default value:: 8192 Applicable socket types:: All, when using TCP, IPC, PGM or NORM transport. ZMQ_OUT_BATCH_SIZE: Maximal send batch size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the maximal amount of messages that can be sent in a single 'send' system call. Cannot be zero. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: messages Default value:: 8192 Applicable socket types:: All, when using TCP, IPC, PGM or NORM transport. ZMQ_TOPICS_COUNT: Number of topic subscriptions received ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the number of topic (prefix) subscriptions either * received on a (X)PUB socket from all the connected (X)SUB sockets or * acknowledged on an (X)SUB socket from all the connected (X)PUB sockets NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: N/A Default value:: 0 Applicable socket types:: ZMQ_PUB, ZMQ_XPUB, ZMQ_SUB, ZMQ_XSUB ZMQ_NORM_MODE: Retrieve NORM Sender Mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the NORM sender mode to control the operation of the NORM transport. NORM supports fixed rate operation (0='ZMQ_NORM_FIXED'), congestion control mode (1='ZMQ_NORM_CC'), loss-tolerant congestion control (2='ZMQ_NORM_CCL'), explicit congestion notification (ECN)-enabled congestion control (3='ZMQ_NORM_CCE'), and ECN-only congestion control (4='ZMQ_NORM_CCE_ECNONLY'). The default value is TCP-friendly congestion control mode. Fixed rate mode (using datarate set by 'ZMQ_RATE') offers better performance, but care must be taken to prevent data loss. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, 1, 2, 3, 4 Default value:: 1 ('ZMQ_NORM_CC') Applicable socket types:: All, when using NORM transport. ZMQ_NORM_UNICAST_NACK: Retrieve NORM Unicast NACK mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Retrieves status of NORM unicast NACK mode setting for multicast receivers. If set, NORM receiver will send Negative ACKnowledgements (NACKs) back to the sender using unicast instead of multicast. NORM transport endpoints specifying a unicast address will use unicast NACKs by default (without setting 'ZMQ_NORM_UNICAST_NACK'). NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: All, when using NORM transport. ZMQ_NORM_BUFFER_SIZE: Retrieve NORM buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets NORM buffer size for NORM transport sender, receiver, and stream. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: kilobytes Default value:: 2048 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_SEGMENT_SIZE: Retrieve NORM segment size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets NORM sender segment size, which is the maximum message payload size of individual NORM messages (ZMQ messages may be split over multiple NORM messages). Ideally, this value should fit within the system/network maximum transmission unit (MTU) after accounting for additional NORM message headers (up to 48 bytes). NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: bytes Default value:: 1400 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_BLOCK_SIZE: Retrieve NORM block size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets NORM sender block size, which is the number of segments in a NORM FEC coding block. NORM repair operations take place at block boundaries. Maximum value is 255, but parity packets ('ZMQ_NORM_NUM_PARITY') are limited to a value of (255 - 'ZMQ_NORM_BLOCK_SIZE'). Minimum value is ('ZMQ_NORM_NUM_PARITY' + 1). Effective value may be different based on the settings of 'ZMQ_NORM_NUM_PARITY' and 'ZMQ_NORM_NUM_AUTOPARITY' if invalid settings are provided. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: >0, <=255 Default value:: 16 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_NUM_PARITY: Retrieve NORM parity segment setting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the maximum number of NORM parity symbol segments that the sender is willing to calculate per FEC coding block for the purpose of reparing lost data. Maximum value is 255, but is further limited to a value of (255 - 'ZMQ_NORM_BLOCK_SIZE'). Minimum value is 'ZMQ_NORM_NUM_AUTOPARITY'. Effective value may be different based on the setting of 'ZMQ_NORM_NUM_AUTOPARITY' if invalid settings are provided. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: >0, <255 Default value:: 4 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_NUM_AUTOPARITY: Retrieve proactive NORM parity segment setting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets the number of NORM parity symbol segments that the sender will proactively send at the end of each FEC coding block. By default, no proactive parity segments will be sent; instead, parity segments will only be sent in response to repair requests (NACKs). Maximum value is 255, but is further limited to a maximum value of 'ZMQ_NORM_NUM_PARITY'. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: >=0, <255 Default value:: 0 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_PUSH: Retrieve NORM push mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Gets status of NORM stream push mode, which alters the behavior of the sender when enqueueing new data. By default, NORM will stop accepting new messages while waiting for old data to be transmitted and/or repaired. Enabling push mode discards the oldest data (which may be pending repair or may never have been transmitted) in favor of accepting new data. This may be useful in cases where it is more important to quickly deliver new data instead of reliably delivering older data. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: All, when using NORM transport. == RETURN VALUE The _zmq_getsockopt()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested option _option_name_ is unknown, or the requested _option_len_ or _option_value_ is invalid, or the size of the buffer pointed to by _option_value_, as specified by _option_len_, is insufficient for storing the option value. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal. == EXAMPLE .Retrieving the high water mark for outgoing messages ---- /* Retrieve high water mark into sndhwm */ int sndhwm; size_t sndhwm_size = sizeof (sndhwm); rc = zmq_getsockopt (socket, ZMQ_SNDHWM, &sndhwm, &sndhwm_size); assert (rc == 0); ---- == SEE ALSO * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_getsockopt.adoc
AsciiDoc
gpl-3.0
44,419
= zmq_gssapi(7) == NAME zmq_gssapi - secure authentication and confidentiality == SYNOPSIS The GSSAPI mechanism defines a mechanism for secure authentication and confidentiality for communications between a client and a server using the Generic Security Service Application Program Interface (GSSAPI). The GSSAPI mechanism can be used on both public and private networks. GSSAPI itself is defined in IETF RFC-2743: <http://tools.ietf.org/html/rfc2743>. The ZeroMQ GSSAPI mechanism is defined by this document: <http://rfc.zeromq.org/spec:38>. == CLIENT AND SERVER ROLES A socket using GSSAPI can be either client or server, but not both. To become a GSSAPI server, the application sets the ZMQ_GSSAPI_SERVER option on the socket. To become a GSSAPI client, the application sets the ZMQ_GSSAPI_SERVICE_PRINCIPAL option to the name of the principal on the server to which it intends to connect. On client or server, the application may additionally set the ZMQ_GSSAPI_PRINCIPAL option to provide the socket with the name of the principal for whom GSSAPI credentials should be acquired. If this option is not set, default credentials are used. == OPTIONAL ENCRYPTION By default, the GSSAPI mechanism will encrypt all communications between client and server. If encryption is not desired (e.g. on private networks), the client and server applications can disable it by setting the ZMQ_GSSAPI_PLAINTEXT option. Both the client and server must set this option to the same value. == PRINCIPAL NAMES Principal names specified with the ZMQ_GSSAPI_SERVICE_PRINCIPAL or ZMQ_GSSAPI_PRINCIPAL options are interpreted as "host based" name types by default. The ZMQ_GSSAPI_PRINCIPAL_NAMETYPE and ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE options may be used to change the name type to one of: *ZMQ_GSSAPI_NT_HOSTBASED*:: The name should be of the form "service" or "service@hostname", which will parse into a principal of "service/hostname" in the local realm. This is the default name type. *ZMQ_GSSAPI_NT_USER_NAME*:: The name should be a local username, which will parse into a single-component principal in the local realm. *ZMQ_GSSAPI_NT_KRB5_PRINCIPAL*:: The name is a principal name string. This name type only works with the krb5 GSSAPI mechanism. == SEE ALSO * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_null.adoc[zmq_null] * xref:zmq_curve.adoc[zmq_curve] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_gssapi.adoc
AsciiDoc
gpl-3.0
2,561
= zmq_has(3) == NAME zmq_has - check a ZMQ capability == SYNOPSIS *int zmq_has (const char *capability);* == DESCRIPTION The _zmq_has()_ function shall report whether a specified capability is available in the library. This allows bindings and applications to probe a library directly, for transport and security options. Capabilities shall be lowercase strings. The following capabilities are defined: * ipc - the library supports the ipc:// protocol * pgm - the library supports the pgm:// protocol * tipc - the library supports the tipc:// protocol * norm - the library supports the norm:// protocol * curve - the library supports the CURVE security mechanism * gssapi - the library supports the GSSAPI security mechanism * draft - the library is built with the draft api When this method is provided, the zmq.h header file will define ZMQ_HAS_CAPABILITIES. == RETURN VALUE The _zmq_has()_ function shall return 1 if the specified capability is provided. Otherwise it shall return 0. == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_has.adoc
AsciiDoc
gpl-3.0
1,155
= zmq_inproc(7) == NAME zmq_inproc - 0MQ local in-process (inter-thread) communication transport == SYNOPSIS The in-process transport passes messages via memory directly between threads sharing a single 0MQ 'context'. NOTE: No I/O threads are involved in passing messages using the 'inproc' transport. Therefore, if you are using a 0MQ 'context' for in-process messaging only you can initialise the 'context' with zero I/O threads. See xref:zmq_init.adoc[zmq_init] for details. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the in-process transport, the transport is `inproc`, and the meaning of the 'address' part is defined below. Assigning a local address to a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When assigning a local address to a 'socket' using _zmq_bind()_ with the 'inproc' transport, the 'endpoint' shall be interpreted as an arbitrary string identifying the 'name' to create. The 'name' must be unique within the 0MQ 'context' associated with the 'socket' and may be up to 256 characters in length. No other restrictions are placed on the format of the 'name'. Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a 'socket' to a peer address using _zmq_connect()_ with the 'inproc' transport, the 'endpoint' shall be interpreted as an arbitrary string identifying the 'name' to connect to. Before version 4.0 he 'name' must have been previously created by assigning it to at least one 'socket' within the same 0MQ 'context' as the 'socket' being connected. Since version 4.0 the order of _zmq_bind()_ and _zmq_connect()_ does not matter just like for the tcp transport type. == EXAMPLES .Assigning a local address to a socket ---- // Assign the in-process name "#1" rc = zmq_bind(socket, "inproc://#1"); assert (rc == 0); // Assign the in-process name "my-endpoint" rc = zmq_bind(socket, "inproc://my-endpoint"); assert (rc == 0); ---- .Connecting a socket ---- // Connect to the in-process name "#1" rc = zmq_connect(socket, "inproc://#1"); assert (rc == 0); // Connect to the in-process name "my-endpoint" rc = zmq_connect(socket, "inproc://my-endpoint"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_ipc.adoc[zmq_ipc] * xref:zmq_tcp.adoc[zmq_tcp] * xref:zmq_pgm.adoc[zmq_pgm] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_inproc.adoc
AsciiDoc
gpl-3.0
2,691
= zmq_ipc(7) == NAME zmq_ipc - 0MQ local inter-process communication transport == SYNOPSIS The inter-process transport passes messages between local processes using a system-dependent IPC mechanism. NOTE: The inter-process transport is currently only implemented on operating systems that provide UNIX domain sockets. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the inter-process transport, the transport is `ipc`, and the meaning of the 'address' part is defined below. Binding a socket ~~~~~~~~~~~~~~~~ When binding a 'socket' to a local address using _zmq_bind()_ with the 'ipc' transport, the 'endpoint' shall be interpreted as an arbitrary string identifying the 'pathname' to create. The 'pathname' must be unique within the operating system namespace used by the 'ipc' implementation, and must fulfill any restrictions placed by the operating system on the format and length of a 'pathname'. When the address is wild-card `*`, _zmq_bind()_ shall generate a unique temporary pathname. The caller should retrieve this pathname using the ZMQ_LAST_ENDPOINT socket option. See xref:zmq_getsockopt.adoc[zmq_getsockopt] for details. NOTE: any existing binding to the same endpoint shall be overridden. That is, if a second process binds to an endpoint already bound by a process, this will succeed and the first process will lose its binding. In this behaviour, the 'ipc' transport is not consistent with the 'tcp' or 'inproc' transports. NOTE: the endpoint pathname must be writable by the process. When the endpoint starts with '/', e.g., `ipc:///pathname`, this will be an _absolute_ pathname. If the endpoint specifies a directory that does not exist, the bind shall fail. NOTE: on Linux only, when the endpoint pathname starts with `@`, the abstract namespace shall be used. The abstract namespace is independent of the filesystem and if a process attempts to bind an endpoint already bound by a process, it will fail. See unix(7) for details. NOTE: IPC pathnames have a maximum size that depends on the operating system. On Linux, the maximum is 113 characters including the "ipc://" prefix (107 characters for the real path name). Unbinding wild-card address from a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When wild-card `*` 'endpoint' was used in _zmq_bind()_, the caller should use real 'endpoint' obtained from the ZMQ_LAST_ENDPOINT socket option to unbind this 'endpoint' from a socket using _zmq_unbind()_. Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a 'socket' to a peer address using _zmq_connect()_ with the 'ipc' transport, the 'endpoint' shall be interpreted as an arbitrary string identifying the 'pathname' to connect to. The 'pathname' must have been previously created within the operating system namespace by assigning it to a 'socket' with _zmq_bind()_. == EXAMPLES .Assigning a local address to a socket ---- // Assign the pathname "/tmp/feeds/0" rc = zmq_bind(socket, "ipc:///tmp/feeds/0"); assert (rc == 0); ---- .Connecting a socket ---- // Connect to the pathname "/tmp/feeds/0" rc = zmq_connect(socket, "ipc:///tmp/feeds/0"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq_tcp.adoc[zmq_tcp] * xref:zmq_pgm.adoc[zmq_pgm] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq_getsockopt.adoc[zmq_getsockopt] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ipc.adoc
AsciiDoc
gpl-3.0
3,738
= zmq_msg_close(3) == NAME zmq_msg_close - release 0MQ message == SYNOPSIS *int zmq_msg_close (zmq_msg_t '*msg');* == DESCRIPTION The _zmq_msg_close()_ function shall inform the 0MQ infrastructure that any resources associated with the message object referenced by 'msg' are no longer required and may be released. Actual release of resources associated with the message object shall be postponed by 0MQ until all users of the message or underlying data buffer have indicated it is no longer required. Applications should ensure that _zmq_msg_close()_ is called once a message is no longer required, otherwise memory leaks may occur. Note that this is NOT necessary after a successful _zmq_msg_send()_. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. == RETURN VALUE The _zmq_msg_close()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EFAULT*:: Invalid message. == SEE ALSO * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_data.adoc[zmq_msg_data] * xref:zmq_msg_size.adoc[zmq_msg_size] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_close.adoc
AsciiDoc
gpl-3.0
1,483
= zmq_msg_copy(3) == NAME zmq_msg_copy - copy content of a message to another message == SYNOPSIS *int zmq_msg_copy (zmq_msg_t '*dest', zmq_msg_t '*src');* == DESCRIPTION The _zmq_msg_copy()_ function shall copy the message object referenced by 'src' to the message object referenced by 'dest'. The original content of 'dest', if any, shall be released. You must initialise 'dest' before copying to it. CAUTION: The implementation may choose not to physically copy the message content, rather to share the underlying buffer between 'src' and 'dest'. Avoid modifying message content after a message has been copied with _zmq_msg_copy()_, doing so can result in undefined behaviour. If what you need is an actual hard copy, initialize a new message using _zmq_msg_init_buffer()_ with the message content. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. == RETURN VALUE The _zmq_msg_copy()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EFAULT*:: Invalid message. == EXAMPLE .Copying a message ---- zmq_msg_t msg; zmq_msg_init_buffer (&msg, "Hello, World", 12); zmq_msg_t copy; zmq_msg_init (&copy); zmq_msg_copy (&copy, &msg); ... zmq_msg_close (&copy); zmq_msg_close (&msg); ---- == SEE ALSO * xref:zmq_msg_move.adoc[zmq_msg_move] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_copy.adoc
AsciiDoc
gpl-3.0
1,803
= zmq_msg_data(3) == NAME zmq_msg_data - retrieve pointer to message content == SYNOPSIS *void *zmq_msg_data (zmq_msg_t '*msg');* == DESCRIPTION The _zmq_msg_data()_ function shall return a pointer to the message content of the message object referenced by 'msg'. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. == RETURN VALUE Upon successful completion, _zmq_msg_data()_ shall return a pointer to the message content. == ERRORS No errors are defined. == SEE ALSO * xref:zmq_msg_size.adoc[zmq_msg_size] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_data.adoc
AsciiDoc
gpl-3.0
985
= zmq_msg_get(3) == NAME zmq_msg_get - get message property == SYNOPSIS *int zmq_msg_get (zmq_msg_t '*message', int 'property');* == DESCRIPTION The _zmq_msg_get()_ function shall return the value for the property specified by the 'property' argument for the message pointed to by the 'message' argument. The following properties can be retrieved with the _zmq_msg_get()_ function: *ZMQ_MORE*:: Indicates that there are more message frames to follow after the 'message'. *ZMQ_SRCFD*:: Returns the file descriptor of the socket the 'message' was read from. This allows application to retrieve the remote endpoint via 'getpeername(2)'. Be aware that the respective socket might be closed already, reused even. Currently only implemented for TCP sockets. *ZMQ_SHARED*:: Indicates that a message MAY share underlying storage with another copy of this message. == RETURN VALUE The _zmq_msg_get()_ function shall return the value for the property if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested _property_ is unknown. == EXAMPLE .Receiving a multi-frame message ---- zmq_msg_t frame; while (true) { // Create an empty 0MQ message to hold the message frame int rc = zmq_msg_init (&frame); assert (rc == 0); // Block until a message is available to be received from socket rc = zmq_msg_recv (socket, &frame, 0); assert (rc != -1); if (zmq_msg_get (&frame, ZMQ_MORE)) fprintf (stderr, "more\n"); else { fprintf (stderr, "end\n"); break; } zmq_msg_close (&frame); } ---- == SEE ALSO * xref:zmq_msg_set.adoc[zmq_msg_set] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_get.adoc
AsciiDoc
gpl-3.0
1,937
= zmq_msg_gets(3) == NAME zmq_msg_gets - get message metadata property == SYNOPSIS *const char *zmq_msg_gets (zmq_msg_t '*message', const char *'property');* == DESCRIPTION The _zmq_msg_gets()_ function shall return the string value for the metadata property specified by the 'property' argument for the message pointed to by the 'message' argument. Both the 'property' argument and the 'value' shall be NULL-terminated UTF8-encoded strings. Metadata is defined on a per-connection basis during the ZeroMQ connection handshake as specified in <rfc.zeromq.org/spec:37>. Applications can set metadata properties using xref:zmq_setsockopt.adoc[zmq_setsockopt] option ZMQ_METADATA. Application metadata properties must be prefixed with 'X-'. In addition to application metadata, the following ZMTP properties can be retrieved with the _zmq_msg_gets()_ function: Socket-Type Routing-Id Note: 'Identity' is a deprecated alias for 'Routing-Id'. Additionally, when available for the underlying transport, the *Peer-Address* property will return the IP address of the remote endpoint as returned by getnameinfo(2). The names of these properties are also defined in _zmq.h_ as _ZMQ_MSG_PROPERTY_SOCKET_TYPE_ _ZMQ_MSG_PROPERTY_ROUTING_ID_, and _ZMQ_MSG_PROPERTY_PEER_ADDRESS_. Currently, these definitions are only available as a DRAFT API. Other properties may be defined based on the underlying security mechanism, see ZAP authenticated connection sample below. == RETURN VALUE The _zmq_msg_gets()_ function shall return the string value for the property if successful. Otherwise it shall return NULL and set 'errno' to one of the values defined below. The caller shall not modify or free the returned value, which shall be owned by the message. The encoding of the property and value shall be UTF8. == ERRORS *EINVAL*:: The requested _property_ is unknown. == EXAMPLE .Getting the ZAP authenticated user id for a message: ---- zmq_msg_t msg; zmq_msg_init (&msg); rc = zmq_msg_recv (&msg, dealer, 0); assert (rc != -1); const char *user_id = zmq_msg_gets (&msg, ZMQ_MSG_PROPERTY_USER_ID); zmq_msg_close (&msg); ---- == SEE ALSO * xref:zmq.adoc[zmq] * xref:zmq_setsockopt.adoc[zmq_setsockopt] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_gets.adoc
AsciiDoc
gpl-3.0
2,369
= zmq_msg_init(3) == NAME zmq_msg_init - initialise empty 0MQ message == SYNOPSIS *int zmq_msg_init (zmq_msg_t '*msg');* == DESCRIPTION The _zmq_msg_init()_ function shall initialise the message object referenced by 'msg' to represent an empty message. This function is most useful when called before receiving a message with _zmq_msg_recv()_. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_, _zmq_msg_init_size()_ and _zmq_msg_init_buffer()_ are mutually exclusive. Never initialise the same 'zmq_msg_t' twice. == RETURN VALUE The _zmq_msg_init()_ function always returns zero. == ERRORS No errors are defined. == EXAMPLE .Receiving a message from a socket ---- zmq_msg_t msg; rc = zmq_msg_init (&msg); assert (rc == 0); int nbytes = zmq_msg_recv (socket, &msg, 0); assert (nbytes != -1); ---- == SEE ALSO * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq_msg_data.adoc[zmq_msg_data] * xref:zmq_msg_size.adoc[zmq_msg_size] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_init.adoc
AsciiDoc
gpl-3.0
1,394
= zmq_msg_init_buffer(3) == NAME zmq_msg_init_buffer - initialise 0MQ message with buffer copy == SYNOPSIS *int zmq_msg_init_buffer (zmq_msg_t '*msg', const void '*buf', size_t 'size');* == DESCRIPTION The _zmq_msg_init_buffer()_ function shall allocate any resources required to store a message 'size' bytes long and initialise the message object referenced by 'msg' to represent a copy of the buffer referenced by the 'buf' and 'size' arguments. The implementation shall choose whether to store message content on the stack (small messages) or on the heap (large messages). CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_, _zmq_msg_init_buffer()_ and _zmq_msg_init_buffer()_ are mutually exclusive. Never initialise the same 'zmq_msg_t' twice. == RETURN VALUE The _zmq_msg_init_buffer()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ENOMEM*:: Insufficient storage space is available. == SEE ALSO * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq_msg_data.adoc[zmq_msg_data] * xref:zmq_msg_size.adoc[zmq_msg_size] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_init_buffer.adoc
AsciiDoc
gpl-3.0
1,560
= zmq_msg_init_data(3) == NAME zmq_msg_init_data - initialise 0MQ message from a supplied buffer == SYNOPSIS *typedef void (zmq_free_fn) (void '*data', void '*hint');* *int zmq_msg_init_data (zmq_msg_t '*msg', void '*data', size_t 'size', zmq_free_fn '*ffn', void '*hint');* == DESCRIPTION The _zmq_msg_init_data()_ function shall initialise the message object referenced by 'msg' to represent the content referenced by the buffer located at address 'data', 'size' bytes long. No copy of 'data' shall be performed and 0MQ shall take ownership of the supplied buffer. If provided, the deallocation function 'ffn' shall be called once the data buffer is no longer required by 0MQ, with the 'data' and 'hint' arguments supplied to _zmq_msg_init_data()_. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. CAUTION: The deallocation function 'ffn' needs to be thread-safe, since it will be called from an arbitrary thread. CAUTION: If the deallocation function is not provided, the allocated memory will not be freed, and this may cause a memory leak. CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_, _zmq_msg_init_size()_ and _zmq_msg_init_buffer()_ are mutually exclusive. Never initialise the same 'zmq_msg_t' twice. == RETURN VALUE The _zmq_msg_init_data()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ENOMEM*:: Insufficient storage space is available. == EXAMPLE .Initialising a message from a supplied buffer ---- void my_free (void *data, void *hint) { free (data); } /* ... */ void *data = malloc (6); assert (data); memcpy (data, "ABCDEF", 6); zmq_msg_t msg; rc = zmq_msg_init_data (&msg, data, 6, my_free, NULL); assert (rc == 0); ---- == SEE ALSO * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq_msg_data.adoc[zmq_msg_data] * xref:zmq_msg_size.adoc[zmq_msg_size] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_init_data.adoc
AsciiDoc
gpl-3.0
2,289
= zmq_msg_init_size(3) == NAME zmq_msg_init_size - initialise 0MQ message of a specified size == SYNOPSIS *int zmq_msg_init_size (zmq_msg_t '*msg', size_t 'size');* == DESCRIPTION The _zmq_msg_init_size()_ function shall allocate any resources required to store a message 'size' bytes long and initialise the message object referenced by 'msg' to represent the newly allocated message. The implementation shall choose whether to store message content on the stack (small messages) or on the heap (large messages). For performance reasons _zmq_msg_init_size()_ shall not clear the message data. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. CAUTION: The functions _zmq_msg_init()_, _zmq_msg_init_data()_, _zmq_msg_init_size()_ and _zmq_msg_init_buffer()_ are mutually exclusive. Never initialise the same 'zmq_msg_t' twice. == RETURN VALUE The _zmq_msg_init_size()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ENOMEM*:: Insufficient storage space is available. == SEE ALSO * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq_msg_data.adoc[zmq_msg_data] * xref:zmq_msg_size.adoc[zmq_msg_size] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_init_size.adoc
AsciiDoc
gpl-3.0
1,578
= zmq_msg_more(3) == NAME zmq_msg_more - indicate if there are more message parts to receive == SYNOPSIS *int zmq_msg_more (zmq_msg_t '*message');* == DESCRIPTION The _zmq_msg_more()_ function indicates whether this is part of a multi-part message, and there are further parts to receive. This method can safely be called after _zmq_msg_close()_. This method is identical to _zmq_msg_get()_ with an argument of ZMQ_MORE. == RETURN VALUE The _zmq_msg_more()_ function shall return zero if this is the final part of a multi-part message, or the only part of a single-part message. It shall return 1 if there are further parts to receive. == EXAMPLE .Receiving a multi-part message ---- zmq_msg_t part; while (true) { // Create an empty 0MQ message to hold the message part int rc = zmq_msg_init (&part); assert (rc == 0); // Block until a message is available to be received from socket rc = zmq_msg_recv (socket, &part, 0); assert (rc != -1); if (zmq_msg_more (&part)) fprintf (stderr, "more\n"); else { fprintf (stderr, "end\n"); break; } zmq_msg_close (&part); } ---- == SEE ALSO * xref:zmq_msg_get.adoc[zmq_msg_get] * xref:zmq_msg_set.adoc[zmq_msg_set] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_more.adoc
AsciiDoc
gpl-3.0
1,492
= zmq_msg_move(3) == NAME zmq_msg_move - move content of a message to another message == SYNOPSIS *int zmq_msg_move (zmq_msg_t '*dest', zmq_msg_t '*src');* == DESCRIPTION The _zmq_msg_move()_ function shall move the content of the message object referenced by 'src' to the message object referenced by 'dest'. No actual copying of message content is performed, 'dest' is simply updated to reference the new content. 'src' becomes an empty message after calling _zmq_msg_move()_. The original content of 'dest', if any, shall be released. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. == RETURN VALUE The _zmq_msg_move()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EFAULT*:: Invalid message. == SEE ALSO * xref:zmq_msg_copy.adoc[zmq_msg_copy] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_move.adoc
AsciiDoc
gpl-3.0
1,318
= zmq_msg_recv(3) == NAME zmq_msg_recv - receive a message part from a socket == SYNOPSIS *int zmq_msg_recv (zmq_msg_t '*msg', void '*socket', int 'flags');* == DESCRIPTION The _zmq_msg_recv()_ function is identical to xref:zmq_recvmsg.adoc[zmq_recvmsg], which shall be deprecated in future versions. _zmq_msg_recv()_ is more consistent with other message manipulation functions. The _zmq_msg_recv()_ function shall receive a message part from the socket referenced by the 'socket' argument and store it in the message referenced by the 'msg' argument. Any content previously stored in 'msg' shall be properly deallocated. If there are no message parts available on the specified 'socket' the _zmq_msg_recv()_ function shall block until the request can be satisfied. The 'flags' argument is a combination of the flags defined below: *ZMQ_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If there are no messages available on the specified 'socket', the _zmq_msg_recv()_ function shall fail with 'errno' set to EAGAIN. Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. Each message part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that processes multi-part messages must use the _ZMQ_RCVMORE_ xref:zmq_getsockopt.adoc[zmq_getsockopt] option after calling _zmq_msg_recv()_ to determine if there are further parts to receive. == RETURN VALUE The _zmq_msg_recv()_ function shall return number of bytes in the message if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Either the timeout set via the socket-option ZMQ_RCVTIMEO (see xref:zmq_setsockopt.adoc[zmq_setsockopt]) has been reached (flag ZMQ_DONTWAIT not set) without being able to read a message from the socket or there are no messages available at the moment (flag ZMQ_DONTWAIT set) and the operation would block. *ENOTSUP*:: The _zmq_msg_recv()_ operation is not supported by this socket type. *EFSM*:: The _zmq_msg_recv()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before a message was available. *EFAULT*:: The message passed to the function was invalid. == EXAMPLE .Receiving a message from a socket ---- /* Create an empty 0MQ message */ zmq_msg_t msg; int rc = zmq_msg_init (&msg); assert (rc == 0); /* Block until a message is available to be received from socket */ rc = zmq_msg_recv (&msg, socket, 0); assert (rc != -1); /* Release message */ zmq_msg_close (&msg); ---- .Receiving a multi-part message ---- int more; size_t more_size = sizeof (more); do { /* Create an empty 0MQ message to hold the message part */ zmq_msg_t part; int rc = zmq_msg_init (&part); assert (rc == 0); /* Block until a message is available to be received from socket */ rc = zmq_msg_recv (&part, socket, 0); assert (rc != -1); /* Determine if more message parts are to follow */ rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size); assert (rc == 0); zmq_msg_close (&part); } while (more); ---- == SEE ALSO * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_send.adoc[zmq_send] * xref:zmq_msg_send.adoc[zmq_msg_send] * xref:zmq_getsockopt.adoc[zmq_getsockopt] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_recv.adoc
AsciiDoc
gpl-3.0
4,136
= zmq_msg_routing_id(3) == NAME zmq_msg_routing_id - return routing ID for message, if any == SYNOPSIS *uint32_t zmq_msg_routing_id (zmq_msg_t '*message');* == DESCRIPTION The _zmq_msg_routing_id()_ function returns the routing ID for the message, if any. The routing ID is set on all messages received from a 'ZMQ_SERVER' socket. To send a message to a 'ZMQ_SERVER' socket you must set the routing ID of a connected 'ZMQ_CLIENT' peer. Routing IDs are transient. == RETURN VALUE The _zmq_msg_routing_id()_ function shall return zero if there is no routing ID, otherwise it shall return an unsigned 32-bit integer greater than zero. == EXAMPLE .Receiving a client message and routing ID ---- void *ctx = zmq_ctx_new (); assert (ctx); void *server = zmq_socket (ctx, ZMQ_SERVER); assert (server); int rc = zmq_bind (server, "tcp://127.0.0.1:8080"); assert (rc == 0); zmq_msg_t message; rc = zmq_msg_init (&message); assert (rc == 0); // Receive a message from socket rc = zmq_msg_recv (server, &message, 0); assert (rc != -1); uint32_t routing_id = zmq_msg_routing_id (&message); assert (routing_id); ---- == SEE ALSO * xref:zmq_msg_set_routing_id.adoc[zmq_msg_set_routing_id] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_routing_id.adoc
AsciiDoc
gpl-3.0
1,349
= zmq_msg_send(3) == NAME zmq_msg_send - send a message part on a socket == SYNOPSIS *int zmq_msg_send (zmq_msg_t '*msg', void '*socket', int 'flags');* == DESCRIPTION The _zmq_msg_send()_ function is identical to xref:zmq_sendmsg.adoc[zmq_sendmsg], which shall be deprecated in future versions. _zmq_msg_send()_ is more consistent with other message manipulation functions. The _zmq_msg_send()_ function shall queue the message referenced by the 'msg' argument to be sent to the socket referenced by the 'socket' argument. The 'flags' argument is a combination of the flags defined below: *ZMQ_DONTWAIT*:: For socket types (DEALER, PUSH) that block (either with ZMQ_IMMEDIATE option set and no peer available, or all peers having full high-water mark), specifies that the operation should be performed in non-blocking mode. If the message cannot be queued on the 'socket', the _zmq_msg_send()_ function shall fail with 'errno' set to EAGAIN. *ZMQ_SNDMORE*:: Specifies that the message being sent is a multi-part message, and that further message parts are to follow. Refer to the section regarding multi-part messages below for a detailed description. The _zmq_msg_t_ structure passed to _zmq_msg_send()_ is nullified on a successful call. If you want to send the same message to multiple sockets you have to copy it (e.g. using _zmq_msg_copy()_). If the call fails, the _zmq_msg_t_ structure stays intact, and must be consumed by another call to _zmq_msg_send()_ on the same or another socket, or released using _zmq_msg_close()_ to avoid a memory leak. NOTE: A successful invocation of _zmq_msg_send()_ does not indicate that the message has been transmitted to the network, only that it has been queued on the 'socket' and 0MQ has assumed responsibility for the message. You do not need to call _zmq_msg_close()_ after a successful _zmq_msg_send()_. Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. Each message part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that sends multi-part messages must use the _ZMQ_SNDMORE_ flag when sending each message part except the final one. == RETURN VALUE The _zmq_msg_send()_ function shall return number of bytes in the message if successful (if number of bytes is higher than 'MAX_INT', the function will return 'MAX_INT'). Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Non-blocking mode was requested and the message cannot be sent at the moment. *ENOTSUP*:: The _zmq_msg_send()_ operation is not supported by this socket type. *EINVAL*:: The sender tried to send multipart data, which the socket type does not allow. *EFSM*:: The _zmq_msg_send()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *EFAULT*:: Invalid message. *EHOSTUNREACH*:: The message cannot be routed. == EXAMPLE .Filling in a message and sending it to a socket ---- /* Create a new message, allocating 6 bytes for message content */ zmq_msg_t msg; int rc = zmq_msg_init_size (&msg, 6); assert (rc == 0); /* Fill in message content with 'AAAAAA' */ memset (zmq_msg_data (&msg), 'A', 6); /* Send the message to the socket */ rc = zmq_msg_send (&msg, socket, 0); assert (rc == 6); ---- .Sending a multi-part message ---- /* Send a multi-part message consisting of three parts to socket */ rc = zmq_msg_send (&part1, socket, ZMQ_SNDMORE); rc = zmq_msg_send (&part2, socket, ZMQ_SNDMORE); /* Final part; no more parts to follow */ rc = zmq_msg_send (&part3, socket, 0); ---- == SEE ALSO * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_send.adoc[zmq_send] * xref:zmq_msg_recv.adoc[zmq_msg_recv] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_send.adoc
AsciiDoc
gpl-3.0
4,527
= zmq_msg_set(3) == NAME zmq_msg_set - set message property == SYNOPSIS *int zmq_msg_set (zmq_msg_t '*message', int 'property', int 'value');* == DESCRIPTION The _zmq_msg_set()_ function shall set the property specified by the 'property' argument to the value of the 'value' argument for the 0MQ message fragment pointed to by the 'message' argument. Currently the _zmq_msg_set()_ function does not support any property names. == RETURN VALUE The _zmq_msg_set()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested property _property_ is unknown. == SEE ALSO * xref:zmq_msg_get.adoc[zmq_msg_get] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_set.adoc
AsciiDoc
gpl-3.0
897
= zmq_msg_set_routing_id(3) == NAME zmq_msg_set_routing_id - set routing ID property on message == SYNOPSIS *int zmq_msg_set_routing_id (zmq_msg_t '*message', uint32_t 'routing_id');* == DESCRIPTION The _zmq_msg_set_routing_id()_ function sets the 'routing_id' specified, on the the message pointed to by the 'message' argument. The 'routing_id' must be greater than zero. To get a valid routing ID, you must receive a message from a 'ZMQ_SERVER' socket, and use the libzmq:zmq_msg_routing_id method. Routing IDs are transient. == RETURN VALUE The _zmq_msg_set_routing_id()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The provided 'routing_id' is zero. == SEE ALSO * xref:zmq_msg_routing_id.adoc[zmq_msg_routing_id] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_set_routing_id.adoc
AsciiDoc
gpl-3.0
1,011
= zmq_msg_size(3) == NAME zmq_msg_size - retrieve message content size in bytes == SYNOPSIS *size_t zmq_msg_size (zmq_msg_t '*msg');* == DESCRIPTION The _zmq_msg_size()_ function shall return the size in bytes of the content of the message object referenced by 'msg'. CAUTION: Never access 'zmq_msg_t' members directly, instead always use the _zmq_msg_ family of functions. == RETURN VALUE Upon successful completion, _zmq_msg_size()_ shall return the size of the message content in bytes. == ERRORS No errors are defined. == SEE ALSO * xref:zmq_msg_data.adoc[zmq_msg_data] * xref:zmq_msg_init.adoc[zmq_msg_init] * xref:zmq_msg_init_size.adoc[zmq_msg_init_size] * xref:zmq_msg_init_buffer.adoc[zmq_msg_init_buffer] * xref:zmq_msg_init_data.adoc[zmq_msg_init_data] * xref:zmq_msg_close.adoc[zmq_msg_close] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_msg_size.adoc
AsciiDoc
gpl-3.0
997
= zmq_null(7) == NAME zmq_null - no security or confidentiality == SYNOPSIS The NULL mechanism is defined by the ZMTP 3.0 specification: <http://rfc.zeromq.org/spec:23>. This is the default security mechanism for ZeroMQ sockets. == SEE ALSO * xref:zmq_plain.adoc[zmq_plain] * xref:zmq_curve.adoc[zmq_curve] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_null.adoc
AsciiDoc
gpl-3.0
493
= zmq_pgm(7) == NAME zmq_pgm - 0MQ reliable multicast transport using PGM == SYNOPSIS PGM (Pragmatic General Multicast) is a protocol for reliable multicast transport of data over IP networks. == DESCRIPTION 0MQ implements two variants of PGM, the standard protocol where PGM datagrams are layered directly on top of IP datagrams as defined by RFC 3208 (the 'pgm' transport) and "Encapsulated PGM" or EPGM where PGM datagrams are encapsulated inside UDP datagrams (the 'epgm' transport). The 'pgm' and 'epgm' transports can only be used with the 'ZMQ_PUB' and 'ZMQ_SUB' socket types. Further, PGM sockets are rate limited by default. For details, refer to the 'ZMQ_RATE', and 'ZMQ_RECOVERY_IVL' options documented in xref:zmq_setsockopt.adoc[zmq_setsockopt] CAUTION: The 'pgm' transport implementation requires access to raw IP sockets. Additional privileges may be required on some operating systems for this operation. Applications not requiring direct interoperability with other PGM implementations are encouraged to use the 'epgm' transport instead which does not require any special privileges. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the PGM transport, the transport is `pgm`, and for the EPGM protocol the transport is `epgm`. The meaning of the 'address' part is defined below. Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a socket to a peer address using _zmq_connect()_ with the 'pgm' or 'epgm' transport, the 'endpoint' shall be interpreted as an 'interface' followed by a semicolon, followed by a 'multicast address', followed by a colon and a port number. An 'interface' may be specified by either of the following: * The interface name as defined by the operating system. * The primary IPv4 address assigned to the interface, in its numeric representation. NOTE: Interface names are not standardised in any way and should be assumed to be arbitrary and platform dependent. On Win32 platforms no short interface names exist, thus only the primary IPv4 address may be used to specify an 'interface'. The 'interface' part can be omitted, in that case the default one will be selected. A 'multicast address' is specified by an IPv4 multicast address in its numeric representation. == WIRE FORMAT Consecutive PGM datagrams are interpreted by 0MQ as a single continuous stream of data where 0MQ messages are not necessarily aligned with PGM datagram boundaries and a single 0MQ message may span several PGM datagrams. This stream of data consists of 0MQ messages encapsulated in 'frames' as described in xref:zmq_tcp.adoc[zmq_tcp] PGM datagram payload ~~~~~~~~~~~~~~~~~~~~ The following ABNF grammar represents the payload of a single PGM datagram as used by 0MQ: .... datagram = (offset data) offset = 2OCTET data = *OCTET .... In order for late joining consumers to be able to identify message boundaries, each PGM datagram payload starts with a 16-bit unsigned integer in network byte order specifying either the offset of the first message 'frame' in the datagram or containing the value `0xFFFF` if the datagram contains solely an intermediate part of a larger message. Note that offset specifies where the first message begins rather than the first message part. Thus, if there are trailing message parts at the beginning of the packet the offset ignores them and points to first initial message part in the packet. The following diagram illustrates the layout of a single PGM datagram payload: .... +------------------+----------------------+ | offset (16 bits) | data | +------------------+----------------------+ .... The following diagram further illustrates how three example 0MQ frames are laid out in consecutive PGM datagram payloads: .... First datagram payload +--------------+-------------+---------------------+ | Frame offset | Frame 1 | Frame 2, part 1 | | 0x0000 | (Message 1) | (Message 2, part 1) | +--------------+-------------+---------------------+ Second datagram payload +--------------+---------------------+ | Frame offset | Frame 2, part 2 | | 0xFFFF | (Message 2, part 2) | +--------------+---------------------+ Third datagram payload +--------------+----------------------------+-------------+ | Frame offset | Frame 2, final 8 bytes | Frame 3 | | 0x0008 | (Message 2, final 8 bytes) | (Message 3) | +--------------+----------------------------+-------------+ .... == CONFIGURATION The PGM is protocol is capable of multicasting data at high rates (500Mbps+) with large messages (1MB+), however it requires setting the relevant ZMQ socket options that are documented in xref:zmq_setsockopt.adoc[zmq_setsockopt]: * The 'ZMQ_RATE' should be set sufficiently high, e.g. 1Gbps * The 'ZMQ_RCVBUF' should be increased on the subscriber, e.g. 4MB * The 'ZMQ_SNDBUF' should be increased on the publisher, e.g. 4MB It's important to note that the 'ZMQ_RCVBUF' and 'ZMQ_SNDBUF' options are limited by the underlying host OS tx/rx buffer size limit. On linux, these can be increased for the current session with the following commands: .... # set tx/rx buffers to 4MB (default can also be read as the initial buffer size) sudo sysctl -w net.core.rmem_max=4194304 sudo sysctl -w net.core.wmem_max=4194304 sudo sysctl -w net.core.rmem_default=4194304 sudo sysctl -w net.core.wmem_default=4194304 .... == EXAMPLE .Connecting a socket ---- // Connecting to the multicast address 239.192.1.1, port 5555, // using the first Ethernet network interface on Linux // and the Encapsulated PGM protocol rc = zmq_connect(socket, "epgm://eth0;239.192.1.1:5555"); assert (rc == 0); // Connecting to the multicast address 239.192.1.1, port 5555, // using the network interface with the address 192.168.1.1 // and the standard PGM protocol rc = zmq_connect(socket, "pgm://192.168.1.1;239.192.1.1:5555"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_tcp.adoc[zmq_tcp] * xref:zmq_ipc.adoc[zmq_ipc] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_pgm.adoc
AsciiDoc
gpl-3.0
6,491
= zmq_plain(7) == NAME zmq_plain - clear-text authentication == SYNOPSIS The PLAIN mechanism defines a simple username/password mechanism that lets a server authenticate a client. PLAIN makes no attempt at security or confidentiality. It is intended for use on internal networks where security requirements are low. The PLAIN mechanism is defined by this document: <http://rfc.zeromq.org/spec:24>. == USAGE To use PLAIN, the server shall set the ZMQ_PLAIN_SERVER option, and the client shall set the ZMQ_PLAIN_USERNAME and ZMQ_PLAIN_PASSWORD socket options. Which peer binds, and which connects, is not relevant. == SEE ALSO * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_null.adoc[zmq_null] * xref:zmq_curve.adoc[zmq_curve] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_plain.adoc
AsciiDoc
gpl-3.0
925
= zmq_poll(3) == NAME zmq_poll - input/output multiplexing == SYNOPSIS *int zmq_poll (zmq_pollitem_t '*items', int 'nitems', long 'timeout');* == DESCRIPTION The _zmq_poll()_ function provides a mechanism for applications to multiplex input/output events in a level-triggered fashion over a set of sockets. Each member of the array pointed to by the 'items' argument is a *zmq_pollitem_t* structure. The 'nitems' argument specifies the number of items in the 'items' array. The *zmq_pollitem_t* structure is defined as follows: ["literal", subs="quotes"] typedef struct { void '*socket'; zmq_fd_t 'fd'; short 'events'; short 'revents'; } zmq_pollitem_t; For each *zmq_pollitem_t* item, _zmq_poll()_ shall examine either the 0MQ socket referenced by 'socket' *or* the standard socket specified by the file descriptor 'fd', for the event(s) specified in 'events'. If both 'socket' and 'fd' are set in a single *zmq_pollitem_t*, the 0MQ socket referenced by 'socket' shall take precedence and the value of 'fd' shall be ignored. For each *zmq_pollitem_t* item, _zmq_poll()_ shall first clear the 'revents' member, and then indicate any requested events that have occurred by setting the bit corresponding to the event condition in the 'revents' member. If none of the requested events have occurred on any *zmq_pollitem_t* item, _zmq_poll()_ shall wait 'timeout' milliseconds for an event to occur on any of the requested items. If the value of 'timeout' is `0`, _zmq_poll()_ shall return immediately. If the value of 'timeout' is `-1`, _zmq_poll()_ shall block indefinitely until a requested event has occurred on at least one *zmq_pollitem_t*. The 'events' and 'revents' members of *zmq_pollitem_t* are bit masks constructed by OR'ing a combination of the following event flags: *ZMQ_POLLIN*:: For 0MQ sockets, at least one message may be received from the 'socket' without blocking. For standard sockets this is equivalent to the 'POLLIN' flag of the _poll()_ system call and generally means that at least one byte of data may be read from 'fd' without blocking. *ZMQ_POLLOUT*:: For 0MQ sockets, at least one message may be sent to the 'socket' without blocking. For standard sockets this is equivalent to the 'POLLOUT' flag of the _poll()_ system call and generally means that at least one byte of data may be written to 'fd' without blocking. *ZMQ_POLLERR*:: For standard sockets, this flag is passed through _zmq_poll()_ to the underlying _poll()_ system call and generally means that some sort of error condition is present on the socket specified by 'fd'. For 0MQ sockets this flag has no effect if set in 'events', and shall never be returned in 'revents' by _zmq_poll()_. *ZMQ_POLLPRI*:: For 0MQ sockets this flags is of no use. For standard sockets this means there is urgent data to read. Refer to the POLLPRI flag for more information. For file descriptor, refer to your use case: as an example, GPIO interrupts are signaled through a POLLPRI event. This flag has no effect on Windows. NOTE: The _zmq_poll()_ function may be implemented or emulated using operating system interfaces other than _poll()_, and as such may be subject to the limits of those interfaces in ways not defined in this documentation. == THREAD SAFETY The *zmq_pollitem_t* array must only be used by the thread which will/is calling _zmq_poll_. If a socket is contained in multiple *zmq_pollitem_t* arrays, each owned by a different thread, the socket itself needs to be thread-safe (Server, Client, ...). Otherwise, behaviour is undefined. == RETURN VALUE Upon successful completion, the _zmq_poll()_ function shall return the number of *zmq_pollitem_t* structures with events signaled in 'revents' or `0` if no events have been signaled. Upon failure, _zmq_poll()_ shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ETERM*:: At least one of the members of the 'items' array refers to a 'socket' whose associated 0MQ 'context' was terminated. *EFAULT*:: The provided 'items' was not valid (NULL). *EINTR*:: The operation was interrupted by delivery of a signal before any events were available. == EXAMPLE .Polling indefinitely for input events on both a 0MQ socket and a standard socket. ---- zmq_pollitem_t items [2]; /* First item refers to 0MQ socket 'socket' */ items[0].socket = socket; items[0].events = ZMQ_POLLIN; /* Second item refers to standard socket 'fd' */ items[1].socket = NULL; items[1].fd = fd; items[1].events = ZMQ_POLLIN; /* Poll for events indefinitely */ int rc = zmq_poll (items, 2, -1); assert (rc >= 0); /* Returned events will be stored in items[].revents */ ---- == SEE ALSO * xref:zmq_socket.adoc[zmq_socket] * xref:zmq_send.adoc[zmq_send] * xref:zmq_recv.adoc[zmq_recv] * xref:zmq.adoc[zmq] Your operating system documentation for the _poll()_ system call. == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_poll.adoc
AsciiDoc
gpl-3.0
5,005
= zmq_poller(3) == NAME zmq_poller - input/output multiplexing == SYNOPSIS *void *zmq_poller_new (void);* *int zmq_poller_destroy (void '****poller_p');* *int zmq_poller_size (void '*poller');* *int zmq_poller_add (void '*poller', void '*socket', void '*user_data', short 'events');* *int zmq_poller_modify (void '*poller', void '*socket', short 'events');* *int zmq_poller_remove (void '*poller', void '*socket');* *int zmq_poller_add_fd (void '*poller', int 'fd', void '*user_data', short 'events');* *int zmq_poller_modify_fd (void '*poller', int 'fd', short 'events');* *int zmq_poller_remove_fd (void '*poller', int 'fd');* *int zmq_poller_wait (void '*poller', zmq_poller_event_t '*event', long 'timeout');* *int zmq_poller_wait_all (void '*poller', zmq_poller_event_t '*events', int 'n_events', long 'timeout');* *int zmq_poller_fd (void '*poller', zmq_fd_t '*fd');* == DESCRIPTION The _zmq_poller_*_ functions provide a mechanism for applications to multiplex input/output events in a level-triggered fashion over a set of sockets. _zmq_poller_new_ and _zmq_poller_destroy_ manage the lifetime of a poller instance. _zmq_poller_new_ creates and returns a new poller instance, while _zmq_poller_destroy_ destroys it. A pointer to a valid poller must be passed as the _poller_p_ argument of _zmq_poller_destroy_. In particular, _zmq_poller_destroy_ may not be called multiple times for the same poller instance. _zmq_poller_destroy_ sets the passed pointer to NULL in case of a successful execution. _zmq_poller_destroy_ implicitly unregisters all registered sockets and file descriptors. _zmq_poller_size_ queries the number of sockets or file descriptors registered with a poller. The initial size of a poller is 0, a successful add operation increases the size by 1 and a successful remove operation decreases the size by 1. The size is unaffected by the events specified. _zmq_poller_add_, _zmq_poller_modify_ and _zmq_poller_remove_ manage the 0MQ sockets registered with a poller. _zmq_poller_add_ registers a new _socket_ with a given _poller_. Both _poller_ and _socket_ must point to valid 0MQ objects. The _events_ parameter specifies which event types the client wants to subscribe to. It is legal to specify no events (i.e. 0), and activate them later with _zmq_poller_modify_. In addition, _user_data_ may be specified, which is not used by the poller, but passed back to the caller when an event was signalled in a call to _zmq_poller_wait_ or _zmq_poller_wait_all_. _user_data_ may be NULL. If it is not NULL, it must be a valid pointer. Otherwise, behaviour is undefined. You must only add a socket to a single poller instance once (unless _zmq_poller_remove_ has been called for that socket before). You may add a socket to multiple poller instances, if the socket itself is explicitly thread-safe (Server, Client, ...). If the socket is not, you may invoke undefined behavior. _zmq_poller_modify_ modifies the subscribed events for a socket. It is legal to specify no events (i.e. 0) to disable events temporarily, and reactivate them later with another call to _zmq_poller_modify_. _zmq_poller_remove_ removes a socket registration completely. _zmq_poller_remove_ must be called before a socket is closed with _zmq_close_. Note that it is not necessary to call _zmq_poller_remove_ for any socket before calling _zmq_poller_destroy_. Also note that calling _zmq_poller_remove_ is not equivalent to calling _zmq_poller_modify_ with no events. _zmq_poller_modify_ does not free resources associated with the socket registration, and requires that the _socket_ remains valid. _zmq_poller_add_fd_, _zmq_poller_modify_fd_ and _zmq_poller_remove_fd_ are analogous to the previous functions but manage regular file descriptors registered with a poller. On Windows, these functions can only be used with WinSock sockets. In the following, 0MQ sockets added with _zmq_poller_add_ and file descriptors added with _zmq_poller_add_fd_ are referred to as 'registered objects'. The *zmq_poller_event_t* structure is defined as follows: ["literal", subs="quotes"] typedef struct { void *socket; zmq_fd_t fd; void *user_data; short events; } zmq_poller_event_t; For each registered object, _zmq_poller_wait_all()_ shall examine the registered objects for the event(s) currently registered. If none of the registered events have occurred, _zmq_poller_wait_all_ shall wait 'timeout' milliseconds for an event to occur on any of the registered objects. If the value of 'timeout' is `0`, _zmq_poller_wait_all_ shall return immediately. If the value of 'timeout' is `-1`, _zmq_poller_wait_all_ shall block indefinitely until one event has occurred on any of the registered objects. The 'events' argument _zmq_poller_wait_all_ must be a pointer to an array of at least 'n_events' elements. Behaviour is undefined if 'events' does not point to an array of at least 'n_events' elements. _zmq_poller_wait_all_ returns at most 'n_events' events. If more than 'n_events' events were signalled, only an unspecified subset of the signalled events is returned through 'events'. A caller is advised to ensure that 'n_events' is equal to the number of registered objects. Otherwise, a livelock situation may result: If more than 'n_events' registered objects have an active event on each call to _zmq_poller_wait_all_, it might happen that the same subset of registered objects is always returned, and the caller never notices the events on the others. The number of objects registered can be queried with _zmq_poller_size_. _zmq_poller_wait_all_ returns the number of valid elements. The valid elements are placed in positions '0' to 'n_events - 1' in the 'events' array. All members of a valid element are set to valid values by _zmq_poller_wait_all_. For socket events 'socket' is non-null and 'fd' is an operating system specific value for an invalid socket (-1 or INVALID_SOCKET). For fd events 'socket' is NULL and 'fd' is a valid file descriptor. The client does therefore not need to initialize the contents of the events array before a call to _zmq_poller_wait_all_. It is unspecified whether the the remaining elements of 'events' are written to by _zmq_poller_wait_all_. _zmq_poller_fd_ queries the file descriptor associated with the zmq_poller, and stores it in the address pointer to by 'fd'. The zmq_poller is only guaranteed to have a file descriptor if at least one thread-safe socket is currently registered. Note that closing a socket that is registered in a poller leads to undefined behavior. The socket must be unregistered first. == EVENT TYPES The 'events' parameter of _zmq_poller_add_ and _zmq_poller_modify_, and the 'events' member of the zmq_poller_event_t structure are bit masks constructed by OR'ing a combination of the following event flags: *ZMQ_POLLIN*:: For 0MQ sockets, at least one message may be received from the 'socket' without blocking. For standard sockets this is equivalent to the 'POLLIN' flag of the _poll()_ system call and generally means that at least one byte of data may be read from 'fd' without blocking. *ZMQ_POLLOUT*:: For 0MQ sockets, at least one message may be sent to the 'socket' without blocking. For standard sockets this is equivalent to the 'POLLOUT' flag of the _poll()_ system call and generally means that at least one byte of data may be written to 'fd' without blocking. *ZMQ_POLLERR*:: For 0MQ sockets this flag has no effect on the _zmq_poller_add_ and _zmq_poller_modify_ functions, and is never set in the 'events' member of the zmq_poller_event_t structure. For standard sockets, this flag is passed through _zmq_poller_wait_all_ to the underlying _poll()_ system call and generally means that some sort of error condition is present on the socket specified by 'fd'. *ZMQ_POLLPRI*:: For 0MQ sockets this flag has no effect on the _zmq_poller_add_ and _zmq_poller_modify_ functions, and is never set in the 'events' member of the zmq_poller_event_t structure. For standard sockets this means there is urgent data to read. Refer to the POLLPRI flag for more information. For a file descriptor, refer to your OS documentation: as an example, GPIO interrupts are signaled through a POLLPRI event. This flag has no effect on Windows. NOTE: The _zmq_poller_*_ functions may be implemented or emulated using operating system interfaces other than _poll()_, and as such may be subject to the limits of those interfaces in ways not defined in this documentation. == THREAD SAFETY Like most other 0MQ objects, a poller is not thread-safe. All operations must be called from the same thread. Otherwise, behaviour is undefined. In addition to that, if you want to add a socket to multiple existing poller instances, the socket itself needs to be thread-safe (Server, Client, ...). Otherwise, behaviour is undefined. == RETURN VALUE _zmq_poller_new_ returns a valid pointer to a poller, or NULL in case of a failure. All functions that return an int, return -1 in case of a failure. In that case, zmq_errno() can be used to query the type of the error as described below. _zmq_poller_wait_all_ returns the number of events signalled and returned in the events array. It never returns 0. All other functions return 0 in case of a successful execution. == ERRORS On _zmq_poller_new_: *ENOMEM*:: A new poller could not be allocated successfully. On _zmq_poller_destroy_: *EFAULT*:: _poller_p_ did not point to a valid poller. Note that passing an invalid pointer (e.g. pointer to deallocated memory) may cause undefined behaviour (e.g. an access violation). On _zmq_poller_size_: *EFAULT*:: _poller_ did not point to a valid poller. Note that passing an invalid pointer (e.g. pointer to deallocated memory) may cause undefined behaviour (e.g. an access violation). On _zmq_poller_add_, _zmq_poller_modify_ and _zmq_poller_remove_: *EFAULT*:: _poller_ did not point to a valid poller. Note that passing an invalid pointer (e.g. pointer to deallocated memory) may cause undefined behaviour (e.g. an access violation). *ENOTSOCK*:: _socket_ did not point to a valid socket. Note that passing an invalid pointer (e.g. pointer to deallocated memory) may cause undefined behaviour (e.g. an access violation). On _zmq_poller_add_: *EMFILE*:: TODO On _zmq_poller_add_ or _zmq_poller_add_fd_: *ENOMEM*:: Necessary resources could not be allocated. *EINVAL*:: _socket_ resp. _fd_ was already registered with the poller. On _zmq_poller_modify_, _zmq_poller_modify_fd_, _zmq_poller_remove_ or _zmq_poller_remove_fd_: *EINVAL*:: _socket_ resp. _fd_ was not registered with the poller. On _zmq_poller_add_fd_, _zmq_poller_modify_fd_ and _zmq_poller_remove_fd_: *EBADF*:: The _fd_ specified was the retired fd. On _zmq_poller_wait_ and _zmq_poller_wait_all_: *ENOMEM*:: Necessary resources could not be allocated. *ETERM*:: At least one of the registered objects is a 'socket' whose associated 0MQ 'context' was terminated. *EFAULT*:: The provided 'events' was NULL, or 'poller' did not point to a valid poller, or there are no registered objects or all event subscriptions are disabled and 'timeout' was negative. *EINTR*:: The operation was interrupted by delivery of a signal before any events were available. *EAGAIN*:: No registered event was signalled before the timeout was reached. On _zmq_poller_fd_: *EINVAL*:: The poller has no associated file descriptor. *EFAULT*:: The provided 'poller' did not point to a valid poller. == EXAMPLE .Polling indefinitely for input events on both a 0MQ socket and a standard socket. ---- void *poller = zmq_poller_new (); /* First item refers to 0MQ socket 'socket' */ zmq_poller_add (poller, socket, NULL, ZMQ_POLLIN); /* Second item refers to standard socket 'fd' */ zmq_poller_add_fd (poller, fd, NULL, ZMQ_POLLIN); zmq_poller_event_t events [2]; /* Poll for events indefinitely */ int rc = zmq_poller_wait_all (poller, events, 2, -1); assert (rc >= 0); /* Returned events will be stored in 'events' */ for (int i = 0; i < 2; ++i) { if (events[i].socket == socket && events[i].events & ZMQ_POLLIN) { // ... } else if (events[i].fd == fd && events[i].events & ZMQ_POLLIN)) { // ... } } zmq_poller_destroy (&poller); ---- == SEE ALSO * xref:zmq_socket.adoc[zmq_socket] * xref:zmq_send.adoc[zmq_send] * xref:zmq_recv.adoc[zmq_recv] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_poller.adoc
AsciiDoc
gpl-3.0
12,658
= zmq_poll(3) == NAME zmq_ppoll - input/output multiplexing with signal mask == SYNOPSIS *int zmq_ppoll (zmq_pollitem_t '*items', int 'nitems', long 'timeout', const sigset_t '*sigmask');* == DESCRIPTION The relationship between _zmq_poll()_ and _zmq_ppoll()_ is analogous to the relationship between poll(2) and ppoll(2) and between select(2) and pselect(2): _zmq_ppoll()_ allows an application to safely wait until either a file descriptor becomes ready or until a signal is caught. When using _zmq_ppoll()_ with 'sigmask' set to NULL, its behavior is identical to that of _zmq_poll()_. See xref:zmq_poll.adoc[zmq_poll] for more on this. To make full use of _zmq_ppoll()_, a non-NULL pointer to a signal mask must be constructed and passed to 'sigmask'. See sigprocmask(2) for more details. When this is done, inside the actual _ppoll()_ (or _pselect()_, see note below) system call, an atomic operation consisting of three steps is performed: 1. The current signal mask is replaced by the one pointed to by 'sigmask'. 2. The actual _poll()_ call is done. 3. The original signal mask is restored. Because these operations are done atomically, there is no opportunity for race conditions in between the calls changing the signal mask and the poll/select system call. This means that only during this (atomic) call, we can unblock certain signals, so that they can be handled *at that time only*, not outside of the call. This means that effectively, we extend our poller into a function that not only watches sockets for changes, but also watches the "POSIX signal socket" for incoming signals. At other times, these signals will be blocked, and we will not have to deal with interruptions in system calls at these other times. NOTE: The _zmq_ppoll()_ function may be implemented or emulated using operating system interfaces other than _ppoll()_, and as such may be subject to the limits of those interfaces in ways not defined in this documentation. NOTE: There is no _ppoll_ or _pselect_ on Windows, so _zmq_ppoll()_ is not supported in Windows builds. It is still callable, but its 'sigmask' has void pointer type (because 'sigset_t' is also not available on Windows) and _zmq_ppoll()_ will return with an error (see error section below). == THREAD SAFETY The *zmq_pollitem_t* array must only be used by the thread which will/is calling _zmq_ppoll_. If a socket is contained in multiple *zmq_pollitem_t* arrays, each owned by a different thread, the socket itself needs to be thead-safe (Server, Client, ...). Otherwise, behaviour is undefined. == RETURN VALUE Upon successful completion, the _zmq_ppoll()_ function shall return the number of *zmq_pollitem_t* structures with events signaled in 'revents' or `0` if no events have been signaled. Upon failure, _zmq_ppoll()_ shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *ETERM*:: At least one of the members of the 'items' array refers to a 'socket' whose associated 0MQ 'context' was terminated. *EFAULT*:: The provided 'items' was not valid (NULL). *EINTR*:: The operation was interrupted by delivery of a signal before any events were available. *EINTR*:: The operation was interrupted by delivery of a signal before any events were available. *ENOTSUP*:: _zmq_ppoll()_ was not activated in this build. == EXAMPLE .Polling indefinitely for input events on both a 0MQ socket and a standard socket. See the _example section_ of xref:zmq_poll.adoc[zmq_poll] One only needs to replace the _zmq_poll_ call with _zmq_ppoll_ and add a _NULL_ argument for the 'sigmask' parameter. .Handle SIGTERM during _zmq_ppoll_ (and block it otherwise). ---- // simple global signal handler for SIGTERM static bool sigterm_received = false; void handle_sigterm (int signum) { sigterm_received = true; } // set up signal mask and install handler for SIGTERM sigset_t sigmask, sigmask_without_sigterm; sigemptyset(&sigmask); sigaddset(&sigmask, SIGTERM); sigprocmask(SIG_BLOCK, &sigmask, &sigmask_without_sigterm); struct sigaction sa; memset(&sa, '\0', sizeof(sa)); sa.sa_handler = handle_sigterm; // poll zmq_pollitem_t items [1]; // Just one item, which refers to 0MQ socket 'socket' */ items[0].socket = socket; items[0].events = ZMQ_POLLIN; // Poll for events indefinitely, but also exit on SIGTERM int rc = zmq_poll (items, 2, -1, &sigmask_without_sigterm); if (rc < 0 && errno == EINTR && sigterm_received) { // do your SIGTERM business } else { // do your non-SIGTERM error handling } ---- == SEE ALSO * xref:zmq_poll.adoc[zmq_poll] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq_send.adoc[zmq_send] * xref:zmq_recv.adoc[zmq_recv] * xref:zmq.adoc[zmq] Your operating system documentation for the _poll()_ system call. == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_ppoll.adoc
AsciiDoc
gpl-3.0
4,891
= zmq_proxy(3) == NAME zmq_proxy - start built-in 0MQ proxy == SYNOPSIS *int zmq_proxy (void '*frontend', void '*backend', void '*capture');* == DESCRIPTION The _zmq_proxy()_ function starts the built-in 0MQ proxy in the current application thread. The proxy connects a frontend socket to a backend socket. Conceptually, data flows from frontend to backend. Depending on the socket types, replies may flow in the opposite direction. The direction is conceptual only; the proxy is fully symmetric and there is no technical difference between frontend and backend. Before calling _zmq_proxy()_ you must set any socket options, and connect or bind both frontend and backend sockets. The two conventional proxy models are: _zmq_proxy()_ runs in the current thread and returns only if/when the current context is closed. If the capture socket is not NULL, the proxy shall send all messages, received on both frontend and backend, to the capture socket. The capture socket should be a 'ZMQ_PUB', 'ZMQ_DEALER', 'ZMQ_PUSH', or 'ZMQ_PAIR' socket. Refer to xref:zmq_socket.adoc[zmq_socket] for a description of the available socket types. == EXAMPLE USAGE Shared Queue ~~~~~~~~~~~~ When the frontend is a ZMQ_ROUTER socket, and the backend is a ZMQ_DEALER socket, the proxy shall act as a shared queue that collects requests from a set of clients, and distributes these fairly among a set of services. Requests shall be fair-queued from frontend connections and distributed evenly across backend connections. Replies shall automatically return to the client that made the original request. Forwarder ~~~~~~~~~ When the frontend is a ZMQ_XSUB socket, and the backend is a ZMQ_XPUB socket, the proxy shall act as a message forwarder that collects messages from a set of publishers and forwards these to a set of subscribers. This may be used to bridge networks transports, e.g. read on tcp:// and forward on pgm://. Streamer ~~~~~~~~ When the frontend is a ZMQ_PULL socket, and the backend is a ZMQ_PUSH socket, the proxy shall collect tasks from a set of clients and forwards these to a set of workers using the pipeline pattern. == RETURN VALUE The _zmq_proxy()_ function always returns `-1` and 'errno' set to *ETERM* or *EINTR* (the 0MQ 'context' associated with either of the specified sockets was terminated) or *EFAULT* (the provided 'frontend' or 'backend' was invalid). == EXAMPLE .Creating a shared queue proxy ---- // Create frontend and backend sockets void *frontend = zmq_socket (context, ZMQ_ROUTER); assert (frontend); void *backend = zmq_socket (context, ZMQ_DEALER); assert (backend); // Bind both sockets to TCP ports assert (zmq_bind (frontend, "tcp://*:5555") == 0); assert (zmq_bind (backend, "tcp://*:5556") == 0); // Start the queue proxy, which runs until ETERM zmq_proxy (frontend, backend, NULL); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_proxy.adoc
AsciiDoc
gpl-3.0
3,136
= zmq_proxy_steerable(3) == NAME zmq_proxy_steerable - built-in 0MQ proxy with control flow == SYNOPSIS *int zmq_proxy_steerable (const void '*frontend', const void '*backend', const void '*capture', const void '*control');* == DESCRIPTION The _zmq_proxy_steerable()_ function is a variant of the _zmq_proxy()_ function. It accepts a fourth _control_ socket. When the _control_ socket is _NULL_ the two functions operate identically. When a _control_ socket of type _REP_ or _PAIR_ is provided to the proxy function the application may send commands to the proxy. The following commands are supported. _PAUSE_:: The proxy will cease transferring messages between its endpoints. _REP_ control socket will reply with an empty message. No response otherwise. _RESUME_:: The proxy will resume transferring messages between its endpoints. _REP_ control socket will reply with an empty message. No response otherwise. _TERMINATE_:: The proxy function will exit with a return value of 0. _REP_ control socket will reply with an empty message. No response otherwise. _STATISTICS_:: The proxy state will remain unchanged and reply with a set of simple summary values of the messages that have been sent through the proxy as described next. Control socket must support sending. There are eight statistics values, each of size _uint64_t_ in the multi-part message reply to the _STATISTICS_ command. These are: - number of messages received by the frontend socket - number of bytes received by the frontend socket - number of messages sent by the frontend socket - number of bytes sent by the frontend socket - number of messages received by the backend socket - number of bytes received by the backend socket - number of messages sent by the backend socket - number of bytes sent by the backend socket Message totals count each part in a multipart message individually. == RETURN VALUE The _zmq_proxy_steerable()_ function returns 0 if TERMINATE is received on its control socket. Otherwise, it returns -1 and errno set to ETERM or EINTR (the 0MQ context associated with either of the specified sockets was terminated) or EFAULT (the provided frontend or backend was invalid). == EXAMPLE .Create a function to run the proxy ---- // Create the frontend and backend sockets to be proxied void *frontend = zmq_socket (context, ZMQ_ROUTER); void *backend = zmq_socket (context, ZMQ_DEALER); // Create the proxy control socket void *control = zmq_socket (context, ZMQ_REP); // Bind the sockets. zmq_bind (frontend, "tcp://*:5555"); zmq_bind (backend, "tcp://*:5556"); zmq_bind (control, "tcp://*:5557"); zmq_proxy_steerable(frontend, backend, NULL, control); ---- .Code in another thread/process to steer the proxy. ---- void *control = zmq_socket (context, ZMQ_REQ); zmq_connect (control, "tcp://*:5557"); zmq_msg_t msg; zmq_send (control, "PAUSE", 5, 0); zmq_msg_recv (&msg, control, 0)); zmq_send (control, "RESUME", 6, 0); zmq_msg_recv (&msg, control, 0)); zmq_send (control, "STATISTICS", 10, 0); while (1) { zmq_msg_recv (&msg, control, 0)); printf(" %lu", *(uint64_t *)zmq_msg_data (&msg)); if (!zmq_msg_get (&msg, ZMQ_MORE)) break; } printf("\n"); zmq_send (control, "TERMINATE", 9, 0); zmq_msg_recv (&msg, control, 0)); zmq_close(frontend); zmq_close(backend); zmq_close(control); ---- == SEE ALSO * xref:zmq_proxy.adoc[zmq_proxy] * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_proxy_steerable.adoc
AsciiDoc
gpl-3.0
3,694
= zmq_recv(3) == NAME zmq_recv - receive a message part from a socket == SYNOPSIS *int zmq_recv (void '*socket', void '*buf', size_t 'len', int 'flags');* == DESCRIPTION The _zmq_recv()_ function shall receive a message from the socket referenced by the 'socket' argument and store it in the buffer referenced by the 'buf' argument. Any bytes exceeding the length specified by the 'len' argument shall be truncated. If there are no messages available on the specified 'socket' the _zmq_recv()_ function shall block until the request can be satisfied. The 'flags' argument is a combination of the flags defined below: The 'buf' argument may be null if len is zero. *ZMQ_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If there are no messages available on the specified 'socket', the _zmq_recv()_ function shall fail with 'errno' set to EAGAIN. Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that processes multi-part messages must use the _ZMQ_RCVMORE_ xref:zmq_getsockopt.adoc[zmq_getsockopt] option after calling _zmq_recv()_ to determine if there are further parts to receive. == RETURN VALUE The _zmq_recv()_ function shall return number of bytes in the message if successful. Note that the value can exceed the value of the 'len' parameter in case the message was truncated. If not successful the function shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Either the timeout set via the socket-option ZMQ_RCVTIMEO (see xref:zmq_setsockopt.adoc[zmq_setsockopt]) has been reached (flag ZMQ_DONTWAIT not set) without being able to read a message from the socket or there are no messages available at the moment (flag ZMQ_DONTWAIT set) and the operation would block. *ENOTSUP*:: The _zmq_recv()_ operation is not supported by this socket type. *EFSM*:: The _zmq_recv()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before a message was available. == EXAMPLE .Receiving a message from a socket ---- char buf [256]; nbytes = zmq_recv (socket, buf, 256, 0); assert (nbytes != -1); ---- == SEE ALSO * xref:zmq_send.adoc[zmq_send] * xref:zmq_getsockopt.adoc[zmq_getsockopt] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_recv.adoc
AsciiDoc
gpl-3.0
3,126
= zmq_recvmsg(3) == NAME zmq_recvmsg - receive a message part from a socket == SYNOPSIS *int zmq_recvmsg (void '*socket', zmq_msg_t '*msg', int 'flags');* == DESCRIPTION The _zmq_recvmsg()_ function shall receive a message part from the socket referenced by the 'socket' argument and store it in the message referenced by the 'msg' argument. Any content previously stored in 'msg' shall be properly deallocated. If there are no message parts available on the specified 'socket' the _zmq_recvmsg()_ function shall block until the request can be satisfied. The 'flags' argument is a combination of the flags defined below: *ZMQ_DONTWAIT*:: Specifies that the operation should be performed in non-blocking mode. If there are no messages available on the specified 'socket', the _zmq_recvmsg()_ function shall fail with 'errno' set to EAGAIN. NOTE: this API method is deprecated in favor of zmq_msg_recv(3). Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. Each message part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that processes multi-part messages must use the _ZMQ_RCVMORE_ xref:zmq_getsockopt.adoc[zmq_getsockopt] option after calling _zmq_recvmsg()_ to determine if there are further parts to receive. == RETURN VALUE The _zmq_recvmsg()_ function shall return number of bytes in the message if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Either the timeout set via the socket-option ZMQ_RCVTIMEO (see xref:zmq_setsockopt.adoc[zmq_setsockopt]) has been reached (flag ZMQ_DONTWAIT not set) without being able to read a message from the socket or there are no messages available at the moment (flag ZMQ_DONTWAIT set) and the operation would block. *ENOTSUP*:: The _zmq_recvmsg()_ operation is not supported by this socket type. *EFSM*:: The _zmq_recvmsg()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before a message was available. *EFAULT*:: The message passed to the function was invalid. == EXAMPLE .Receiving a message from a socket ---- /* Create an empty 0MQ message */ zmq_msg_t msg; int rc = zmq_msg_init (&msg); assert (rc == 0); /* Block until a message is available to be received from socket */ rc = zmq_recvmsg (socket, &msg, 0); assert (rc != -1); /* Release message */ zmq_msg_close (&msg); ---- .Receiving a multi-part message ---- int more; size_t more_size = sizeof (more); do { /* Create an empty 0MQ message to hold the message part */ zmq_msg_t part; int rc = zmq_msg_init (&part); assert (rc == 0); /* Block until a message is available to be received from socket */ rc = zmq_recvmsg (socket, &part, 0); assert (rc != -1); /* Determine if more message parts are to follow */ rc = zmq_getsockopt (socket, ZMQ_RCVMORE, &more, &more_size); assert (rc == 0); zmq_msg_close (&part); } while (more); ---- == SEE ALSO * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_send.adoc[zmq_send] * xref:zmq_getsockopt.adoc[zmq_getsockopt] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_recvmsg.adoc
AsciiDoc
gpl-3.0
3,943
= zmq_send(3) == NAME zmq_send - send a message part on a socket == SYNOPSIS *int zmq_send (void '*socket', const void '*buf', size_t 'len', int 'flags');* == DESCRIPTION The _zmq_send()_ function shall queue a message created from the buffer referenced by the 'buf' and 'len' arguments. The 'flags' argument is a combination of the flags defined below: *ZMQ_DONTWAIT*:: For socket types (DEALER, PUSH) that block (either with ZMQ_IMMEDIATE option set and no peer available, or all peers having full high-water mark), specifies that the operation should be performed in non-blocking mode. If the message cannot be queued on the 'socket', the _zmq_send()_ function shall fail with 'errno' set to EAGAIN. *ZMQ_SNDMORE*:: Specifies that the message being sent is a multi-part message, and that further message parts are to follow. Refer to the section regarding multi-part messages below for a detailed description. NOTE: A successful invocation of _zmq_send()_ does not indicate that the message has been transmitted to the network, only that it has been queued on the 'socket' and 0MQ has assumed responsibility for the message. Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that sends multi-part messages must use the _ZMQ_SNDMORE_ flag when sending each message part except the final one. == RETURN VALUE The _zmq_send()_ function shall return number of bytes in the message if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Non-blocking mode was requested and the message cannot be sent at the moment. *ENOTSUP*:: The _zmq_send()_ operation is not supported by this socket type. *EINVAL*:: The sender tried to send multipart data, which the socket type does not allow. *EFSM*:: The _zmq_send()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *EHOSTUNREACH*:: The message cannot be routed. == EXAMPLE .Sending a multi-part message ---- /* Send a multi-part message consisting of three parts to socket */ rc = zmq_send (socket, "ABC", 3, ZMQ_SNDMORE); assert (rc == 3); rc = zmq_send (socket, "DEFGH", 5, ZMQ_SNDMORE); assert (rc == 5); /* Final part; no more parts to follow */ rc = zmq_send (socket, "JK", 2, 0); assert (rc == 2); ---- == SEE ALSO * xref:zmq_send_const.adoc[zmq_send_const] * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_send.adoc
AsciiDoc
gpl-3.0
3,260
= zmq_send_const(3) == NAME zmq_send_const - send a constant-memory message part on a socket == SYNOPSIS *int zmq_send_const (void '*socket', const void '*buf', size_t 'len', int 'flags');* == DESCRIPTION The _zmq_send_const()_ function shall queue a message created from the buffer referenced by the 'buf' and 'len' arguments. The message buffer is assumed to be constant-memory and will therefore not be copied or deallocated in any way. The 'flags' argument is a combination of the flags defined below: *ZMQ_DONTWAIT*:: For socket types (DEALER, PUSH) that block (either with ZMQ_IMMEDIATE option set and no peer available, or all peers having full high-water mark), specifies that the operation should be performed in non-blocking mode. If the message cannot be queued on the 'socket', the _zmq_send_const()_ function shall fail with 'errno' set to EAGAIN. *ZMQ_SNDMORE*:: Specifies that the message being sent is a multi-part message, and that further message parts are to follow. Refer to the section regarding multi-part messages below for a detailed description. NOTE: A successful invocation of _zmq_send_const()_ does not indicate that the message has been transmitted to the network, only that it has been queued on the 'socket' and 0MQ has assumed responsibility for the message. Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that sends multi-part messages must use the _ZMQ_SNDMORE_ flag when sending each message part except the final one. == RETURN VALUE The _zmq_send_const()_ function shall return number of bytes in the message if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Non-blocking mode was requested and the message cannot be sent at the moment. *ENOTSUP*:: The _zmq_send_const()_ operation is not supported by this socket type. *EFSM*:: The _zmq_send_const()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *EHOSTUNREACH*:: The message cannot be routed. == EXAMPLE .Sending a multi-part message ---- /* Send a multi-part message consisting of three parts to socket */ rc = zmq_send_const (socket, "ABC", 3, ZMQ_SNDMORE); assert (rc == 3); rc = zmq_send_const (socket, "DEFGH", 5, ZMQ_SNDMORE); assert (rc == 5); /* Final part; no more parts to follow */ rc = zmq_send_const (socket, "JK", 2, 0); assert (rc == 2); ---- == SEE ALSO * xref:zmq_send.adoc[zmq_send] * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_send_const.adoc
AsciiDoc
gpl-3.0
3,358
= zmq_sendmsg(3) == NAME zmq_sendmsg - send a message part on a socket == SYNOPSIS *int zmq_sendmsg (void '*socket', zmq_msg_t '*msg', int 'flags');* == DESCRIPTION The _zmq_sendmsg()_ function shall queue the message referenced by the 'msg' argument to be sent to the socket referenced by the 'socket' argument. The 'flags' argument is a combination of the flags defined below: *ZMQ_DONTWAIT*:: For socket types (DEALER, PUSH) that block (either with ZMQ_IMMEDIATE option set and no peer available, or all peers having full high-water mark), specifies that the operation should be performed in non-blocking mode. If the message cannot be queued on the 'socket', the _zmq_sendmsg()_ function shall fail with 'errno' set to EAGAIN. *ZMQ_SNDMORE*:: Specifies that the message being sent is a multi-part message, and that further message parts are to follow. Refer to the section regarding multi-part messages below for a detailed description. The _zmq_msg_t_ structure passed to _zmq_sendmsg()_ is nullified during the call. If you want to send the same message to multiple sockets you have to copy it (e.g. using _zmq_msg_copy()_). NOTE: A successful invocation of _zmq_sendmsg()_ does not indicate that the message has been transmitted to the network, only that it has been queued on the 'socket' and 0MQ has assumed responsibility for the message. NOTE: this API method is deprecated in favor of zmq_msg_send(3). Multi-part messages ~~~~~~~~~~~~~~~~~~~ A 0MQ message is composed of 1 or more message parts. Each message part is an independent 'zmq_msg_t' in its own right. 0MQ ensures atomic delivery of messages: peers shall receive either all _message parts_ of a message or none at all. The total number of message parts is unlimited except by available memory. An application that sends multi-part messages must use the _ZMQ_SNDMORE_ flag when sending each message part except the final one. == RETURN VALUE The _zmq_sendmsg()_ function shall return number of bytes in the message if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EAGAIN*:: Non-blocking mode was requested and the message cannot be sent at the moment. *ENOTSUP*:: The _zmq_sendmsg()_ operation is not supported by this socket type. *EINVAL*:: The sender tried to send multipart data, which the socket type does not allow. *EFSM*:: The _zmq_sendmsg()_ operation cannot be performed on this socket at the moment due to the socket not being in the appropriate state. This error may occur with socket types that switch between several states, such as ZMQ_REP. See the _messaging patterns_ section of xref:zmq_socket.adoc[zmq_socket] for more information. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal before the message was sent. *EFAULT*:: Invalid message. *EHOSTUNREACH*:: The message cannot be routed. == EXAMPLE .Filling in a message and sending it to a socket ---- /* Create a new message, allocating 6 bytes for message content */ zmq_msg_t msg; int rc = zmq_msg_init_size (&msg, 6); assert (rc == 0); /* Fill in message content with 'AAAAAA' */ memset (zmq_msg_data (&msg), 'A', 6); /* Send the message to the socket */ rc = zmq_sendmsg (socket, &msg, 0); assert (rc == 6); ---- .Sending a multi-part message ---- /* Send a multi-part message consisting of three parts to socket */ rc = zmq_sendmsg (socket, &part1, ZMQ_SNDMORE); rc = zmq_sendmsg (socket, &part2, ZMQ_SNDMORE); /* Final part; no more parts to follow */ rc = zmq_sendmsg (socket, &part3, 0); ---- == SEE ALSO * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_sendmsg.adoc
AsciiDoc
gpl-3.0
3,927
= zmq_setsockopt(3) == NAME zmq_setsockopt - set 0MQ socket options == SYNOPSIS *int zmq_setsockopt (void '*socket', int 'option_name', const void '*option_value', size_t 'option_len');* Caution: All options, with the exception of ZMQ_SUBSCRIBE, ZMQ_UNSUBSCRIBE, ZMQ_LINGER, ZMQ_ROUTER_HANDOVER, ZMQ_ROUTER_MANDATORY, ZMQ_PROBE_ROUTER, ZMQ_XPUB_VERBOSE, ZMQ_XPUB_VERBOSER, ZMQ_REQ_CORRELATE, ZMQ_REQ_RELAXED, ZMQ_SNDHWM and ZMQ_RCVHWM, only take effect for subsequent socket bind/connects. Specifically, security options take effect for subsequent bind/connect calls, and can be changed at any time to affect subsequent binds and/or connects. == DESCRIPTION The _zmq_setsockopt()_ function shall set the option specified by the 'option_name' argument to the value pointed to by the 'option_value' argument for the 0MQ socket pointed to by the 'socket' argument. The 'option_len' argument is the size of the option value in bytes. For options taking a value of type "character string", the provided byte data should either contain no zero bytes, or end in a single zero byte (terminating ASCII NUL character). The following socket options can be set with the _zmq_setsockopt()_ function: ZMQ_AFFINITY: Set I/O thread affinity ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_AFFINITY' option shall set the I/O thread affinity for newly created connections on the specified 'socket'. Affinity determines which threads from the 0MQ I/O thread pool associated with the socket's _context_ shall handle newly created connections. A value of zero specifies no affinity, meaning that work shall be distributed fairly among all 0MQ I/O threads in the thread pool. For non-zero values, the lowest bit corresponds to thread 1, second lowest bit to thread 2 and so on. For example, a value of 3 specifies that subsequent connections on 'socket' shall be handled exclusively by I/O threads 1 and 2. See also xref:zmq_init.adoc[zmq_init] for details on allocating the number of I/O threads for a specific _context_. [horizontal] Option value type:: uint64_t Option value unit:: N/A (bitmap) Default value:: 0 Applicable socket types:: N/A ZMQ_BACKLOG: Set maximum length of the queue of outstanding connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_BACKLOG' option shall set the maximum length of the queue of outstanding peer connections for the specified 'socket'; this only applies to connection-oriented transports. For details refer to your operating system documentation for the 'listen' function. [horizontal] Option value type:: int Option value unit:: connections Default value:: 100 Applicable socket types:: all, only for connection-oriented transports. ZMQ_BINDTODEVICE: Set name of device to bind the socket to ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_BINDTODEVICE' option binds this socket to a particular device, eg. an interface or VRF. If a socket is bound to an interface, only packets received from that particular interface are processed by the socket. If device is a VRF device, then subsequent binds/connects to that socket use addresses in the VRF routing table. NOTE: requires setting CAP_NET_RAW on the compiled program. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP or UDP transports. ZMQ_BUSY_POLL: This removes delays caused by the interrupt and the resultant context switch. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Busy polling helps reduce latency in the network receive path by allowing socket layer code to poll the receive queue of a network device, and disabling network interrupts. This removes delays caused by the interrupt and the resultant context switch. However, it also increases CPU utilization. Busy polling also prevents the CPU from sleeping, which can incur additional power consumption. [horizontal] Option value type:: int Option value unit:: 0,1 Default value:: 0 Applicable socket types:: all ZMQ_CONNECT_RID: Assign the next outbound connection id ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This option name is now deprecated. Use ZMQ_CONNECT_ROUTING_ID instead. ZMQ_CONNECT_RID remains as an alias for now. ZMQ_CONNECT_ROUTING_ID: Assign the next outbound routing id ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_CONNECT_ROUTING_ID' option sets the peer id of the peer connected via the next zmq_connect() call, such that that connection is immediately ready for data transfer with the given routing id. This option applies only to the first subsequent call to zmq_connect(), zmq_connect() calls thereafter use the default connection behaviour. Typical use is to set this socket option ahead of each zmq_connect() call. Each connection MUST be assigned a unique routing id. Assigning a routing id that is already in use is not allowed. Useful when connecting ROUTER to ROUTER, or STREAM to STREAM, as it allows for immediate sending to peers. Outbound routing id framing requirements for ROUTER and STREAM sockets apply. The routing id must be from 1 to 255 bytes long and MAY NOT start with a zero byte (such routing ids are reserved for internal use by the 0MQ infrastructure). [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_ROUTER, ZMQ_STREAM ZMQ_CONFLATE: Keep only last message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If set, a socket shall keep only one message in its inbound/outbound queue, this message being the last message received/the last message to be sent. Ignores 'ZMQ_RCVHWM' and 'ZMQ_SNDHWM' options. Does not support multi-part messages, in particular, only one part of it is kept in the socket internal queue. NOTE: If recv is not called on the inbound socket, the queue and memory will grow with each message received. Use xref:zmq_getsockopt.adoc[zmq_getsockopt] with ZMQ_EVENTS to trigger the conflation of the messages. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: ZMQ_PULL, ZMQ_PUSH, ZMQ_SUB, ZMQ_PUB, ZMQ_DEALER ZMQ_CONNECT_TIMEOUT: Set connect() timeout ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets how long to wait before timing-out a connect() system call. The connect() system call normally takes a long time before it returns a time out error. Setting this option allows the library to time out the call at an earlier interval. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 (disabled) Applicable socket types:: all, when using TCP transports. ZMQ_CURVE_PUBLICKEY: Set CURVE public key ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the socket's long term public key. You must set this on CURVE client sockets, see xref:zmq_curve.adoc[zmq_curve] You can provide the key as 32 binary bytes, or as a 40-character string encoded in the Z85 encoding format and terminated in a null byte. The public key must always be used with the matching secret key. To generate a public/secret key pair, use xref:zmq_curve_keypair.adoc[zmq_curve_keypair] To derive the public key from a secret key, use xref:zmq_curve_public.adoc[zmq_curve_public] NOTE: an option value size of 40 is supported for backwards compatibility, though is deprecated. [horizontal] Option value type:: binary data or Z85 text string Option value size:: 32 or 41 Default value:: NULL Applicable socket types:: all, when using TCP transport ZMQ_CURVE_SECRETKEY: Set CURVE secret key ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the socket's long term secret key. You must set this on both CURVE client and server sockets, see xref:zmq_curve.adoc[zmq_curve] You can provide the key as 32 binary bytes, or as a 40-character string encoded in the Z85 encoding format and terminated in a null byte. To generate a public/secret key pair, use xref:zmq_curve_keypair.adoc[zmq_curve_keypair] To derive the public key from a secret key, use xref:zmq_curve_public.adoc[zmq_curve_public] NOTE: an option value size of 40 is supported for backwards compatibility, though is deprecated. [horizontal] Option value type:: binary data or Z85 text string Option value size:: 32 or 41 Default value:: NULL Applicable socket types:: all, when using TCP transport ZMQ_CURVE_SERVER: Set CURVE server role ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Defines whether the socket will act as server for CURVE security, see xref:zmq_curve.adoc[zmq_curve] A value of '1' means the socket will act as CURVE server. A value of '0' means the socket will not act as CURVE server, and its security role then depends on other option settings. Setting this to '0' shall reset the socket security to NULL. When you set this you must also set the server's secret key using the ZMQ_CURVE_SECRETKEY option. A server socket does not need to know its own public key. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: all, when using TCP transport ZMQ_CURVE_SERVERKEY: Set CURVE server key ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the socket's long term server key. You must set this on CURVE client sockets, see xref:zmq_curve.adoc[zmq_curve] You can provide the key as 32 binary bytes, or as a 40-character string encoded in the Z85 encoding format and terminated in a null byte. This key must have been generated together with the server's secret key. To generate a public/secret key pair, use xref:zmq_curve_keypair.adoc[zmq_curve_keypair] NOTE: an option value size of 40 is supported for backwards compatibility, though is deprecated. [horizontal] Option value type:: binary data or Z85 text string Option value size:: 32 or 41 Default value:: NULL Applicable socket types:: all, when using TCP transport ZMQ_DISCONNECT_MSG: set a disconnect message that the socket will generate when accepted peer disconnect ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When set, the socket will generate a disconnect message when accepted peer has been disconnected. You may set this on ROUTER, SERVER and PEER sockets. The combination with ZMQ_HEARTBEAT_IVL is powerful and simplify protocols, when heartbeat recognize a connection drop it will generate a disconnect message that can match the protocol of the application. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_ROUTER, ZMQ_SERVER and ZMQ_PEER ZMQ_HICCUP_MSG: set a hiccup message that the socket will generate when connected peer temporarily disconnect ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When set, the socket will generate a hiccup message when connect peer has been disconnected. You may set this on DEALER, CLIENT and PEER sockets. The combination with ZMQ_HEARTBEAT_IVL is powerful and simplify protocols, when heartbeat recognize a connection drop it will generate a hiccup message that can match the protocol of the application. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_DEALER, ZMQ_CLIENT and ZMQ_PEER ZMQ_GSSAPI_PLAINTEXT: Disable GSSAPI encryption ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Defines whether communications on the socket will be encrypted, see xref:zmq_gssapi.adoc[zmq_gssapi] A value of '1' means that communications will be plaintext. A value of '0' means communications will be encrypted. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 (false) Applicable socket types:: all, when using TCP transport ZMQ_GSSAPI_PRINCIPAL: Set name of GSSAPI principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the name of the principal for whom GSSAPI credentials should be acquired. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_GSSAPI_SERVER: Set GSSAPI server role ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Defines whether the socket will act as server for GSSAPI security, see xref:zmq_gssapi.adoc[zmq_gssapi] A value of '1' means the socket will act as GSSAPI server. A value of '0' means the socket will act as GSSAPI client. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 (false) Applicable socket types:: all, when using TCP transport ZMQ_GSSAPI_SERVICE_PRINCIPAL: Set name of GSSAPI service principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the name of the principal of the GSSAPI server to which a GSSAPI client intends to connect. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE: Set name type of service principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the name type of the GSSAPI service principal. A value of 'ZMQ_GSSAPI_NT_HOSTBASED' (0) means the name specified with 'ZMQ_GSSAPI_SERVICE_PRINCIPAL' is interpreted as a host based name. A value of 'ZMQ_GSSAPI_NT_USER_NAME' (1) means it is interpreted as a local user name. A value of 'ZMQ_GSSAPI_NT_KRB5_PRINCIPAL' (2) means it is interpreted as an unparsed principal name string (valid only with the krb5 GSSAPI mechanism). [horizontal] Option value type:: int Option value unit:: 0, 1, 2 Default value:: 0 (ZMQ_GSSAPI_NT_HOSTBASED) Applicable socket types:: all, when using TCP or IPC transport ZMQ_GSSAPI_PRINCIPAL_NAMETYPE: Set name type of principal ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the name type of the GSSAPI principal. A value of 'ZMQ_GSSAPI_NT_HOSTBASED' (0) means the name specified with 'ZMQ_GSSAPI_PRINCIPAL' is interpreted as a host based name. A value of 'ZMQ_GSSAPI_NT_USER_NAME' (1) means it is interpreted as a local user name. A value of 'ZMQ_GSSAPI_NT_KRB5_PRINCIPAL' (2) means it is interpreted as an unparsed principal name string (valid only with the krb5 GSSAPI mechanism). [horizontal] Option value type:: int Option value unit:: 0, 1, 2 Default value:: 0 (ZMQ_GSSAPI_NT_HOSTBASED) Applicable socket types:: all, when using TCP or IPC transport ZMQ_HANDSHAKE_IVL: Set maximum handshake interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_HANDSHAKE_IVL' option shall set the maximum handshake interval for the specified 'socket'. Handshaking is the exchange of socket configuration information (socket type, routing id, security) that occurs when a connection is first opened, only for connection-oriented transports. If handshaking does not complete within the configured time, the connection shall be closed. The value 0 means no handshake time limit. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 30000 Applicable socket types:: all but ZMQ_STREAM, only for connection-oriented transports ZMQ_HELLO_MSG: set an hello message that will be sent when a new peer connect ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When set, the socket will automatically send an hello message when a new connection is made or accepted. You may set this on DEALER, ROUTER, CLIENT, SERVER and PEER sockets. The combination with ZMQ_HEARTBEAT_IVL is powerful and simplify protocols, as now heartbeat and sending the hello message can be left out of protocols and be handled by zeromq. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_ROUTER, ZMQ_DEALER, ZMQ_CLIENT, ZMQ_SERVER and ZMQ_PEER ZMQ_HEARTBEAT_IVL: Set interval between sending ZMTP heartbeats ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_HEARTBEAT_IVL' option shall set the interval between sending ZMTP heartbeats for the specified 'socket'. If this option is set and is greater than 0, then a 'PING' ZMTP command will be sent every 'ZMQ_HEARTBEAT_IVL' milliseconds. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 Applicable socket types:: all, when using connection-oriented transports ZMQ_HEARTBEAT_TIMEOUT: Set timeout for ZMTP heartbeats ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_HEARTBEAT_TIMEOUT' option shall set how long to wait before timing-out a connection after sending a 'PING' ZMTP command and not receiving any traffic. This option is only valid if 'ZMQ_HEARTBEAT_IVL' is also set, and is greater than 0. The connection will time out if there is no traffic received after sending the 'PING' command, but the received traffic does not have to be a 'PONG' command - any received traffic will cancel the timeout. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 normally, ZMQ_HEARTBEAT_IVL if it is set Applicable socket types:: all, when using connection-oriented transports ZMQ_HEARTBEAT_TTL: Set the TTL value for ZMTP heartbeats ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_HEARTBEAT_TTL' option shall set the timeout on the remote peer for ZMTP heartbeats. If this option is greater than 0, the remote side shall time out the connection if it does not receive any more traffic within the TTL period. This option does not have any effect if 'ZMQ_HEARTBEAT_IVL' is not set or is 0. Internally, this value is rounded down to the nearest decisecond, any value less than 100 will have no effect. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 Maximum value:: 6553599 (which is 2^16-1 deciseconds) Applicable socket types:: all, when using connection-oriented transports ZMQ_IDENTITY: Set socket identity ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This option name is now deprecated. Use ZMQ_ROUTING_ID instead. ZMQ_IDENTITY remains as an alias for now. ZMQ_IMMEDIATE: Queue messages only to completed connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default queues will fill on outgoing connections even if the connection has not completed. This can lead to "lost" messages on sockets with round-robin routing (REQ, PUSH, DEALER). If this option is set to `1`, messages shall be queued only to completed connections. This will cause the socket to block if there are no other connections, but will prevent queues from filling on pipes awaiting connection. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: all, only for connection-oriented transports. ZMQ_INVERT_MATCHING: Invert message filtering ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Reverses the filtering behavior of PUB-SUB sockets, when set to 1. On 'PUB' and 'XPUB' sockets, this causes messages to be sent to all connected sockets 'except' those subscribed to a prefix that matches the message. On 'SUB' sockets, this causes only incoming messages that do 'not' match any of the socket's subscriptions to be received by the user. Whenever 'ZMQ_INVERT_MATCHING' is set to 1 on a 'PUB' socket, all 'SUB' sockets connecting to it must also have the option set to 1. Failure to do so will have the 'SUB' sockets reject everything the 'PUB' socket sends them. 'XSUB' sockets do not need to do this because they do not filter incoming messages. [horizontal] Option value type:: int Option value unit:: 0,1 Default value:: 0 Applicable socket types:: ZMQ_PUB, ZMQ_XPUB, ZMQ_SUB ZMQ_IPV6: Enable IPv6 on socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set the IPv6 option for the socket. A value of `1` means IPv6 is enabled on the socket, while `0` means the socket will use only IPv4. When IPv6 is enabled the socket will connect to, or accept connections from, both IPv4 and IPv6 hosts. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: all, when using TCP transports. ZMQ_LINGER: Set linger period for socket shutdown ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_LINGER' option shall set the linger period for the specified 'socket'. The linger period determines how long pending messages which have yet to be sent to a peer shall linger in memory after a socket is disconnected with xref:zmq_disconnect.adoc[zmq_disconnect] or closed with xref:zmq_close.adoc[zmq_close], and further affects the termination of the socket's context with xref:zmq_ctx_term.adoc[zmq_ctx_term] The following outlines the different behaviours: * A value of '-1' specifies an infinite linger period. Pending messages shall not be discarded after a call to _zmq_disconnect()_ or _zmq_close()_; attempting to terminate the socket's context with _zmq_ctx_term()_ shall block until all pending messages have been sent to a peer. * The value of '0' specifies no linger period. Pending messages shall be discarded immediately after a call to _zmq_disconnect()_ or _zmq_close()_. * Positive values specify an upper bound for the linger period in milliseconds. Pending messages shall not be discarded after a call to _zmq_disconnect()_ or _zmq_close()_; attempting to terminate the socket's context with _zmq_ctx_term()_ shall block until either all pending messages have been sent to a peer, or the linger period expires, after which any pending messages shall be discarded. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 (infinite) Applicable socket types:: all ZMQ_MAXMSGSIZE: Maximum acceptable inbound message size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Limits the size of the inbound message. If a peer sends a message larger than ZMQ_MAXMSGSIZE it is disconnected. Value of -1 means 'no limit'. [horizontal] Option value type:: int64_t Option value unit:: bytes Default value:: -1 Applicable socket types:: all ZMQ_METADATA: Add application metadata properties to a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The _ZMQ_METADATA_ option shall add application metadata to the specified _socket_, the metadata is exchanged with peers during connection setup. A metadata property is specified as a string, delimited by a colon, starting with the metadata _property_ followed by the metadata value, for example "X-key:value". _Property_ names are restricted to maximum 255 characters and must be prefixed by "X-". Multiple application metadata properties can be added to a socket by executing zmq_setsockopt() multiple times. As the argument is a null-terminated string, binary data must be encoded before it is added e.g. using Z85 (xref:zmq_z85_encode.adoc[zmq_z85_encode]). NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all ZMQ_MULTICAST_HOPS: Maximum network hops for multicast packets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the time-to-live field in every multicast packet sent from this socket. The default is 1 which means that the multicast packets don't leave the local network. [horizontal] Option value type:: int Option value unit:: network hops Default value:: 1 Applicable socket types:: all, when using multicast transports ZMQ_MULTICAST_MAXTPDU: Maximum transport data unit size for multicast packets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the maximum transport data unit size used for outbound multicast packets. This must be set at or below the minimum Maximum Transmission Unit (MTU) for all network paths over which multicast reception is required. [horizontal] Option value type:: int Option value unit:: bytes Default value:: 1500 Applicable socket types:: all, when using multicast transports ZMQ_PLAIN_PASSWORD: Set PLAIN security password ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the password for outgoing connections over TCP or IPC. If you set this to a non-null value, the security mechanism used for connections shall be PLAIN, see xref:zmq_plain.adoc[zmq_plain] If you set this to a null value, the security mechanism used for connections shall be NULL, see xref:zmq_null.adoc[zmq_null] [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_PLAIN_SERVER: Set PLAIN server role ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Defines whether the socket will act as server for PLAIN security, see xref:zmq_plain.adoc[zmq_plain] A value of '1' means the socket will act as PLAIN server. A value of '0' means the socket will not act as PLAIN server, and its security role then depends on other option settings. Setting this to '0' shall reset the socket security to NULL. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: all, when using TCP transport ZMQ_PLAIN_USERNAME: Set PLAIN security username ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the username for outgoing connections over TCP or IPC. If you set this to a non-null value, the security mechanism used for connections shall be PLAIN, see xref:zmq_plain.adoc[zmq_plain] If you set this to a null value, the security mechanism used for connections shall be NULL, see xref:zmq_null.adoc[zmq_null] [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_USE_FD: Set the pre-allocated socket file descriptor ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When set to a positive integer value before zmq_bind is called on the socket, the socket shall use the corresponding file descriptor for connections over TCP or IPC instead of allocating a new file descriptor. Useful for writing systemd socket activated services. If set to -1 (default), a new file descriptor will be allocated instead (default behaviour). NOTE: if set after calling zmq_bind, this option shall have no effect. NOTE: the file descriptor passed through MUST have been ran through the "bind" and "listen" system calls beforehand. Also, socket option that would normally be passed through zmq_setsockopt like TCP buffers length, IP_TOS or SO_REUSEADDR MUST be set beforehand by the caller, as they must be set before the socket is bound. [horizontal] Option value type:: int Option value unit:: file descriptor Default value:: -1 Applicable socket types:: all bound sockets, when using IPC or TCP transport ZMQ_PRIORITY: Set the Priority on socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the protocol-defined priority for all packets to be sent on this socket, where supported by the OS. In Linux, values greater than 6 require admin capability (CAP_NET_ADMIN) [horizontal] Option value type:: int Option value unit:: >0 Default value:: 0 Applicable socket types:: all, only for connection-oriented transports ZMQ_PROBE_ROUTER: bootstrap connections to ROUTER sockets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When set to 1, the socket will automatically send an empty message when a new connection is made or accepted. You may set this on REQ, DEALER, or ROUTER sockets connected to a ROUTER socket. The application must filter such empty messages. The ZMQ_PROBE_ROUTER option in effect provides the ROUTER application with an event signaling the arrival of a new peer. NOTE: do not set this option on a socket that talks to any other socket types: the results are undefined. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_ROUTER, ZMQ_DEALER, ZMQ_REQ ZMQ_RATE: Set multicast data rate ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RATE' option shall set the maximum send or receive data rate for multicast transports such as xref:zmq_pgm.adoc[zmq_pgm] using the specified 'socket'. [horizontal] Option value type:: int Option value unit:: kilobits per second Default value:: 100 Applicable socket types:: all, when using multicast transports ZMQ_RCVBUF: Set kernel receive buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RCVBUF' option shall set the underlying kernel receive buffer size for the 'socket' to the specified size in bytes. A value of -1 means leave the OS default unchanged. For details refer to your operating system documentation for the 'SO_RCVBUF' socket option. [horizontal] Option value type:: int Option value unit:: bytes Default value:: -1 Applicable socket types:: all ZMQ_RCVHWM: Set high water mark for inbound messages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RCVHWM' option shall set the high water mark for inbound messages on the specified 'socket'. The high water mark is a hard limit on the maximum number of outstanding messages 0MQ shall queue in memory for any single peer that the specified 'socket' is communicating with. A value of zero means no limit. If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, 0MQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in xref:zmq_socket.adoc[zmq_socket] for details on the exact action taken for each socket type. NOTE: 0MQ does not guarantee that the socket will be able to queue as many as ZMQ_RCVHWM messages, and the actual limit may be lower or higher, depending on socket transport. A notable example is for sockets using TCP transport; see xref:zmq_tcp.adoc[zmq_tcp] [horizontal] Option value type:: int Option value unit:: messages Default value:: 1000 Applicable socket types:: all ZMQ_RCVTIMEO: Maximum time before a recv operation returns with EAGAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the timeout for receive operation on the socket. If the value is `0`, _zmq_recv(3)_ will return immediately, with a EAGAIN error if there is no message to receive. If the value is `-1`, it will block until a message is available. For all other values, it will wait for a message for that amount of time before returning with an EAGAIN error. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 (infinite) Applicable socket types:: all ZMQ_RECONNECT_IVL: Set reconnection interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECONNECT_IVL' option shall set the initial reconnection interval for the specified 'socket'. The reconnection interval is the period 0MQ shall wait between attempts to reconnect disconnected peers when using connection-oriented transports. The value -1 means no reconnection. NOTE: The reconnection interval may be randomized by 0MQ to prevent reconnection storms in topologies with a large number of peers per socket. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 100 Applicable socket types:: all, only for connection-oriented transports ZMQ_RECONNECT_IVL_MAX: Set max reconnection interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECONNECT_IVL_MAX' option shall set the max reconnection interval for the specified 'socket'. 0MQ shall wait at most the configured interval between reconnection attempts. The interval grows exponentionally (i.e.: it is doubled) with each attempt until it reaches ZMQ_RECONNECT_IVL_MAX. Default value means that the reconnect interval is based exclusively on ZMQ_RECONNECT_IVL and no exponential backoff is performed. NOTE: Value has to be greater or equal than ZMQ_RECONNECT_IVL, or else it will be ignored. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 (ZMQ_RECONNECT_IVL will be used) Applicable socket types:: all, only for connection-oriented transports ZMQ_RECONNECT_STOP: Set condition where reconnection will stop ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECONNECT_STOP' option shall set the conditions under which automatic reconnection will stop. This can be useful when a process binds to a wild-card port, where the OS supplies an ephemeral port. The 'ZMQ_RECONNECT_STOP_CONN_REFUSED' option will stop reconnection when 0MQ receives the ECONNREFUSED return code from the connect. This indicates that there is no code bound to the specified endpoint. The 'ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED' option will stop reconnection if the 0MQ handshake fails. This can be used to detect and/or prevent errant connection attempts to non-0MQ sockets. Note that when specifying this option you may also want to set `ZMQ_HANDSHAKE_IVL` -- the default handshake interval is 30000 (30 seconds), which is typically too large. The 'ZMQ_RECONNECT_STOP_AFTER_DISCONNECT' option will stop reconnection when zmq_disconnect() has been called. This can be useful when the user's request failed (server not ready), as the socket does not need to continue to reconnect after user disconnect actively. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, ZMQ_RECONNECT_STOP_CONN_REFUSED, ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED, ZMQ_RECONNECT_STOP_CONN_REFUSED | ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED Default value:: 0 Applicable socket types:: all, only for connection-oriented transports (ZMQ_HANDSHAKE_IVL is not applicable for ZMQ_STREAM sockets) ZMQ_RECOVERY_IVL: Set multicast recovery interval ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_RECOVERY_IVL' option shall set the recovery interval for multicast transports using the specified 'socket'. The recovery interval determines the maximum time in milliseconds that a receiver can be absent from a multicast group before unrecoverable data loss will occur. CAUTION: Exercise care when setting large recovery intervals as the data needed for recovery will be held in memory. For example, a 1 minute recovery interval at a data rate of 1Gbps requires a 7GB in-memory buffer. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 10000 Applicable socket types:: all, when using multicast transports ZMQ_REQ_CORRELATE: match replies with requests ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The default behaviour of REQ sockets is to rely on the ordering of messages to match requests and responses and that is usually sufficient. When this option is set to 1, the REQ socket will prefix outgoing messages with an extra frame containing a request id. That means the full message is (request id, 0, user frames...). The REQ socket will discard all incoming messages that don't begin with these two frames. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_REQ ZMQ_REQ_RELAXED: relax strict alternation between request and reply ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ By default, a REQ socket does not allow initiating a new request with _zmq_send(3)_ until the reply to the previous one has been received. When set to 1, sending another message is allowed and previous replies will be discarded if any. The request-reply state machine is reset and a new request is sent to the next available peer. If set to 1, also enable ZMQ_REQ_CORRELATE to ensure correct matching of requests and replies. Otherwise a late reply to an aborted request can be reported as the reply to the superseding request. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_REQ ZMQ_ROUTER_HANDOVER: handle duplicate client routing ids on ROUTER sockets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If two clients use the same routing id when connecting to a ROUTER, the results shall depend on the ZMQ_ROUTER_HANDOVER option setting. If that is not set (or set to the default of zero), the ROUTER socket shall reject clients trying to connect with an already-used routing id. If that option is set to 1, the ROUTER socket shall hand-over the connection to the new client and disconnect the existing one. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_ROUTER ZMQ_ROUTER_MANDATORY: accept only routable messages on ROUTER sockets ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the ROUTER socket behaviour when an unroutable message is encountered. A value of `0` is the default and discards the message silently when it cannot be routed or the peers SNDHWM is reached. A value of `1` returns an 'EHOSTUNREACH' error code if the message cannot be routed or 'EAGAIN' error code if the SNDHWM is reached and ZMQ_DONTWAIT was used. Without ZMQ_DONTWAIT it will block until the SNDTIMEO is reached or a spot in the send queue opens up. When ZMQ_ROUTER_MANDATORY is set to `1`, 'ZMQ_POLLOUT' events will be generated if one or more messages can be sent to at least one of the peers. If ZMQ_ROUTER_MANDATORY is set to `0`, the socket will generate a 'ZMQ_POLLOUT' event on every call to 'zmq_poll' resp. 'zmq_poller_wait_all'. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_ROUTER ZMQ_ROUTER_RAW: switch ROUTER socket to raw mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the raw mode on the ROUTER, when set to 1. When the ROUTER socket is in raw mode, and when using the tcp:// transport, it will read and write TCP data without 0MQ framing. This lets 0MQ applications talk to non-0MQ applications. When using raw mode, you cannot set explicit identities, and the ZMQ_SNDMORE flag is ignored when sending data messages. In raw mode you can close a specific connection by sending it a zero-length message (following the routing id frame). NOTE: This option is deprecated, please use ZMQ_STREAM sockets instead. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_ROUTER ZMQ_ROUTING_ID: Set socket routing id ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_ROUTING_ID' option shall set the routing id of the specified 'socket' when connecting to a ROUTER socket. A routing id must be at least one byte and at most 255 bytes long. Identities starting with a zero byte are reserved for use by the 0MQ infrastructure. If two clients use the same routing id when connecting to a ROUTER, the results shall depend on the ZMQ_ROUTER_HANDOVER option setting. If that is not set (or set to the default of zero), the ROUTER socket shall reject clients trying to connect with an already-used routing id. If that option is set to 1, the ROUTER socket shall hand-over the connection to the new client and disconnect the existing one. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_REQ, ZMQ_REP, ZMQ_ROUTER, ZMQ_DEALER. ZMQ_SNDBUF: Set kernel transmit buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SNDBUF' option shall set the underlying kernel transmit buffer size for the 'socket' to the specified size in bytes. A value of -1 means leave the OS default unchanged. For details please refer to your operating system documentation for the 'SO_SNDBUF' socket option. [horizontal] Option value type:: int Option value unit:: bytes Default value:: -1 Applicable socket types:: all ZMQ_SNDHWM: Set high water mark for outbound messages ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SNDHWM' option shall set the high water mark for outbound messages on the specified 'socket'. The high water mark is a hard limit on the maximum number of outstanding messages 0MQ shall queue in memory for any single peer that the specified 'socket' is communicating with. A value of zero means no limit. If this limit has been reached the socket shall enter an exceptional state and depending on the socket type, 0MQ shall take appropriate action such as blocking or dropping sent messages. Refer to the individual socket descriptions in xref:zmq_socket.adoc[zmq_socket] for details on the exact action taken for each socket type. NOTE: 0MQ does not guarantee that the socket will accept as many as ZMQ_SNDHWM messages, and the actual limit may be as much as 90% lower depending on the flow of messages on the socket. The socket may even be able to accept more messages than the ZMQ_SNDHWM threshold; a notable example is for sockets using TCP transport; see xref:zmq_tcp.adoc[zmq_tcp] [horizontal] Option value type:: int Option value unit:: messages Default value:: 1000 Applicable socket types:: all ZMQ_SNDTIMEO: Maximum time before a send operation returns with EAGAIN ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the timeout for send operation on the socket. If the value is `0`, _zmq_send(3)_ will return immediately, with a EAGAIN error if the message cannot be sent. If the value is `-1`, it will block until the message is sent. For all other values, it will try to send the message for that amount of time before returning with an EAGAIN error. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 (infinite) Applicable socket types:: all ZMQ_SOCKS_PROXY: Set SOCKS5 proxy address ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the SOCKS5 proxy address that shall be used by the socket for the TCP connection(s). Supported authentication methods are: no authentication or basic authentication when setup with ZMQ_SOCKS_USERNAME. If the endpoints are domain names instead of addresses they shall not be resolved and they shall be forwarded unchanged to the SOCKS proxy service in the client connection request message (address type 0x03 domain name). [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_SOCKS_USERNAME: Set SOCKS username and select basic authentication ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the username for authenticated connection to the SOCKS5 proxy. If you set this to a non-null and non-empty value, the authentication method used for the SOCKS5 connection shall be basic authentication. In this case, use ZMQ_SOCKS_PASSWORD option in order to set the password. If you set this to a null value or empty value, the authentication method shall be no authentication, the default. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_SOCKS_PASSWORD: Set SOCKS basic authentication password ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the password for authenticating to the SOCKS5 proxy server. This is used only when the SOCKS5 authentication method has been set to basic authentication through the ZMQ_SOCKS_USERNAME option. Setting this to a null value (the default) is equivalent to an empty password string. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: not set Applicable socket types:: all, when using TCP transport ZMQ_STREAM_NOTIFY: send connect and disconnect notifications ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enables connect and disconnect notifications on a STREAM socket, when set to 1. When notifications are enabled, the socket delivers a zero-length message when a peer connects or disconnects. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 1 Applicable socket types:: ZMQ_STREAM ZMQ_SUBSCRIBE: Establish message filter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_SUBSCRIBE' option shall establish a new message filter on a 'ZMQ_SUB' socket. Newly created 'ZMQ_SUB' sockets shall filter out all incoming messages, therefore you should call this option to establish an initial message filter. An empty 'option_value' of length zero shall subscribe to all incoming messages. A non-empty 'option_value' shall subscribe to all messages beginning with the specified prefix. Multiple filters may be attached to a single 'ZMQ_SUB' socket, in which case a message shall be accepted if it matches at least one filter. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: N/A Applicable socket types:: ZMQ_SUB ZMQ_TCP_KEEPALIVE: Override SO_KEEPALIVE socket option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'SO_KEEPALIVE' socket option (where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,0,1 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_KEEPALIVE_CNT: Override TCP_KEEPCNT socket option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'TCP_KEEPCNT' socket option (where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,>0 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_KEEPALIVE_IDLE: Override TCP_KEEPIDLE (or TCP_KEEPALIVE on some OS) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'TCP_KEEPIDLE' (or 'TCP_KEEPALIVE' on some OS) socket option (where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,>0 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_KEEPALIVE_INTVL: Override TCP_KEEPINTVL socket option ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Override 'TCP_KEEPINTVL' socket option(where supported by OS). The default value of `-1` means to skip any overrides and leave it to OS default. [horizontal] Option value type:: int Option value unit:: -1,>0 Default value:: -1 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TCP_MAXRT: Set TCP Maximum Retransmit Timeout ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ On OSes where it is supported, sets how long before an unacknowledged TCP retransmit times out. The system normally attempts many TCP retransmits following an exponential backoff strategy. This means that after a network outage, it may take a long time before the session can be re-established. Setting this option allows the timeout to happen at a shorter interval. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: 0 (leave to OS default) Applicable socket types:: all, when using TCP transports. ZMQ_TOS: Set the Type-of-Service on socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the ToS fields (Differentiated services (DS) and Explicit Congestion Notification (ECN) field of the IP header. The ToS field is typically used to specify a packets priority. The availability of this option is dependent on intermediate network equipment that inspect the ToS field and provide a path for low-delay, high-throughput, highly-reliable service, etc. [horizontal] Option value type:: int Option value unit:: >0 Default value:: 0 Applicable socket types:: all, only for connection-oriented transports ZMQ_UNSUBSCRIBE: Remove message filter ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The 'ZMQ_UNSUBSCRIBE' option shall remove an existing message filter on a 'ZMQ_SUB' socket. The filter specified must match an existing filter previously established with the 'ZMQ_SUBSCRIBE' option. If the socket has several instances of the same filter attached the 'ZMQ_UNSUBSCRIBE' option shall remove only one instance, leaving the rest in place and functional. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: N/A Applicable socket types:: ZMQ_SUB ZMQ_XPUB_VERBOSE: pass duplicate subscribe messages on XPUB socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the 'XPUB' socket behaviour on new duplicated subscriptions. If enabled, the socket passes all subscribe messages to the caller. If disabled, only the first subscription to each filter will be passed. The default is 0 (disabled). [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_XPUB ZMQ_XPUB_VERBOSER: pass duplicate subscribe and unsubscribe messages on XPUB socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the 'XPUB' socket behaviour on new duplicated subscriptions and unsubscriptions. If enabled, the socket passes all subscribe and unsubscribe messages to the caller. If disabled, only the first subscription to each filter and the last unsubscription from each filter will be passed. The default is 0 (disabled). [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_XPUB ZMQ_XPUB_MANUAL: change the subscription handling to manual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the 'XPUB' socket subscription handling mode manual/automatic. A value of '0' is the default and subscription requests will be handled automatically. A value of '1' will change the subscription requests handling to manual, with manual mode subscription requests are not added to the subscription list. To add subscription the user need to call setsockopt with ZMQ_SUBSCRIBE on XPUB socket. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_XPUB ZMQ_XPUB_MANUAL_LAST_VALUE: change the subscription handling to manual ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ This option is similar to ZMQ_XPUB_MANUAL. The difference is that ZMQ_XPUB_MANUAL_LAST_VALUE changes the 'XPUB' socket behaviour to send the first message to the last subscriber after the socket receives a subscription and call setsockopt with ZMQ_SUBSCRIBE on 'XPUB' socket. This prevents duplicated messages when using last value caching(LVC). NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_XPUB ZMQ_XPUB_NODROP: do not silently drop messages if SENDHWM is reached ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the 'XPUB' socket behaviour to return error EAGAIN if SENDHWM is reached and the message could not be send. A value of `0` is the default and drops the message silently when the peers SNDHWM is reached. A value of `1` returns an 'EAGAIN' error code if the SNDHWM is reached and ZMQ_DONTWAIT was used. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_XPUB, ZMQ_PUB ZMQ_XPUB_WELCOME_MSG: set welcome message that will be received by subscriber when connecting ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets a welcome message the will be received by subscriber when connecting. Subscriber must subscribe to the Welcome message before connecting. Welcome message will also be sent on reconnecting. For welcome message to work well user must poll on incoming subscription messages on the XPUB socket and handle them. Use NULL and length of zero to disable welcome message. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: NULL Applicable socket types:: ZMQ_XPUB ZMQ_XSUB_VERBOSE_UNSUBSCRIBE: pass duplicate unsubscribe messages on XSUB socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the 'XSUB' socket behaviour on duplicated unsubscriptions. If enabled, the socket passes all unsubscribe messages to the caller. If disabled, only the last unsubscription from each filter will be passed. The default is 0 (disabled). NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: ZMQ_XSUB ZMQ_ONLY_FIRST_SUBSCRIBE: Process only first subscribe/unsubscribe in a multipart message ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If set, only the first part of the multipart message is processed as a subscribe/unsubscribe message. The rest are forwarded as user data regardless of message contents. It not set (default), subscribe/unsubscribe messages in a multipart message are processed as such regardless of their number and order. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: ZMQ_XSUB, ZMQ_XPUB ZMQ_ZAP_DOMAIN: Set RFC 27 authentication domain ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the domain for ZAP (ZMQ RFC 27) authentication. A ZAP domain must be specified to enable authentication. When the ZAP domain is empty, which is the default, ZAP authentication is disabled. This is not compatible with previous versions of libzmq, so it can be controlled by ZMQ_ZAP_ENFORCE_DOMAIN which for now is disabled by default. See http://rfc.zeromq.org/spec:27 for more details. [horizontal] Option value type:: character string Option value unit:: N/A Default value:: empty Applicable socket types:: all, when using TCP transport ZMQ_ZAP_ENFORCE_DOMAIN: Set ZAP domain handling to strictly adhere the RFC ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZAP (ZMQ RFC 27) authentication protocol specifies that a domain must always be set. Older versions of libzmq did not follow the spec and allowed an empty domain to be set. This option can be used to enabled or disable the stricter, backward incompatible behaviour. For now it is disabled by default, but in a future version it will be enabled by default. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 0 Applicable socket types:: all, when using ZAP ZMQ_TCP_ACCEPT_FILTER: Assign filters to allow new TCP connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign an arbitrary number of filters that will be applied for each new TCP transport connection on a listening socket. If no filters are applied, then the TCP transport allows connections from any IP address. If at least one filter is applied then new connection source ip should be matched. To clear all filters call zmq_setsockopt(socket, ZMQ_TCP_ACCEPT_FILTER, NULL, 0). Filter is a null-terminated string with ipv6 or ipv4 CIDR. NOTE: This option is deprecated, please use authentication via the ZAP API and IP address allowing / blocking. [horizontal] Option value type:: binary data Option value unit:: N/A Default value:: no filters (allow from all) Applicable socket types:: all listening sockets, when using TCP transports. ZMQ_IPC_FILTER_GID: Assign group ID filters to allow new IPC connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign an arbitrary number of filters that will be applied for each new IPC transport connection on a listening socket. If no IPC filters are applied, then the IPC transport allows connections from any process. If at least one UID, GID, or PID filter is applied then new connection credentials should be matched. To clear all GID filters call zmq_setsockopt(socket, ZMQ_IPC_FILTER_GID, NULL, 0). NOTE: GID filters are only available on platforms supporting SO_PEERCRED or LOCAL_PEERCRED socket options (currently only Linux and later versions of OS X). NOTE: This option is deprecated, please use authentication via the ZAP API and IPC allowing / blocking. [horizontal] Option value type:: gid_t Option value unit:: N/A Default value:: no filters (allow from all) Applicable socket types:: all listening sockets, when using IPC transports. ZMQ_IPC_FILTER_PID: Assign process ID filters to allow new IPC connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign an arbitrary number of filters that will be applied for each new IPC transport connection on a listening socket. If no IPC filters are applied, then the IPC transport allows connections from any process. If at least one UID, GID, or PID filter is applied then new connection credentials should be matched. To clear all PID filters call zmq_setsockopt(socket, ZMQ_IPC_FILTER_PID, NULL, 0). NOTE: PID filters are only available on platforms supporting the SO_PEERCRED socket option (currently only Linux). NOTE: This option is deprecated, please use authentication via the ZAP API and IPC allowing / blocking. [horizontal] Option value type:: pid_t Option value unit:: N/A Default value:: no filters (allow from all) Applicable socket types:: all listening sockets, when using IPC transports. ZMQ_IPC_FILTER_UID: Assign user ID filters to allow new IPC connections ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Assign an arbitrary number of filters that will be applied for each new IPC transport connection on a listening socket. If no IPC filters are applied, then the IPC transport allows connections from any process. If at least one UID, GID, or PID filter is applied then new connection credentials should be matched. To clear all UID filters call zmq_setsockopt(socket, ZMQ_IPC_FILTER_UID, NULL, 0). NOTE: UID filters are only available on platforms supporting SO_PEERCRED or LOCAL_PEERCRED socket options (currently only Linux and later versions of OS X). NOTE: This option is deprecated, please use authentication via the ZAP API and IPC allowing / blocking. [horizontal] Option value type:: uid_t Option value unit:: N/A Default value:: no filters (allow from all) Applicable socket types:: all listening sockets, when using IPC transports. ZMQ_IPV4ONLY: Use IPv4-only on socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Set the IPv4-only option for the socket. This option is deprecated. Please use the ZMQ_IPV6 option. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 1 (true) Applicable socket types:: all, when using TCP transports. ZMQ_VMCI_BUFFER_SIZE: Set buffer size of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_BUFFER_SIZE` option shall set the size of the underlying buffer for the socket. Used during negotiation before the connection is established. [horizontal] Option value type:: uint64_t Option value unit:: bytes Default value:: 65546 Applicable socket types:: all, when using VMCI transport ZMQ_VMCI_BUFFER_MIN_SIZE: Set min buffer size of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_BUFFER_MIN_SIZE` option shall set the min size of the underlying buffer for the socket. Used during negotiation before the connection is established. [horizontal] Option value type:: uint64_t Option value unit:: bytes Default value:: 128 Applicable socket types:: all, when using VMCI transport ZMQ_VMCI_BUFFER_MAX_SIZE: Set max buffer size of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_BUFFER_MAX_SIZE` option shall set the max size of the underlying buffer for the socket. Used during negotiation before the connection is established. [horizontal] Option value type:: uint64_t Option value unit:: bytes Default value:: 262144 Applicable socket types:: all, when using VMCI transport ZMQ_VMCI_CONNECT_TIMEOUT: Set connection timeout of the VMCI socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The `ZMQ_VMCI_CONNECT_TIMEOUT` option shall set connection timeout for the socket. [horizontal] Option value type:: int Option value unit:: milliseconds Default value:: -1 Applicable socket types:: all, when using VMCI transport ZMQ_MULTICAST_LOOP: Control multicast local loopback ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ For multicast UDP sender sockets this option sets whether the data sent should be looped back on local listening sockets. [horizontal] Option value type:: int Option value unit:: 0, 1 Default value:: 1 Applicable socket types:: ZMQ_RADIO, when using UDP multicast transport ZMQ_ROUTER_NOTIFY: Send connect and disconnect notifications ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enable connect and disconnect notifications on a ROUTER socket. When enabled, the socket delivers a zero-length message (with routing-id as first frame) when a peer connects or disconnects. It's possible to notify both events for a peer by OR-ing the flag values. This option only applies to stream oriented (tcp, ipc) transports. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, ZMQ_NOTIFY_CONNECT, ZMQ_NOTIFY_DISCONNECT, ZMQ_NOTIFY_CONNECT | ZMQ_NOTIFY_DISCONNECT Default value:: 0 Applicable socket types:: ZMQ_ROUTER ZMQ_IN_BATCH_SIZE: Maximal receive batch size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the maximal amount of messages that can be received in a single 'recv' system call. WARNING: this option should almost never be changed. The default has been chosen to offer the best compromise between latency and throughtput. In the vast majority of cases, changing this option will result in worst result if not outright breakages. Cannot be zero. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: messages Default value:: 8192 Applicable socket types:: All, when using TCP, IPC, PGM or NORM transport. ZMQ_OUT_BATCH_SIZE: Maximal send batch size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the maximal amount of messages that can be sent in a single 'send' system call. WARNING: this option should almost never be changed. The default has been chosen to offer the best compromise between latency and throughtput. In the vast majority of cases, changing this option will result in worst result if not outright breakages. Cannot be zero. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: messages Default value:: 8192 Applicable socket types:: All, when using TCP, IPC, PGM or NORM transport. ZMQ_NORM_MODE: NORM Sender Mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the NORM sender mode to control the operation of the NORM transport. NORM supports fixed rate operation (0='ZMQ_NORM_FIXED'), congestion control mode (1='ZMQ_NORM_CC'), loss-tolerant congestion control (2='ZMQ_NORM_CCL'), explicit congestion notification (ECN)-enabled congestion control (3='ZMQ_NORM_CCE'), and ECN-only congestion control (4='ZMQ_NORM_CCE_ECNONLY'). The default value is TCP-friendly congestion control mode. Fixed rate mode (using datarate set by 'ZMQ_RATE') offers better performance, but care must be taken to prevent data loss. ECN modes will set one of the ECN Capable Transport bits in the given 'ZMQ_TOS' if it is not set already. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: 0, 1, 2, 3, 4 Default value:: 1 ('ZMQ_NORM_CC') Applicable socket types:: All, when using NORM transport. ZMQ_NORM_UNICAST_NACK: Set NORM Unicast NACK mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ If set, NORM receiver will send Negative ACKnowledgements (NACKs) back to the sender using unicast instead of multicast. NORM transport endpoints specifying a unicast address will enable this by default, but it is disabled by default for multicast addresses. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: All, when using NORM transport. ZMQ_NORM_BUFFER_SIZE: Set NORM buffer size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets NORM buffer size for NORM transport sender, receiver, and stream. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: kilobytes Default value:: 2048 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_SEGMENT_SIZE: Set NORM segment size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets NORM sender segment size, which is the maximum message payload size of individual NORM messages (ZMQ messages may be split over multiple NORM messages). Ideally, this value should fit within the system/network maximum transmission unit (MTU) after accounting for additional NORM message headers (up to 48 bytes). NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: bytes Default value:: 1400 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_BLOCK_SIZE: Set NORM block size ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets NORM sender block size, which is the number of segments in a NORM FEC coding block. NORM repair operations take place at block boundaries. Maximum value is 255, but parity packets ('ZMQ_NORM_NUM_PARITY') are limited to a value of (255 - 'ZMQ_NORM_BLOCK_SIZE'). Minimum value is ('ZMQ_NORM_NUM_PARITY' + 1). Effective value may be different based on the settings of 'ZMQ_NORM_NUM_PARITY' and 'ZMQ_NORM_NUM_AUTOPARITY' if invalid settings are provided. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: >0, <=255 Default value:: 16 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_NUM_PARITY: Set number of NORM parity segments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the maximum number of NORM parity symbol segments that the sender is willing to calculate per FEC coding block for the purpose of reparing lost data. Maximum value is 255, but is further limited to a value of (255 - 'ZMQ_NORM_BLOCK_SIZE'). Minimum value is 'ZMQ_NORM_NUM_AUTOPARITY'. Effective value may be different based on the setting of 'ZMQ_NORM_NUM_AUTOPARITY' if invalid settings are provided. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: >0, <255 Default value:: 4 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_NUM_AUTOPARITY: Set number of proactive NORM parity segments ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Sets the number of NORM parity symbol segments that the sender will proactively send at the end of each FEC coding block. By default, no proactive parity segments will be sent; instead, parity segments will only be sent in response to repair requests (NACKs). Maximum value is 255, but is further limited to a maximum value of 'ZMQ_NORM_NUM_PARITY'. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: >=0, <255 Default value:: 0 Applicable socket types:: All, when using NORM transport. ZMQ_NORM_PUSH: Enable NORM push mode ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Enables NORM stream push mode, which alters the behavior of the sender when enqueueing new data. By default, NORM will stop accepting new messages while waiting for old data to be transmitted and/or repaired. Enabling push mode discards the oldest data (which may be pending repair or may never have been transmitted) in favor of accepting new data. This may be useful in cases where it is more important to quickly deliver new data instead of reliably delivering older data. NOTE: in DRAFT state, not yet available in stable releases. [horizontal] Option value type:: int Option value unit:: boolean Default value:: 0 (false) Applicable socket types:: All, when using NORM transport. == RETURN VALUE The _zmq_setsockopt()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested option _option_name_ is unknown, or the requested _option_len_ or _option_value_ is invalid. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *EINTR*:: The operation was interrupted by delivery of a signal. == EXAMPLE .Subscribing to messages on a 'ZMQ_SUB' socket ---- /* Subscribe to all messages */ rc = zmq_setsockopt (socket, ZMQ_SUBSCRIBE, "", 0); assert (rc == 0); /* Subscribe to messages prefixed with "ANIMALS.CATS" */ rc = zmq_setsockopt (socket, ZMQ_SUBSCRIBE, "ANIMALS.CATS", 12); ---- .Setting I/O thread affinity ---- int64_t affinity; /* Incoming connections on TCP port 5555 shall be handled by I/O thread 1 */ affinity = 1; rc = zmq_setsockopt (socket, ZMQ_AFFINITY, &affinity, sizeof (affinity)); assert (rc); rc = zmq_bind (socket, "tcp://lo:5555"); assert (rc); /* Incoming connections on TCP port 5556 shall be handled by I/O thread 2 */ affinity = 2; rc = zmq_setsockopt (socket, ZMQ_AFFINITY, &affinity, sizeof (affinity)); assert (rc); rc = zmq_bind (socket, "tcp://lo:5556"); assert (rc); ---- == SEE ALSO * xref:zmq_getsockopt.adoc[zmq_getsockopt] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq_plain.adoc[zmq_plain] * xref:zmq_curve.adoc[zmq_curve] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_setsockopt.adoc
AsciiDoc
gpl-3.0
69,544
= zmq_socket(3) == NAME zmq_socket - create 0MQ socket == SYNOPSIS *void *zmq_socket (void '*context', int 'type');* == DESCRIPTION The 'zmq_socket()' function shall create a 0MQ socket within the specified 'context' and return an opaque handle to the newly created socket. The 'type' argument specifies the socket type, which determines the semantics of communication over the socket. The newly created socket is initially unbound, and not associated with any endpoints. In order to establish a message flow a socket must first be connected to at least one endpoint with xref:zmq_connect.adoc[zmq_connect], or at least one endpoint must be created for accepting incoming connections with xref:zmq_bind.adoc[zmq_bind] .Key differences to conventional sockets Generally speaking, conventional sockets present a _synchronous_ interface to either connection-oriented reliable byte streams (SOCK_STREAM), or connection-less unreliable datagrams (SOCK_DGRAM). In comparison, 0MQ sockets present an abstraction of an asynchronous _message queue_, with the exact queueing semantics depending on the socket type in use. Where conventional sockets transfer streams of bytes or discrete datagrams, 0MQ sockets transfer discrete _messages_. 0MQ sockets being _asynchronous_ means that the timings of the physical connection setup and tear down, reconnect and effective delivery are transparent to the user and organized by 0MQ itself. Further, messages may be _queued_ in the event that a peer is unavailable to receive them. Conventional sockets allow only strict one-to-one (two peers), many-to-one (many clients, one server), or in some cases one-to-many (multicast) relationships. With the exception of 'ZMQ_PAIR' and 'ZMQ_CHANNEL', 0MQ sockets may be connected *to multiple endpoints* using _zmq_connect()_, while simultaneously accepting incoming connections *from multiple endpoints* bound to the socket using _zmq_bind()_, thus allowing many-to-many relationships. .Thread safety 0MQ has both thread safe socket type and _not_ thread safe socket types. Applications MUST NOT use a _not_ thread safe socket from multiple threads under any circumstances. Doing so results in undefined behaviour. Following are the thread safe sockets: * ZMQ_CLIENT * ZMQ_SERVER * ZMQ_DISH * ZMQ_RADIO * ZMQ_SCATTER * ZMQ_GATHER * ZMQ_PEER * ZMQ_CHANNEL .Socket types The following sections present the socket types defined by 0MQ, grouped by the general _messaging pattern_ which is built from related socket types. Client-server pattern ~~~~~~~~~~~~~~~~~~~~~ The client-server pattern is used to allow a single 'ZMQ_SERVER' _server_ talk to one or more 'ZMQ_CLIENT' _clients_. The client always starts the conversation, after which either peer can send messages asynchronously, to the other. The client-server pattern is formally defined by http://rfc.zeromq.org/spec:41. NOTE: Server-client is still in draft phase. ZMQ_CLIENT ^^^^^^^^^^ A 'ZMQ_CLIENT' socket talks to a 'ZMQ_SERVER' socket. Either peer can connect, though the usual and recommended model is to bind the 'ZMQ_SERVER' and connect the 'ZMQ_CLIENT'. If the 'ZMQ_CLIENT' socket has established a connection, xref:zmq_send.adoc[zmq_send] will accept messages, queue them, and send them as rapidly as the network allows. The outgoing buffer limit is defined by the high water mark for the socket. If the outgoing buffer is full, or, for connection-oriented transports, if the ZMQ_IMMEDIATE option is set and there is no connected peer, xref:zmq_send.adoc[zmq_send] will block. The 'ZMQ_CLIENT' socket will not drop messages. When a 'ZMQ_CLIENT' socket is connected to multiple 'ZMQ_SERVER' sockets, outgoing messages are distributed between connected peers on a round-robin basis. Likewise, the 'ZMQ_CLIENT' socket receives messages fairly from each connected peer. This usage is sensible only for stateless protocols. 'ZMQ_CLIENT' sockets are threadsafe and can be used from multiple threads at the same time. Note that replies from a 'ZMQ_SERVER' socket will go to the first client thread that calls xref:zmq_msg_recv.adoc[zmq_msg_recv] If you need to get replies back to the originating thread, use one 'ZMQ_CLIENT' socket per thread. NOTE: 'ZMQ_CLIENT' sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends not ZMQ_RCVMORE on receives. This limits them to single part data. The intention is to extend the API to allow scatter/gather of multi-part data. [horizontal] .Summary of ZMQ_CLIENT characteristics Compatible peer sockets:: 'ZMQ_SERVER' Direction:: Bidirectional Send/receive pattern:: Unrestricted Outgoing routing strategy:: Round-robin Incoming routing strategy:: Fair-queued Action in mute state:: Block ZMQ_SERVER ^^^^^^^^^^ A 'ZMQ_SERVER' socket talks to a set of 'ZMQ_CLIENT' sockets. A 'ZMQ_SERVER' socket can only reply to an incoming message: the 'ZMQ_CLIENT' peer must always initiate a conversation. Each received message has a 'routing_id' that is a 32-bit unsigned integer. The application can fetch this with xref:zmq_msg_routing_id.adoc[zmq_msg_routing_id] To send a message to a given 'ZMQ_CLIENT' peer the application must set the peer's 'routing_id' on the message, using xref:zmq_msg_set_routing_id.adoc[zmq_msg_set_routing_id] If the 'routing_id' is not specified, or does not refer to a connected client peer, the send call will fail with EHOSTUNREACH. If the outgoing buffer for the client peer is full, the send call shall block, unless ZMQ_DONTWAIT is used in the send, in which case it shall fail with EAGAIN. The 'ZMQ_SERVER' socket shall not drop messages in any case. NOTE: 'ZMQ_SERVER' sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends not ZMQ_RCVMORE on receives. This limits them to single part data. The intention is to extend the API to allow scatter/gather of multi-part data. [horizontal] .Summary of ZMQ_SERVER characteristics Compatible peer sockets:: 'ZMQ_CLIENT' Direction:: Bidirectional Send/receive pattern:: Unrestricted Outgoing routing strategy:: See text Incoming routing strategy:: Fair-queued Action in mute state:: Return EAGAIN Radio-dish pattern ~~~~~~~~~~~~~~~~~~ The radio-dish pattern is used for one-to-many distribution of data from a single _publisher_ to multiple _subscribers_ in a fan out fashion. Radio-dish is using groups (vs Pub-sub topics), Dish sockets can join a group and each message sent by Radio sockets belong to a group. Groups are null terminated strings limited to 16 chars length (including null). The intention is to increase the length to 40 chars (including null). The encoding of groups shall be UTF8. Groups are matched using exact matching (vs prefix matching of PubSub). NOTE: Radio-dish is still in draft phase. ZMQ_RADIO ^^^^^^^^^ A socket of type 'ZMQ_RADIO' is used by a _publisher_ to distribute data. Each message belong to a group, a group is specified with xref:zmq_msg_set_group.adoc[zmq_msg_set_group] Messages are distributed to all members of a group. The xref:zmq_recv.adoc[zmq_recv] function is not implemented for this socket type. When a 'ZMQ_RADIO' socket enters the 'mute' state due to having reached the high water mark for a _subscriber_, then any messages that would be sent to the _subscriber_ in question shall instead be dropped until the mute state ends. The _zmq_send()_ function shall never block for this socket type. NOTE: 'ZMQ_RADIO' sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends. This limits them to single part data. [horizontal] .Summary of ZMQ_RADIO characteristics Compatible peer sockets:: 'ZMQ_DISH' Direction:: Unidirectional Send/receive pattern:: Send only Incoming routing strategy:: N/A Outgoing routing strategy:: Fan out Action in mute state:: Drop ZMQ_DISH ^^^^^^^^ A socket of type 'ZMQ_DISH' is used by a _subscriber_ to subscribe to groups distributed by a _radio_. Initially a 'ZMQ_DISH' socket is not subscribed to any groups, use xref:zmq_join.adoc[zmq_join] to join a group. To get the group the message belong to call xref:zmq_msg_group.adoc[zmq_msg_group] The _zmq_send()_ function is not implemented for this socket type. NOTE: 'ZMQ_DISH' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data. [horizontal] .Summary of ZMQ_DISH characteristics Compatible peer sockets:: 'ZMQ_RADIO' Direction:: Unidirectional Send/receive pattern:: Receive only Incoming routing strategy:: Fair-queued Outgoing routing strategy:: N/A Publish-subscribe pattern ~~~~~~~~~~~~~~~~~~~~~~~~~ The publish-subscribe pattern is used for one-to-many distribution of data from a single _publisher_ to multiple _subscribers_ in a fan out fashion. The publish-subscribe pattern is formally defined by http://rfc.zeromq.org/spec:29. ZMQ_PUB ^^^^^^^ A socket of type 'ZMQ_PUB' is used by a _publisher_ to distribute data. Messages sent are distributed in a fan out fashion to all connected peers. The xref:zmq_recv.adoc[zmq_recv] function is not implemented for this socket type. When a 'ZMQ_PUB' socket enters the 'mute' state due to having reached the high water mark for a _subscriber_, then any messages that would be sent to the _subscriber_ in question shall instead be dropped until the mute state ends. The _zmq_send()_ function shall never block for this socket type. [horizontal] .Summary of ZMQ_PUB characteristics Compatible peer sockets:: 'ZMQ_SUB', 'ZMQ_XSUB' Direction:: Unidirectional Send/receive pattern:: Send only Incoming routing strategy:: N/A Outgoing routing strategy:: Fan out Action in mute state:: Drop ZMQ_SUB ^^^^^^^ A socket of type 'ZMQ_SUB' is used by a _subscriber_ to subscribe to data distributed by a _publisher_. Initially a 'ZMQ_SUB' socket is not subscribed to any messages, use the 'ZMQ_SUBSCRIBE' option of xref:zmq_setsockopt.adoc[zmq_setsockopt] to specify which messages to subscribe to. The _zmq_send()_ function is not implemented for this socket type. [horizontal] .Summary of ZMQ_SUB characteristics Compatible peer sockets:: 'ZMQ_PUB', 'ZMQ_XPUB' Direction:: Unidirectional Send/receive pattern:: Receive only Incoming routing strategy:: Fair-queued Outgoing routing strategy:: N/A ZMQ_XPUB ^^^^^^^^ Same as ZMQ_PUB except that you can receive subscriptions from the peers in form of incoming messages. Subscription message is a byte 1 (for subscriptions) or byte 0 (for unsubscriptions) followed by the subscription body. Messages without a sub/unsub prefix are also received, but have no effect on subscription status. [horizontal] .Summary of ZMQ_XPUB characteristics Compatible peer sockets:: 'ZMQ_SUB', 'ZMQ_XSUB' Direction:: Unidirectional Send/receive pattern:: Send messages, receive subscriptions Incoming routing strategy:: N/A Outgoing routing strategy:: Fan out Action in mute state:: Drop ZMQ_XSUB ^^^^^^^^ Same as ZMQ_SUB except that you subscribe by sending subscription messages to the socket. Subscription message is a byte 1 (for subscriptions) or byte 0 (for unsubscriptions) followed by the subscription body. Messages without a sub/unsub prefix may also be sent, but have no effect on subscription status. [horizontal] .Summary of ZMQ_XSUB characteristics Compatible peer sockets:: 'ZMQ_PUB', 'ZMQ_XPUB' Direction:: Unidirectional Send/receive pattern:: Receive messages, send subscriptions Incoming routing strategy:: Fair-queued Outgoing routing strategy:: N/A Action in mute state:: Drop Pipeline pattern ~~~~~~~~~~~~~~~~ The pipeline pattern is used for distributing data to _nodes_ arranged in a pipeline. Data always flows down the pipeline, and each stage of the pipeline is connected to at least one _node_. When a pipeline stage is connected to multiple _nodes_ data is round-robined among all connected _nodes_. The pipeline pattern is formally defined by http://rfc.zeromq.org/spec:30. ZMQ_PUSH ^^^^^^^^ A socket of type 'ZMQ_PUSH' is used by a pipeline _node_ to send messages to downstream pipeline _nodes_. Messages are round-robined to all connected downstream _nodes_. The _zmq_recv()_ function is not implemented for this socket type. When a 'ZMQ_PUSH' socket enters the 'mute' state due to having reached the high water mark for all downstream _nodes_, or, for connection-oriented transports, if the ZMQ_IMMEDIATE option is set and there are no downstream _nodes_ at all, then any xref:zmq_send.adoc[zmq_send] operations on the socket shall block until the mute state ends or at least one downstream _node_ becomes available for sending; messages are not discarded. [horizontal] .Summary of ZMQ_PUSH characteristics Compatible peer sockets:: 'ZMQ_PULL' Direction:: Unidirectional Send/receive pattern:: Send only Incoming routing strategy:: N/A Outgoing routing strategy:: Round-robin Action in mute state:: Block ZMQ_PULL ^^^^^^^^ A socket of type 'ZMQ_PULL' is used by a pipeline _node_ to receive messages from upstream pipeline _nodes_. Messages are fair-queued from among all connected upstream _nodes_. The _zmq_send()_ function is not implemented for this socket type. [horizontal] .Summary of ZMQ_PULL characteristics Compatible peer sockets:: 'ZMQ_PUSH' Direction:: Unidirectional Send/receive pattern:: Receive only Incoming routing strategy:: Fair-queued Outgoing routing strategy:: N/A Action in mute state:: Block Scatter-gather pattern ~~~~~~~~~~~~~~~~~~~~~~ The scatter-gather pattern is the thread-safe version of the pipeline pattern. The scatter-gather pattern is used for distributing data to _nodes_ arranged in a pipeline. Data always flows down the pipeline, and each stage of the pipeline is connected to at least one _node_. When a pipeline stage is connected to multiple _nodes_ data is round-robined among all connected _nodes_. ZMQ_SCATTER ^^^^^^^^^^^ A socket of type 'ZMQ_SCATTER' is used by a scatter-gather _node_ to send messages to downstream scatter-gather _nodes_. Messages are round-robined to all connected downstream _nodes_. The _zmq_recv()_ function is not implemented for this socket type. When a 'ZMQ_SCATTER' socket enters the 'mute' state due to having reached the high water mark for all downstream _nodes_, or, for connection-oriented transports, if the ZMQ_IMMEDIATE option is set and there are no downstream _nodes_ at all, then any xref:zmq_send.adoc[zmq_send] operations on the socket shall block until the mute state ends or at least one downstream _node_ becomes available for sending; messages are not discarded. NOTE: 'ZMQ_SCATTER' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data. [horizontal] .Summary of ZMQ_SCATTER characteristics Compatible peer sockets:: 'ZMQ_SCATTER' Direction:: Unidirectional Send/receive pattern:: Send only Incoming routing strategy:: N/A Outgoing routing strategy:: Round-robin Action in mute state:: Block ZMQ_GATHER ^^^^^^^^^^ A socket of type 'ZMQ_GATHER' is used by a scatter-gather _node_ to receive messages from upstream scatter-gather _nodes_. Messages are fair-queued from among all connected upstream _nodes_. The _zmq_send()_ function is not implemented for this socket type. NOTE: 'ZMQ_GATHER' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data. [horizontal] .Summary of ZMQ_GATHER characteristics Compatible peer sockets:: 'ZMQ_GATHER' Direction:: Unidirectional Send/receive pattern:: Receive only Incoming routing strategy:: Fair-queued Outgoing routing strategy:: N/A Action in mute state:: Block Exclusive pair pattern ~~~~~~~~~~~~~~~~~~~~~~ The exclusive pair pattern is used to connect a peer to precisely one other peer. This pattern is used for inter-thread communication across the inproc transport. The exclusive pair pattern is formally defined by http://rfc.zeromq.org/spec:31. ZMQ_PAIR ^^^^^^^^ A socket of type 'ZMQ_PAIR' can only be connected to a single peer at any one time. No message routing or filtering is performed on messages sent over a 'ZMQ_PAIR' socket. When a 'ZMQ_PAIR' socket enters the 'mute' state due to having reached the high water mark for the connected peer, or, for connection-oriented transports, if the ZMQ_IMMEDIATE option is set and there is no connected peer, then any xref:zmq_send.adoc[zmq_send] operations on the socket shall block until the peer becomes available for sending; messages are not discarded. While 'ZMQ_PAIR' sockets can be used over transports other than xref:zmq_inproc.adoc[zmq_inproc], their inability to auto-reconnect coupled with the fact new incoming connections will be terminated while any previous connections (including ones in a closing state) exist makes them unsuitable for TCP in most cases. NOTE: 'ZMQ_PAIR' sockets are designed for inter-thread communication across the xref:zmq_inproc.adoc[zmq_inproc] transport and do not implement functionality such as auto-reconnection. [horizontal] .Summary of ZMQ_PAIR characteristics Compatible peer sockets:: 'ZMQ_PAIR' Direction:: Bidirectional Send/receive pattern:: Unrestricted Incoming routing strategy:: N/A Outgoing routing strategy:: N/A Action in mute state:: Block Peer-to-peer pattern ~~~~~~~~~~~~~~~~~~~~ The peer-to-peer pattern is used to connect a peer to multiple peers. Peer can both connect and bind and mix both of them with the same socket. The peer-to-peer pattern is useful to build peer-to-peer networks (e.g zyre, bitcoin, torrent) where a peer can both accept connections from other peers or connect to them. NOTE: Peer-to-peer is still in draft phase. ZMQ_PEER ^^^^^^^^ A 'ZMQ_PEER' socket talks to a set of 'ZMQ_PEER' sockets. To connect and fetch the 'routing_id' of the peer use xref:zmq_connect_peer.adoc[zmq_connect_peer] Each received message has a 'routing_id' that is a 32-bit unsigned integer. The application can fetch this with xref:zmq_msg_routing_id.adoc[zmq_msg_routing_id] To send a message to a given 'ZMQ_PEER' peer the application must set the peer's 'routing_id' on the message, using xref:zmq_msg_set_routing_id.adoc[zmq_msg_set_routing_id] If the 'routing_id' is not specified, or does not refer to a connected client peer, the send call will fail with EHOSTUNREACH. If the outgoing buffer for the peer is full, the send call shall block, unless ZMQ_DONTWAIT is used in the send, in which case it shall fail with EAGAIN. The 'ZMQ_PEER' socket shall not drop messages in any case. NOTE: 'ZMQ_PEER' sockets are threadsafe. They do not accept the ZMQ_SNDMORE option on sends not ZMQ_RCVMORE on receives. This limits them to single part data. [horizontal] .Summary of ZMQ_PEER characteristics Compatible peer sockets:: 'ZMQ_PEER' Direction:: Bidirectional Send/receive pattern:: Unrestricted Outgoing routing strategy:: See text Incoming routing strategy:: Fair-queued Action in mute state:: Return EAGAIN Channel pattern ~~~~~~~~~~~~~~~ The channel pattern is the thread-safe version of the exclusive pair pattern. The channel pattern is used to connect a peer to precisely one other peer. This pattern is used for inter-thread communication across the inproc transport. NOTE: Channel is still in draft phase. ZMQ_CHANNEL ^^^^^^^^^^^ A socket of type 'ZMQ_CHANNEL' can only be connected to a single peer at any one time. No message routing or filtering is performed on messages sent over a 'ZMQ_CHANNEL' socket. When a 'ZMQ_CHANNEL' socket enters the 'mute' state due to having reached the high water mark for the connected peer, or, for connection-oriented transports, if the ZMQ_IMMEDIATE option is set and there is no connected peer, then any xref:zmq_send.adoc[zmq_send] operations on the socket shall block until the peer becomes available for sending; messages are not discarded. While 'ZMQ_CHANNEL' sockets can be used over transports other than xref:zmq_inproc.adoc[zmq_inproc], their inability to auto-reconnect coupled with the fact new incoming connections will be terminated while any previous connections (including ones in a closing state) exist makes them unsuitable for TCP in most cases. NOTE: 'ZMQ_CHANNEL' sockets are designed for inter-thread communication across the xref:zmq_inproc.adoc[zmq_inproc] transport and do not implement functionality such as auto-reconnection. NOTE: 'ZMQ_CHANNEL' sockets are threadsafe. They do not accept ZMQ_RCVMORE on receives. This limits them to single part data. [horizontal] .Summary of ZMQ_CHANNEL characteristics Compatible peer sockets:: 'ZMQ_CHANNEL' Direction:: Bidirectional Send/receive pattern:: Unrestricted Incoming routing strategy:: N/A Outgoing routing strategy:: N/A Action in mute state:: Block Native Pattern ~~~~~~~~~~~~~~ The native pattern is used for communicating with TCP peers and allows asynchronous requests and replies in either direction. ZMQ_STREAM ^^^^^^^^^^ A socket of type 'ZMQ_STREAM' is used to send and receive TCP data from a non-0MQ peer, when using the tcp:// transport. A 'ZMQ_STREAM' socket can act as client and/or server, sending and/or receiving TCP data asynchronously. When receiving TCP data, a 'ZMQ_STREAM' socket shall prepend a message part containing the _routing id_ of the originating peer to the message before passing it to the application. Messages received are fair-queued from among all connected peers. When sending TCP data, a 'ZMQ_STREAM' socket shall remove the first part of the message and use it to determine the _routing id_ of the peer the message shall be routed to, and unroutable messages shall cause an EHOSTUNREACH or EAGAIN error. To open a connection to a server, use the zmq_connect call, and then fetch the socket routing id using the zmq_getsockopt call with the ZMQ_ROUTING_ID option. To close a specific connection, send the routing id frame followed by a zero-length message (see EXAMPLE section). When a connection is made, a zero-length message will be received by the application. Similarly, when the peer disconnects (or the connection is lost), a zero-length message will be received by the application. You must send one routing id frame followed by one data frame. The ZMQ_SNDMORE flag is required for routing id frames but is ignored on data frames. [horizontal] .Summary of ZMQ_STREAM characteristics Compatible peer sockets:: none. Direction:: Bidirectional Send/receive pattern:: Unrestricted Outgoing routing strategy:: See text Incoming routing strategy:: Fair-queued Action in mute state:: EAGAIN Request-reply pattern ~~~~~~~~~~~~~~~~~~~~~ The request-reply pattern is used for sending requests from a ZMQ_REQ _client_ to one or more ZMQ_REP _services_, and receiving subsequent replies to each request sent. The request-reply pattern is formally defined by http://rfc.zeromq.org/spec:28. ZMQ_REQ ^^^^^^^ A socket of type 'ZMQ_REQ' is used by a _client_ to send requests to and receive replies from a _service_. This socket type allows only an alternating sequence of _zmq_send(request)_ and subsequent _zmq_recv(reply)_ calls. Each request sent is round-robined among all _services_, and each reply received is matched with the last issued request. For connection-oriented transports, If the ZMQ_IMMEDIATE option is set and there is no service available, then any send operation on the socket shall block until at least one _service_ becomes available. The REQ socket shall not discard messages. [horizontal] .Summary of ZMQ_REQ characteristics Compatible peer sockets:: 'ZMQ_REP', 'ZMQ_ROUTER' Direction:: Bidirectional Send/receive pattern:: Send, Receive, Send, Receive, ... Outgoing routing strategy:: Round-robin Incoming routing strategy:: Last peer Action in mute state:: Block ZMQ_REP ^^^^^^^ A socket of type 'ZMQ_REP' is used by a _service_ to receive requests from and send replies to a _client_. This socket type allows only an alternating sequence of _zmq_recv(request)_ and subsequent _zmq_send(reply)_ calls. Each request received is fair-queued from among all _clients_, and each reply sent is routed to the _client_ that issued the last request. If the original requester does not exist any more the reply is silently discarded. [horizontal] .Summary of ZMQ_REP characteristics Compatible peer sockets:: 'ZMQ_REQ', 'ZMQ_DEALER' Direction:: Bidirectional Send/receive pattern:: Receive, Send, Receive, Send, ... Incoming routing strategy:: Fair-queued Outgoing routing strategy:: Last peer ZMQ_DEALER ^^^^^^^^^^ A socket of type 'ZMQ_DEALER' is an advanced pattern used for extending request/reply sockets. Each message sent is round-robined among all connected peers, and each message received is fair-queued from all connected peers. When a 'ZMQ_DEALER' socket enters the 'mute' state due to having reached the high water mark for all peers, or, for connection-oriented transports, if the ZMQ_IMMEDIATE option is set and there are no peers at all, then any xref:zmq_send.adoc[zmq_send] operations on the socket shall block until the mute state ends or at least one peer becomes available for sending; messages are not discarded. When a 'ZMQ_DEALER' socket is connected to a 'ZMQ_REP' socket each message sent must consist of an empty message part, the _delimiter_, followed by one or more _body parts_. [horizontal] .Summary of ZMQ_DEALER characteristics Compatible peer sockets:: 'ZMQ_ROUTER', 'ZMQ_REP', 'ZMQ_DEALER' Direction:: Bidirectional Send/receive pattern:: Unrestricted Outgoing routing strategy:: Round-robin Incoming routing strategy:: Fair-queued Action in mute state:: Block ZMQ_ROUTER ^^^^^^^^^^ A socket of type 'ZMQ_ROUTER' is an advanced socket type used for extending request/reply sockets. When receiving messages a 'ZMQ_ROUTER' socket shall prepend a message part containing the _routing id_ of the originating peer to the message before passing it to the application. Messages received are fair-queued from among all connected peers. When sending messages a 'ZMQ_ROUTER' socket shall remove the first part of the message and use it to determine the _routing id _ of the peer the message shall be routed to. If the peer does not exist anymore, or has never existed, the message shall be silently discarded. However, if 'ZMQ_ROUTER_MANDATORY' socket option is set to '1', the socket shall fail with EHOSTUNREACH in both cases. When a 'ZMQ_ROUTER' socket enters the 'mute' state due to having reached the high water mark for all peers, then any messages sent to the socket shall be dropped until the mute state ends. Likewise, any messages routed to a peer for which the individual high water mark has been reached shall also be dropped. If, 'ZMQ_ROUTER_MANDATORY' is set to '1', the socket shall block or return EAGAIN in both cases. When a 'ZMQ_ROUTER' socket has 'ZMQ_ROUTER_MANDATORY' flag set to '1', the socket shall generate 'ZMQ_POLLIN' events upon reception of messages from one or more peers. Likewise, the socket shall generate 'ZMQ_POLLOUT' events when at least one message can be sent to one or more peers. When a 'ZMQ_REQ' socket is connected to a 'ZMQ_ROUTER' socket, in addition to the _routing id_ of the originating peer each message received shall contain an empty _delimiter_ message part. Hence, the entire structure of each received message as seen by the application becomes: one or more _routing id_ parts, _delimiter_ part, one or more _body parts_. When sending replies to a 'ZMQ_REQ' socket the application must include the _delimiter_ part. [horizontal] .Summary of ZMQ_ROUTER characteristics Compatible peer sockets:: 'ZMQ_DEALER', 'ZMQ_REQ', 'ZMQ_ROUTER' Direction:: Bidirectional Send/receive pattern:: Unrestricted Outgoing routing strategy:: See text Incoming routing strategy:: Fair-queued Action in mute state:: Drop (see text) == RETURN VALUE The _zmq_socket()_ function shall return an opaque handle to the newly created socket if successful. Otherwise, it shall return NULL and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The requested socket 'type' is invalid. *EFAULT*:: The provided 'context' is invalid. *EMFILE*:: The limit on the total number of open 0MQ sockets has been reached. *ETERM*:: The context specified was shutdown or terminated. == EXAMPLE .Creating a simple HTTP server using ZMQ_STREAM ---- void *ctx = zmq_ctx_new (); assert (ctx); /* Create ZMQ_STREAM socket */ void *socket = zmq_socket (ctx, ZMQ_STREAM); assert (socket); int rc = zmq_bind (socket, "tcp://*:8080"); assert (rc == 0); /* Data structure to hold the ZMQ_STREAM routing id */ uint8_t routing_id [256]; size_t routing_id_size = 256; /* Data structure to hold the ZMQ_STREAM received data */ uint8_t raw [256]; size_t raw_size = 256; while (1) { /* Get HTTP request; routing id frame and then request */ routing_id_size = zmq_recv (socket, routing_id, 256, 0); assert (routing_id_size > 0); do { raw_size = zmq_recv (socket, raw, 256, 0); assert (raw_size >= 0); } while (raw_size == 256); /* Prepares the response */ char http_response [] = "HTTP/1.0 200 OK\r\n" "Content-Type: text/plain\r\n" "\r\n" "Hello, World!"; /* Sends the routing id frame followed by the response */ zmq_send (socket, routing_id, routing_id_size, ZMQ_SNDMORE); zmq_send (socket, http_response, strlen (http_response), 0); /* Closes the connection by sending the routing id frame followed by a zero response */ zmq_send (socket, routing_id, routing_id_size, ZMQ_SNDMORE); zmq_send (socket, 0, 0, 0); } zmq_close (socket); zmq_ctx_destroy (ctx); ---- == SEE ALSO * xref:zmq_init.adoc[zmq_init] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_send.adoc[zmq_send] * xref:zmq_recv.adoc[zmq_recv] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_socket.adoc
AsciiDoc
gpl-3.0
29,707
= zmq_socket_monitor(3) == NAME zmq_socket_monitor - monitor socket events == SYNOPSIS *int zmq_socket_monitor (void '*socket', char '*endpoint', int 'events');* == DESCRIPTION The _zmq_socket_monitor()_ method lets an application thread track socket events (like connects) on a ZeroMQ socket. Each call to this method creates a 'ZMQ_PAIR' socket and binds that to the specified inproc:// 'endpoint'. To collect the socket events, you must create your own 'ZMQ_PAIR' socket, and connect that to the endpoint. Note that there is also a DRAFT function xref:zmq_socket_monitor_versioned.adoc[zmq_socket_monitor_versioned], which allows to subscribe to events that provide more information. Calling zmq_socket_monitor is equivalent to calling 'zmq_socket_monitor_versioned' with the 'event_version' parameter set to 1, with the exception of error cases. The 'events' argument is a bitmask of the socket events you wish to monitor, see 'Supported events' below. To monitor all events, use the event value ZMQ_EVENT_ALL. NOTE: as new events are added, the catch-all value will start returning them. An application that relies on a strict and fixed sequence of events must not use ZMQ_EVENT_ALL in order to guarantee compatibility with future versions. Each event is sent as two frames. The first frame contains an event number (16 bits), and an event value (32 bits) that provides additional data according to the event number. The second frame contains a string that specifies the affected endpoint. ---- The _zmq_socket_monitor()_ method supports only connection-oriented transports, that is, TCP, IPC, and TIPC. ---- Supported events ---------------- ZMQ_EVENT_CONNECTED ~~~~~~~~~~~~~~~~~~~ The socket has successfully connected to a remote peer. The event value is the file descriptor (FD) of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event. ZMQ_EVENT_CONNECT_DELAYED ~~~~~~~~~~~~~~~~~~~~~~~~~ A connect request on the socket is pending. The event value is unspecified. ZMQ_EVENT_CONNECT_RETRIED ~~~~~~~~~~~~~~~~~~~~~~~~~ A connect request failed, and is now being retried. The event value is the reconnect interval in milliseconds. Note that the reconnect interval is recalculated at each retry. ZMQ_EVENT_LISTENING ~~~~~~~~~~~~~~~~~~~ The socket was successfully bound to a network interface. The event value is the FD of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event. ZMQ_EVENT_BIND_FAILED ~~~~~~~~~~~~~~~~~~~~~ The socket could not bind to a given interface. The event value is the errno generated by the system bind call. ZMQ_EVENT_ACCEPTED ~~~~~~~~~~~~~~~~~~ The socket has accepted a connection from a remote peer. The event value is the FD of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event. ZMQ_EVENT_ACCEPT_FAILED ~~~~~~~~~~~~~~~~~~~~~~~ The socket has rejected a connection from a remote peer. The event value is the errno generated by the accept call. ZMQ_EVENT_CLOSED ~~~~~~~~~~~~~~~~ The socket was closed. The event value is the FD of the (now closed) network socket. ZMQ_EVENT_CLOSE_FAILED ~~~~~~~~~~~~~~~~~~~~~~ The socket close failed. The event value is the errno returned by the system call. Note that this event occurs only on IPC transports. ZMQ_EVENT_DISCONNECTED ~~~~~~~~~~~~~~~~~~~~~~ The socket was disconnected unexpectedly. The event value is the FD of the underlying network socket. Warning: this socket will be closed. ZMQ_EVENT_MONITOR_STOPPED ~~~~~~~~~~~~~~~~~~~~~~~~~ Monitoring on this socket ended. ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unspecified error during handshake. The event value is an errno. ZMQ_EVENT_HANDSHAKE_SUCCEEDED ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZMTP security mechanism handshake succeeded. The event value is unspecified. ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZMTP security mechanism handshake failed due to some mechanism protocol error, either between the ZMTP mechanism peers, or between the mechanism server and the ZAP handler. This indicates a configuration or implementation error in either peer resp. the ZAP handler. The event value is one of the ZMQ_PROTOCOL_ERROR_* values: ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA ZMQ_EVENT_HANDSHAKE_FAILED_AUTH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZMTP security mechanism handshake failed due to an authentication failure. The event value is the status code returned by the ZAP handler (i.e. 300, 400 or 500). == RETURN VALUE The _zmq_socket_monitor()_ function returns a value of 0 or greater if successful. Otherwise it returns `-1` and sets 'errno' to one of the values defined below. == ERRORS *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *EPROTONOSUPPORT*:: The requested 'transport' protocol is not supported. Monitor sockets are required to use the inproc:// transport. *EINVAL*:: The endpoint supplied is invalid. == EXAMPLE .Monitoring client and server sockets ---- // Read one event off the monitor socket; return value and address // by reference, if not null, and event number by value. Returns -1 // in case of error. static int get_monitor_event (void *monitor, int *value, char **address) { // First frame in message contains event number and value zmq_msg_t msg; zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (zmq_msg_more (&msg)); uint8_t *data = (uint8_t *) zmq_msg_data (&msg); uint16_t event = *(uint16_t *) (data); if (value) *value = *(uint32_t *) (data + 2); // Second frame in message contains event address zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (!zmq_msg_more (&msg)); if (address) { uint8_t *data = (uint8_t *) zmq_msg_data (&msg); size_t size = zmq_msg_size (&msg); *address = (char *) malloc (size + 1); memcpy (*address, data, size); (*address)[size] = 0; } return event; } int main (void) { void *ctx = zmq_ctx_new (); assert (ctx); // We'll monitor these two sockets void *client = zmq_socket (ctx, ZMQ_DEALER); assert (client); void *server = zmq_socket (ctx, ZMQ_DEALER); assert (server); // Socket monitoring only works over inproc:// int rc = zmq_socket_monitor (client, "tcp://127.0.0.1:9999", 0); assert (rc == -1); assert (zmq_errno () == EPROTONOSUPPORT); // Monitor all events on client and server sockets rc = zmq_socket_monitor (client, "inproc://monitor-client", ZMQ_EVENT_ALL); assert (rc == 0); rc = zmq_socket_monitor (server, "inproc://monitor-server", ZMQ_EVENT_ALL); assert (rc == 0); // Create two sockets for collecting monitor events void *client_mon = zmq_socket (ctx, ZMQ_PAIR); assert (client_mon); void *server_mon = zmq_socket (ctx, ZMQ_PAIR); assert (server_mon); // Connect these to the inproc endpoints so they'll get events rc = zmq_connect (client_mon, "inproc://monitor-client"); assert (rc == 0); rc = zmq_connect (server_mon, "inproc://monitor-server"); assert (rc == 0); // Now do a basic ping test rc = zmq_bind (server, "tcp://127.0.0.1:9998"); assert (rc == 0); rc = zmq_connect (client, "tcp://127.0.0.1:9998"); assert (rc == 0); bounce (client, server); // Close client and server close_zero_linger (client); close_zero_linger (server); // Now collect and check events from both sockets int event = get_monitor_event (client_mon, NULL, NULL); if (event == ZMQ_EVENT_CONNECT_DELAYED) event = get_monitor_event (client_mon, NULL, NULL); assert (event == ZMQ_EVENT_CONNECTED); event = get_monitor_event (client_mon, NULL, NULL); assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEEDED); event = get_monitor_event (client_mon, NULL, NULL); assert (event == ZMQ_EVENT_MONITOR_STOPPED); // This is the flow of server events event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_LISTENING); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_ACCEPTED); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_HANDSHAKE_SUCCEEDED); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_CLOSED); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_MONITOR_STOPPED); // Close down the sockets close_zero_linger (client_mon); close_zero_linger (server_mon); zmq_ctx_term (ctx); return 0 ; } ---- == SEE ALSO * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_socket_monitor.adoc
AsciiDoc
gpl-3.0
9,945
= zmq_socket_monitor_versioned(3) == NAME zmq_socket_monitor_versioned - monitor socket events == SYNOPSIS *int zmq_socket_monitor_versioned (void '*socket', char '*endpoint', uint64_t 'events', int 'event_version', int 'type');* *int zmq_socket_monitor_pipes_stats (void '*socket');* == DESCRIPTION The _zmq_socket_monitor_versioned()_ method lets an application thread track socket events (like connects) on a ZeroMQ socket. Each call to this method creates a 'ZMQ_PAIR' socket and binds that to the specified inproc:// 'endpoint'. To collect the socket events, you must create your own 'ZMQ_PAIR' socket, and connect that to the endpoint. The 'events' argument is a bitmask of the socket events you wish to monitor, see 'Supported events' below. To monitor all events for a version, use the event value ZMQ_EVENT_ALL_V<version>, e.g. ZMQ_EVENT_ALL_V1. For non-DRAFT event versions, this value will not change in the future, so new event types will only be added in new versions (note that this is a change over zmq_socket_monitor and the unversioned ZMQ_EVENT_ALL). Note that event_version 2 is currently in DRAFT mode. The protocol may be changed at any time for event_versions in DRAFT. ZMQ_CURRENT_EVENT_VERSION and ZMQ_CURRENT_EVENT_VERSION_DRAFT are always defined to the most recent stable or DRAFT event version, which are currently 1 resp. 2 This page describes the protocol for 'event_version' 2 only. For the protocol used with 'event_version' 1, please refer to xref:zmq_socket_monitor.adoc[zmq_socket_monitor] Each event is sent in multiple frames. The first frame contains an event number (64 bits). The number and content of further frames depend on this event number. Unless it is specified differently, the second frame contains the number of value frames that will follow it as a 64 bits integer. The third frame to N-th frames contain an event value (64 bits) that provides additional data according to the event number. Each event type might have a different number of values. The second-to-last and last frames contain strings that specifies the affected connection or endpoint. The former frame contains a string denoting the local endpoint, while the latter frame contains a string denoting the remote endpoint. Either of these may be empty, depending on the event type and whether the connection uses a bound or connected local endpoint. Note that the format of the second and further frames, and also the number of frames, may be different for events added in the future. The 'type' argument is used to specify the type of the monitoring socket. Supported types are 'ZMQ_PAIR', 'ZMQ_PUB' and 'ZMQ_PUSH'. Note that consumers of the events will have to be compatible with the socket type, for instance a monitoring socket of type 'ZMQ_PUB' will require consumers of type 'ZMQ_SUB'. In the case that the monitoring socket type is of 'ZMQ_PUB', the multipart message topic is the event number, thus consumers should subscribe to the events they want to receive. The _zmq_socket_monitor_pipes_stats()_ method triggers an event of type ZMQ_EVENT_PIPES_STATS for each connected peer of the monitored socket. NOTE: _zmq_socket_monitor_pipes_stats()_ is in DRAFT state. ---- Monitoring events are only generated by some transports: At the moment these are SOCKS, TCP, IPC, and TIPC. Note that it is not an error to call 'zmq_socket_monitor_versioned' on a socket that is connected or bound to some other transport, as this may not be known at the time 'zmq_socket_monitor_versioned' is called. Also, a socket can be connected/bound to multiple endpoints using different transports. ---- Supported events (v1) ---------------- ZMQ_EVENT_CONNECTED ~~~~~~~~~~~~~~~~~~~ The socket has successfully connected to a remote peer. The event value is the file descriptor (FD) of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event. ZMQ_EVENT_CONNECT_DELAYED ~~~~~~~~~~~~~~~~~~~~~~~~~ A connect request on the socket is pending. The event value is unspecified. ZMQ_EVENT_CONNECT_RETRIED ~~~~~~~~~~~~~~~~~~~~~~~~~ A connect request failed, and is now being retried. The event value is the reconnect interval in milliseconds. Note that the reconnect interval is recalculated for each retry. ZMQ_EVENT_LISTENING ~~~~~~~~~~~~~~~~~~~ The socket was successfully bound to a network interface. The event value is the FD of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event. ZMQ_EVENT_BIND_FAILED ~~~~~~~~~~~~~~~~~~~~~ The socket could not bind to a given interface. The event value is the errno generated by the system bind call. ZMQ_EVENT_ACCEPTED ~~~~~~~~~~~~~~~~~~ The socket has accepted a connection from a remote peer. The event value is the FD of the underlying network socket. Warning: there is no guarantee that the FD is still valid by the time your code receives this event. ZMQ_EVENT_ACCEPT_FAILED ~~~~~~~~~~~~~~~~~~~~~~~ The socket has rejected a connection from a remote peer. The event value is the errno generated by the accept call. ZMQ_EVENT_CLOSED ~~~~~~~~~~~~~~~~ The socket was closed. The event value is the FD of the (now closed) network socket. ZMQ_EVENT_CLOSE_FAILED ~~~~~~~~~~~~~~~~~~~~~~ The socket close failed. The event value is the errno returned by the system call. Note that this event occurs only on IPC transports. ZMQ_EVENT_DISCONNECTED ~~~~~~~~~~~~~~~~~~~~~~ The socket was disconnected unexpectedly. The event value is the FD of the underlying network socket. Warning: this socket will be closed. ZMQ_EVENT_MONITOR_STOPPED ~~~~~~~~~~~~~~~~~~~~~~~~~ Monitoring on this socket ended. ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Unspecified error during handshake. The event value is an errno. ZMQ_EVENT_HANDSHAKE_SUCCEEDED ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZMTP security mechanism handshake succeeded. The event value is unspecified. ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZMTP security mechanism handshake failed due to some mechanism protocol error, either between the ZMTP mechanism peers, or between the mechanism server and the ZAP handler. This indicates a configuration or implementation error in either peer resp. the ZAP handler. The event value is one of the ZMQ_PROTOCOL_ERROR_* values: ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA ZMQ_EVENT_HANDSHAKE_FAILED_AUTH ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ The ZMTP security mechanism handshake failed due to an authentication failure. The event value is the status code returned by the ZAP handler (i.e. 300, 400 or 500). ---- Supported events (v2) ---------------- ZMQ_EVENT_PIPES_STATS ~~~~~~~~~~~~~~~~~~~~~ This event provides two values, the number of messages in each of the two queues associated with the returned endpoint (respectively egress and ingress). This event only triggers after calling the function _zmq_socket_monitor_pipes_stats()_. NOTE: this measurement is asynchronous, so by the time the message is received the internal state might have already changed. NOTE: when the monitored socket and the monitor are not used in a poll, the event might not be delivered until an API has been called on the monitored socket, like zmq_getsockopt for example (the option is irrelevant). NOTE: in DRAFT state, not yet available in stable releases. == RETURN VALUE The _zmq_socket_monitor()_ and _zmq_socket_monitor_pipes_stats()_ functions return a value of 0 or greater if successful. Otherwise they return `-1` and set 'errno' to one of the values defined below. ERRORS - _zmq_socket_monitor()_ ------------------------------- *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *EPROTONOSUPPORT*:: The transport protocol of the monitor 'endpoint' is not supported. Monitor sockets are required to use the inproc:// transport. *EINVAL*:: The monitor 'endpoint' supplied does not exist or the specified socket 'type' is not supported. ERRORS - _zmq_socket_monitor_pipes_stats()_ ------------------------------------------- *ENOTSOCK*:: The 'socket' parameter was not a valid 0MQ socket. *EINVAL*:: The socket did not have monitoring enabled. *EAGAIN*:: The monitored socket did not have any connections to monitor yet. == EXAMPLE .Monitoring client and server sockets ---- // Read one event off the monitor socket; return values and addresses // by reference, if not null, and event number by value. Returns -1 // in case of error. static uint64_t get_monitor_event (void *monitor, uint64_t **value, char **local_address, char **remote_address) { // First frame in message contains event number zmq_msg_t msg; zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (zmq_msg_more (&msg)); uint64_t event; memcpy (&event, zmq_msg_data (&msg), sizeof (event)); zmq_msg_close (&msg); // Second frame in message contains the number of values zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (zmq_msg_more (&msg)); uint64_t value_count; memcpy (&value_count, zmq_msg_data (&msg), sizeof (value_count)); zmq_msg_close (&msg); if (value) { *value = (uint64_t *) malloc (value_count * sizeof (uint64_t)); assert (*value); } for (uint64_t i = 0; i < value_count; ++i) { // Subsequent frames in message contain event values zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (zmq_msg_more (&msg)); if (value && *value) memcpy (&(*value)[i], zmq_msg_data (&msg), sizeof (uint64_t)); zmq_msg_close (&msg); } // Second-to-last frame in message contains local address zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (zmq_msg_more (&msg)); if (local_address_) { uint8_t *data = (uint8_t *) zmq_msg_data (&msg); size_t size = zmq_msg_size (&msg); *local_address_ = (char *) malloc (size + 1); memcpy (*local_address_, data, size); (*local_address_)[size] = 0; } zmq_msg_close (&msg); // Last frame in message contains remote address zmq_msg_init (&msg); if (zmq_msg_recv (&msg, monitor, 0) == -1) return -1; // Interrupted, presumably assert (!zmq_msg_more (&msg)); if (remote_address_) { uint8_t *data = (uint8_t *) zmq_msg_data (&msg); size_t size = zmq_msg_size (&msg); *remote_address_ = (char *) malloc (size + 1); memcpy (*remote_address_, data, size); (*remote_address_)[size] = 0; } zmq_msg_close (&msg); return event; } int main (void) { void *ctx = zmq_ctx_new (); assert (ctx); // We'll monitor these two sockets void *client = zmq_socket (ctx, ZMQ_DEALER); assert (client); void *server = zmq_socket (ctx, ZMQ_DEALER); assert (server); // Socket monitoring only works over inproc:// int rc = zmq_socket_monitor_versioned (client, "tcp://127.0.0.1:9999", 0, 2); assert (rc == -1); assert (zmq_errno () == EPROTONOSUPPORT); // Monitor all events on client and server sockets rc = zmq_socket_monitor_versioned (client, "inproc://monitor-client", ZMQ_EVENT_ALL, 2); assert (rc == 0); rc = zmq_socket_monitor_versioned (server, "inproc://monitor-server", ZMQ_EVENT_ALL, 2); assert (rc == 0); // Create two sockets for collecting monitor events void *client_mon = zmq_socket (ctx, ZMQ_PAIR); assert (client_mon); void *server_mon = zmq_socket (ctx, ZMQ_PAIR); assert (server_mon); // Connect these to the inproc endpoints so they'll get events rc = zmq_connect (client_mon, "inproc://monitor-client"); assert (rc == 0); rc = zmq_connect (server_mon, "inproc://monitor-server"); assert (rc == 0); // Now do a basic ping test rc = zmq_bind (server, "tcp://127.0.0.1:9998"); assert (rc == 0); rc = zmq_connect (client, "tcp://127.0.0.1:9998"); assert (rc == 0); bounce (client, server); // Close client and server close_zero_linger (client); close_zero_linger (server); // Now collect and check events from both sockets int event = get_monitor_event (client_mon, NULL, NULL); if (event == ZMQ_EVENT_CONNECT_DELAYED) event = get_monitor_event (client_mon, NULL, NULL); assert (event == ZMQ_EVENT_CONNECTED); event = get_monitor_event (client_mon, NULL, NULL); assert (event == ZMQ_EVENT_MONITOR_STOPPED); // This is the flow of server events event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_LISTENING); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_ACCEPTED); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_CLOSED); event = get_monitor_event (server_mon, NULL, NULL); assert (event == ZMQ_EVENT_MONITOR_STOPPED); // Close down the sockets close_zero_linger (client_mon); close_zero_linger (server_mon); zmq_ctx_term (ctx); return 0 ; } ---- == SEE ALSO * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_socket_monitor_versioned.adoc
AsciiDoc
gpl-3.0
14,445
= zmq_strerror(3) == NAME zmq_strerror - get 0MQ error message string == SYNOPSIS *const char *zmq_strerror (int 'errnum');* == DESCRIPTION The _zmq_strerror()_ function shall return a pointer to an error message string corresponding to the error number specified by the 'errnum' argument. As 0MQ defines additional error numbers over and above those defined by the operating system, applications should use _zmq_strerror()_ in preference to the standard _strerror()_ function. == RETURN VALUE The _zmq_strerror()_ function shall return a pointer to an error message string. == ERRORS No errors are defined. == EXAMPLE .Displaying an error message when a 0MQ context cannot be initialised ---- void *ctx = zmq_init (1, 1, 0); if (!ctx) { printf ("Error occurred during zmq_init(): %s\n", zmq_strerror (errno)); abort (); } ---- == SEE ALSO * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_strerror.adoc
AsciiDoc
gpl-3.0
1,042
= zmq_tcp(7) == NAME zmq_tcp - 0MQ unicast transport using TCP == SYNOPSIS TCP is an ubiquitous, reliable, unicast transport. When connecting distributed applications over a network with 0MQ, using the TCP transport will likely be your first choice. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the TCP transport, the transport is `tcp`, and the meaning of the 'address' part is defined below. Assigning a local address to a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When assigning a local address to a socket using _zmq_bind()_ with the 'tcp' transport, the 'endpoint' shall be interpreted as an 'interface' followed by a colon and the TCP port number to use. An 'interface' may be specified by either of the following: * The wild-card `*`, meaning all available interfaces. * The primary IPv4 or IPv6 address assigned to the interface, in its numeric representation. * The non-portable interface name as defined by the operating system. The TCP port number may be specified by: * A numeric value, usually above 1024 on POSIX systems. * The wild-card `*`, meaning a system-assigned ephemeral port. When using ephemeral ports, the caller should retrieve the actual assigned port using the ZMQ_LAST_ENDPOINT socket option. See xref:zmq_getsockopt.adoc[zmq_getsockopt] for details. Unbinding wild-card address from a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When wild-card `*` 'endpoint' was used in _zmq_bind()_, the caller should use real 'endpoint' obtained from the ZMQ_LAST_ENDPOINT socket option to unbind this 'endpoint' from a socket using _zmq_unbind()_. Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a socket to a peer address using _zmq_connect()_ with the 'tcp' transport, the 'endpoint' shall be interpreted as a 'peer address' followed by a colon and the TCP port number to use. You can optionally specify a 'source_endpoint' which will be used as the source address for your connection; tcp://'source_endpoint';'endpoint', see the 'interface' description above for details. A 'peer address' may be specified by either of the following: * The DNS name of the peer. * The IPv4 or IPv6 address of the peer, in its numeric representation. Note: A description of the ZeroMQ Message Transport Protocol (ZMTP) which is used by the TCP transport can be found at <http://rfc.zeromq.org/spec:23> == HWM For the TCP transport, the high water mark (HWM) mechanism works in conjunction with the TCP socket buffers handled at OS level. Depending on the OS and several other factors the size of such TCP buffers will be different. Moreover TCP buffers provided by the OS will accommodate a varying number of messages depending on the size of messages (unlike ZMQ HWM settings the TCP socket buffers are measured in bytes and not messages). This may result in apparently inexplicable behaviors: e.g., you may expect that setting ZMQ_SNDHWM to 100 on a socket using TCP transport will have the effect of blocking the transmission of the 101-th message if the receiver is slow. This is very unlikely when using TCP transport since OS TCP buffers will typically provide enough buffering to allow you sending much more than 100 messages. Of course if the receiver is slow, transmitting on a TCP ZMQ socket will eventually trigger the "mute state" of the socket; simply don't rely on the exact HWM value. Obviously the same considerations apply for the receive HWM (see ZMQ_RCVHWM). == EXAMPLES .Assigning a local address to a socket ---- // TCP port 5555 on all available interfaces rc = zmq_bind(socket, "tcp://*:5555"); assert (rc == 0); // TCP port 5555 on the local loop-back interface on all platforms rc = zmq_bind(socket, "tcp://127.0.0.1:5555"); assert (rc == 0); // TCP port 5555 on the first Ethernet network interface on Linux rc = zmq_bind(socket, "tcp://eth0:5555"); assert (rc == 0); ---- .Connecting a socket ---- // Connecting using an IP address rc = zmq_connect(socket, "tcp://192.168.1.1:5555"); assert (rc == 0); // Connecting using a DNS name rc = zmq_connect(socket, "tcp://server1:5555"); assert (rc == 0); // Connecting using a DNS name and bind to eth1 rc = zmq_connect(socket, "tcp://eth1:0;server1:5555"); assert (rc == 0); // Connecting using a IP address and bind to an IP address rc = zmq_connect(socket, "tcp://192.168.1.17:5555;192.168.1.1:5555"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_pgm.adoc[zmq_pgm] * xref:zmq_ipc.adoc[zmq_ipc] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_tcp.adoc
AsciiDoc
gpl-3.0
4,928
= zmq_timers(3) == NAME zmq_timers - helper functions for cross-platform timers callbacks == SYNOPSIS *typedef void(zmq_timer_fn) (int 'timer_id', void *'arg');* *void *zmq_timers_new (void);* *int zmq_timers_destroy (void **'timers_p');* *int zmq_timers_add (void *'timers', size_t 'interval', zmq_timer_fn 'handler', void *'arg');* *int zmq_timers_cancel (void *'timers', int 'timer_id');* *int zmq_timers_set_interval (void *'timers', int 'timer_id', size_t 'interval');* *int zmq_timers_reset (void *'timers', int 'timer_id');* *long zmq_timers_timeout (void *'timers');* *int zmq_timers_execute (void *'timers');* == DESCRIPTION The _zmq_timers_*_ functions provide cross-platform access to timers callbacks. Once a timer has been registered, it will repeat at the specified interval until it gets manually cancelled. To run the callbacks, _zmq_timers_execute_ must be ran. _zmq_timers_new_ and _zmq_timers_destroy_ manage the lifetime of a timer instance. _zmq_timers_new_ creates and returns a new timer instance, while _zmq_timers_destroy_ destroys it. A pointer to a valid timer must be passed as the _timers_p_ argument of _zmq_timers_destroy_. In particular, _zmq_timers_destroy_ may not be called multiple times for the same timer instance. _zmq_timers_destroy_ sets the passed pointer to NULL in case of a successful execution. _zmq_timers_add_ and _zmq_timers_cancel_ manage the timers registered. _zmq_timers_add_ registers a new _timer_ with a given instance. _timers_ must point to a valid _timers_ object. The _interval_ parameter specifies the expiration of the timer in milliseconds. _handler_ and _arg_ specify the callback that will be invoked on expiration and the optional parameter that will be passed through. The callback must be a valid function implementing the _zmq_timer_fn_ prototype. An ID will be returned that can be used to modify or cancel the timer. _zmq_timers_cancel_ will cancel the timer associated with _timer_id_ from the instance _timers_. _zmq_timers_set_interval_ will set the expiration of the timer associated with _timer_id_ from the instance _timers_ to _interval_ milliseconds into the future. _zmq_timers_reset_ will restart the timer associated with _timer_id_ from the instance _timers_. _zmq_timers_timeout_ will return the time left in milliseconds until the next timer registered with _timers_ expires. _zmq_timers_execute_ will run callbacks of all expired timers from the instance _timers_. == THREAD SAFETY Like most other 0MQ objects, timers are not thread-safe. All operations must be called from the same thread. Otherwise, behaviour is undefined. == RETURN VALUE _zmq_timers_new_ always returns a valid pointer to a poller. All functions that return an int, return -1 in case of a failure. In that case, zmq_errno() can be used to query the type of the error as described below. _zmq_timers_timeout_ returns the time left in milliseconds until the next timer registered with _timers_ expires, or -1 if there are no timers left. All other functions return 0 in case of a successful execution. == ERRORS On _zmq_timers_destroy_, _zmq_poller_cancel_, _zmq_timers_set_interval_, _zmq_timers_reset_, zmq_timers_timeout_, and _zmq_timers_execute_: *EFAULT*:: _timers_ did not point to a valid timer. Note that passing an invalid pointer (e.g. pointer to deallocated memory) may cause undefined behaviour (e.g. an access violation). On _zmq_timers_add_: *EFAULT*:: _timers_ did not point to a valid timer or _handler_ did not point to a valid function. On _zmq_poller_cancel_, _zmq_timers_set_interval_ and zmq_timers_timeout_: *EINVAL*:: _timer_id_ did not exist or was already cancelled. == EXAMPLE .Add one timer with a simple callback that changes a boolean. ---- void handler (int timer_id_, void *arg_) { (void) timer_id_; // Stop 'unused' compiler warnings *((bool *) arg_) = true; } ... void *timers = zmq_timers_new (); assert (timers); bool timer_invoked = false; const unsigned long full_timeout = 100; int timer_id = zmq_timers_add (timers, full_timeout, handler, &timer_invoked); assert (timer_id); // Timer should not have been invoked yet int rc = zmq_timers_execute (timers); assert (rc == 0); // Wait half the time and check again long timeout = zmq_timers_timeout (timers); assert (rc != -1); msleep (timeout / 2); rc = zmq_timers_execute (timers); assert (rc == 0); // Wait until the end rc = msleep (zmq_timers_timeout (timers)); assert (rc == 0); // The handler will be executed rc = zmq_timers_execute (timers); assert (rc == 0); assert (timer_invoked); rc = zmq_timers_destroy (&timers); assert (rc == 0); ---- == SEE ALSO * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_timers.adoc
AsciiDoc
gpl-3.0
4,968
= zmq_tipc(7) == NAME zmq_tipc - 0MQ unicast transport using TIPC == SYNOPSIS TIPC is a cluster IPC protocol with a location transparent addressing scheme. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the TIPC transport, the transport is `tipc`, and the meaning of the 'address' part is defined below. Assigning a port name to a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When assigning a port name to a socket using _zmq_bind()_ with the 'tipc' transport, the 'endpoint' is defined in the form: {type, lower, upper} * Type is the numerical (u32) ID of your service. * Lower and Upper specify a range for your service. Publishing the same service with overlapping lower/upper ID's will cause connection requests to be distributed over these in a round-robin manner. Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a socket to a peer address using _zmq_connect()_ with the 'tipc' transport, the 'endpoint' shall be interpreted as a service ID, followed by a comma and the instance ID. The instance ID must be within the lower/upper range of a published port name for the endpoint to be valid. == EXAMPLES .Assigning a local address to a socket ---- // Publish TIPC service ID 5555 rc = zmq_bind(socket, "tipc://{5555,0,0}"); assert (rc == 0); // Publish TIPC service ID 5555 with a service range of 0-100 rc = zmq_bind(socket, "tipc://{5555,0,100}"); assert (rc == 0); ---- .Connecting a socket ---- // Connect to service 5555 instance id 50 rc = zmq_connect(socket, "tipc://{5555,50}"); assert (rc == 0); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_tcp.adoc[zmq_tcp] * xref:zmq_pgm.adoc[zmq_pgm] * xref:zmq_ipc.adoc[zmq_ipc] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_tipc.adoc
AsciiDoc
gpl-3.0
2,137
= zmq_udp(7) == NAME zmq_udp - 0MQ UDP multicast and unicast transport == SYNOPSIS UDP is unreliable protocol transport of data over IP networks. UDP support both unicast and multicast communication. == DESCRIPTION UDP transport can only be used with the 'ZMQ_RADIO' and 'ZMQ_DISH' socket types. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the UDP transport, the transport is `udp`. The meaning of the 'address' part is defined below. Binding a socket ---------------- With 'udp' we can only bind the 'ZMQ_DISH' socket type. When binding a socket using _zmq_bind()_ with the 'udp' transport the 'endpoint' shall be interpreted as an 'interface' followed by a colon and the UDP port number to use. An 'interface' may be specified by either of the following: * The wild-card `*`, meaning all available interfaces. * The name of the network interface (i.e. eth0, lo, wlan0 etc...) * The primary address assigned to the interface, in its numeric representation. * Multicast address in its numeric representation the socket should join. The UDP port number may be specified a numeric value, usually above 1024 on POSIX systems. Connecting a socket ------------------- With 'udp' we can only connect the 'ZMQ_RADIO' socket type. When connecting a socket to a peer address using _zmq_connect()_ with the 'udp' transport, the 'endpoint' shall be interpreted as a 'peer address' followed by a colon and the UDP port number to use. A 'peer address' may be specified by either of the following: * The IPv4 or IPv6 address of the peer, in its numeric representation or using its hostname. * Multicast address in its numeric representation. == EXAMPLES .Binding a socket ---- // Unicast - UDP port 5555 on all available interfaces rc = zmq_bind(dish, "udp://*:5555"); assert (rc == 0); // Unicast - UDP port 5555 on the local loop-back interface rc = zmq_bind(dish, "udp://127.0.0.1:5555"); assert (rc == 0); // Unicast - UDP port 5555 on interface eth1 rc = zmq_bind(dish, "udp://eth1:5555"); assert (rc == 0); // Multicast - UDP port 5555 on a Multicast address rc = zmq_bind(dish, "udp://239.0.0.1:5555"); assert (rc == 0); // Same as above but joining only on interface eth0 rc = zmq_bind(dish, "udp://eth0;239.0.0.1:5555"); assert (rc == 0); // Same as above using IPv6 multicast rc = zmq_bind(dish, "udp://eth0;[ff02::1]:5555"); assert (rc == 0); ---- .Connecting a socket ---- // Connecting using an Unicast IP address rc = zmq_connect(radio, "udp://192.168.1.1:5555"); assert (rc == 0); // Connecting using a Multicast address rc = zmq_connect(socket, "udp://239.0.0.1:5555); assert (rc == 0); // Connecting using a Multicast address using local interface wlan0 rc = zmq_connect(socket, "udp://wlan0;239.0.0.1:5555); assert (rc == 0); // Connecting to IPv6 multicast rc = zmq_connect(socket, "udp://[ff02::1]:5555); assert (rc == 0); ---- == SEE ALSO * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_setsockopt.adoc[zmq_setsockopt] * xref:zmq_tcp.adoc[zmq_tcp] * xref:zmq_ipc.adoc[zmq_ipc] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_udp.adoc
AsciiDoc
gpl-3.0
3,449
= zmq_unbind(3) == NAME zmq_unbind - Stop accepting connections on a socket == SYNOPSIS int zmq_unbind (void '*socket', const char '*endpoint'); == DESCRIPTION The _zmq_unbind()_ function shall unbind a socket specified by the 'socket' argument from the endpoint specified by the 'endpoint' argument. Additionally the incoming message queue associated with the endpoint will be discarded. This means that after unbinding an endpoint it is possible to received messages originating from that same endpoint if they were already present in the incoming message queue before unbinding. The 'endpoint' argument is as described in xref:zmq_bind.adoc[zmq_bind] Unbinding wild-card address from a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When wild-card `*` 'endpoint' (described in xref:zmq_tcp.adoc[zmq_tcp], xref:zmq_ipc.adoc[zmq_ipc], xref:zmq_udp.adoc[zmq_udp] and xref:zmq_vmci.adoc[zmq_vmci]) was used in _zmq_bind()_, the caller should use real 'endpoint' obtained from the ZMQ_LAST_ENDPOINT socket option to unbind this 'endpoint' from a socket. == RETURN VALUE The _zmq_unbind()_ function shall return zero if successful. Otherwise it shall return `-1` and set 'errno' to one of the values defined below. == ERRORS *EINVAL*:: The endpoint supplied is invalid. *ETERM*:: The 0MQ 'context' associated with the specified 'socket' was terminated. *ENOTSOCK*:: The provided 'socket' was invalid. *ENOENT*:: The endpoint supplied was not previously bound. == EXAMPLES .Unbind a subscriber socket from a TCP transport ---- /* Create a ZMQ_SUB socket */ void *socket = zmq_socket (context, ZMQ_SUB); assert (socket); /* Connect it to the host server001, port 5555 using a TCP transport */ rc = zmq_bind (socket, "tcp://127.0.0.1:5555"); assert (rc == 0); /* Disconnect from the previously connected endpoint */ rc = zmq_unbind (socket, "tcp://127.0.0.1:5555"); assert (rc == 0); ---- .Unbind wild-card `*` binded socket ---- /* Create a ZMQ_SUB socket */ void *socket = zmq_socket (context, ZMQ_SUB); assert (socket); /* Bind it to the system-assigned ephemeral port using a TCP transport */ rc = zmq_bind (socket, "tcp://127.0.0.1:*"); assert (rc == 0); /* Obtain real endpoint */ const size_t buf_size = 32; char buf[buf_size]; rc = zmq_getsockopt (socket, ZMQ_LAST_ENDPOINT, buf, (size_t *)&buf_size); assert (rc == 0); /* Unbind socket by real endpoint */ rc = zmq_unbind (socket, buf); assert (rc == 0); ---- == NOTE Note that while the implementation is similar to _zmq_disconnect()_, the semantics are different and the two functions should not be used interchangeably. Bound sockets should be unbound, and connected sockets should be disconnected. == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_socket.adoc[zmq_socket] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_unbind.adoc
AsciiDoc
gpl-3.0
2,933
= zmq_version(3) == NAME zmq_version - report 0MQ library version == SYNOPSIS *void zmq_version (int '*major', int '*minor', int '*patch');* == DESCRIPTION The _zmq_version()_ function shall fill in the integer variables pointed to by the 'major', 'minor' and 'patch' arguments with the major, minor and patch level components of the 0MQ library version. This functionality is intended for applications or language bindings dynamically linking to the 0MQ library that wish to determine the actual version of the 0MQ library they are using. == RETURN VALUE There is no return value. == ERRORS No errors are defined. == EXAMPLE .Printing out the version of the 0MQ library ---- int major, minor, patch; zmq_version (&major, &minor, &patch); printf ("Current 0MQ version is %d.%d.%d\n", major, minor, patch); ---- == SEE ALSO * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_version.adoc
AsciiDoc
gpl-3.0
1,017
= zmq_vmci(7) == NAME zmq_vmci - 0MQ transport over virtual machine communicatios interface (VMCI) sockets == SYNOPSIS The VMCI transport passes messages between VMware virtual machines running on the same host, between virtual machine and the host and within virtual machines (inter-process transport like ipc). NOTE: Communication between a virtual machine and the host is not supported on Mac OS X 10.9 and above. == ADDRESSING A 0MQ endpoint is a string consisting of a 'transport'`://` followed by an 'address'. The 'transport' specifies the underlying protocol to use. The 'address' specifies the transport-specific address to connect to. For the VMCI transport, the transport is `vmci`, and the meaning of the 'address' part is defined below. Binding a socket ~~~~~~~~~~~~~~~~ When binding a 'socket' to a local address using _zmq_bind()_ with the 'vmci' transport, the 'endpoint' shall be interpreted as an 'interface' followed by a colon and the TCP port number to use. An 'interface' may be specified by either of the following: * The wild-card `*`, meaning all available interfaces. * An integer returned by `VMCISock_GetLocalCID` or `@` (ZeroMQ will call VMCISock_GetLocalCID internally). The port may be specified by: * A numeric value, usually above 1024 on POSIX systems. * The wild-card `*`, meaning a system-assigned ephemeral port. Unbinding wild-card address from a socket ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ When wild-card `*` 'endpoint' was used in _zmq_bind()_, the caller should use real 'endpoint' obtained from the ZMQ_LAST_ENDPOINT socket option to unbind this 'endpoint' from a socket using _zmq_unbind()_. Connecting a socket ~~~~~~~~~~~~~~~~~~~ When connecting a socket to a peer address using _zmq_connect()_ with the 'vmci' transport, the 'endpoint' shall be interpreted as a 'peer address' followed by a colon and the port number to use. A 'peer address' must be a CID of the peer. == EXAMPLES .Assigning a local address to a socket ---- // VMCI port 5555 on all available interfaces rc = zmq_bind(socket, "vmci://*:5555"); assert (rc == 0); // VMCI port 5555 on the local loop-back interface on all platforms cid = VMCISock_GetLocalCID(); sprintf(endpoint, "vmci://%d:5555", cid); rc = zmq_bind(socket, endpoint); assert (rc == 0); ---- .Connecting a socket ---- // Connecting using a CID sprintf(endpoint, "vmci://%d:5555", cid); rc = zmq_connect(socket, endpoint); assert (rc == 0); ---- == SEE ALSO * xref:zmq_bind.adoc[zmq_bind] * xref:zmq_connect.adoc[zmq_connect] * xref:zmq_inproc.adoc[zmq_inproc] * xref:zmq_tcp.adoc[zmq_tcp] * xref:zmq_pgm.adoc[zmq_pgm] * xref:zmq_vmci.adoc[zmq_vmci] * xref:zmq_getsockopt.adoc[zmq_getsockopt] * xref:zmq.adoc[zmq] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_vmci.adoc
AsciiDoc
gpl-3.0
2,879
= zmq_z85_decode(3) == NAME zmq_z85_decode - decode a binary key from Z85 printable text == SYNOPSIS *uint8_t *zmq_z85_decode (uint8_t *dest, const char *string);* == DESCRIPTION The _zmq_z85_decode()_ function shall decode 'string' into 'dest'. The length of 'string' shall be divisible by 5. 'dest' must be large enough for the decoded value (0.8 x strlen (string)). The encoding shall follow the ZMQ RFC 32 specification. == RETURN VALUE The _zmq_z85_decode()_ function shall return 'dest' if successful, else it shall return NULL. == EXAMPLE .Decoding a CURVE key ---- const char decoded [] = "rq:rM>}U?@Lns47E1%kR.o@n%FcmmsL/@{H8]yf7"; uint8_t public_key [32]; zmq_z85_decode (public_key, decoded); ---- == SEE ALSO * xref:zmq_z85_encode.adoc[zmq_z85_encode] * xref:zmq_curve_keypair.adoc[zmq_curve_keypair] * xref:zmq_curve_public.adoc[zmq_curve_public] * xref:zmq_curve.adoc[zmq_curve] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_z85_decode.adoc
AsciiDoc
gpl-3.0
1,065
= zmq_z85_encode(3) == NAME zmq_z85_encode - encode a binary key as Z85 printable text == SYNOPSIS *char *zmq_z85_encode (char *dest, const uint8_t *data, size_t size);* == DESCRIPTION The _zmq_z85_encode()_ function shall encode the binary block specified by 'data' and 'size' into a string in 'dest'. The size of the binary block must be divisible by 4. The 'dest' must have sufficient space for size * 1.25 plus 1 for a null terminator. A 32-byte CURVE key is encoded as 40 ASCII characters plus a null terminator. The encoding shall follow the ZMQ RFC 32 specification. == RETURN VALUE The _zmq_z85_encode()_ function shall return 'dest' if successful, else it shall return NULL. == EXAMPLE .Encoding a CURVE key ---- #include <sodium.h> uint8_t public_key [32]; uint8_t secret_key [32]; int rc = crypto_box_keypair (public_key, secret_key); assert (rc == 0); char encoded [41]; zmq_z85_encode (encoded, public_key, 32); puts (encoded); ---- == SEE ALSO * xref:zmq_z85_decode.adoc[zmq_z85_decode] * xref:zmq_curve_keypair.adoc[zmq_curve_keypair] * xref:zmq_curve_public.adoc[zmq_curve_public] * xref:zmq_curve.adoc[zmq_curve] == AUTHORS This page was written by the 0MQ community. To make a change please read the 0MQ Contribution Policy at <https://zeromq.org/how-to-contribute/>.
sophomore_public/libzmq
doc/zmq_z85_encode.adoc
AsciiDoc
gpl-3.0
1,304
/* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> */ #include "sha1.h" #include <string.h> /* constant table */ static uint32_t _K[] = {0x5a827999, 0x6ed9eba1, 0x8f1bbcdc, 0xca62c1d6}; #define K(t) _K[(t) / 20] #define F0(b, c, d) (((b) & (c)) | ((~(b)) & (d))) #define F1(b, c, d) (((b) ^ (c)) ^ (d)) #define F2(b, c, d) (((b) & (c)) | ((b) & (d)) | ((c) & (d))) #define F3(b, c, d) (((b) ^ (c)) ^ (d)) #define S(n, x) (((x) << (n)) | ((x) >> (32 - (n)))) #define H(n) (ctxt->h.b32[(n)]) #define COUNT (ctxt->count) #define BCOUNT (ctxt->c.b64[0] / 8) #define W(n) (ctxt->m.b32[(n)]) #define PUTBYTE(x) \ do { \ ctxt->m.b8[(COUNT % 64)] = (x); \ COUNT++; \ COUNT %= 64; \ ctxt->c.b64[0] += 8; \ if (COUNT % 64 == 0) \ sha1_step(ctxt); \ } while (0) #define PUTPAD(x) \ do { \ ctxt->m.b8[(COUNT % 64)] = (x); \ COUNT++; \ COUNT %= 64; \ if (COUNT % 64 == 0) \ sha1_step(ctxt); \ } while (0) static void sha1_step(struct sha1_ctxt *); static void sha1_step(struct sha1_ctxt * ctxt) { uint32_t a, b, c, d, e; size_t t, s; uint32_t tmp; #ifndef WORDS_BIGENDIAN struct sha1_ctxt tctxt; memmove(&tctxt.m.b8[0], &ctxt->m.b8[0], 64); ctxt->m.b8[0] = tctxt.m.b8[3]; ctxt->m.b8[1] = tctxt.m.b8[2]; ctxt->m.b8[2] = tctxt.m.b8[1]; ctxt->m.b8[3] = tctxt.m.b8[0]; ctxt->m.b8[4] = tctxt.m.b8[7]; ctxt->m.b8[5] = tctxt.m.b8[6]; ctxt->m.b8[6] = tctxt.m.b8[5]; ctxt->m.b8[7] = tctxt.m.b8[4]; ctxt->m.b8[8] = tctxt.m.b8[11]; ctxt->m.b8[9] = tctxt.m.b8[10]; ctxt->m.b8[10] = tctxt.m.b8[9]; ctxt->m.b8[11] = tctxt.m.b8[8]; ctxt->m.b8[12] = tctxt.m.b8[15]; ctxt->m.b8[13] = tctxt.m.b8[14]; ctxt->m.b8[14] = tctxt.m.b8[13]; ctxt->m.b8[15] = tctxt.m.b8[12]; ctxt->m.b8[16] = tctxt.m.b8[19]; ctxt->m.b8[17] = tctxt.m.b8[18]; ctxt->m.b8[18] = tctxt.m.b8[17]; ctxt->m.b8[19] = tctxt.m.b8[16]; ctxt->m.b8[20] = tctxt.m.b8[23]; ctxt->m.b8[21] = tctxt.m.b8[22]; ctxt->m.b8[22] = tctxt.m.b8[21]; ctxt->m.b8[23] = tctxt.m.b8[20]; ctxt->m.b8[24] = tctxt.m.b8[27]; ctxt->m.b8[25] = tctxt.m.b8[26]; ctxt->m.b8[26] = tctxt.m.b8[25]; ctxt->m.b8[27] = tctxt.m.b8[24]; ctxt->m.b8[28] = tctxt.m.b8[31]; ctxt->m.b8[29] = tctxt.m.b8[30]; ctxt->m.b8[30] = tctxt.m.b8[29]; ctxt->m.b8[31] = tctxt.m.b8[28]; ctxt->m.b8[32] = tctxt.m.b8[35]; ctxt->m.b8[33] = tctxt.m.b8[34]; ctxt->m.b8[34] = tctxt.m.b8[33]; ctxt->m.b8[35] = tctxt.m.b8[32]; ctxt->m.b8[36] = tctxt.m.b8[39]; ctxt->m.b8[37] = tctxt.m.b8[38]; ctxt->m.b8[38] = tctxt.m.b8[37]; ctxt->m.b8[39] = tctxt.m.b8[36]; ctxt->m.b8[40] = tctxt.m.b8[43]; ctxt->m.b8[41] = tctxt.m.b8[42]; ctxt->m.b8[42] = tctxt.m.b8[41]; ctxt->m.b8[43] = tctxt.m.b8[40]; ctxt->m.b8[44] = tctxt.m.b8[47]; ctxt->m.b8[45] = tctxt.m.b8[46]; ctxt->m.b8[46] = tctxt.m.b8[45]; ctxt->m.b8[47] = tctxt.m.b8[44]; ctxt->m.b8[48] = tctxt.m.b8[51]; ctxt->m.b8[49] = tctxt.m.b8[50]; ctxt->m.b8[50] = tctxt.m.b8[49]; ctxt->m.b8[51] = tctxt.m.b8[48]; ctxt->m.b8[52] = tctxt.m.b8[55]; ctxt->m.b8[53] = tctxt.m.b8[54]; ctxt->m.b8[54] = tctxt.m.b8[53]; ctxt->m.b8[55] = tctxt.m.b8[52]; ctxt->m.b8[56] = tctxt.m.b8[59]; ctxt->m.b8[57] = tctxt.m.b8[58]; ctxt->m.b8[58] = tctxt.m.b8[57]; ctxt->m.b8[59] = tctxt.m.b8[56]; ctxt->m.b8[60] = tctxt.m.b8[63]; ctxt->m.b8[61] = tctxt.m.b8[62]; ctxt->m.b8[62] = tctxt.m.b8[61]; ctxt->m.b8[63] = tctxt.m.b8[60]; #endif a = H(0); b = H(1); c = H(2); d = H(3); e = H(4); for (t = 0; t < 20; t++) { s = t & 0x0f; if (t >= 16) W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F0(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 20; t < 40; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F1(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 40; t < 60; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F2(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } for (t = 60; t < 80; t++) { s = t & 0x0f; W(s) = S(1, W((s + 13) & 0x0f) ^ W((s + 8) & 0x0f) ^ W((s + 2) & 0x0f) ^ W(s)); tmp = S(5, a) + F3(b, c, d) + e + W(s) + K(t); e = d; d = c; c = S(30, b); b = a; a = tmp; } H(0) = H(0) + a; H(1) = H(1) + b; H(2) = H(2) + c; H(3) = H(3) + d; H(4) = H(4) + e; memset(&ctxt->m.b8[0], 0, 64); } /*------------------------------------------------------------*/ void sha1_init(struct sha1_ctxt * ctxt) { memset(ctxt, 0, sizeof(struct sha1_ctxt)); H(0) = 0x67452301; H(1) = 0xefcdab89; H(2) = 0x98badcfe; H(3) = 0x10325476; H(4) = 0xc3d2e1f0; } void sha1_pad(struct sha1_ctxt * ctxt) { size_t padlen; /* pad length in bytes */ size_t padstart; PUTPAD(0x80); padstart = COUNT % 64; padlen = 64 - padstart; if (padlen < 8) { memset(&ctxt->m.b8[padstart], 0, padlen); COUNT += (uint8_t) padlen; COUNT %= 64; sha1_step(ctxt); padstart = COUNT % 64; /* should be 0 */ padlen = 64 - padstart; /* should be 64 */ } memset(&ctxt->m.b8[padstart], 0, padlen - 8); COUNT += ((uint8_t) padlen - 8); COUNT %= 64; #ifdef WORDS_BIGENDIAN PUTPAD(ctxt->c.b8[0]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[7]); #else PUTPAD(ctxt->c.b8[7]); PUTPAD(ctxt->c.b8[6]); PUTPAD(ctxt->c.b8[5]); PUTPAD(ctxt->c.b8[4]); PUTPAD(ctxt->c.b8[3]); PUTPAD(ctxt->c.b8[2]); PUTPAD(ctxt->c.b8[1]); PUTPAD(ctxt->c.b8[0]); #endif } void sha1_loop(struct sha1_ctxt * ctxt, const uint8_t *input0, size_t len) { const uint8_t *input; size_t gaplen; size_t gapstart; size_t off; size_t copysiz; input = (const uint8_t *) input0; off = 0; while (off < len) { gapstart = COUNT % 64; gaplen = 64 - gapstart; copysiz = (gaplen < len - off) ? gaplen : len - off; memmove(&ctxt->m.b8[gapstart], &input[off], copysiz); COUNT += (uint8_t) copysiz; COUNT %= 64; ctxt->c.b64[0] += copysiz * 8; if (COUNT % 64 == 0) sha1_step(ctxt); off += copysiz; } } void sha1_result(struct sha1_ctxt * ctxt, uint8_t *digest0) { uint8_t *digest; digest = (uint8_t *) digest0; sha1_pad(ctxt); #ifdef WORDS_BIGENDIAN memmove(digest, &ctxt->h.b8[0], 20); #else digest[0] = ctxt->h.b8[3]; digest[1] = ctxt->h.b8[2]; digest[2] = ctxt->h.b8[1]; digest[3] = ctxt->h.b8[0]; digest[4] = ctxt->h.b8[7]; digest[5] = ctxt->h.b8[6]; digest[6] = ctxt->h.b8[5]; digest[7] = ctxt->h.b8[4]; digest[8] = ctxt->h.b8[11]; digest[9] = ctxt->h.b8[10]; digest[10] = ctxt->h.b8[9]; digest[11] = ctxt->h.b8[8]; digest[12] = ctxt->h.b8[15]; digest[13] = ctxt->h.b8[14]; digest[14] = ctxt->h.b8[13]; digest[15] = ctxt->h.b8[12]; digest[16] = ctxt->h.b8[19]; digest[17] = ctxt->h.b8[18]; digest[18] = ctxt->h.b8[17]; digest[19] = ctxt->h.b8[16]; #endif }
sophomore_public/libzmq
external/sha1/sha1.c
C++
gpl-3.0
8,692
/* contrib/pgcrypto/sha1.h */ /* $KAME: sha1.h,v 1.4 2000/02/22 14:01:18 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * 3. Neither the name of the project nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE PROJECT OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ /* * FIPS pub 180-1: Secure Hash Algorithm (SHA-1) * THIS SOFTWARE IS PROVIDED BY THE PROJECT AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * based on: http://www.itl.nist.gov/fipspubs/fip180-1.htm * implemented by Jun-ichiro itojun Itoh <itojun@itojun.org> */ #ifndef _NETINET6_SHA1_H_ #define _NETINET6_SHA1_H_ #ifdef __cplusplus extern "C" { #endif #include <stdlib.h> #include "../../src/stdint.hpp" struct sha1_ctxt { union { uint8_t b8[20]; uint32_t b32[5]; } h; union { uint8_t b8[8]; uint64_t b64[1]; } c; union { uint8_t b8[64]; uint32_t b32[16]; } m; uint8_t count; }; void sha1_init(struct sha1_ctxt *); void sha1_pad(struct sha1_ctxt *); void sha1_loop(struct sha1_ctxt *, const uint8_t *, size_t); void sha1_result(struct sha1_ctxt *, uint8_t *); // Compatibility with OpenSSL API #define SHA_DIGEST_LENGTH 20 typedef struct sha1_ctxt SHA_CTX; #define SHA1_Init(x) sha1_init((x)) #define SHA1_Update(x, y, z) sha1_loop((x), (y), (z)) #define SHA1_Final(x, y) sha1_result((y), (x)) #define SHA1_RESULTLEN (160/8) #ifdef __cplusplus } #endif #endif /* _NETINET6_SHA1_H_ */
sophomore_public/libzmq
external/sha1/sha1.h
C++
gpl-3.0
2,720
/* ========================================================================= Unity Project - A Test Framework for C Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ============================================================================ */ #define UNITY_INCLUDE_SETUP_STUBS #include "unity.h" #include <stddef.h> /* If omitted from header, declare overrideable prototypes here so they're ready for use */ #ifdef UNITY_OMIT_OUTPUT_CHAR_HEADER_DECLARATION void UNITY_OUTPUT_CHAR(int); #endif /* Helpful macros for us to use here in Assert functions */ #define UNITY_FAIL_AND_BAIL { Unity.CurrentTestFailed = 1; TEST_ABORT(); } #define UNITY_IGNORE_AND_BAIL { Unity.CurrentTestIgnored = 1; TEST_ABORT(); } #define RETURN_IF_FAIL_OR_IGNORE if (Unity.CurrentTestFailed || Unity.CurrentTestIgnored) return struct UNITY_STORAGE_T Unity; #ifdef UNITY_OUTPUT_COLOR static const char UnityStrOk[] = "\033[42mOK\033[00m"; static const char UnityStrPass[] = "\033[42mPASS\033[00m"; static const char UnityStrFail[] = "\033[41mFAIL\033[00m"; static const char UnityStrIgnore[] = "\033[43mIGNORE\033[00m"; #else static const char UnityStrOk[] = "OK"; static const char UnityStrPass[] = "PASS"; static const char UnityStrFail[] = "FAIL"; static const char UnityStrIgnore[] = "IGNORE"; #endif static const char UnityStrNull[] = "NULL"; static const char UnityStrSpacer[] = ". "; static const char UnityStrExpected[] = " Expected "; static const char UnityStrWas[] = " Was "; static const char UnityStrGt[] = " to be greater than "; static const char UnityStrLt[] = " to be less than "; static const char UnityStrOrEqual[] = "or equal to "; static const char UnityStrElement[] = " Element "; static const char UnityStrByte[] = " Byte "; static const char UnityStrMemory[] = " Memory Mismatch."; static const char UnityStrDelta[] = " Values Not Within Delta "; static const char UnityStrPointless[] = " You Asked Me To Compare Nothing, Which Was Pointless."; static const char UnityStrNullPointerForExpected[] = " Expected pointer to be NULL"; static const char UnityStrNullPointerForActual[] = " Actual pointer was NULL"; #ifndef UNITY_EXCLUDE_FLOAT static const char UnityStrNot[] = "Not "; static const char UnityStrInf[] = "Infinity"; static const char UnityStrNegInf[] = "Negative Infinity"; static const char UnityStrNaN[] = "NaN"; static const char UnityStrDet[] = "Determinate"; static const char UnityStrInvalidFloatTrait[] = "Invalid Float Trait"; #endif const char UnityStrErrFloat[] = "Unity Floating Point Disabled"; const char UnityStrErrDouble[] = "Unity Double Precision Disabled"; const char UnityStrErr64[] = "Unity 64-bit Support Disabled"; static const char UnityStrBreaker[] = "-----------------------"; static const char UnityStrResultsTests[] = " Tests "; static const char UnityStrResultsFailures[] = " Failures "; static const char UnityStrResultsIgnored[] = " Ignored "; static const char UnityStrDetail1Name[] = UNITY_DETAIL1_NAME " "; static const char UnityStrDetail2Name[] = " " UNITY_DETAIL2_NAME " "; /*----------------------------------------------- * Pretty Printers & Test Result Output Handlers *-----------------------------------------------*/ void UnityPrint(const char* string) { const char* pch = string; if (pch != NULL) { while (*pch) { /* printable characters plus CR & LF are printed */ if ((*pch <= 126) && (*pch >= 32)) { UNITY_OUTPUT_CHAR(*pch); } /* write escaped carriage returns */ else if (*pch == 13) { UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('r'); } /* write escaped line feeds */ else if (*pch == 10) { UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('n'); } #ifdef UNITY_OUTPUT_COLOR /* print ANSI escape code */ else if (*pch == 27 && *(pch + 1) == '[') { while (*pch && *pch != 'm') { UNITY_OUTPUT_CHAR(*pch); pch++; } UNITY_OUTPUT_CHAR('m'); } #endif /* unprintable characters are shown as codes */ else { UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('x'); UnityPrintNumberHex((UNITY_UINT)*pch, 2); } pch++; } } } void UnityPrintLen(const char* string, const UNITY_UINT32 length) { const char* pch = string; if (pch != NULL) { while (*pch && (UNITY_UINT32)(pch - string) < length) { /* printable characters plus CR & LF are printed */ if ((*pch <= 126) && (*pch >= 32)) { UNITY_OUTPUT_CHAR(*pch); } /* write escaped carriage returns */ else if (*pch == 13) { UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('r'); } /* write escaped line feeds */ else if (*pch == 10) { UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('n'); } /* unprintable characters are shown as codes */ else { UNITY_OUTPUT_CHAR('\\'); UNITY_OUTPUT_CHAR('x'); UnityPrintNumberHex((UNITY_UINT)*pch, 2); } pch++; } } } /*-----------------------------------------------*/ void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style) { if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { UnityPrintNumber(number); } else if ((style & UNITY_DISPLAY_RANGE_UINT) == UNITY_DISPLAY_RANGE_UINT) { UnityPrintNumberUnsigned((UNITY_UINT)number); } else { UNITY_OUTPUT_CHAR('0'); UNITY_OUTPUT_CHAR('x'); UnityPrintNumberHex((UNITY_UINT)number, (char)((style & 0xF) * 2)); } } /*-----------------------------------------------*/ void UnityPrintNumber(const UNITY_INT number_to_print) { UNITY_UINT number = (UNITY_UINT)number_to_print; if (number_to_print < 0) { /* A negative number, including MIN negative */ UNITY_OUTPUT_CHAR('-'); number = (UNITY_UINT)(-number_to_print); } UnityPrintNumberUnsigned(number); } /*----------------------------------------------- * basically do an itoa using as little ram as possible */ void UnityPrintNumberUnsigned(const UNITY_UINT number) { UNITY_UINT divisor = 1; /* figure out initial divisor */ while (number / divisor > 9) { divisor *= 10; } /* now mod and print, then divide divisor */ do { UNITY_OUTPUT_CHAR((char)('0' + (number / divisor % 10))); divisor /= 10; } while (divisor > 0); } /*-----------------------------------------------*/ void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles_to_print) { int nibble; char nibbles = nibbles_to_print; if ((unsigned)nibbles > (2 * sizeof(number))) nibbles = 2 * sizeof(number); while (nibbles > 0) { nibbles--; nibble = (int)(number >> (nibbles * 4)) & 0x0F; if (nibble <= 9) { UNITY_OUTPUT_CHAR((char)('0' + nibble)); } else { UNITY_OUTPUT_CHAR((char)('A' - 10 + nibble)); } } } /*-----------------------------------------------*/ void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number) { UNITY_UINT current_bit = (UNITY_UINT)1 << (UNITY_INT_WIDTH - 1); UNITY_INT32 i; for (i = 0; i < UNITY_INT_WIDTH; i++) { if (current_bit & mask) { if (current_bit & number) { UNITY_OUTPUT_CHAR('1'); } else { UNITY_OUTPUT_CHAR('0'); } } else { UNITY_OUTPUT_CHAR('X'); } current_bit = current_bit >> 1; } } /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT_PRINT /* This function prints a floating-point value in a format similar to * printf("%.6g"). It can work with either single- or double-precision, * but for simplicity, it prints only 6 significant digits in either case. * Printing more than 6 digits accurately is hard (at least in the single- * precision case) and isn't attempted here. */ void UnityPrintFloat(const UNITY_DOUBLE input_number) { UNITY_DOUBLE number = input_number; /* print minus sign (including for negative zero) */ if (number < 0.0f || (number == 0.0f && 1.0f / number < 0.0f)) { UNITY_OUTPUT_CHAR('-'); number = -number; } /* handle zero, NaN, and +/- infinity */ if (number == 0.0f) UnityPrint("0"); else if (isnan(number)) UnityPrint("nan"); else if (isinf(number)) UnityPrint("inf"); else { int exponent = 0; int decimals, digits; UNITY_INT32 n; char buf[16]; /* scale up or down by powers of 10 */ while (number < 100000.0f / 1e6f) { number *= 1e6f; exponent -= 6; } while (number < 100000.0f) { number *= 10.0f; exponent--; } while (number > 1000000.0f * 1e6f) { number /= 1e6f; exponent += 6; } while (number > 1000000.0f) { number /= 10.0f; exponent++; } /* round to nearest integer */ n = ((UNITY_INT32)(number + number) + 1) / 2; if (n > 999999) { n = 100000; exponent++; } /* determine where to place decimal point */ decimals = (exponent <= 0 && exponent >= -9) ? -exponent : 5; exponent += decimals; /* truncate trailing zeroes after decimal point */ while (decimals > 0 && n % 10 == 0) { n /= 10; decimals--; } /* build up buffer in reverse order */ digits = 0; while (n != 0 || digits < decimals + 1) { buf[digits++] = (char)('0' + n % 10); n /= 10; } while (digits > 0) { if(digits == decimals) UNITY_OUTPUT_CHAR('.'); UNITY_OUTPUT_CHAR(buf[--digits]); } /* print exponent if needed */ if (exponent != 0) { UNITY_OUTPUT_CHAR('e'); if(exponent < 0) { UNITY_OUTPUT_CHAR('-'); exponent = -exponent; } else { UNITY_OUTPUT_CHAR('+'); } digits = 0; while (exponent != 0 || digits < 2) { buf[digits++] = (char)('0' + exponent % 10); exponent /= 10; } while (digits > 0) { UNITY_OUTPUT_CHAR(buf[--digits]); } } } } #endif /* ! UNITY_EXCLUDE_FLOAT_PRINT */ /*-----------------------------------------------*/ static void UnityTestResultsBegin(const char* file, const UNITY_LINE_TYPE line) { UnityPrint(file); UNITY_OUTPUT_CHAR(':'); UnityPrintNumber((UNITY_INT)line); UNITY_OUTPUT_CHAR(':'); UnityPrint(Unity.CurrentTestName); UNITY_OUTPUT_CHAR(':'); } /*-----------------------------------------------*/ static void UnityTestResultsFailBegin(const UNITY_LINE_TYPE line) { UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrFail); UNITY_OUTPUT_CHAR(':'); } /*-----------------------------------------------*/ void UnityConcludeTest(void) { if (Unity.CurrentTestIgnored) { Unity.TestIgnores++; } else if (!Unity.CurrentTestFailed) { UnityTestResultsBegin(Unity.TestFile, Unity.CurrentTestLineNumber); UnityPrint(UnityStrPass); } else { Unity.TestFailures++; } Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; UNITY_PRINT_EOL(); UNITY_FLUSH_CALL(); } /*-----------------------------------------------*/ static void UnityAddMsgIfSpecified(const char* msg) { if (msg) { UnityPrint(UnityStrSpacer); #ifndef UNITY_EXCLUDE_DETAILS if (Unity.CurrentDetail1) { UnityPrint(UnityStrDetail1Name); UnityPrint(Unity.CurrentDetail1); if (Unity.CurrentDetail2) { UnityPrint(UnityStrDetail2Name); UnityPrint(Unity.CurrentDetail2); } UnityPrint(UnityStrSpacer); } #endif UnityPrint(msg); } } /*-----------------------------------------------*/ static void UnityPrintExpectedAndActualStrings(const char* expected, const char* actual) { UnityPrint(UnityStrExpected); if (expected != NULL) { UNITY_OUTPUT_CHAR('\''); UnityPrint(expected); UNITY_OUTPUT_CHAR('\''); } else { UnityPrint(UnityStrNull); } UnityPrint(UnityStrWas); if (actual != NULL) { UNITY_OUTPUT_CHAR('\''); UnityPrint(actual); UNITY_OUTPUT_CHAR('\''); } else { UnityPrint(UnityStrNull); } } /*-----------------------------------------------*/ static void UnityPrintExpectedAndActualStringsLen(const char* expected, const char* actual, const UNITY_UINT32 length) { UnityPrint(UnityStrExpected); if (expected != NULL) { UNITY_OUTPUT_CHAR('\''); UnityPrintLen(expected, length); UNITY_OUTPUT_CHAR('\''); } else { UnityPrint(UnityStrNull); } UnityPrint(UnityStrWas); if (actual != NULL) { UNITY_OUTPUT_CHAR('\''); UnityPrintLen(actual, length); UNITY_OUTPUT_CHAR('\''); } else { UnityPrint(UnityStrNull); } } /*----------------------------------------------- * Assertion & Control Helpers *-----------------------------------------------*/ static int UnityIsOneArrayNull(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_LINE_TYPE lineNumber, const char* msg) { if (expected == actual) return 0; /* Both are NULL or same pointer */ /* print and return true if just expected is NULL */ if (expected == NULL) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrNullPointerForExpected); UnityAddMsgIfSpecified(msg); return 1; } /* print and return true if just actual is NULL */ if (actual == NULL) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrNullPointerForActual); UnityAddMsgIfSpecified(msg); return 1; } return 0; /* return false if neither is NULL */ } /*----------------------------------------------- * Assertion Functions *-----------------------------------------------*/ void UnityAssertBits(const UNITY_INT mask, const UNITY_INT expected, const UNITY_INT actual, const char* msg, const UNITY_LINE_TYPE lineNumber) { RETURN_IF_FAIL_OR_IGNORE; if ((mask & expected) != (mask & actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)expected); UnityPrint(UnityStrWas); UnityPrintMask((UNITY_UINT)mask, (UNITY_UINT)actual); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_INT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style) { RETURN_IF_FAIL_OR_IGNORE; if (expected != actual) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(expected, style); UnityPrint(UnityStrWas); UnityPrintNumberByStyle(actual, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, const UNITY_INT actual, const UNITY_COMPARISON_T compare, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style) { int failed = 0; RETURN_IF_FAIL_OR_IGNORE; if (threshold == actual && compare & UNITY_EQUAL_TO) return; if (threshold == actual) failed = 1; if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { if (actual > threshold && compare & UNITY_SMALLER_THAN) failed = 1; if (actual < threshold && compare & UNITY_GREATER_THAN) failed = 1; } else /* UINT or HEX */ { if ((UNITY_UINT)actual > (UNITY_UINT)threshold && compare & UNITY_SMALLER_THAN) failed = 1; if ((UNITY_UINT)actual < (UNITY_UINT)threshold && compare & UNITY_GREATER_THAN) failed = 1; } if (failed) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(actual, style); if (compare & UNITY_GREATER_THAN) UnityPrint(UnityStrGt); if (compare & UNITY_SMALLER_THAN) UnityPrint(UnityStrLt); if (compare & UNITY_EQUAL_TO) UnityPrint(UnityStrOrEqual); UnityPrintNumberByStyle(threshold, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } #define UnityPrintPointlessAndBail() \ { \ UnityTestResultsFailBegin(lineNumber); \ UnityPrint(UnityStrPointless); \ UnityAddMsgIfSpecified(msg); \ UNITY_FAIL_AND_BAIL; } /*-----------------------------------------------*/ void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style, const UNITY_FLAGS_T flags) { UNITY_UINT32 elements = num_elements; unsigned int length = style & 0xF; RETURN_IF_FAIL_OR_IGNORE; if (num_elements == 0) { UnityPrintPointlessAndBail(); } if (expected == actual) return; /* Both are NULL or same pointer */ if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) UNITY_FAIL_AND_BAIL; while ((elements > 0) && elements--) { UNITY_INT expect_val; UNITY_INT actual_val; switch (length) { case 1: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT8*)actual; break; case 2: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT16*)actual; break; #ifdef UNITY_SUPPORT_64 case 8: expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT64*)actual; break; #endif default: /* length 4 bytes */ expect_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)expected; actual_val = *(UNITY_PTR_ATTRIBUTE const UNITY_INT32*)actual; length = 4; break; } if (expect_val != actual_val) { if (style & UNITY_DISPLAY_RANGE_UINT && length < sizeof(expect_val)) { /* For UINT, remove sign extension (padding 1's) from signed type casts above */ UNITY_INT mask = 1; mask = (mask << 8 * length) - 1; expect_val &= mask; actual_val &= mask; } UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(num_elements - elements - 1); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(expect_val, style); UnityPrint(UnityStrWas); UnityPrintNumberByStyle(actual_val, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } if (flags == UNITY_ARRAY_TO_ARRAY) { expected = (UNITY_INTERNAL_PTR)(length + (const char*)expected); } actual = (UNITY_INTERNAL_PTR)(length + (const char*)actual); } } /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_FLOAT /* Wrap this define in a function with variable types as float or double */ #define UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff) \ if (isinf(expected) && isinf(actual) && ((expected < 0) == (actual < 0))) return 1; \ if (UNITY_NAN_CHECK) return 1; \ diff = actual - expected; \ if (diff < 0) diff = -diff; \ if (delta < 0) delta = -delta; \ return !(isnan(diff) || isinf(diff) || (diff > delta)) /* This first part of this condition will catch any NaN or Infinite values */ #ifndef UNITY_NAN_NOT_EQUAL_NAN #define UNITY_NAN_CHECK isnan(expected) && isnan(actual) #else #define UNITY_NAN_CHECK 0 #endif #ifndef UNITY_EXCLUDE_FLOAT_PRINT #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ { \ UnityPrint(UnityStrExpected); \ UnityPrintFloat(expected); \ UnityPrint(UnityStrWas); \ UnityPrintFloat(actual); } #else #define UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual) \ UnityPrint(UnityStrDelta) #endif /* UNITY_EXCLUDE_FLOAT_PRINT */ static int UnityFloatsWithin(UNITY_FLOAT delta, UNITY_FLOAT expected, UNITY_FLOAT actual) { UNITY_FLOAT diff; UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); } void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags) { UNITY_UINT32 elements = num_elements; UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_expected = expected; UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* ptr_actual = actual; RETURN_IF_FAIL_OR_IGNORE; if (elements == 0) { UnityPrintPointlessAndBail(); } if (expected == actual) return; /* Both are NULL or same pointer */ if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) UNITY_FAIL_AND_BAIL; while (elements--) { if (!UnityFloatsWithin(*ptr_expected * UNITY_FLOAT_PRECISION, *ptr_expected, *ptr_actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(num_elements - elements - 1); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)*ptr_expected, (UNITY_DOUBLE)*ptr_actual); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } if (flags == UNITY_ARRAY_TO_ARRAY) { ptr_expected++; } ptr_actual++; } } /*-----------------------------------------------*/ void UnityAssertFloatsWithin(const UNITY_FLOAT delta, const UNITY_FLOAT expected, const UNITY_FLOAT actual, const char* msg, const UNITY_LINE_TYPE lineNumber) { RETURN_IF_FAIL_OR_IGNORE; if (!UnityFloatsWithin(delta, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT((UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style) { const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; UNITY_INT should_be_trait = ((UNITY_INT)style & 1); UNITY_INT is_trait = !should_be_trait; UNITY_INT trait_index = (UNITY_INT)(style >> 1); RETURN_IF_FAIL_OR_IGNORE; switch (style) { case UNITY_FLOAT_IS_INF: case UNITY_FLOAT_IS_NOT_INF: is_trait = isinf(actual) && (actual > 0); break; case UNITY_FLOAT_IS_NEG_INF: case UNITY_FLOAT_IS_NOT_NEG_INF: is_trait = isinf(actual) && (actual < 0); break; case UNITY_FLOAT_IS_NAN: case UNITY_FLOAT_IS_NOT_NAN: is_trait = isnan(actual) ? 1 : 0; break; case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ case UNITY_FLOAT_IS_NOT_DET: is_trait = !isinf(actual) && !isnan(actual); break; default: trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; break; } if (is_trait != should_be_trait) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); if (!should_be_trait) UnityPrint(UnityStrNot); UnityPrint(trait_names[trait_index]); UnityPrint(UnityStrWas); #ifndef UNITY_EXCLUDE_FLOAT_PRINT UnityPrintFloat((UNITY_DOUBLE)actual); #else if (should_be_trait) UnityPrint(UnityStrNot); UnityPrint(trait_names[trait_index]); #endif UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } #endif /* not UNITY_EXCLUDE_FLOAT */ /*-----------------------------------------------*/ #ifndef UNITY_EXCLUDE_DOUBLE static int UnityDoublesWithin(UNITY_DOUBLE delta, UNITY_DOUBLE expected, UNITY_DOUBLE actual) { UNITY_DOUBLE diff; UNITY_FLOAT_OR_DOUBLE_WITHIN(delta, expected, actual, diff); } void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags) { UNITY_UINT32 elements = num_elements; UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_expected = expected; UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* ptr_actual = actual; RETURN_IF_FAIL_OR_IGNORE; if (elements == 0) { UnityPrintPointlessAndBail(); } if (expected == actual) return; /* Both are NULL or same pointer */ if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) UNITY_FAIL_AND_BAIL; while (elements--) { if (!UnityDoublesWithin(*ptr_expected * UNITY_DOUBLE_PRECISION, *ptr_expected, *ptr_actual)) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(num_elements - elements - 1); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(*ptr_expected, *ptr_actual); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } if (flags == UNITY_ARRAY_TO_ARRAY) { ptr_expected++; } ptr_actual++; } } /*-----------------------------------------------*/ void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, const UNITY_DOUBLE expected, const UNITY_DOUBLE actual, const char* msg, const UNITY_LINE_TYPE lineNumber) { RETURN_IF_FAIL_OR_IGNORE; if (!UnityDoublesWithin(delta, expected, actual)) { UnityTestResultsFailBegin(lineNumber); UNITY_PRINT_EXPECTED_AND_ACTUAL_FLOAT(expected, actual); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style) { const char* trait_names[] = {UnityStrInf, UnityStrNegInf, UnityStrNaN, UnityStrDet}; UNITY_INT should_be_trait = ((UNITY_INT)style & 1); UNITY_INT is_trait = !should_be_trait; UNITY_INT trait_index = (UNITY_INT)(style >> 1); RETURN_IF_FAIL_OR_IGNORE; switch (style) { case UNITY_FLOAT_IS_INF: case UNITY_FLOAT_IS_NOT_INF: is_trait = isinf(actual) && (actual > 0); break; case UNITY_FLOAT_IS_NEG_INF: case UNITY_FLOAT_IS_NOT_NEG_INF: is_trait = isinf(actual) && (actual < 0); break; case UNITY_FLOAT_IS_NAN: case UNITY_FLOAT_IS_NOT_NAN: is_trait = isnan(actual) ? 1 : 0; break; case UNITY_FLOAT_IS_DET: /* A determinate number is non infinite and not NaN. */ case UNITY_FLOAT_IS_NOT_DET: is_trait = !isinf(actual) && !isnan(actual); break; default: trait_index = 0; trait_names[0] = UnityStrInvalidFloatTrait; break; } if (is_trait != should_be_trait) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrExpected); if (!should_be_trait) UnityPrint(UnityStrNot); UnityPrint(trait_names[trait_index]); UnityPrint(UnityStrWas); #ifndef UNITY_EXCLUDE_FLOAT_PRINT UnityPrintFloat(actual); #else if (should_be_trait) UnityPrint(UnityStrNot); UnityPrint(trait_names[trait_index]); #endif UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } #endif /* not UNITY_EXCLUDE_DOUBLE */ /*-----------------------------------------------*/ void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_INT expected, const UNITY_INT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style) { RETURN_IF_FAIL_OR_IGNORE; if ((style & UNITY_DISPLAY_RANGE_INT) == UNITY_DISPLAY_RANGE_INT) { if (actual > expected) Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); else Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); } else { if ((UNITY_UINT)actual > (UNITY_UINT)expected) Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(actual - expected) > delta); else Unity.CurrentTestFailed = (UNITY_UINT)((UNITY_UINT)(expected - actual) > delta); } if (Unity.CurrentTestFailed) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrDelta); UnityPrintNumberByStyle((UNITY_INT)delta, style); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(expected, style); UnityPrint(UnityStrWas); UnityPrintNumberByStyle(actual, style); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertEqualString(const char* expected, const char* actual, const char* msg, const UNITY_LINE_TYPE lineNumber) { UNITY_UINT32 i; RETURN_IF_FAIL_OR_IGNORE; /* if both pointers not null compare the strings */ if (expected && actual) { for (i = 0; expected[i] || actual[i]; i++) { if (expected[i] != actual[i]) { Unity.CurrentTestFailed = 1; break; } } } else { /* handle case of one pointers being null (if both null, test should pass) */ if (expected != actual) { Unity.CurrentTestFailed = 1; } } if (Unity.CurrentTestFailed) { UnityTestResultsFailBegin(lineNumber); UnityPrintExpectedAndActualStrings(expected, actual); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertEqualStringLen(const char* expected, const char* actual, const UNITY_UINT32 length, const char* msg, const UNITY_LINE_TYPE lineNumber) { UNITY_UINT32 i; RETURN_IF_FAIL_OR_IGNORE; /* if both pointers not null compare the strings */ if (expected && actual) { for (i = 0; (i < length) && (expected[i] || actual[i]); i++) { if (expected[i] != actual[i]) { Unity.CurrentTestFailed = 1; break; } } } else { /* handle case of one pointers being null (if both null, test should pass) */ if (expected != actual) { Unity.CurrentTestFailed = 1; } } if (Unity.CurrentTestFailed) { UnityTestResultsFailBegin(lineNumber); UnityPrintExpectedAndActualStringsLen(expected, actual, length); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } /*-----------------------------------------------*/ void UnityAssertEqualStringArray(UNITY_INTERNAL_PTR expected, const char** actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags) { UNITY_UINT32 i = 0; UNITY_UINT32 j = 0; const char* expd = NULL; const char* act = NULL; RETURN_IF_FAIL_OR_IGNORE; /* if no elements, it's an error */ if (num_elements == 0) { UnityPrintPointlessAndBail(); } if ((const void*)expected == (const void*)actual) { return; /* Both are NULL or same pointer */ } if (UnityIsOneArrayNull((UNITY_INTERNAL_PTR)expected, (UNITY_INTERNAL_PTR)actual, lineNumber, msg)) { UNITY_FAIL_AND_BAIL; } if (flags != UNITY_ARRAY_TO_ARRAY) { expd = (const char*)expected; } do { act = actual[j]; if (flags == UNITY_ARRAY_TO_ARRAY) { expd = ((const char* const*)expected)[j]; } /* if both pointers not null compare the strings */ if (expd && act) { for (i = 0; expd[i] || act[i]; i++) { if (expd[i] != act[i]) { Unity.CurrentTestFailed = 1; break; } } } else { /* handle case of one pointers being null (if both null, test should pass) */ if (expd != act) { Unity.CurrentTestFailed = 1; } } if (Unity.CurrentTestFailed) { UnityTestResultsFailBegin(lineNumber); if (num_elements > 1) { UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(j); } UnityPrintExpectedAndActualStrings(expd, act); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } } while (++j < num_elements); } /*-----------------------------------------------*/ void UnityAssertEqualMemory(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 length, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags) { UNITY_PTR_ATTRIBUTE const unsigned char* ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; UNITY_PTR_ATTRIBUTE const unsigned char* ptr_act = (UNITY_PTR_ATTRIBUTE const unsigned char*)actual; UNITY_UINT32 elements = num_elements; UNITY_UINT32 bytes; RETURN_IF_FAIL_OR_IGNORE; if ((elements == 0) || (length == 0)) { UnityPrintPointlessAndBail(); } if (expected == actual) return; /* Both are NULL or same pointer */ if (UnityIsOneArrayNull(expected, actual, lineNumber, msg)) UNITY_FAIL_AND_BAIL; while (elements--) { bytes = length; while (bytes--) { if (*ptr_exp != *ptr_act) { UnityTestResultsFailBegin(lineNumber); UnityPrint(UnityStrMemory); if (num_elements > 1) { UnityPrint(UnityStrElement); UnityPrintNumberUnsigned(num_elements - elements - 1); } UnityPrint(UnityStrByte); UnityPrintNumberUnsigned(length - bytes - 1); UnityPrint(UnityStrExpected); UnityPrintNumberByStyle(*ptr_exp, UNITY_DISPLAY_STYLE_HEX8); UnityPrint(UnityStrWas); UnityPrintNumberByStyle(*ptr_act, UNITY_DISPLAY_STYLE_HEX8); UnityAddMsgIfSpecified(msg); UNITY_FAIL_AND_BAIL; } ptr_exp++; ptr_act++; } if (flags == UNITY_ARRAY_TO_VAL) { ptr_exp = (UNITY_PTR_ATTRIBUTE const unsigned char*)expected; } } } /*-----------------------------------------------*/ static union { UNITY_INT8 i8; UNITY_INT16 i16; UNITY_INT32 i32; #ifdef UNITY_SUPPORT_64 UNITY_INT64 i64; #endif #ifndef UNITY_EXCLUDE_FLOAT float f; #endif #ifndef UNITY_EXCLUDE_DOUBLE double d; #endif } UnityQuickCompare; UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size) { switch(size) { case 1: UnityQuickCompare.i8 = (UNITY_INT8)num; return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i8); case 2: UnityQuickCompare.i16 = (UNITY_INT16)num; return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i16); #ifdef UNITY_SUPPORT_64 case 8: UnityQuickCompare.i64 = (UNITY_INT64)num; return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i64); #endif default: /* 4 bytes */ UnityQuickCompare.i32 = (UNITY_INT32)num; return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.i32); } } #ifndef UNITY_EXCLUDE_FLOAT UNITY_INTERNAL_PTR UnityFloatToPtr(const float num) { UnityQuickCompare.f = num; return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.f); } #endif #ifndef UNITY_EXCLUDE_DOUBLE UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num) { UnityQuickCompare.d = num; return (UNITY_INTERNAL_PTR)(&UnityQuickCompare.d); } #endif /*----------------------------------------------- * Control Functions *-----------------------------------------------*/ void UnityFail(const char* msg, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrFail); if (msg != NULL) { UNITY_OUTPUT_CHAR(':'); #ifndef UNITY_EXCLUDE_DETAILS if (Unity.CurrentDetail1) { UnityPrint(UnityStrDetail1Name); UnityPrint(Unity.CurrentDetail1); if (Unity.CurrentDetail2) { UnityPrint(UnityStrDetail2Name); UnityPrint(Unity.CurrentDetail2); } UnityPrint(UnityStrSpacer); } #endif if (msg[0] != ' ') { UNITY_OUTPUT_CHAR(' '); } UnityPrint(msg); } UNITY_FAIL_AND_BAIL; } /*-----------------------------------------------*/ void UnityIgnore(const char* msg, const UNITY_LINE_TYPE line) { RETURN_IF_FAIL_OR_IGNORE; UnityTestResultsBegin(Unity.TestFile, line); UnityPrint(UnityStrIgnore); if (msg != NULL) { UNITY_OUTPUT_CHAR(':'); UNITY_OUTPUT_CHAR(' '); UnityPrint(msg); } UNITY_IGNORE_AND_BAIL; } /*-----------------------------------------------*/ void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum) { Unity.CurrentTestName = FuncName; Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)FuncLineNum; Unity.NumberOfTests++; UNITY_CLR_DETAILS(); if (TEST_PROTECT()) { setUp(); Func(); } if (TEST_PROTECT()) { tearDown(); } UnityConcludeTest(); } /*-----------------------------------------------*/ void UnityBegin(const char* filename) { Unity.TestFile = filename; Unity.CurrentTestName = NULL; Unity.CurrentTestLineNumber = 0; Unity.NumberOfTests = 0; Unity.TestFailures = 0; Unity.TestIgnores = 0; Unity.CurrentTestFailed = 0; Unity.CurrentTestIgnored = 0; UNITY_CLR_DETAILS(); UNITY_OUTPUT_START(); } /*-----------------------------------------------*/ int UnityEnd(void) { UNITY_PRINT_EOL(); UnityPrint(UnityStrBreaker); UNITY_PRINT_EOL(); UnityPrintNumber((UNITY_INT)(Unity.NumberOfTests)); UnityPrint(UnityStrResultsTests); UnityPrintNumber((UNITY_INT)(Unity.TestFailures)); UnityPrint(UnityStrResultsFailures); UnityPrintNumber((UNITY_INT)(Unity.TestIgnores)); UnityPrint(UnityStrResultsIgnored); UNITY_PRINT_EOL(); if (Unity.TestFailures == 0U) { UnityPrint(UnityStrOk); } else { UnityPrint(UnityStrFail); #ifdef UNITY_DIFFERENTIATE_FINAL_FAIL UNITY_OUTPUT_CHAR('E'); UNITY_OUTPUT_CHAR('D'); #endif } UNITY_PRINT_EOL(); UNITY_FLUSH_CALL(); UNITY_OUTPUT_COMPLETE(); return (int)(Unity.TestFailures); } /*----------------------------------------------- * Command Line Argument Support *-----------------------------------------------*/ #ifdef UNITY_USE_COMMAND_LINE_ARGS char* UnityOptionIncludeNamed = NULL; char* UnityOptionExcludeNamed = NULL; int UnityVerbosity = 1; int UnityParseOptions(int argc, char** argv) { UnityOptionIncludeNamed = NULL; UnityOptionExcludeNamed = NULL; for (int i = 1; i < argc; i++) { if (argv[i][0] == '-') { switch (argv[i][1]) { case 'l': /* list tests */ return -1; case 'n': /* include tests with name including this string */ case 'f': /* an alias for -n */ if (argv[i][2] == '=') UnityOptionIncludeNamed = &argv[i][3]; else if (++i < argc) UnityOptionIncludeNamed = argv[i]; else { UnityPrint("ERROR: No Test String to Include Matches For"); UNITY_PRINT_EOL(); return 1; } break; case 'q': /* quiet */ UnityVerbosity = 0; break; case 'v': /* verbose */ UnityVerbosity = 2; break; case 'x': /* exclude tests with name including this string */ if (argv[i][2] == '=') UnityOptionExcludeNamed = &argv[i][3]; else if (++i < argc) UnityOptionExcludeNamed = argv[i]; else { UnityPrint("ERROR: No Test String to Exclude Matches For"); UNITY_PRINT_EOL(); return 1; } break; default: UnityPrint("ERROR: Unknown Option "); UNITY_OUTPUT_CHAR(argv[i][1]); UNITY_PRINT_EOL(); return 1; } } } return 0; } int IsStringInBiggerString(const char* longstring, const char* shortstring) { const char* lptr = longstring; const char* sptr = shortstring; const char* lnext = lptr; if (*sptr == '*') return 1; while (*lptr) { lnext = lptr + 1; /* If they current bytes match, go on to the next bytes */ while (*lptr && *sptr && (*lptr == *sptr)) { lptr++; sptr++; /* We're done if we match the entire string or up to a wildcard */ if (*sptr == '*') return 1; if (*sptr == ',') return 1; if (*sptr == '"') return 1; if (*sptr == '\'') return 1; if (*sptr == ':') return 2; if (*sptr == 0) return 1; } /* Otherwise we start in the long pointer 1 character further and try again */ lptr = lnext; sptr = shortstring; } return 0; } int UnityStringArgumentMatches(const char* str) { int retval; const char* ptr1; const char* ptr2; const char* ptrf; /* Go through the options and get the substrings for matching one at a time */ ptr1 = str; while (ptr1[0] != 0) { if ((ptr1[0] == '"') || (ptr1[0] == '\'')) ptr1++; /* look for the start of the next partial */ ptr2 = ptr1; ptrf = 0; do { ptr2++; if ((ptr2[0] == ':') && (ptr2[1] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')) ptrf = &ptr2[1]; } while ((ptr2[0] != 0) && (ptr2[0] != '\'') && (ptr2[0] != '"') && (ptr2[0] != ',')); while ((ptr2[0] != 0) && ((ptr2[0] == ':') || (ptr2[0] == '\'') || (ptr2[0] == '"') || (ptr2[0] == ','))) ptr2++; /* done if complete filename match */ retval = IsStringInBiggerString(Unity.TestFile, ptr1); if (retval == 1) return retval; /* done if testname match after filename partial match */ if ((retval == 2) && (ptrf != 0)) { if (IsStringInBiggerString(Unity.CurrentTestName, ptrf)) return 1; } /* done if complete testname match */ if (IsStringInBiggerString(Unity.CurrentTestName, ptr1) == 1) return 1; ptr1 = ptr2; } /* we couldn't find a match for any substrings */ return 0; } int UnityTestMatches(void) { /* Check if this test name matches the included test pattern */ int retval; if (UnityOptionIncludeNamed) { retval = UnityStringArgumentMatches(UnityOptionIncludeNamed); } else retval = 1; /* Check if this test name matches the excluded test pattern */ if (UnityOptionExcludeNamed) { if (UnityStringArgumentMatches(UnityOptionExcludeNamed)) retval = 0; } return retval; } #endif /* UNITY_USE_COMMAND_LINE_ARGS */ /*-----------------------------------------------*/
sophomore_public/libzmq
external/unity/unity.c
C++
gpl-3.0
49,374
/* ========================================== Unity Project - A Test Framework for C Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ #ifndef UNITY_FRAMEWORK_H #define UNITY_FRAMEWORK_H #define UNITY #ifdef __cplusplus extern "C" { #endif #include "unity_internals.h" /*------------------------------------------------------- * Test Setup / Teardown *-------------------------------------------------------*/ /* These functions are intended to be called before and after each test. */ void setUp(void); void tearDown(void); /* These functions are intended to be called at the beginning and end of an * entire test suite. suiteTearDown() is passed the number of tests that * failed, and its return value becomes the exit code of main(). */ void suiteSetUp(void); int suiteTearDown(int num_failures); /* If the compiler supports it, the following block provides stub * implementations of the above functions as weak symbols. Note that on * some platforms (MinGW for example), weak function implementations need * to be in the same translation unit they are called from. This can be * achieved by defining UNITY_INCLUDE_SETUP_STUBS before including unity.h. */ #ifdef UNITY_INCLUDE_SETUP_STUBS #ifdef UNITY_WEAK_ATTRIBUTE UNITY_WEAK_ATTRIBUTE void setUp(void) { } UNITY_WEAK_ATTRIBUTE void tearDown(void) { } UNITY_WEAK_ATTRIBUTE void suiteSetUp(void) { } UNITY_WEAK_ATTRIBUTE int suiteTearDown(int num_failures) { return num_failures; } #elif defined(UNITY_WEAK_PRAGMA) #pragma weak setUp void setUp(void) { } #pragma weak tearDown void tearDown(void) { } #pragma weak suiteSetUp void suiteSetUp(void) { } #pragma weak suiteTearDown int suiteTearDown(int num_failures) { return num_failures; } #endif #endif /*------------------------------------------------------- * Configuration Options *------------------------------------------------------- * All options described below should be passed as a compiler flag to all files using Unity. If you must add #defines, place them BEFORE the #include above. * Integers/longs/pointers * - Unity attempts to automatically discover your integer sizes * - define UNITY_EXCLUDE_STDINT_H to stop attempting to look in <stdint.h> * - define UNITY_EXCLUDE_LIMITS_H to stop attempting to look in <limits.h> * - If you cannot use the automatic methods above, you can force Unity by using these options: * - define UNITY_SUPPORT_64 * - set UNITY_INT_WIDTH * - set UNITY_LONG_WIDTH * - set UNITY_POINTER_WIDTH * Floats * - define UNITY_EXCLUDE_FLOAT to disallow floating point comparisons * - define UNITY_FLOAT_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_FLOAT * - define UNITY_FLOAT_TYPE to specify doubles instead of single precision floats * - define UNITY_INCLUDE_DOUBLE to allow double floating point comparisons * - define UNITY_EXCLUDE_DOUBLE to disallow double floating point comparisons (default) * - define UNITY_DOUBLE_PRECISION to specify the precision to use when doing TEST_ASSERT_EQUAL_DOUBLE * - define UNITY_DOUBLE_TYPE to specify something other than double * - define UNITY_EXCLUDE_FLOAT_PRINT to trim binary size, won't print floating point values in errors * Output * - by default, Unity prints to standard out with putchar. define UNITY_OUTPUT_CHAR(a) with a different function if desired * - define UNITY_DIFFERENTIATE_FINAL_FAIL to print FAILED (vs. FAIL) at test end summary - for automated search for failure * Optimization * - by default, line numbers are stored in unsigned shorts. Define UNITY_LINE_TYPE with a different type if your files are huge * - by default, test and failure counters are unsigned shorts. Define UNITY_COUNTER_TYPE with a different type if you want to save space or have more than 65535 Tests. * Test Cases * - define UNITY_SUPPORT_TEST_CASES to include the TEST_CASE macro, though really it's mostly about the runner generator script * Parameterized Tests * - you'll want to create a define of TEST_CASE(...) which basically evaluates to nothing * Tests with Arguments * - you'll want to define UNITY_USE_COMMAND_LINE_ARGS if you have the test runner passing arguments to Unity *------------------------------------------------------- * Basic Fail and Ignore *-------------------------------------------------------*/ #define TEST_FAIL_MESSAGE(message) UNITY_TEST_FAIL(__LINE__, (message)) #define TEST_FAIL() UNITY_TEST_FAIL(__LINE__, NULL) #define TEST_IGNORE_MESSAGE(message) UNITY_TEST_IGNORE(__LINE__, (message)) #define TEST_IGNORE() UNITY_TEST_IGNORE(__LINE__, NULL) #define TEST_ONLY() /* It is not necessary for you to call PASS. A PASS condition is assumed if nothing fails. * This method allows you to abort a test immediately with a PASS state, ignoring the remainder of the test. */ #define TEST_PASS() TEST_ABORT() /* This macro does nothing, but it is useful for build tools (like Ceedling) to make use of this to figure out * which files should be linked to in order to perform a test. Use it like TEST_FILE("sandwiches.c") */ #define TEST_FILE(a) /*------------------------------------------------------- * Test Asserts (simple) *-------------------------------------------------------*/ /* Boolean */ #define TEST_ASSERT(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expression Evaluated To FALSE") #define TEST_ASSERT_TRUE(condition) UNITY_TEST_ASSERT( (condition), __LINE__, " Expected TRUE Was FALSE") #define TEST_ASSERT_UNLESS(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expression Evaluated To TRUE") #define TEST_ASSERT_FALSE(condition) UNITY_TEST_ASSERT( !(condition), __LINE__, " Expected FALSE Was TRUE") #define TEST_ASSERT_NULL(pointer) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, " Expected NULL") #define TEST_ASSERT_NOT_NULL(pointer) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, " Expected Non-NULL") /* Integers (of all sizes) */ #define TEST_ASSERT_EQUAL_INT(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL(expected, actual) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_NOT_EQUAL(expected, actual) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, " Expected Not-Equal") #define TEST_ASSERT_EQUAL_UINT(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT8(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT16(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT32(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT64(expected, actual) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX8(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX16(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX32(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX64(expected, actual) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS(mask, expected, actual) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS_HIGH(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) #define TEST_ASSERT_BITS_LOW(mask, actual) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, NULL) #define TEST_ASSERT_BIT_HIGH(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, NULL) #define TEST_ASSERT_BIT_LOW(bit, actual) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, NULL) /* Integer Greater Than/ Less Than (of all sizes) */ #define TEST_ASSERT_GREATER_THAN(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_THAN_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_INT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_UINT64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, NULL) #define TEST_ASSERT_LESS_OR_EQUAL_HEX64(threshold, actual) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, NULL) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_INT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_INT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_INT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_INT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_UINT64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX8_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX16_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX32_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_HEX64_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, NULL) /* Structs and Strings */ #define TEST_ASSERT_EQUAL_PTR(expected, actual) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_STRING(expected, actual) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, NULL) #define TEST_ASSERT_EQUAL_MEMORY(expected, actual, len) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, NULL) /* Arrays */ #define TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, NULL) /* Arrays Compared To Single Value */ #define TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, NULL) /* Floating Point (If Enabled) */ #define TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT(expected, actual) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NOT_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, NULL) #define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, NULL) /* Double (If Enabled) */ #define TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE(expected, actual) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, NULL) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NOT_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, NULL) #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, NULL) /*------------------------------------------------------- * Test Asserts (with additional messages) *-------------------------------------------------------*/ /* Boolean */ #define TEST_ASSERT_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) #define TEST_ASSERT_TRUE_MESSAGE(condition, message) UNITY_TEST_ASSERT( (condition), __LINE__, (message)) #define TEST_ASSERT_UNLESS_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) #define TEST_ASSERT_FALSE_MESSAGE(condition, message) UNITY_TEST_ASSERT( !(condition), __LINE__, (message)) #define TEST_ASSERT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NULL( (pointer), __LINE__, (message)) #define TEST_ASSERT_NOT_NULL_MESSAGE(pointer, message) UNITY_TEST_ASSERT_NOT_NULL((pointer), __LINE__, (message)) /* Integers (of all sizes) */ #define TEST_ASSERT_EQUAL_INT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT8((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT16((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT32((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT64((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_INT((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_NOT_EQUAL_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT(((expected) != (actual)), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT8( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT16( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT32( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_UINT64( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX8_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX8( (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX16_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX16((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX32_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX32((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX64_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_HEX64((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_BITS_MESSAGE(mask, expected, actual, message) UNITY_TEST_ASSERT_BITS((mask), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_BITS_HIGH_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) #define TEST_ASSERT_BITS_LOW_MESSAGE(mask, actual, message) UNITY_TEST_ASSERT_BITS((mask), (UNITY_UINT32)(0), (actual), __LINE__, (message)) #define TEST_ASSERT_BIT_HIGH_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(-1), (actual), __LINE__, (message)) #define TEST_ASSERT_BIT_LOW_MESSAGE(bit, actual, message) UNITY_TEST_ASSERT_BITS(((UNITY_UINT32)1 << (bit)), (UNITY_UINT32)(0), (actual), __LINE__, (message)) /* Integer Greater Than/ Less Than (of all sizes) */ #define TEST_ASSERT_GREATER_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_THAN_HEX64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_THAN_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_GREATER_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_INT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_UINT64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX8_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX16_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX32_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX32((threshold), (actual), __LINE__, (message)) #define TEST_ASSERT_LESS_OR_EQUAL_HEX64_MESSAGE(threshold, actual, message) UNITY_TEST_ASSERT_SMALLER_THAN_HEX64((threshold), (actual), __LINE__, (message)) /* Integer Ranges (of all sizes) */ #define TEST_ASSERT_INT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_INT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_INT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_INT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_INT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_INT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT8_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT16_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_UINT64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_UINT64_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX8_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX8_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX16_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX16_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX32_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX32_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_HEX64_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_HEX64_WITHIN((delta), (expected), (actual), __LINE__, (message)) /* Structs and Strings */ #define TEST_ASSERT_EQUAL_PTR_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_PTR((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_STRING_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_STRING((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_STRING_LEN_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_STRING_LEN((expected), (actual), (len), __LINE__, (message)) #define TEST_ASSERT_EQUAL_MEMORY_MESSAGE(expected, actual, len, message) UNITY_TEST_ASSERT_EQUAL_MEMORY((expected), (actual), (len), __LINE__, (message)) /* Arrays */ #define TEST_ASSERT_EQUAL_INT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_INT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_UINT64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX8_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX16_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX32_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_HEX64_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_PTR_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_STRING_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EQUAL_MEMORY_ARRAY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY((expected), (actual), (len), (num_elements), __LINE__, (message)) /* Arrays Compared To Single Value*/ #define TEST_ASSERT_EACH_EQUAL_INT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_INT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT8((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_INT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT16((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_INT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_INT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_INT64((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT8((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT16((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_UINT64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_UINT64((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX8_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX8((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX16_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX16((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX32_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX32((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_HEX64_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_HEX64((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_PTR_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_PTR((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_STRING_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_STRING((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_MEMORY_MESSAGE(expected, actual, len, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY((expected), (actual), (len), (num_elements), __LINE__, (message)) /* Floating Point (If Enabled) */ #define TEST_ASSERT_FLOAT_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_FLOAT((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_FLOAT_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_FLOAT_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NAN((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN((actual), __LINE__, (message)) #define TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE((actual), __LINE__, (message)) /* Double (If Enabled) */ #define TEST_ASSERT_DOUBLE_WITHIN_MESSAGE(delta, expected, actual, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((delta), (expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_MESSAGE(expected, actual, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE((expected), (actual), __LINE__, (message)) #define TEST_ASSERT_EQUAL_DOUBLE_ARRAY_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_EACH_EQUAL_DOUBLE_MESSAGE(expected, actual, num_elements, message) UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE((expected), (actual), (num_elements), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NAN((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NOT_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NOT_NAN_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN((actual), __LINE__, (message)) #define TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE_MESSAGE(actual, message) UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE((actual), __LINE__, (message)) /* end of UNITY_FRAMEWORK_H */ #ifdef __cplusplus } #endif #endif
sophomore_public/libzmq
external/unity/unity.h
C++
gpl-3.0
66,485
/* ========================================== Unity Project - A Test Framework for C Copyright (c) 2007-14 Mike Karlesky, Mark VanderVoord, Greg Williams [Released under MIT License. Please refer to license.txt for details] ========================================== */ #ifndef UNITY_INTERNALS_H #define UNITY_INTERNALS_H #ifdef UNITY_INCLUDE_CONFIG_H #include "unity_config.h" #endif #ifndef UNITY_EXCLUDE_SETJMP_H #include <setjmp.h> #endif #ifndef UNITY_EXCLUDE_MATH_H #include <math.h> #endif /* Unity Attempts to Auto-Detect Integer Types * Attempt 1: UINT_MAX, ULONG_MAX in <limits.h>, or default to 32 bits * Attempt 2: UINTPTR_MAX in <stdint.h>, or default to same size as long * The user may override any of these derived constants: * UNITY_INT_WIDTH, UNITY_LONG_WIDTH, UNITY_POINTER_WIDTH */ #ifndef UNITY_EXCLUDE_STDINT_H #include <stdint.h> #endif #ifndef UNITY_EXCLUDE_LIMITS_H #include <limits.h> #endif /*------------------------------------------------------- * Guess Widths If Not Specified *-------------------------------------------------------*/ /* Determine the size of an int, if not already specified. * We cannot use sizeof(int), because it is not yet defined * at this stage in the translation of the C program. * Therefore, infer it from UINT_MAX if possible. */ #ifndef UNITY_INT_WIDTH #ifdef UINT_MAX #if (UINT_MAX == 0xFFFF) #define UNITY_INT_WIDTH (16) #elif (UINT_MAX == 0xFFFFFFFF) #define UNITY_INT_WIDTH (32) #elif (UINT_MAX == 0xFFFFFFFFFFFFFFFF) #define UNITY_INT_WIDTH (64) #endif #else /* Set to default */ #define UNITY_INT_WIDTH (32) #endif /* UINT_MAX */ #endif /* Determine the size of a long, if not already specified. */ #ifndef UNITY_LONG_WIDTH #ifdef ULONG_MAX #if (ULONG_MAX == 0xFFFF) #define UNITY_LONG_WIDTH (16) #elif (ULONG_MAX == 0xFFFFFFFF) #define UNITY_LONG_WIDTH (32) #elif (ULONG_MAX == 0xFFFFFFFFFFFFFFFF) #define UNITY_LONG_WIDTH (64) #endif #else /* Set to default */ #define UNITY_LONG_WIDTH (32) #endif /* ULONG_MAX */ #endif /* Determine the size of a pointer, if not already specified. */ #ifndef UNITY_POINTER_WIDTH #ifdef UINTPTR_MAX #if (UINTPTR_MAX <= 0xFFFF) #define UNITY_POINTER_WIDTH (16) #elif (UINTPTR_MAX <= 0xFFFFFFFF) #define UNITY_POINTER_WIDTH (32) #elif (UINTPTR_MAX <= 0xFFFFFFFFFFFFFFFF) #define UNITY_POINTER_WIDTH (64) #endif #else /* Set to default */ #define UNITY_POINTER_WIDTH UNITY_LONG_WIDTH #endif /* UINTPTR_MAX */ #endif /*------------------------------------------------------- * Int Support (Define types based on detected sizes) *-------------------------------------------------------*/ #if (UNITY_INT_WIDTH == 32) typedef unsigned char UNITY_UINT8; typedef unsigned short UNITY_UINT16; typedef unsigned int UNITY_UINT32; typedef signed char UNITY_INT8; typedef signed short UNITY_INT16; typedef signed int UNITY_INT32; #elif (UNITY_INT_WIDTH == 16) typedef unsigned char UNITY_UINT8; typedef unsigned int UNITY_UINT16; typedef unsigned long UNITY_UINT32; typedef signed char UNITY_INT8; typedef signed int UNITY_INT16; typedef signed long UNITY_INT32; #else #error Invalid UNITY_INT_WIDTH specified! (16 or 32 are supported) #endif /*------------------------------------------------------- * 64-bit Support *-------------------------------------------------------*/ #ifndef UNITY_SUPPORT_64 #if UNITY_LONG_WIDTH == 64 || UNITY_POINTER_WIDTH == 64 #define UNITY_SUPPORT_64 #endif #endif #ifndef UNITY_SUPPORT_64 /* No 64-bit Support */ typedef UNITY_UINT32 UNITY_UINT; typedef UNITY_INT32 UNITY_INT; #else /* 64-bit Support */ #if (UNITY_LONG_WIDTH == 32) typedef unsigned long long UNITY_UINT64; typedef signed long long UNITY_INT64; #elif (UNITY_LONG_WIDTH == 64) typedef unsigned long UNITY_UINT64; typedef signed long UNITY_INT64; #else #error Invalid UNITY_LONG_WIDTH specified! (32 or 64 are supported) #endif typedef UNITY_UINT64 UNITY_UINT; typedef UNITY_INT64 UNITY_INT; #endif /*------------------------------------------------------- * Pointer Support *-------------------------------------------------------*/ #if (UNITY_POINTER_WIDTH == 32) #define UNITY_PTR_TO_INT UNITY_INT32 #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX32 #elif (UNITY_POINTER_WIDTH == 64) #define UNITY_PTR_TO_INT UNITY_INT64 #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX64 #elif (UNITY_POINTER_WIDTH == 16) #define UNITY_PTR_TO_INT UNITY_INT16 #define UNITY_DISPLAY_STYLE_POINTER UNITY_DISPLAY_STYLE_HEX16 #else #error Invalid UNITY_POINTER_WIDTH specified! (16, 32 or 64 are supported) #endif #ifndef UNITY_PTR_ATTRIBUTE #define UNITY_PTR_ATTRIBUTE #endif #ifndef UNITY_INTERNAL_PTR #define UNITY_INTERNAL_PTR UNITY_PTR_ATTRIBUTE const void* #endif /*------------------------------------------------------- * Float Support *-------------------------------------------------------*/ #ifdef UNITY_EXCLUDE_FLOAT /* No Floating Point Support */ #ifndef UNITY_EXCLUDE_DOUBLE #define UNITY_EXCLUDE_DOUBLE /* Remove double when excluding float support */ #endif #ifndef UNITY_EXCLUDE_FLOAT_PRINT #define UNITY_EXCLUDE_FLOAT_PRINT #endif #else /* Floating Point Support */ #ifndef UNITY_FLOAT_PRECISION #define UNITY_FLOAT_PRECISION (0.00001f) #endif #ifndef UNITY_FLOAT_TYPE #define UNITY_FLOAT_TYPE float #endif typedef UNITY_FLOAT_TYPE UNITY_FLOAT; /* isinf & isnan macros should be provided by math.h */ #ifndef isinf /* The value of Inf - Inf is NaN */ #define isinf(n) (isnan((n) - (n)) && !isnan(n)) #endif #ifndef isnan /* NaN is the only floating point value that does NOT equal itself. * Therefore if n != n, then it is NaN. */ #define isnan(n) ((n != n) ? 1 : 0) #endif #endif /*------------------------------------------------------- * Double Float Support *-------------------------------------------------------*/ /* unlike float, we DON'T include by default */ #if defined(UNITY_EXCLUDE_DOUBLE) || !defined(UNITY_INCLUDE_DOUBLE) /* No Floating Point Support */ #ifndef UNITY_EXCLUDE_DOUBLE #define UNITY_EXCLUDE_DOUBLE #else #undef UNITY_INCLUDE_DOUBLE #endif #ifndef UNITY_EXCLUDE_FLOAT #ifndef UNITY_DOUBLE_TYPE #define UNITY_DOUBLE_TYPE double #endif typedef UNITY_FLOAT UNITY_DOUBLE; /* For parameter in UnityPrintFloat(UNITY_DOUBLE), which aliases to double or float */ #endif #else /* Double Floating Point Support */ #ifndef UNITY_DOUBLE_PRECISION #define UNITY_DOUBLE_PRECISION (1e-12) #endif #ifndef UNITY_DOUBLE_TYPE #define UNITY_DOUBLE_TYPE double #endif typedef UNITY_DOUBLE_TYPE UNITY_DOUBLE; #endif /*------------------------------------------------------- * Output Method: stdout (DEFAULT) *-------------------------------------------------------*/ #ifndef UNITY_OUTPUT_CHAR /* Default to using putchar, which is defined in stdio.h */ #include <stdio.h> #define UNITY_OUTPUT_CHAR(a) (void)putchar(a) #else /* If defined as something else, make sure we declare it here so it's ready for use */ #ifdef UNITY_OUTPUT_CHAR_HEADER_DECLARATION extern void UNITY_OUTPUT_CHAR_HEADER_DECLARATION; #endif #endif #ifndef UNITY_OUTPUT_FLUSH #ifdef UNITY_USE_FLUSH_STDOUT /* We want to use the stdout flush utility */ #include <stdio.h> #define UNITY_OUTPUT_FLUSH() (void)fflush(stdout) #else /* We've specified nothing, therefore flush should just be ignored */ #define UNITY_OUTPUT_FLUSH() #endif #else /* We've defined flush as something else, so make sure we declare it here so it's ready for use */ #ifdef UNITY_OUTPUT_FLUSH_HEADER_DECLARATION extern void UNITY_OMIT_OUTPUT_FLUSH_HEADER_DECLARATION; #endif #endif #ifndef UNITY_OUTPUT_FLUSH #define UNITY_FLUSH_CALL() #else #define UNITY_FLUSH_CALL() UNITY_OUTPUT_FLUSH() #endif #ifndef UNITY_PRINT_EOL #define UNITY_PRINT_EOL() UNITY_OUTPUT_CHAR('\n') #endif #ifndef UNITY_OUTPUT_START #define UNITY_OUTPUT_START() #endif #ifndef UNITY_OUTPUT_COMPLETE #define UNITY_OUTPUT_COMPLETE() #endif /*------------------------------------------------------- * Footprint *-------------------------------------------------------*/ #ifndef UNITY_LINE_TYPE #define UNITY_LINE_TYPE UNITY_UINT #endif #ifndef UNITY_COUNTER_TYPE #define UNITY_COUNTER_TYPE UNITY_UINT #endif /*------------------------------------------------------- * Language Features Available *-------------------------------------------------------*/ #if !defined(UNITY_WEAK_ATTRIBUTE) && !defined(UNITY_WEAK_PRAGMA) # if defined(__GNUC__) || defined(__ghs__) /* __GNUC__ includes clang */ # if !(defined(__WIN32__) && defined(__clang__)) && !defined(__TMS470__) # define UNITY_WEAK_ATTRIBUTE __attribute__((weak)) # endif # endif #endif #ifdef UNITY_NO_WEAK # undef UNITY_WEAK_ATTRIBUTE # undef UNITY_WEAK_PRAGMA #endif /*------------------------------------------------------- * Internal Structs Needed *-------------------------------------------------------*/ typedef void (*UnityTestFunction)(void); #define UNITY_DISPLAY_RANGE_INT (0x10) #define UNITY_DISPLAY_RANGE_UINT (0x20) #define UNITY_DISPLAY_RANGE_HEX (0x40) typedef enum { UNITY_DISPLAY_STYLE_INT = sizeof(int)+ UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT8 = 1 + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT16 = 2 + UNITY_DISPLAY_RANGE_INT, UNITY_DISPLAY_STYLE_INT32 = 4 + UNITY_DISPLAY_RANGE_INT, #ifdef UNITY_SUPPORT_64 UNITY_DISPLAY_STYLE_INT64 = 8 + UNITY_DISPLAY_RANGE_INT, #endif UNITY_DISPLAY_STYLE_UINT = sizeof(unsigned) + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT8 = 1 + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT16 = 2 + UNITY_DISPLAY_RANGE_UINT, UNITY_DISPLAY_STYLE_UINT32 = 4 + UNITY_DISPLAY_RANGE_UINT, #ifdef UNITY_SUPPORT_64 UNITY_DISPLAY_STYLE_UINT64 = 8 + UNITY_DISPLAY_RANGE_UINT, #endif UNITY_DISPLAY_STYLE_HEX8 = 1 + UNITY_DISPLAY_RANGE_HEX, UNITY_DISPLAY_STYLE_HEX16 = 2 + UNITY_DISPLAY_RANGE_HEX, UNITY_DISPLAY_STYLE_HEX32 = 4 + UNITY_DISPLAY_RANGE_HEX, #ifdef UNITY_SUPPORT_64 UNITY_DISPLAY_STYLE_HEX64 = 8 + UNITY_DISPLAY_RANGE_HEX, #endif UNITY_DISPLAY_STYLE_UNKNOWN } UNITY_DISPLAY_STYLE_T; typedef enum { UNITY_EQUAL_TO = 1, UNITY_GREATER_THAN = 2, UNITY_GREATER_OR_EQUAL = 2 + UNITY_EQUAL_TO, UNITY_SMALLER_THAN = 4, UNITY_SMALLER_OR_EQUAL = 4 + UNITY_EQUAL_TO } UNITY_COMPARISON_T; #ifndef UNITY_EXCLUDE_FLOAT typedef enum UNITY_FLOAT_TRAIT { UNITY_FLOAT_IS_NOT_INF = 0, UNITY_FLOAT_IS_INF, UNITY_FLOAT_IS_NOT_NEG_INF, UNITY_FLOAT_IS_NEG_INF, UNITY_FLOAT_IS_NOT_NAN, UNITY_FLOAT_IS_NAN, UNITY_FLOAT_IS_NOT_DET, UNITY_FLOAT_IS_DET, UNITY_FLOAT_INVALID_TRAIT } UNITY_FLOAT_TRAIT_T; #endif typedef enum { UNITY_ARRAY_TO_VAL = 0, UNITY_ARRAY_TO_ARRAY } UNITY_FLAGS_T; struct UNITY_STORAGE_T { const char* TestFile; const char* CurrentTestName; #ifndef UNITY_EXCLUDE_DETAILS const char* CurrentDetail1; const char* CurrentDetail2; #endif UNITY_LINE_TYPE CurrentTestLineNumber; UNITY_COUNTER_TYPE NumberOfTests; UNITY_COUNTER_TYPE TestFailures; UNITY_COUNTER_TYPE TestIgnores; UNITY_COUNTER_TYPE CurrentTestFailed; UNITY_COUNTER_TYPE CurrentTestIgnored; #ifndef UNITY_EXCLUDE_SETJMP_H jmp_buf AbortFrame; #endif }; extern struct UNITY_STORAGE_T Unity; /*------------------------------------------------------- * Test Suite Management *-------------------------------------------------------*/ void UnityBegin(const char* filename); int UnityEnd(void); void UnityConcludeTest(void); void UnityDefaultTestRun(UnityTestFunction Func, const char* FuncName, const int FuncLineNum); /*------------------------------------------------------- * Details Support *-------------------------------------------------------*/ #ifdef UNITY_EXCLUDE_DETAILS #define UNITY_CLR_DETAILS() #define UNITY_SET_DETAIL(d1) #define UNITY_SET_DETAILS(d1,d2) #else #define UNITY_CLR_DETAILS() { Unity.CurrentDetail1 = 0; Unity.CurrentDetail2 = 0; } #define UNITY_SET_DETAIL(d1) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = 0; } #define UNITY_SET_DETAILS(d1,d2) { Unity.CurrentDetail1 = d1; Unity.CurrentDetail2 = d2; } #ifndef UNITY_DETAIL1_NAME #define UNITY_DETAIL1_NAME "Function" #endif #ifndef UNITY_DETAIL2_NAME #define UNITY_DETAIL2_NAME "Argument" #endif #endif /*------------------------------------------------------- * Test Output *-------------------------------------------------------*/ void UnityPrint(const char* string); void UnityPrintLen(const char* string, const UNITY_UINT32 length); void UnityPrintMask(const UNITY_UINT mask, const UNITY_UINT number); void UnityPrintNumberByStyle(const UNITY_INT number, const UNITY_DISPLAY_STYLE_T style); void UnityPrintNumber(const UNITY_INT number); void UnityPrintNumberUnsigned(const UNITY_UINT number); void UnityPrintNumberHex(const UNITY_UINT number, const char nibbles); #ifndef UNITY_EXCLUDE_FLOAT_PRINT void UnityPrintFloat(const UNITY_DOUBLE input_number); #endif /*------------------------------------------------------- * Test Assertion Functions *------------------------------------------------------- * Use the macros below this section instead of calling * these directly. The macros have a consistent naming * convention and will pull in file and line information * for you. */ void UnityAssertEqualNumber(const UNITY_INT expected, const UNITY_INT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); void UnityAssertGreaterOrLessOrEqualNumber(const UNITY_INT threshold, const UNITY_INT actual, const UNITY_COMPARISON_T compare, const char *msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); void UnityAssertEqualIntArray(UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style, const UNITY_FLAGS_T flags); void UnityAssertBits(const UNITY_INT mask, const UNITY_INT expected, const UNITY_INT actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void UnityAssertEqualString(const char* expected, const char* actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void UnityAssertEqualStringLen(const char* expected, const char* actual, const UNITY_UINT32 length, const char* msg, const UNITY_LINE_TYPE lineNumber); void UnityAssertEqualStringArray( UNITY_INTERNAL_PTR expected, const char** actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags); void UnityAssertEqualMemory( UNITY_INTERNAL_PTR expected, UNITY_INTERNAL_PTR actual, const UNITY_UINT32 length, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags); void UnityAssertNumbersWithin(const UNITY_UINT delta, const UNITY_INT expected, const UNITY_INT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_DISPLAY_STYLE_T style); void UnityFail(const char* message, const UNITY_LINE_TYPE line); void UnityIgnore(const char* message, const UNITY_LINE_TYPE line); #ifndef UNITY_EXCLUDE_FLOAT void UnityAssertFloatsWithin(const UNITY_FLOAT delta, const UNITY_FLOAT expected, const UNITY_FLOAT actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void UnityAssertEqualFloatArray(UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* expected, UNITY_PTR_ATTRIBUTE const UNITY_FLOAT* actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags); void UnityAssertFloatSpecial(const UNITY_FLOAT actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style); #endif #ifndef UNITY_EXCLUDE_DOUBLE void UnityAssertDoublesWithin(const UNITY_DOUBLE delta, const UNITY_DOUBLE expected, const UNITY_DOUBLE actual, const char* msg, const UNITY_LINE_TYPE lineNumber); void UnityAssertEqualDoubleArray(UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* expected, UNITY_PTR_ATTRIBUTE const UNITY_DOUBLE* actual, const UNITY_UINT32 num_elements, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLAGS_T flags); void UnityAssertDoubleSpecial(const UNITY_DOUBLE actual, const char* msg, const UNITY_LINE_TYPE lineNumber, const UNITY_FLOAT_TRAIT_T style); #endif /*------------------------------------------------------- * Helpers *-------------------------------------------------------*/ UNITY_INTERNAL_PTR UnityNumToPtr(const UNITY_INT num, const UNITY_UINT8 size); #ifndef UNITY_EXCLUDE_FLOAT UNITY_INTERNAL_PTR UnityFloatToPtr(const float num); #endif #ifndef UNITY_EXCLUDE_DOUBLE UNITY_INTERNAL_PTR UnityDoubleToPtr(const double num); #endif /*------------------------------------------------------- * Error Strings We Might Need *-------------------------------------------------------*/ extern const char UnityStrErrFloat[]; extern const char UnityStrErrDouble[]; extern const char UnityStrErr64[]; /*------------------------------------------------------- * Test Running Macros *-------------------------------------------------------*/ #ifndef UNITY_EXCLUDE_SETJMP_H #define TEST_PROTECT() (setjmp(Unity.AbortFrame) == 0) #define TEST_ABORT() longjmp(Unity.AbortFrame, 1) #else #define TEST_PROTECT() 1 #define TEST_ABORT() return #endif /* This tricky series of macros gives us an optional line argument to treat it as RUN_TEST(func, num=__LINE__) */ #ifndef RUN_TEST #ifdef __STDC_VERSION__ #if __STDC_VERSION__ >= 199901L #define RUN_TEST(...) UnityDefaultTestRun(RUN_TEST_FIRST(__VA_ARGS__), RUN_TEST_SECOND(__VA_ARGS__)) #define RUN_TEST_FIRST(...) RUN_TEST_FIRST_HELPER(__VA_ARGS__, throwaway) #define RUN_TEST_FIRST_HELPER(first, ...) (first), #first #define RUN_TEST_SECOND(...) RUN_TEST_SECOND_HELPER(__VA_ARGS__, __LINE__, throwaway) #define RUN_TEST_SECOND_HELPER(first, second, ...) (second) #endif #endif #endif /* If we can't do the tricky version, we'll just have to require them to always include the line number */ #ifndef RUN_TEST #ifdef CMOCK #define RUN_TEST(func, num) UnityDefaultTestRun(func, #func, num) #else #define RUN_TEST(func) UnityDefaultTestRun(func, #func, __LINE__) #endif #endif #define TEST_LINE_NUM (Unity.CurrentTestLineNumber) #define TEST_IS_IGNORED (Unity.CurrentTestIgnored) #define UNITY_NEW_TEST(a) \ Unity.CurrentTestName = (a); \ Unity.CurrentTestLineNumber = (UNITY_LINE_TYPE)(__LINE__); \ Unity.NumberOfTests++; #ifndef UNITY_BEGIN #define UNITY_BEGIN() UnityBegin(__FILE__) #endif #ifndef UNITY_END #define UNITY_END() UnityEnd() #endif /*----------------------------------------------- * Command Line Argument Support *-----------------------------------------------*/ #ifdef UNITY_USE_COMMAND_LINE_ARGS int UnityParseOptions(int argc, char** argv); int UnityTestMatches(void); #endif /*------------------------------------------------------- * Basic Fail and Ignore *-------------------------------------------------------*/ #define UNITY_TEST_FAIL(line, message) UnityFail( (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_IGNORE(line, message) UnityIgnore( (message), (UNITY_LINE_TYPE)(line)) /*------------------------------------------------------- * Test Asserts *-------------------------------------------------------*/ #define UNITY_TEST_ASSERT(condition, line, message) if (condition) {} else {UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), (message));} #define UNITY_TEST_ASSERT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) == NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_NOT_NULL(pointer, line, message) UNITY_TEST_ASSERT(((pointer) != NULL), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_INT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_EQUAL_INT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_EQUAL_INT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_EQUAL_INT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_EQUAL_UINT(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_EQUAL_UINT8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_EQUAL_UINT16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_EQUAL_UINT32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) #define UNITY_TEST_ASSERT_EQUAL_HEX8(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_EQUAL_HEX16(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_EQUAL_HEX32(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_BITS(mask, expected, actual, line, message) UnityAssertBits((UNITY_INT)(mask), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_GREATER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_GREATER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_GREATER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_GREATER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_SMALLER_THAN_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_SMALLER_THAN_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_SMALLER_THAN_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_SMALLER_THAN_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT8 )(threshold), (UNITY_INT)(UNITY_INT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT16)(threshold), (UNITY_INT)(UNITY_INT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_INT32)(threshold), (UNITY_INT)(UNITY_INT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX8(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT8 )(threshold), (UNITY_INT)(UNITY_UINT8 )(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX16(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT16)(threshold), (UNITY_INT)(UNITY_UINT16)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX32(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(UNITY_UINT32)(threshold), (UNITY_INT)(UNITY_UINT32)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_INT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT) #define UNITY_TEST_ASSERT_INT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_INT8 )(expected), (UNITY_INT)(UNITY_INT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8) #define UNITY_TEST_ASSERT_INT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_INT16)(expected), (UNITY_INT)(UNITY_INT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16) #define UNITY_TEST_ASSERT_INT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_INT32)(expected), (UNITY_INT)(UNITY_INT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32) #define UNITY_TEST_ASSERT_UINT_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT) #define UNITY_TEST_ASSERT_UINT8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8) #define UNITY_TEST_ASSERT_UINT16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16) #define UNITY_TEST_ASSERT_UINT32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32) #define UNITY_TEST_ASSERT_HEX8_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT8 )(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT8 )(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8) #define UNITY_TEST_ASSERT_HEX16_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT16)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT16)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16) #define UNITY_TEST_ASSERT_HEX32_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((UNITY_UINT32)(delta), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(expected), (UNITY_INT)(UNITY_UINT)(UNITY_UINT32)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32) #define UNITY_TEST_ASSERT_EQUAL_PTR(expected, actual, line, message) UnityAssertEqualNumber((UNITY_PTR_TO_INT)(expected), (UNITY_PTR_TO_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER) #define UNITY_TEST_ASSERT_EQUAL_STRING(expected, actual, line, message) UnityAssertEqualString((const char*)(expected), (const char*)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_STRING_LEN(expected, actual, len, line, message) UnityAssertEqualStringLen((const char*)(expected), (const char*)(actual), (UNITY_UINT32)(len), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_MEMORY(expected, actual, len, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), 1, (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_INT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_INT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_INT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_INT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_HEX8_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_HEX16_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_HEX32_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_PTR_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_STRING_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_MEMORY_ARRAY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) expected, sizeof(int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )expected, 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT8, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )expected, 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT16, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )expected, 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT32, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT) expected, sizeof(unsigned int)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT8 )expected, 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT8, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT16)expected, 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT16, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT32)expected, 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT32, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_HEX8(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT8 )expected, 1), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX8, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_HEX16(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT16 )expected, 2), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX16, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_HEX32(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT32 )expected, 4), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX32, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_PTR(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_PTR_TO_INT) expected, sizeof(int*)), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_POINTER, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_STRING(expected, actual, num_elements, line, message) UnityAssertEqualStringArray((UNITY_INTERNAL_PTR)(expected), (const char**)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_MEMORY(expected, actual, len, num_elements, line, message) UnityAssertEqualMemory((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(len), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #ifdef UNITY_SUPPORT_64 #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UnityAssertEqualNumber((UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualIntArray((UNITY_INTERNAL_PTR)(expected), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_INT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_UINT64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_UINT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_EACH_EQUAL_HEX64(expected, actual, num_elements, line, message) UnityAssertEqualIntArray(UnityNumToPtr((UNITY_INT)(UNITY_INT64)expected, 8), (UNITY_INTERNAL_PTR)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UnityAssertNumbersWithin((delta), (UNITY_INT)(expected), (UNITY_INT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_GREATER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_THAN, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_INT64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_UINT64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UnityAssertGreaterOrLessOrEqualNumber((UNITY_INT)(threshold), (UNITY_INT)(actual), UNITY_SMALLER_OR_EQUAL, (message), (UNITY_LINE_TYPE)(line), UNITY_DISPLAY_STYLE_HEX64) #else #define UNITY_TEST_ASSERT_EQUAL_INT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_UINT64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_HEX64(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_INT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_UINT64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_EQUAL_HEX64_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_INT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_UINT64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_HEX64_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_GREATER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_GREATER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_GREATER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_GREATER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_THAN_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_THAN_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_THAN_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_INT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_UINT64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #define UNITY_TEST_ASSERT_SMALLER_OR_EQUAL_HEX64(threshold, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErr64) #endif #ifdef UNITY_EXCLUDE_FLOAT #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrFloat) #else #define UNITY_TEST_ASSERT_FLOAT_WITHIN(delta, expected, actual, line, message) UnityAssertFloatsWithin((UNITY_FLOAT)(delta), (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT(expected, actual, line, message) UNITY_TEST_ASSERT_FLOAT_WITHIN((UNITY_FLOAT)(expected) * (UNITY_FLOAT)UNITY_FLOAT_PRECISION, (UNITY_FLOAT)(expected), (UNITY_FLOAT)(actual), (UNITY_LINE_TYPE)(line), (message)) #define UNITY_TEST_ASSERT_EQUAL_FLOAT_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray((UNITY_FLOAT*)(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_FLOAT(expected, actual, num_elements, line, message) UnityAssertEqualFloatArray(UnityFloatToPtr(expected), (UNITY_FLOAT*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)(line), UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_FLOAT_IS_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) #define UNITY_TEST_ASSERT_FLOAT_IS_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NEG_INF(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NEG_INF) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_NAN(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NAN) #define UNITY_TEST_ASSERT_FLOAT_IS_NOT_DETERMINATE(actual, line, message) UnityAssertFloatSpecial((UNITY_FLOAT)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) #endif #ifdef UNITY_EXCLUDE_DOUBLE #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UNITY_TEST_FAIL((UNITY_LINE_TYPE)(line), UnityStrErrDouble) #else #define UNITY_TEST_ASSERT_DOUBLE_WITHIN(delta, expected, actual, line, message) UnityAssertDoublesWithin((UNITY_DOUBLE)(delta), (UNITY_DOUBLE)(expected), (UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)line) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE(expected, actual, line, message) UNITY_TEST_ASSERT_DOUBLE_WITHIN((UNITY_DOUBLE)(expected) * (UNITY_DOUBLE)UNITY_DOUBLE_PRECISION, (UNITY_DOUBLE)expected, (UNITY_DOUBLE)actual, (UNITY_LINE_TYPE)(line), message) #define UNITY_TEST_ASSERT_EQUAL_DOUBLE_ARRAY(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray((UNITY_DOUBLE*)(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_ARRAY) #define UNITY_TEST_ASSERT_EACH_EQUAL_DOUBLE(expected, actual, num_elements, line, message) UnityAssertEqualDoubleArray(UnityDoubleToPtr(expected), (UNITY_DOUBLE*)(actual), (UNITY_UINT32)(num_elements), (message), (UNITY_LINE_TYPE)line, UNITY_ARRAY_TO_VAL) #define UNITY_TEST_ASSERT_DOUBLE_IS_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NEG_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NAN) #define UNITY_TEST_ASSERT_DOUBLE_IS_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_DET) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NEG_INF(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NEG_INF) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_NAN(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_NAN) #define UNITY_TEST_ASSERT_DOUBLE_IS_NOT_DETERMINATE(actual, line, message) UnityAssertDoubleSpecial((UNITY_DOUBLE)(actual), (message), (UNITY_LINE_TYPE)(line), UNITY_FLOAT_IS_NOT_DET) #endif /* End of UNITY_INTERNALS_H */ #endif
sophomore_public/libzmq
external/unity/unity_internals.h
C++
gpl-3.0
69,577
https://github.com/ThrowTheSwitch/Unity/commit/b4aca70fd9e0ddf0afbdafb1b826f5edcfc1049b
sophomore_public/libzmq
external/unity/version.txt
Text
gpl-3.0
88
# wepoll - epoll for windows [![][ci status badge]][ci status link] This library implements the [epoll][man epoll] API for Windows applications. It is fast and scalable, and it closely resembles the API and behavior of Linux' epoll. ## Rationale Unlike Linux, OS X, and many other operating systems, Windows doesn't have a good API for receiving socket state notifications. It only supports the `select` and `WSAPoll` APIs, but they [don't scale][select scale] and suffer from [other issues][wsapoll broken]. Using I/O completion ports isn't always practical when software is designed to be cross-platform. Wepoll offers an alternative that is much closer to a drop-in replacement for software that was designed to run on Linux. ## Features * Can poll 100000s of sockets efficiently. * Fully thread-safe. * Multiple threads can poll the same epoll port. * Sockets can be added to multiple epoll sets. * All epoll events (`EPOLLIN`, `EPOLLOUT`, `EPOLLPRI`, `EPOLLRDHUP`) are supported. * Level-triggered and one-shot (`EPOLLONESTHOT`) modes are supported * Trivial to embed: you need [only two files][dist]. ## Limitations * Only works with sockets. * Edge-triggered (`EPOLLET`) mode isn't supported. ## How to use The library is [distributed][dist] as a single source file ([wepoll.c][wepoll.c]) and a single header file ([wepoll.h][wepoll.h]).<br> Compile the .c file as part of your project, and include the header wherever needed. ## Compatibility * Requires Windows Vista or higher. * Can be compiled with recent versions of MSVC, Clang, and GCC. ## API ### General remarks * The epoll port is a `HANDLE`, not a file descriptor. * All functions set both `errno` and `GetLastError()` on failure. * For more extensive documentation, see the [epoll(7) man page][man epoll], and the per-function man pages that are linked below. ### epoll_create/epoll_create1 ```c HANDLE epoll_create(int size); HANDLE epoll_create1(int flags); ``` * Create a new epoll instance (port). * `size` is ignored but most be greater than zero. * `flags` must be zero as there are no supported flags. * Returns `NULL` on failure. * [Linux man page][man epoll_create] ### epoll_close ```c int epoll_close(HANDLE ephnd); ``` * Close an epoll port. * Do not attempt to close the epoll port with `close()`, `CloseHandle()` or `closesocket()`. ### epoll_ctl ```c int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* event); ``` * Control which socket events are monitored by an epoll port. * `ephnd` must be a HANDLE created by [`epoll_create()`](#epoll_createepoll_create1) or [`epoll_create1()`](#epoll_createepoll_create1). * `op` must be one of `EPOLL_CTL_ADD`, `EPOLL_CTL_MOD`, `EPOLL_CTL_DEL`. * `sock` must be a valid socket created by [`socket()`][msdn socket], [`WSASocket()`][msdn wsasocket], or [`accept()`][msdn accept]. * `event` should be a pointer to a [`struct epoll_event`](#struct-epoll_event).<br> If `op` is `EPOLL_CTL_DEL` then the `event` parameter is ignored, and it may be `NULL`. * Returns 0 on success, -1 on failure. * It is recommended to always explicitly remove a socket from its epoll set using `EPOLL_CTL_DEL` *before* closing it.<br> As on Linux, closed sockets are automatically removed from the epoll set, but wepoll may not be able to detect that a socket was closed until the next call to [`epoll_wait()`](#epoll_wait). * [Linux man page][man epoll_ctl] ### epoll_wait ```c int epoll_wait(HANDLE ephnd, struct epoll_event* events, int maxevents, int timeout); ``` * Receive socket events from an epoll port. * `events` should point to a caller-allocated array of [`epoll_event`](#struct-epoll_event) structs, which will receive the reported events. * `maxevents` is the maximum number of events that will be written to the `events` array, and must be greater than zero. * `timeout` specifies whether to block when no events are immediately available. - `<0` block indefinitely - `0` report any events that are already waiting, but don't block - `≥1` block for at most N milliseconds * Return value: - `-1` an error occurred - `0` timed out without any events to report - `≥1` the number of events stored in the `events` buffer * [Linux man page][man epoll_wait] ### struct epoll_event ```c typedef union epoll_data { void* ptr; int fd; uint32_t u32; uint64_t u64; SOCKET sock; /* Windows specific */ HANDLE hnd; /* Windows specific */ } epoll_data_t; ``` ```c struct epoll_event { uint32_t events; /* Epoll events and flags */ epoll_data_t data; /* User data variable */ }; ``` * The `events` field is a bit mask containing the events being monitored/reported, and optional flags.<br> Flags are accepted by [`epoll_ctl()`](#epoll_ctl), but they are not reported back by [`epoll_wait()`](#epoll_wait). * The `data` field can be used to associate application-specific information with a socket; its value will be returned unmodified by [`epoll_wait()`](#epoll_wait). * [Linux man page][man epoll_ctl] | Event | Description | |---------------|----------------------------------------------------------------------| | `EPOLLIN` | incoming data available, or incoming connection ready to be accepted | | `EPOLLOUT` | ready to send data, or outgoing connection successfully established | | `EPOLLRDHUP` | remote peer initiated graceful socket shutdown | | `EPOLLPRI` | out-of-band data available for reading | | `EPOLLERR` | socket error<sup>1</sup> | | `EPOLLHUP` | socket hang-up<sup>1</sup> | | `EPOLLRDNORM` | same as `EPOLLIN` | | `EPOLLRDBAND` | same as `EPOLLPRI` | | `EPOLLWRNORM` | same as `EPOLLOUT` | | `EPOLLWRBAND` | same as `EPOLLOUT` | | `EPOLLMSG` | never reported | | Flag | Description | |------------------|---------------------------| | `EPOLLONESHOT` | report event(s) only once | | `EPOLLET` | not supported by wepoll | | `EPOLLEXCLUSIVE` | not supported by wepoll | | `EPOLLWAKEUP` | not supported by wepoll | <sup>1</sup>: the `EPOLLERR` and `EPOLLHUP` events may always be reported by [`epoll_wait()`](#epoll_wait), regardless of the event mask that was passed to [`epoll_ctl()`](#epoll_ctl). [ci status badge]: https://ci.appveyor.com/api/projects/status/github/piscisaureus/wepoll?branch=master&svg=true [ci status link]: https://ci.appveyor.com/project/piscisaureus/wepoll/branch/master [dist]: https://github.com/piscisaureus/wepoll/tree/dist [man epoll]: http://man7.org/linux/man-pages/man7/epoll.7.html [man epoll_create]: http://man7.org/linux/man-pages/man2/epoll_create.2.html [man epoll_ctl]: http://man7.org/linux/man-pages/man2/epoll_ctl.2.html [man epoll_wait]: http://man7.org/linux/man-pages/man2/epoll_wait.2.html [msdn accept]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms737526(v=vs.85).aspx [msdn socket]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms740506(v=vs.85).aspx [msdn wsasocket]: https://msdn.microsoft.com/en-us/library/windows/desktop/ms742212(v=vs.85).aspx [select scale]: https://daniel.haxx.se/docs/poll-vs-select.html [wsapoll broken]: https://daniel.haxx.se/blog/2012/10/10/wsapoll-is-broken/ [wepoll.c]: https://github.com/piscisaureus/wepoll/blob/dist/wepoll.c [wepoll.h]: https://github.com/piscisaureus/wepoll/blob/dist/wepoll.h
sophomore_public/libzmq
external/wepoll/README.md
Markdown
gpl-3.0
7,944
https://github.com/piscisaureus/wepoll/tree/v1.5.8
sophomore_public/libzmq
external/wepoll/version.txt
Text
gpl-3.0
51
/* * wepoll - epoll for Windows * https://github.com/piscisaureus/wepoll * * Copyright 2012-2020, Bert Belder <bertbelder@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef WEPOLL_EXPORT #define WEPOLL_EXPORT #endif #include <stdint.h> enum EPOLL_EVENTS { EPOLLIN = (int) (1U << 0), EPOLLPRI = (int) (1U << 1), EPOLLOUT = (int) (1U << 2), EPOLLERR = (int) (1U << 3), EPOLLHUP = (int) (1U << 4), EPOLLRDNORM = (int) (1U << 6), EPOLLRDBAND = (int) (1U << 7), EPOLLWRNORM = (int) (1U << 8), EPOLLWRBAND = (int) (1U << 9), EPOLLMSG = (int) (1U << 10), /* Never reported. */ EPOLLRDHUP = (int) (1U << 13), EPOLLONESHOT = (int) (1U << 31) }; #define EPOLLIN (1U << 0) #define EPOLLPRI (1U << 1) #define EPOLLOUT (1U << 2) #define EPOLLERR (1U << 3) #define EPOLLHUP (1U << 4) #define EPOLLRDNORM (1U << 6) #define EPOLLRDBAND (1U << 7) #define EPOLLWRNORM (1U << 8) #define EPOLLWRBAND (1U << 9) #define EPOLLMSG (1U << 10) #define EPOLLRDHUP (1U << 13) #define EPOLLONESHOT (1U << 31) #define EPOLL_CTL_ADD 1 #define EPOLL_CTL_MOD 2 #define EPOLL_CTL_DEL 3 typedef void* HANDLE; typedef uintptr_t SOCKET; typedef union epoll_data { void* ptr; int fd; uint32_t u32; uint64_t u64; SOCKET sock; /* Windows specific */ HANDLE hnd; /* Windows specific */ } epoll_data_t; struct epoll_event { uint32_t events; /* Epoll events and flags */ epoll_data_t data; /* User data variable */ }; #ifdef __cplusplus extern "C" { #endif WEPOLL_EXPORT HANDLE epoll_create(int size); WEPOLL_EXPORT HANDLE epoll_create1(int flags); WEPOLL_EXPORT int epoll_close(HANDLE ephnd); WEPOLL_EXPORT int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* event); WEPOLL_EXPORT int epoll_wait(HANDLE ephnd, struct epoll_event* events, int maxevents, int timeout); #ifdef __cplusplus } /* extern "C" */ #endif #include <assert.h> #include <stdlib.h> #define WEPOLL_INTERNAL static #define WEPOLL_INTERNAL_EXTERN static #if defined(__clang__) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wnonportable-system-include-path" #pragma clang diagnostic ignored "-Wreserved-id-macro" #elif defined(_MSC_VER) #pragma warning(push, 1) #endif #undef WIN32_LEAN_AND_MEAN #define WIN32_LEAN_AND_MEAN #undef _WIN32_WINNT #define _WIN32_WINNT 0x0600 #include <winsock2.h> #include <ws2tcpip.h> #include <windows.h> #if defined(__clang__) #pragma clang diagnostic pop #elif defined(_MSC_VER) #pragma warning(pop) #endif WEPOLL_INTERNAL int nt_global_init(void); typedef LONG NTSTATUS; typedef NTSTATUS* PNTSTATUS; #ifndef NT_SUCCESS #define NT_SUCCESS(status) (((NTSTATUS)(status)) >= 0) #endif #ifndef STATUS_SUCCESS #define STATUS_SUCCESS ((NTSTATUS) 0x00000000L) #endif #ifndef STATUS_PENDING #define STATUS_PENDING ((NTSTATUS) 0x00000103L) #endif #ifndef STATUS_CANCELLED #define STATUS_CANCELLED ((NTSTATUS) 0xC0000120L) #endif #ifndef STATUS_NOT_FOUND #define STATUS_NOT_FOUND ((NTSTATUS) 0xC0000225L) #endif typedef struct _IO_STATUS_BLOCK { NTSTATUS Status; ULONG_PTR Information; } IO_STATUS_BLOCK, *PIO_STATUS_BLOCK; typedef VOID(NTAPI* PIO_APC_ROUTINE)(PVOID ApcContext, PIO_STATUS_BLOCK IoStatusBlock, ULONG Reserved); typedef struct _UNICODE_STRING { USHORT Length; USHORT MaximumLength; PWSTR Buffer; } UNICODE_STRING, *PUNICODE_STRING; #define RTL_CONSTANT_STRING(s) \ { sizeof(s) - sizeof((s)[0]), sizeof(s), s } typedef struct _OBJECT_ATTRIBUTES { ULONG Length; HANDLE RootDirectory; PUNICODE_STRING ObjectName; ULONG Attributes; PVOID SecurityDescriptor; PVOID SecurityQualityOfService; } OBJECT_ATTRIBUTES, *POBJECT_ATTRIBUTES; #define RTL_CONSTANT_OBJECT_ATTRIBUTES(ObjectName, Attributes) \ { sizeof(OBJECT_ATTRIBUTES), NULL, ObjectName, Attributes, NULL, NULL } #ifndef FILE_OPEN #define FILE_OPEN 0x00000001UL #endif #define KEYEDEVENT_WAIT 0x00000001UL #define KEYEDEVENT_WAKE 0x00000002UL #define KEYEDEVENT_ALL_ACCESS \ (STANDARD_RIGHTS_REQUIRED | KEYEDEVENT_WAIT | KEYEDEVENT_WAKE) #define NT_NTDLL_IMPORT_LIST(X) \ X(NTSTATUS, \ NTAPI, \ NtCancelIoFileEx, \ (HANDLE FileHandle, \ PIO_STATUS_BLOCK IoRequestToCancel, \ PIO_STATUS_BLOCK IoStatusBlock)) \ \ X(NTSTATUS, \ NTAPI, \ NtCreateFile, \ (PHANDLE FileHandle, \ ACCESS_MASK DesiredAccess, \ POBJECT_ATTRIBUTES ObjectAttributes, \ PIO_STATUS_BLOCK IoStatusBlock, \ PLARGE_INTEGER AllocationSize, \ ULONG FileAttributes, \ ULONG ShareAccess, \ ULONG CreateDisposition, \ ULONG CreateOptions, \ PVOID EaBuffer, \ ULONG EaLength)) \ \ X(NTSTATUS, \ NTAPI, \ NtCreateKeyedEvent, \ (PHANDLE KeyedEventHandle, \ ACCESS_MASK DesiredAccess, \ POBJECT_ATTRIBUTES ObjectAttributes, \ ULONG Flags)) \ \ X(NTSTATUS, \ NTAPI, \ NtDeviceIoControlFile, \ (HANDLE FileHandle, \ HANDLE Event, \ PIO_APC_ROUTINE ApcRoutine, \ PVOID ApcContext, \ PIO_STATUS_BLOCK IoStatusBlock, \ ULONG IoControlCode, \ PVOID InputBuffer, \ ULONG InputBufferLength, \ PVOID OutputBuffer, \ ULONG OutputBufferLength)) \ \ X(NTSTATUS, \ NTAPI, \ NtReleaseKeyedEvent, \ (HANDLE KeyedEventHandle, \ PVOID KeyValue, \ BOOLEAN Alertable, \ PLARGE_INTEGER Timeout)) \ \ X(NTSTATUS, \ NTAPI, \ NtWaitForKeyedEvent, \ (HANDLE KeyedEventHandle, \ PVOID KeyValue, \ BOOLEAN Alertable, \ PLARGE_INTEGER Timeout)) \ \ X(ULONG, WINAPI, RtlNtStatusToDosError, (NTSTATUS Status)) #define X(return_type, attributes, name, parameters) \ WEPOLL_INTERNAL_EXTERN return_type(attributes* name) parameters; NT_NTDLL_IMPORT_LIST(X) #undef X #define AFD_POLL_RECEIVE 0x0001 #define AFD_POLL_RECEIVE_EXPEDITED 0x0002 #define AFD_POLL_SEND 0x0004 #define AFD_POLL_DISCONNECT 0x0008 #define AFD_POLL_ABORT 0x0010 #define AFD_POLL_LOCAL_CLOSE 0x0020 #define AFD_POLL_ACCEPT 0x0080 #define AFD_POLL_CONNECT_FAIL 0x0100 typedef struct _AFD_POLL_HANDLE_INFO { HANDLE Handle; ULONG Events; NTSTATUS Status; } AFD_POLL_HANDLE_INFO, *PAFD_POLL_HANDLE_INFO; typedef struct _AFD_POLL_INFO { LARGE_INTEGER Timeout; ULONG NumberOfHandles; ULONG Exclusive; AFD_POLL_HANDLE_INFO Handles[1]; } AFD_POLL_INFO, *PAFD_POLL_INFO; WEPOLL_INTERNAL int afd_create_device_handle(HANDLE iocp_handle, HANDLE* afd_device_handle_out); WEPOLL_INTERNAL int afd_poll(HANDLE afd_device_handle, AFD_POLL_INFO* poll_info, IO_STATUS_BLOCK* io_status_block); WEPOLL_INTERNAL int afd_cancel_poll(HANDLE afd_device_handle, IO_STATUS_BLOCK* io_status_block); #define return_map_error(value) \ do { \ err_map_win_error(); \ return (value); \ } while (0) #define return_set_error(value, error) \ do { \ err_set_win_error(error); \ return (value); \ } while (0) WEPOLL_INTERNAL void err_map_win_error(void); WEPOLL_INTERNAL void err_set_win_error(DWORD error); WEPOLL_INTERNAL int err_check_handle(HANDLE handle); #define IOCTL_AFD_POLL 0x00012024 static UNICODE_STRING afd__device_name = RTL_CONSTANT_STRING(L"\\Device\\Afd\\Wepoll"); static OBJECT_ATTRIBUTES afd__device_attributes = RTL_CONSTANT_OBJECT_ATTRIBUTES(&afd__device_name, 0); int afd_create_device_handle(HANDLE iocp_handle, HANDLE* afd_device_handle_out) { HANDLE afd_device_handle; IO_STATUS_BLOCK iosb; NTSTATUS status; /* By opening \Device\Afd without specifying any extended attributes, we'll * get a handle that lets us talk to the AFD driver, but that doesn't have an * associated endpoint (so it's not a socket). */ status = NtCreateFile(&afd_device_handle, SYNCHRONIZE, &afd__device_attributes, &iosb, NULL, 0, FILE_SHARE_READ | FILE_SHARE_WRITE, FILE_OPEN, 0, NULL, 0); if (status != STATUS_SUCCESS) return_set_error(-1, RtlNtStatusToDosError(status)); if (CreateIoCompletionPort(afd_device_handle, iocp_handle, 0, 0) == NULL) goto error; if (!SetFileCompletionNotificationModes(afd_device_handle, FILE_SKIP_SET_EVENT_ON_HANDLE)) goto error; *afd_device_handle_out = afd_device_handle; return 0; error: CloseHandle(afd_device_handle); return_map_error(-1); } int afd_poll(HANDLE afd_device_handle, AFD_POLL_INFO* poll_info, IO_STATUS_BLOCK* io_status_block) { NTSTATUS status; /* Blocking operation is not supported. */ assert(io_status_block != NULL); io_status_block->Status = STATUS_PENDING; status = NtDeviceIoControlFile(afd_device_handle, NULL, NULL, io_status_block, io_status_block, IOCTL_AFD_POLL, poll_info, sizeof *poll_info, poll_info, sizeof *poll_info); if (status == STATUS_SUCCESS) return 0; else if (status == STATUS_PENDING) return_set_error(-1, ERROR_IO_PENDING); else return_set_error(-1, RtlNtStatusToDosError(status)); } int afd_cancel_poll(HANDLE afd_device_handle, IO_STATUS_BLOCK* io_status_block) { NTSTATUS cancel_status; IO_STATUS_BLOCK cancel_iosb; /* If the poll operation has already completed or has been cancelled earlier, * there's nothing left for us to do. */ if (io_status_block->Status != STATUS_PENDING) return 0; cancel_status = NtCancelIoFileEx(afd_device_handle, io_status_block, &cancel_iosb); /* NtCancelIoFileEx() may return STATUS_NOT_FOUND if the operation completed * just before calling NtCancelIoFileEx(). This is not an error. */ if (cancel_status == STATUS_SUCCESS || cancel_status == STATUS_NOT_FOUND) return 0; else return_set_error(-1, RtlNtStatusToDosError(cancel_status)); } WEPOLL_INTERNAL int epoll_global_init(void); WEPOLL_INTERNAL int init(void); typedef struct port_state port_state_t; typedef struct queue queue_t; typedef struct sock_state sock_state_t; typedef struct ts_tree_node ts_tree_node_t; WEPOLL_INTERNAL port_state_t* port_new(HANDLE* iocp_handle_out); WEPOLL_INTERNAL int port_close(port_state_t* port_state); WEPOLL_INTERNAL int port_delete(port_state_t* port_state); WEPOLL_INTERNAL int port_wait(port_state_t* port_state, struct epoll_event* events, int maxevents, int timeout); WEPOLL_INTERNAL int port_ctl(port_state_t* port_state, int op, SOCKET sock, struct epoll_event* ev); WEPOLL_INTERNAL int port_register_socket(port_state_t* port_state, sock_state_t* sock_state, SOCKET socket); WEPOLL_INTERNAL void port_unregister_socket(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL sock_state_t* port_find_socket(port_state_t* port_state, SOCKET socket); WEPOLL_INTERNAL void port_request_socket_update(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL void port_cancel_socket_update(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL void port_add_deleted_socket(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL void port_remove_deleted_socket(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL HANDLE port_get_iocp_handle(port_state_t* port_state); WEPOLL_INTERNAL queue_t* port_get_poll_group_queue(port_state_t* port_state); WEPOLL_INTERNAL port_state_t* port_state_from_handle_tree_node( ts_tree_node_t* tree_node); WEPOLL_INTERNAL ts_tree_node_t* port_state_to_handle_tree_node( port_state_t* port_state); /* The reflock is a special kind of lock that normally prevents a chunk of * memory from being freed, but does allow the chunk of memory to eventually be * released in a coordinated fashion. * * Under normal operation, threads increase and decrease the reference count, * which are wait-free operations. * * Exactly once during the reflock's lifecycle, a thread holding a reference to * the lock may "destroy" the lock; this operation blocks until all other * threads holding a reference to the lock have dereferenced it. After * "destroy" returns, the calling thread may assume that no other threads have * a reference to the lock. * * Attemmpting to lock or destroy a lock after reflock_unref_and_destroy() has * been called is invalid and results in undefined behavior. Therefore the user * should use another lock to guarantee that this can't happen. */ typedef struct reflock { volatile long state; /* 32-bit Interlocked APIs operate on `long` values. */ } reflock_t; WEPOLL_INTERNAL int reflock_global_init(void); WEPOLL_INTERNAL void reflock_init(reflock_t* reflock); WEPOLL_INTERNAL void reflock_ref(reflock_t* reflock); WEPOLL_INTERNAL void reflock_unref(reflock_t* reflock); WEPOLL_INTERNAL void reflock_unref_and_destroy(reflock_t* reflock); #include <stdbool.h> /* N.b.: the tree functions do not set errno or LastError when they fail. Each * of the API functions has at most one failure mode. It is up to the caller to * set an appropriate error code when necessary. */ typedef struct tree tree_t; typedef struct tree_node tree_node_t; typedef struct tree { tree_node_t* root; } tree_t; typedef struct tree_node { tree_node_t* left; tree_node_t* right; tree_node_t* parent; uintptr_t key; bool red; } tree_node_t; WEPOLL_INTERNAL void tree_init(tree_t* tree); WEPOLL_INTERNAL void tree_node_init(tree_node_t* node); WEPOLL_INTERNAL int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key); WEPOLL_INTERNAL void tree_del(tree_t* tree, tree_node_t* node); WEPOLL_INTERNAL tree_node_t* tree_find(const tree_t* tree, uintptr_t key); WEPOLL_INTERNAL tree_node_t* tree_root(const tree_t* tree); typedef struct ts_tree { tree_t tree; SRWLOCK lock; } ts_tree_t; typedef struct ts_tree_node { tree_node_t tree_node; reflock_t reflock; } ts_tree_node_t; WEPOLL_INTERNAL void ts_tree_init(ts_tree_t* rtl); WEPOLL_INTERNAL void ts_tree_node_init(ts_tree_node_t* node); WEPOLL_INTERNAL int ts_tree_add(ts_tree_t* ts_tree, ts_tree_node_t* node, uintptr_t key); WEPOLL_INTERNAL ts_tree_node_t* ts_tree_del_and_ref(ts_tree_t* ts_tree, uintptr_t key); WEPOLL_INTERNAL ts_tree_node_t* ts_tree_find_and_ref(ts_tree_t* ts_tree, uintptr_t key); WEPOLL_INTERNAL void ts_tree_node_unref(ts_tree_node_t* node); WEPOLL_INTERNAL void ts_tree_node_unref_and_destroy(ts_tree_node_t* node); static ts_tree_t epoll__handle_tree; int epoll_global_init(void) { ts_tree_init(&epoll__handle_tree); return 0; } static HANDLE epoll__create(void) { port_state_t* port_state; HANDLE ephnd; ts_tree_node_t* tree_node; if (init() < 0) return NULL; port_state = port_new(&ephnd); if (port_state == NULL) return NULL; tree_node = port_state_to_handle_tree_node(port_state); if (ts_tree_add(&epoll__handle_tree, tree_node, (uintptr_t) ephnd) < 0) { /* This should never happen. */ port_delete(port_state); return_set_error(NULL, ERROR_ALREADY_EXISTS); } return ephnd; } HANDLE epoll_create(int size) { if (size <= 0) return_set_error(NULL, ERROR_INVALID_PARAMETER); return epoll__create(); } HANDLE epoll_create1(int flags) { if (flags != 0) return_set_error(NULL, ERROR_INVALID_PARAMETER); return epoll__create(); } int epoll_close(HANDLE ephnd) { ts_tree_node_t* tree_node; port_state_t* port_state; if (init() < 0) return -1; tree_node = ts_tree_del_and_ref(&epoll__handle_tree, (uintptr_t) ephnd); if (tree_node == NULL) { err_set_win_error(ERROR_INVALID_PARAMETER); goto err; } port_state = port_state_from_handle_tree_node(tree_node); port_close(port_state); ts_tree_node_unref_and_destroy(tree_node); return port_delete(port_state); err: err_check_handle(ephnd); return -1; } int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* ev) { ts_tree_node_t* tree_node; port_state_t* port_state; int r; if (init() < 0) return -1; tree_node = ts_tree_find_and_ref(&epoll__handle_tree, (uintptr_t) ephnd); if (tree_node == NULL) { err_set_win_error(ERROR_INVALID_PARAMETER); goto err; } port_state = port_state_from_handle_tree_node(tree_node); r = port_ctl(port_state, op, sock, ev); ts_tree_node_unref(tree_node); if (r < 0) goto err; return 0; err: /* On Linux, in the case of epoll_ctl(), EBADF takes priority over other * errors. Wepoll mimics this behavior. */ err_check_handle(ephnd); err_check_handle((HANDLE) sock); return -1; } int epoll_wait(HANDLE ephnd, struct epoll_event* events, int maxevents, int timeout) { ts_tree_node_t* tree_node; port_state_t* port_state; int num_events; if (maxevents <= 0) return_set_error(-1, ERROR_INVALID_PARAMETER); if (init() < 0) return -1; tree_node = ts_tree_find_and_ref(&epoll__handle_tree, (uintptr_t) ephnd); if (tree_node == NULL) { err_set_win_error(ERROR_INVALID_PARAMETER); goto err; } port_state = port_state_from_handle_tree_node(tree_node); num_events = port_wait(port_state, events, maxevents, timeout); ts_tree_node_unref(tree_node); if (num_events < 0) goto err; return num_events; err: err_check_handle(ephnd); return -1; } #include <errno.h> #define ERR__ERRNO_MAPPINGS(X) \ X(ERROR_ACCESS_DENIED, EACCES) \ X(ERROR_ALREADY_EXISTS, EEXIST) \ X(ERROR_BAD_COMMAND, EACCES) \ X(ERROR_BAD_EXE_FORMAT, ENOEXEC) \ X(ERROR_BAD_LENGTH, EACCES) \ X(ERROR_BAD_NETPATH, ENOENT) \ X(ERROR_BAD_NET_NAME, ENOENT) \ X(ERROR_BAD_NET_RESP, ENETDOWN) \ X(ERROR_BAD_PATHNAME, ENOENT) \ X(ERROR_BROKEN_PIPE, EPIPE) \ X(ERROR_CANNOT_MAKE, EACCES) \ X(ERROR_COMMITMENT_LIMIT, ENOMEM) \ X(ERROR_CONNECTION_ABORTED, ECONNABORTED) \ X(ERROR_CONNECTION_ACTIVE, EISCONN) \ X(ERROR_CONNECTION_REFUSED, ECONNREFUSED) \ X(ERROR_CRC, EACCES) \ X(ERROR_DIR_NOT_EMPTY, ENOTEMPTY) \ X(ERROR_DISK_FULL, ENOSPC) \ X(ERROR_DUP_NAME, EADDRINUSE) \ X(ERROR_FILENAME_EXCED_RANGE, ENOENT) \ X(ERROR_FILE_NOT_FOUND, ENOENT) \ X(ERROR_GEN_FAILURE, EACCES) \ X(ERROR_GRACEFUL_DISCONNECT, EPIPE) \ X(ERROR_HOST_DOWN, EHOSTUNREACH) \ X(ERROR_HOST_UNREACHABLE, EHOSTUNREACH) \ X(ERROR_INSUFFICIENT_BUFFER, EFAULT) \ X(ERROR_INVALID_ADDRESS, EADDRNOTAVAIL) \ X(ERROR_INVALID_FUNCTION, EINVAL) \ X(ERROR_INVALID_HANDLE, EBADF) \ X(ERROR_INVALID_NETNAME, EADDRNOTAVAIL) \ X(ERROR_INVALID_PARAMETER, EINVAL) \ X(ERROR_INVALID_USER_BUFFER, EMSGSIZE) \ X(ERROR_IO_PENDING, EINPROGRESS) \ X(ERROR_LOCK_VIOLATION, EACCES) \ X(ERROR_MORE_DATA, EMSGSIZE) \ X(ERROR_NETNAME_DELETED, ECONNABORTED) \ X(ERROR_NETWORK_ACCESS_DENIED, EACCES) \ X(ERROR_NETWORK_BUSY, ENETDOWN) \ X(ERROR_NETWORK_UNREACHABLE, ENETUNREACH) \ X(ERROR_NOACCESS, EFAULT) \ X(ERROR_NONPAGED_SYSTEM_RESOURCES, ENOMEM) \ X(ERROR_NOT_ENOUGH_MEMORY, ENOMEM) \ X(ERROR_NOT_ENOUGH_QUOTA, ENOMEM) \ X(ERROR_NOT_FOUND, ENOENT) \ X(ERROR_NOT_LOCKED, EACCES) \ X(ERROR_NOT_READY, EACCES) \ X(ERROR_NOT_SAME_DEVICE, EXDEV) \ X(ERROR_NOT_SUPPORTED, ENOTSUP) \ X(ERROR_NO_MORE_FILES, ENOENT) \ X(ERROR_NO_SYSTEM_RESOURCES, ENOMEM) \ X(ERROR_OPERATION_ABORTED, EINTR) \ X(ERROR_OUT_OF_PAPER, EACCES) \ X(ERROR_PAGED_SYSTEM_RESOURCES, ENOMEM) \ X(ERROR_PAGEFILE_QUOTA, ENOMEM) \ X(ERROR_PATH_NOT_FOUND, ENOENT) \ X(ERROR_PIPE_NOT_CONNECTED, EPIPE) \ X(ERROR_PORT_UNREACHABLE, ECONNRESET) \ X(ERROR_PROTOCOL_UNREACHABLE, ENETUNREACH) \ X(ERROR_REM_NOT_LIST, ECONNREFUSED) \ X(ERROR_REQUEST_ABORTED, EINTR) \ X(ERROR_REQ_NOT_ACCEP, EWOULDBLOCK) \ X(ERROR_SECTOR_NOT_FOUND, EACCES) \ X(ERROR_SEM_TIMEOUT, ETIMEDOUT) \ X(ERROR_SHARING_VIOLATION, EACCES) \ X(ERROR_TOO_MANY_NAMES, ENOMEM) \ X(ERROR_TOO_MANY_OPEN_FILES, EMFILE) \ X(ERROR_UNEXP_NET_ERR, ECONNABORTED) \ X(ERROR_WAIT_NO_CHILDREN, ECHILD) \ X(ERROR_WORKING_SET_QUOTA, ENOMEM) \ X(ERROR_WRITE_PROTECT, EACCES) \ X(ERROR_WRONG_DISK, EACCES) \ X(WSAEACCES, EACCES) \ X(WSAEADDRINUSE, EADDRINUSE) \ X(WSAEADDRNOTAVAIL, EADDRNOTAVAIL) \ X(WSAEAFNOSUPPORT, EAFNOSUPPORT) \ X(WSAECONNABORTED, ECONNABORTED) \ X(WSAECONNREFUSED, ECONNREFUSED) \ X(WSAECONNRESET, ECONNRESET) \ X(WSAEDISCON, EPIPE) \ X(WSAEFAULT, EFAULT) \ X(WSAEHOSTDOWN, EHOSTUNREACH) \ X(WSAEHOSTUNREACH, EHOSTUNREACH) \ X(WSAEINPROGRESS, EBUSY) \ X(WSAEINTR, EINTR) \ X(WSAEINVAL, EINVAL) \ X(WSAEISCONN, EISCONN) \ X(WSAEMSGSIZE, EMSGSIZE) \ X(WSAENETDOWN, ENETDOWN) \ X(WSAENETRESET, EHOSTUNREACH) \ X(WSAENETUNREACH, ENETUNREACH) \ X(WSAENOBUFS, ENOMEM) \ X(WSAENOTCONN, ENOTCONN) \ X(WSAENOTSOCK, ENOTSOCK) \ X(WSAEOPNOTSUPP, EOPNOTSUPP) \ X(WSAEPROCLIM, ENOMEM) \ X(WSAESHUTDOWN, EPIPE) \ X(WSAETIMEDOUT, ETIMEDOUT) \ X(WSAEWOULDBLOCK, EWOULDBLOCK) \ X(WSANOTINITIALISED, ENETDOWN) \ X(WSASYSNOTREADY, ENETDOWN) \ X(WSAVERNOTSUPPORTED, ENOSYS) static errno_t err__map_win_error_to_errno(DWORD error) { switch (error) { #define X(error_sym, errno_sym) \ case error_sym: \ return errno_sym; ERR__ERRNO_MAPPINGS(X) #undef X } return EINVAL; } void err_map_win_error(void) { errno = err__map_win_error_to_errno(GetLastError()); } void err_set_win_error(DWORD error) { SetLastError(error); errno = err__map_win_error_to_errno(error); } int err_check_handle(HANDLE handle) { DWORD flags; /* GetHandleInformation() succeeds when passed INVALID_HANDLE_VALUE, so check * for this condition explicitly. */ if (handle == INVALID_HANDLE_VALUE) return_set_error(-1, ERROR_INVALID_HANDLE); if (!GetHandleInformation(handle, &flags)) return_map_error(-1); return 0; } #include <stddef.h> #define array_count(a) (sizeof(a) / (sizeof((a)[0]))) #define container_of(ptr, type, member) \ ((type*) ((uintptr_t) (ptr) - offsetof(type, member))) #define unused_var(v) ((void) (v)) /* Polyfill `inline` for older versions of msvc (up to Visual Studio 2013) */ #if defined(_MSC_VER) && _MSC_VER < 1900 #define inline __inline #endif WEPOLL_INTERNAL int ws_global_init(void); WEPOLL_INTERNAL SOCKET ws_get_base_socket(SOCKET socket); static bool init__done = false; static INIT_ONCE init__once = INIT_ONCE_STATIC_INIT; static BOOL CALLBACK init__once_callback(INIT_ONCE* once, void* parameter, void** context) { unused_var(once); unused_var(parameter); unused_var(context); /* N.b. that initialization order matters here. */ if (ws_global_init() < 0 || nt_global_init() < 0 || reflock_global_init() < 0 || epoll_global_init() < 0) return FALSE; init__done = true; return TRUE; } int init(void) { if (!init__done && !InitOnceExecuteOnce(&init__once, init__once_callback, NULL, NULL)) /* `InitOnceExecuteOnce()` itself is infallible, and it doesn't set any * error code when the once-callback returns FALSE. We return -1 here to * indicate that global initialization failed; the failing init function is * resposible for setting `errno` and calling `SetLastError()`. */ return -1; return 0; } /* Set up a workaround for the following problem: * FARPROC addr = GetProcAddress(...); * MY_FUNC func = (MY_FUNC) addr; <-- GCC 8 warning/error. * MY_FUNC func = (MY_FUNC) (void*) addr; <-- MSVC warning/error. * To compile cleanly with either compiler, do casts with this "bridge" type: * MY_FUNC func = (MY_FUNC) (nt__fn_ptr_cast_t) addr; */ #ifdef __GNUC__ typedef void* nt__fn_ptr_cast_t; #else typedef FARPROC nt__fn_ptr_cast_t; #endif #define X(return_type, attributes, name, parameters) \ WEPOLL_INTERNAL return_type(attributes* name) parameters = NULL; NT_NTDLL_IMPORT_LIST(X) #undef X int nt_global_init(void) { HMODULE ntdll; FARPROC fn_ptr; ntdll = GetModuleHandleW(L"ntdll.dll"); if (ntdll == NULL) return -1; #define X(return_type, attributes, name, parameters) \ fn_ptr = GetProcAddress(ntdll, #name); \ if (fn_ptr == NULL) \ return -1; \ name = (return_type(attributes*) parameters)(nt__fn_ptr_cast_t) fn_ptr; NT_NTDLL_IMPORT_LIST(X) #undef X return 0; } #include <string.h> typedef struct poll_group poll_group_t; typedef struct queue_node queue_node_t; WEPOLL_INTERNAL poll_group_t* poll_group_acquire(port_state_t* port); WEPOLL_INTERNAL void poll_group_release(poll_group_t* poll_group); WEPOLL_INTERNAL void poll_group_delete(poll_group_t* poll_group); WEPOLL_INTERNAL poll_group_t* poll_group_from_queue_node( queue_node_t* queue_node); WEPOLL_INTERNAL HANDLE poll_group_get_afd_device_handle(poll_group_t* poll_group); typedef struct queue_node { queue_node_t* prev; queue_node_t* next; } queue_node_t; typedef struct queue { queue_node_t head; } queue_t; WEPOLL_INTERNAL void queue_init(queue_t* queue); WEPOLL_INTERNAL void queue_node_init(queue_node_t* node); WEPOLL_INTERNAL queue_node_t* queue_first(const queue_t* queue); WEPOLL_INTERNAL queue_node_t* queue_last(const queue_t* queue); WEPOLL_INTERNAL void queue_prepend(queue_t* queue, queue_node_t* node); WEPOLL_INTERNAL void queue_append(queue_t* queue, queue_node_t* node); WEPOLL_INTERNAL void queue_move_to_start(queue_t* queue, queue_node_t* node); WEPOLL_INTERNAL void queue_move_to_end(queue_t* queue, queue_node_t* node); WEPOLL_INTERNAL void queue_remove(queue_node_t* node); WEPOLL_INTERNAL bool queue_is_empty(const queue_t* queue); WEPOLL_INTERNAL bool queue_is_enqueued(const queue_node_t* node); #define POLL_GROUP__MAX_GROUP_SIZE 32 typedef struct poll_group { port_state_t* port_state; queue_node_t queue_node; HANDLE afd_device_handle; size_t group_size; } poll_group_t; static poll_group_t* poll_group__new(port_state_t* port_state) { HANDLE iocp_handle = port_get_iocp_handle(port_state); queue_t* poll_group_queue = port_get_poll_group_queue(port_state); poll_group_t* poll_group = malloc(sizeof *poll_group); if (poll_group == NULL) return_set_error(NULL, ERROR_NOT_ENOUGH_MEMORY); memset(poll_group, 0, sizeof *poll_group); queue_node_init(&poll_group->queue_node); poll_group->port_state = port_state; if (afd_create_device_handle(iocp_handle, &poll_group->afd_device_handle) < 0) { free(poll_group); return NULL; } queue_append(poll_group_queue, &poll_group->queue_node); return poll_group; } void poll_group_delete(poll_group_t* poll_group) { assert(poll_group->group_size == 0); CloseHandle(poll_group->afd_device_handle); queue_remove(&poll_group->queue_node); free(poll_group); } poll_group_t* poll_group_from_queue_node(queue_node_t* queue_node) { return container_of(queue_node, poll_group_t, queue_node); } HANDLE poll_group_get_afd_device_handle(poll_group_t* poll_group) { return poll_group->afd_device_handle; } poll_group_t* poll_group_acquire(port_state_t* port_state) { queue_t* poll_group_queue = port_get_poll_group_queue(port_state); poll_group_t* poll_group = !queue_is_empty(poll_group_queue) ? container_of( queue_last(poll_group_queue), poll_group_t, queue_node) : NULL; if (poll_group == NULL || poll_group->group_size >= POLL_GROUP__MAX_GROUP_SIZE) poll_group = poll_group__new(port_state); if (poll_group == NULL) return NULL; if (++poll_group->group_size == POLL_GROUP__MAX_GROUP_SIZE) queue_move_to_start(poll_group_queue, &poll_group->queue_node); return poll_group; } void poll_group_release(poll_group_t* poll_group) { port_state_t* port_state = poll_group->port_state; queue_t* poll_group_queue = port_get_poll_group_queue(port_state); poll_group->group_size--; assert(poll_group->group_size < POLL_GROUP__MAX_GROUP_SIZE); queue_move_to_end(poll_group_queue, &poll_group->queue_node); /* Poll groups are currently only freed when the epoll port is closed. */ } WEPOLL_INTERNAL sock_state_t* sock_new(port_state_t* port_state, SOCKET socket); WEPOLL_INTERNAL void sock_delete(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL void sock_force_delete(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL int sock_set_event(port_state_t* port_state, sock_state_t* sock_state, const struct epoll_event* ev); WEPOLL_INTERNAL int sock_update(port_state_t* port_state, sock_state_t* sock_state); WEPOLL_INTERNAL int sock_feed_event(port_state_t* port_state, IO_STATUS_BLOCK* io_status_block, struct epoll_event* ev); WEPOLL_INTERNAL sock_state_t* sock_state_from_queue_node( queue_node_t* queue_node); WEPOLL_INTERNAL queue_node_t* sock_state_to_queue_node( sock_state_t* sock_state); WEPOLL_INTERNAL sock_state_t* sock_state_from_tree_node( tree_node_t* tree_node); WEPOLL_INTERNAL tree_node_t* sock_state_to_tree_node(sock_state_t* sock_state); #define PORT__MAX_ON_STACK_COMPLETIONS 256 typedef struct port_state { HANDLE iocp_handle; tree_t sock_tree; queue_t sock_update_queue; queue_t sock_deleted_queue; queue_t poll_group_queue; ts_tree_node_t handle_tree_node; CRITICAL_SECTION lock; size_t active_poll_count; } port_state_t; static inline port_state_t* port__alloc(void) { port_state_t* port_state = malloc(sizeof *port_state); if (port_state == NULL) return_set_error(NULL, ERROR_NOT_ENOUGH_MEMORY); return port_state; } static inline void port__free(port_state_t* port) { assert(port != NULL); free(port); } static inline HANDLE port__create_iocp(void) { HANDLE iocp_handle = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); if (iocp_handle == NULL) return_map_error(NULL); return iocp_handle; } port_state_t* port_new(HANDLE* iocp_handle_out) { port_state_t* port_state; HANDLE iocp_handle; port_state = port__alloc(); if (port_state == NULL) goto err1; iocp_handle = port__create_iocp(); if (iocp_handle == NULL) goto err2; memset(port_state, 0, sizeof *port_state); port_state->iocp_handle = iocp_handle; tree_init(&port_state->sock_tree); queue_init(&port_state->sock_update_queue); queue_init(&port_state->sock_deleted_queue); queue_init(&port_state->poll_group_queue); ts_tree_node_init(&port_state->handle_tree_node); InitializeCriticalSection(&port_state->lock); *iocp_handle_out = iocp_handle; return port_state; err2: port__free(port_state); err1: return NULL; } static inline int port__close_iocp(port_state_t* port_state) { HANDLE iocp_handle = port_state->iocp_handle; port_state->iocp_handle = NULL; if (!CloseHandle(iocp_handle)) return_map_error(-1); return 0; } int port_close(port_state_t* port_state) { int result; EnterCriticalSection(&port_state->lock); result = port__close_iocp(port_state); LeaveCriticalSection(&port_state->lock); return result; } int port_delete(port_state_t* port_state) { tree_node_t* tree_node; queue_node_t* queue_node; /* At this point the IOCP port should have been closed. */ assert(port_state->iocp_handle == NULL); while ((tree_node = tree_root(&port_state->sock_tree)) != NULL) { sock_state_t* sock_state = sock_state_from_tree_node(tree_node); sock_force_delete(port_state, sock_state); } while ((queue_node = queue_first(&port_state->sock_deleted_queue)) != NULL) { sock_state_t* sock_state = sock_state_from_queue_node(queue_node); sock_force_delete(port_state, sock_state); } while ((queue_node = queue_first(&port_state->poll_group_queue)) != NULL) { poll_group_t* poll_group = poll_group_from_queue_node(queue_node); poll_group_delete(poll_group); } assert(queue_is_empty(&port_state->sock_update_queue)); DeleteCriticalSection(&port_state->lock); port__free(port_state); return 0; } static int port__update_events(port_state_t* port_state) { queue_t* sock_update_queue = &port_state->sock_update_queue; /* Walk the queue, submitting new poll requests for every socket that needs * it. */ while (!queue_is_empty(sock_update_queue)) { queue_node_t* queue_node = queue_first(sock_update_queue); sock_state_t* sock_state = sock_state_from_queue_node(queue_node); if (sock_update(port_state, sock_state) < 0) return -1; /* sock_update() removes the socket from the update queue. */ } return 0; } static inline void port__update_events_if_polling(port_state_t* port_state) { if (port_state->active_poll_count > 0) port__update_events(port_state); } static inline int port__feed_events(port_state_t* port_state, struct epoll_event* epoll_events, OVERLAPPED_ENTRY* iocp_events, DWORD iocp_event_count) { int epoll_event_count = 0; DWORD i; for (i = 0; i < iocp_event_count; i++) { IO_STATUS_BLOCK* io_status_block = (IO_STATUS_BLOCK*) iocp_events[i].lpOverlapped; struct epoll_event* ev = &epoll_events[epoll_event_count]; epoll_event_count += sock_feed_event(port_state, io_status_block, ev); } return epoll_event_count; } static inline int port__poll(port_state_t* port_state, struct epoll_event* epoll_events, OVERLAPPED_ENTRY* iocp_events, DWORD maxevents, DWORD timeout) { DWORD completion_count; if (port__update_events(port_state) < 0) return -1; port_state->active_poll_count++; LeaveCriticalSection(&port_state->lock); BOOL r = GetQueuedCompletionStatusEx(port_state->iocp_handle, iocp_events, maxevents, &completion_count, timeout, FALSE); EnterCriticalSection(&port_state->lock); port_state->active_poll_count--; if (!r) return_map_error(-1); return port__feed_events( port_state, epoll_events, iocp_events, completion_count); } int port_wait(port_state_t* port_state, struct epoll_event* events, int maxevents, int timeout) { OVERLAPPED_ENTRY stack_iocp_events[PORT__MAX_ON_STACK_COMPLETIONS]; OVERLAPPED_ENTRY* iocp_events; uint64_t due = 0; DWORD gqcs_timeout; int result; /* Check whether `maxevents` is in range. */ if (maxevents <= 0) return_set_error(-1, ERROR_INVALID_PARAMETER); /* Decide whether the IOCP completion list can live on the stack, or allocate * memory for it on the heap. */ if ((size_t) maxevents <= array_count(stack_iocp_events)) { iocp_events = stack_iocp_events; } else if ((iocp_events = malloc((size_t) maxevents * sizeof *iocp_events)) == NULL) { iocp_events = stack_iocp_events; maxevents = array_count(stack_iocp_events); } /* Compute the timeout for GetQueuedCompletionStatus, and the wait end * time, if the user specified a timeout other than zero or infinite. */ if (timeout > 0) { due = GetTickCount64() + (uint64_t) timeout; gqcs_timeout = (DWORD) timeout; } else if (timeout == 0) { gqcs_timeout = 0; } else { gqcs_timeout = INFINITE; } EnterCriticalSection(&port_state->lock); /* Dequeue completion packets until either at least one interesting event * has been discovered, or the timeout is reached. */ for (;;) { uint64_t now; result = port__poll( port_state, events, iocp_events, (DWORD) maxevents, gqcs_timeout); if (result < 0 || result > 0) break; /* Result, error, or time-out. */ if (timeout < 0) continue; /* When timeout is negative, never time out. */ /* Update time. */ now = GetTickCount64(); /* Do not allow the due time to be in the past. */ if (now >= due) { SetLastError(WAIT_TIMEOUT); break; } /* Recompute time-out argument for GetQueuedCompletionStatus. */ gqcs_timeout = (DWORD)(due - now); } port__update_events_if_polling(port_state); LeaveCriticalSection(&port_state->lock); if (iocp_events != stack_iocp_events) free(iocp_events); if (result >= 0) return result; else if (GetLastError() == WAIT_TIMEOUT) return 0; else return -1; } static inline int port__ctl_add(port_state_t* port_state, SOCKET sock, struct epoll_event* ev) { sock_state_t* sock_state = sock_new(port_state, sock); if (sock_state == NULL) return -1; if (sock_set_event(port_state, sock_state, ev) < 0) { sock_delete(port_state, sock_state); return -1; } port__update_events_if_polling(port_state); return 0; } static inline int port__ctl_mod(port_state_t* port_state, SOCKET sock, struct epoll_event* ev) { sock_state_t* sock_state = port_find_socket(port_state, sock); if (sock_state == NULL) return -1; if (sock_set_event(port_state, sock_state, ev) < 0) return -1; port__update_events_if_polling(port_state); return 0; } static inline int port__ctl_del(port_state_t* port_state, SOCKET sock) { sock_state_t* sock_state = port_find_socket(port_state, sock); if (sock_state == NULL) return -1; sock_delete(port_state, sock_state); return 0; } static inline int port__ctl_op(port_state_t* port_state, int op, SOCKET sock, struct epoll_event* ev) { switch (op) { case EPOLL_CTL_ADD: return port__ctl_add(port_state, sock, ev); case EPOLL_CTL_MOD: return port__ctl_mod(port_state, sock, ev); case EPOLL_CTL_DEL: return port__ctl_del(port_state, sock); default: return_set_error(-1, ERROR_INVALID_PARAMETER); } } int port_ctl(port_state_t* port_state, int op, SOCKET sock, struct epoll_event* ev) { int result; EnterCriticalSection(&port_state->lock); result = port__ctl_op(port_state, op, sock, ev); LeaveCriticalSection(&port_state->lock); return result; } int port_register_socket(port_state_t* port_state, sock_state_t* sock_state, SOCKET socket) { if (tree_add(&port_state->sock_tree, sock_state_to_tree_node(sock_state), socket) < 0) return_set_error(-1, ERROR_ALREADY_EXISTS); return 0; } void port_unregister_socket(port_state_t* port_state, sock_state_t* sock_state) { tree_del(&port_state->sock_tree, sock_state_to_tree_node(sock_state)); } sock_state_t* port_find_socket(port_state_t* port_state, SOCKET socket) { tree_node_t* tree_node = tree_find(&port_state->sock_tree, socket); if (tree_node == NULL) return_set_error(NULL, ERROR_NOT_FOUND); return sock_state_from_tree_node(tree_node); } void port_request_socket_update(port_state_t* port_state, sock_state_t* sock_state) { if (queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_append(&port_state->sock_update_queue, sock_state_to_queue_node(sock_state)); } void port_cancel_socket_update(port_state_t* port_state, sock_state_t* sock_state) { unused_var(port_state); if (!queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_remove(sock_state_to_queue_node(sock_state)); } void port_add_deleted_socket(port_state_t* port_state, sock_state_t* sock_state) { if (queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_append(&port_state->sock_deleted_queue, sock_state_to_queue_node(sock_state)); } void port_remove_deleted_socket(port_state_t* port_state, sock_state_t* sock_state) { unused_var(port_state); if (!queue_is_enqueued(sock_state_to_queue_node(sock_state))) return; queue_remove(sock_state_to_queue_node(sock_state)); } HANDLE port_get_iocp_handle(port_state_t* port_state) { assert(port_state->iocp_handle != NULL); return port_state->iocp_handle; } queue_t* port_get_poll_group_queue(port_state_t* port_state) { return &port_state->poll_group_queue; } port_state_t* port_state_from_handle_tree_node(ts_tree_node_t* tree_node) { return container_of(tree_node, port_state_t, handle_tree_node); } ts_tree_node_t* port_state_to_handle_tree_node(port_state_t* port_state) { return &port_state->handle_tree_node; } void queue_init(queue_t* queue) { queue_node_init(&queue->head); } void queue_node_init(queue_node_t* node) { node->prev = node; node->next = node; } static inline void queue__detach_node(queue_node_t* node) { node->prev->next = node->next; node->next->prev = node->prev; } queue_node_t* queue_first(const queue_t* queue) { return !queue_is_empty(queue) ? queue->head.next : NULL; } queue_node_t* queue_last(const queue_t* queue) { return !queue_is_empty(queue) ? queue->head.prev : NULL; } void queue_prepend(queue_t* queue, queue_node_t* node) { node->next = queue->head.next; node->prev = &queue->head; node->next->prev = node; queue->head.next = node; } void queue_append(queue_t* queue, queue_node_t* node) { node->next = &queue->head; node->prev = queue->head.prev; node->prev->next = node; queue->head.prev = node; } void queue_move_to_start(queue_t* queue, queue_node_t* node) { queue__detach_node(node); queue_prepend(queue, node); } void queue_move_to_end(queue_t* queue, queue_node_t* node) { queue__detach_node(node); queue_append(queue, node); } void queue_remove(queue_node_t* node) { queue__detach_node(node); queue_node_init(node); } bool queue_is_empty(const queue_t* queue) { return !queue_is_enqueued(&queue->head); } bool queue_is_enqueued(const queue_node_t* node) { return node->prev != node; } #define REFLOCK__REF ((long) 0x00000001UL) #define REFLOCK__REF_MASK ((long) 0x0fffffffUL) #define REFLOCK__DESTROY ((long) 0x10000000UL) #define REFLOCK__DESTROY_MASK ((long) 0xf0000000UL) #define REFLOCK__POISON ((long) 0x300dead0UL) static HANDLE reflock__keyed_event = NULL; int reflock_global_init(void) { NTSTATUS status = NtCreateKeyedEvent( &reflock__keyed_event, KEYEDEVENT_ALL_ACCESS, NULL, 0); if (status != STATUS_SUCCESS) return_set_error(-1, RtlNtStatusToDosError(status)); return 0; } void reflock_init(reflock_t* reflock) { reflock->state = 0; } static void reflock__signal_event(void* address) { NTSTATUS status = NtReleaseKeyedEvent(reflock__keyed_event, address, FALSE, NULL); if (status != STATUS_SUCCESS) abort(); } static void reflock__await_event(void* address) { NTSTATUS status = NtWaitForKeyedEvent(reflock__keyed_event, address, FALSE, NULL); if (status != STATUS_SUCCESS) abort(); } void reflock_ref(reflock_t* reflock) { long state = InterlockedAdd(&reflock->state, REFLOCK__REF); /* Verify that the counter didn't overflow and the lock isn't destroyed. */ assert((state & REFLOCK__DESTROY_MASK) == 0); unused_var(state); } void reflock_unref(reflock_t* reflock) { long state = InterlockedAdd(&reflock->state, -REFLOCK__REF); /* Verify that the lock was referenced and not already destroyed. */ assert((state & REFLOCK__DESTROY_MASK & ~REFLOCK__DESTROY) == 0); if (state == REFLOCK__DESTROY) reflock__signal_event(reflock); } void reflock_unref_and_destroy(reflock_t* reflock) { long state = InterlockedAdd(&reflock->state, REFLOCK__DESTROY - REFLOCK__REF); long ref_count = state & REFLOCK__REF_MASK; /* Verify that the lock was referenced and not already destroyed. */ assert((state & REFLOCK__DESTROY_MASK) == REFLOCK__DESTROY); if (ref_count != 0) reflock__await_event(reflock); state = InterlockedExchange(&reflock->state, REFLOCK__POISON); assert(state == REFLOCK__DESTROY); } #define SOCK__KNOWN_EPOLL_EVENTS \ (EPOLLIN | EPOLLPRI | EPOLLOUT | EPOLLERR | EPOLLHUP | EPOLLRDNORM | \ EPOLLRDBAND | EPOLLWRNORM | EPOLLWRBAND | EPOLLMSG | EPOLLRDHUP) typedef enum sock__poll_status { SOCK__POLL_IDLE = 0, SOCK__POLL_PENDING, SOCK__POLL_CANCELLED } sock__poll_status_t; typedef struct sock_state { IO_STATUS_BLOCK io_status_block; AFD_POLL_INFO poll_info; queue_node_t queue_node; tree_node_t tree_node; poll_group_t* poll_group; SOCKET base_socket; epoll_data_t user_data; uint32_t user_events; uint32_t pending_events; sock__poll_status_t poll_status; bool delete_pending; } sock_state_t; static inline sock_state_t* sock__alloc(void) { sock_state_t* sock_state = malloc(sizeof *sock_state); if (sock_state == NULL) return_set_error(NULL, ERROR_NOT_ENOUGH_MEMORY); return sock_state; } static inline void sock__free(sock_state_t* sock_state) { assert(sock_state != NULL); free(sock_state); } static inline int sock__cancel_poll(sock_state_t* sock_state) { assert(sock_state->poll_status == SOCK__POLL_PENDING); if (afd_cancel_poll(poll_group_get_afd_device_handle(sock_state->poll_group), &sock_state->io_status_block) < 0) return -1; sock_state->poll_status = SOCK__POLL_CANCELLED; sock_state->pending_events = 0; return 0; } sock_state_t* sock_new(port_state_t* port_state, SOCKET socket) { SOCKET base_socket; poll_group_t* poll_group; sock_state_t* sock_state; if (socket == 0 || socket == INVALID_SOCKET) return_set_error(NULL, ERROR_INVALID_HANDLE); base_socket = ws_get_base_socket(socket); if (base_socket == INVALID_SOCKET) return NULL; poll_group = poll_group_acquire(port_state); if (poll_group == NULL) return NULL; sock_state = sock__alloc(); if (sock_state == NULL) goto err1; memset(sock_state, 0, sizeof *sock_state); sock_state->base_socket = base_socket; sock_state->poll_group = poll_group; tree_node_init(&sock_state->tree_node); queue_node_init(&sock_state->queue_node); if (port_register_socket(port_state, sock_state, socket) < 0) goto err2; return sock_state; err2: sock__free(sock_state); err1: poll_group_release(poll_group); return NULL; } static int sock__delete(port_state_t* port_state, sock_state_t* sock_state, bool force) { if (!sock_state->delete_pending) { if (sock_state->poll_status == SOCK__POLL_PENDING) sock__cancel_poll(sock_state); port_cancel_socket_update(port_state, sock_state); port_unregister_socket(port_state, sock_state); sock_state->delete_pending = true; } /* If the poll request still needs to complete, the sock_state object can't * be free()d yet. `sock_feed_event()` or `port_close()` will take care * of this later. */ if (force || sock_state->poll_status == SOCK__POLL_IDLE) { /* Free the sock_state now. */ port_remove_deleted_socket(port_state, sock_state); poll_group_release(sock_state->poll_group); sock__free(sock_state); } else { /* Free the socket later. */ port_add_deleted_socket(port_state, sock_state); } return 0; } void sock_delete(port_state_t* port_state, sock_state_t* sock_state) { sock__delete(port_state, sock_state, false); } void sock_force_delete(port_state_t* port_state, sock_state_t* sock_state) { sock__delete(port_state, sock_state, true); } int sock_set_event(port_state_t* port_state, sock_state_t* sock_state, const struct epoll_event* ev) { /* EPOLLERR and EPOLLHUP are always reported, even when not requested by the * caller. However they are disabled after a event has been reported for a * socket for which the EPOLLONESHOT flag was set. */ uint32_t events = ev->events | EPOLLERR | EPOLLHUP; sock_state->user_events = events; sock_state->user_data = ev->data; if ((events & SOCK__KNOWN_EPOLL_EVENTS & ~sock_state->pending_events) != 0) port_request_socket_update(port_state, sock_state); return 0; } static inline DWORD sock__epoll_events_to_afd_events(uint32_t epoll_events) { /* Always monitor for AFD_POLL_LOCAL_CLOSE, which is triggered when the * socket is closed with closesocket() or CloseHandle(). */ DWORD afd_events = AFD_POLL_LOCAL_CLOSE; if (epoll_events & (EPOLLIN | EPOLLRDNORM)) afd_events |= AFD_POLL_RECEIVE | AFD_POLL_ACCEPT; if (epoll_events & (EPOLLPRI | EPOLLRDBAND)) afd_events |= AFD_POLL_RECEIVE_EXPEDITED; if (epoll_events & (EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND)) afd_events |= AFD_POLL_SEND; if (epoll_events & (EPOLLIN | EPOLLRDNORM | EPOLLRDHUP)) afd_events |= AFD_POLL_DISCONNECT; if (epoll_events & EPOLLHUP) afd_events |= AFD_POLL_ABORT; if (epoll_events & EPOLLERR) afd_events |= AFD_POLL_CONNECT_FAIL; return afd_events; } static inline uint32_t sock__afd_events_to_epoll_events(DWORD afd_events) { uint32_t epoll_events = 0; if (afd_events & (AFD_POLL_RECEIVE | AFD_POLL_ACCEPT)) epoll_events |= EPOLLIN | EPOLLRDNORM; if (afd_events & AFD_POLL_RECEIVE_EXPEDITED) epoll_events |= EPOLLPRI | EPOLLRDBAND; if (afd_events & AFD_POLL_SEND) epoll_events |= EPOLLOUT | EPOLLWRNORM | EPOLLWRBAND; if (afd_events & AFD_POLL_DISCONNECT) epoll_events |= EPOLLIN | EPOLLRDNORM | EPOLLRDHUP; if (afd_events & AFD_POLL_ABORT) epoll_events |= EPOLLHUP; if (afd_events & AFD_POLL_CONNECT_FAIL) /* Linux reports all these events after connect() has failed. */ epoll_events |= EPOLLIN | EPOLLOUT | EPOLLERR | EPOLLRDNORM | EPOLLWRNORM | EPOLLRDHUP; return epoll_events; } int sock_update(port_state_t* port_state, sock_state_t* sock_state) { assert(!sock_state->delete_pending); if ((sock_state->poll_status == SOCK__POLL_PENDING) && (sock_state->user_events & SOCK__KNOWN_EPOLL_EVENTS & ~sock_state->pending_events) == 0) { /* All the events the user is interested in are already being monitored by * the pending poll operation. It might spuriously complete because of an * event that we're no longer interested in; when that happens we'll submit * a new poll operation with the updated event mask. */ } else if (sock_state->poll_status == SOCK__POLL_PENDING) { /* A poll operation is already pending, but it's not monitoring for all the * events that the user is interested in. Therefore, cancel the pending * poll operation; when we receive it's completion package, a new poll * operation will be submitted with the correct event mask. */ if (sock__cancel_poll(sock_state) < 0) return -1; } else if (sock_state->poll_status == SOCK__POLL_CANCELLED) { /* The poll operation has already been cancelled, we're still waiting for * it to return. For now, there's nothing that needs to be done. */ } else if (sock_state->poll_status == SOCK__POLL_IDLE) { /* No poll operation is pending; start one. */ sock_state->poll_info.Exclusive = FALSE; sock_state->poll_info.NumberOfHandles = 1; sock_state->poll_info.Timeout.QuadPart = INT64_MAX; sock_state->poll_info.Handles[0].Handle = (HANDLE) sock_state->base_socket; sock_state->poll_info.Handles[0].Status = 0; sock_state->poll_info.Handles[0].Events = sock__epoll_events_to_afd_events(sock_state->user_events); if (afd_poll(poll_group_get_afd_device_handle(sock_state->poll_group), &sock_state->poll_info, &sock_state->io_status_block) < 0) { switch (GetLastError()) { case ERROR_IO_PENDING: /* Overlapped poll operation in progress; this is expected. */ break; case ERROR_INVALID_HANDLE: /* Socket closed; it'll be dropped from the epoll set. */ return sock__delete(port_state, sock_state, false); default: /* Other errors are propagated to the caller. */ return_map_error(-1); } } /* The poll request was successfully submitted. */ sock_state->poll_status = SOCK__POLL_PENDING; sock_state->pending_events = sock_state->user_events; } else { /* Unreachable. */ assert(false); } port_cancel_socket_update(port_state, sock_state); return 0; } int sock_feed_event(port_state_t* port_state, IO_STATUS_BLOCK* io_status_block, struct epoll_event* ev) { sock_state_t* sock_state = container_of(io_status_block, sock_state_t, io_status_block); AFD_POLL_INFO* poll_info = &sock_state->poll_info; uint32_t epoll_events = 0; sock_state->poll_status = SOCK__POLL_IDLE; sock_state->pending_events = 0; if (sock_state->delete_pending) { /* Socket has been deleted earlier and can now be freed. */ return sock__delete(port_state, sock_state, false); } else if (io_status_block->Status == STATUS_CANCELLED) { /* The poll request was cancelled by CancelIoEx. */ } else if (!NT_SUCCESS(io_status_block->Status)) { /* The overlapped request itself failed in an unexpected way. */ epoll_events = EPOLLERR; } else if (poll_info->NumberOfHandles < 1) { /* This poll operation succeeded but didn't report any socket events. */ } else if (poll_info->Handles[0].Events & AFD_POLL_LOCAL_CLOSE) { /* The poll operation reported that the socket was closed. */ return sock__delete(port_state, sock_state, false); } else { /* Events related to our socket were reported. */ epoll_events = sock__afd_events_to_epoll_events(poll_info->Handles[0].Events); } /* Requeue the socket so a new poll request will be submitted. */ port_request_socket_update(port_state, sock_state); /* Filter out events that the user didn't ask for. */ epoll_events &= sock_state->user_events; /* Return if there are no epoll events to report. */ if (epoll_events == 0) return 0; /* If the the socket has the EPOLLONESHOT flag set, unmonitor all events, * even EPOLLERR and EPOLLHUP. But always keep looking for closed sockets. */ if (sock_state->user_events & EPOLLONESHOT) sock_state->user_events = 0; ev->data = sock_state->user_data; ev->events = epoll_events; return 1; } sock_state_t* sock_state_from_queue_node(queue_node_t* queue_node) { return container_of(queue_node, sock_state_t, queue_node); } queue_node_t* sock_state_to_queue_node(sock_state_t* sock_state) { return &sock_state->queue_node; } sock_state_t* sock_state_from_tree_node(tree_node_t* tree_node) { return container_of(tree_node, sock_state_t, tree_node); } tree_node_t* sock_state_to_tree_node(sock_state_t* sock_state) { return &sock_state->tree_node; } void ts_tree_init(ts_tree_t* ts_tree) { tree_init(&ts_tree->tree); InitializeSRWLock(&ts_tree->lock); } void ts_tree_node_init(ts_tree_node_t* node) { tree_node_init(&node->tree_node); reflock_init(&node->reflock); } int ts_tree_add(ts_tree_t* ts_tree, ts_tree_node_t* node, uintptr_t key) { int r; AcquireSRWLockExclusive(&ts_tree->lock); r = tree_add(&ts_tree->tree, &node->tree_node, key); ReleaseSRWLockExclusive(&ts_tree->lock); return r; } static inline ts_tree_node_t* ts_tree__find_node(ts_tree_t* ts_tree, uintptr_t key) { tree_node_t* tree_node = tree_find(&ts_tree->tree, key); if (tree_node == NULL) return NULL; return container_of(tree_node, ts_tree_node_t, tree_node); } ts_tree_node_t* ts_tree_del_and_ref(ts_tree_t* ts_tree, uintptr_t key) { ts_tree_node_t* ts_tree_node; AcquireSRWLockExclusive(&ts_tree->lock); ts_tree_node = ts_tree__find_node(ts_tree, key); if (ts_tree_node != NULL) { tree_del(&ts_tree->tree, &ts_tree_node->tree_node); reflock_ref(&ts_tree_node->reflock); } ReleaseSRWLockExclusive(&ts_tree->lock); return ts_tree_node; } ts_tree_node_t* ts_tree_find_and_ref(ts_tree_t* ts_tree, uintptr_t key) { ts_tree_node_t* ts_tree_node; AcquireSRWLockShared(&ts_tree->lock); ts_tree_node = ts_tree__find_node(ts_tree, key); if (ts_tree_node != NULL) reflock_ref(&ts_tree_node->reflock); ReleaseSRWLockShared(&ts_tree->lock); return ts_tree_node; } void ts_tree_node_unref(ts_tree_node_t* node) { reflock_unref(&node->reflock); } void ts_tree_node_unref_and_destroy(ts_tree_node_t* node) { reflock_unref_and_destroy(&node->reflock); } void tree_init(tree_t* tree) { memset(tree, 0, sizeof *tree); } void tree_node_init(tree_node_t* node) { memset(node, 0, sizeof *node); } #define TREE__ROTATE(cis, trans) \ tree_node_t* p = node; \ tree_node_t* q = node->trans; \ tree_node_t* parent = p->parent; \ \ if (parent) { \ if (parent->left == p) \ parent->left = q; \ else \ parent->right = q; \ } else { \ tree->root = q; \ } \ \ q->parent = parent; \ p->parent = q; \ p->trans = q->cis; \ if (p->trans) \ p->trans->parent = p; \ q->cis = p; static inline void tree__rotate_left(tree_t* tree, tree_node_t* node) { TREE__ROTATE(left, right) } static inline void tree__rotate_right(tree_t* tree, tree_node_t* node) { TREE__ROTATE(right, left) } #define TREE__INSERT_OR_DESCEND(side) \ if (parent->side) { \ parent = parent->side; \ } else { \ parent->side = node; \ break; \ } #define TREE__REBALANCE_AFTER_INSERT(cis, trans) \ tree_node_t* grandparent = parent->parent; \ tree_node_t* uncle = grandparent->trans; \ \ if (uncle && uncle->red) { \ parent->red = uncle->red = false; \ grandparent->red = true; \ node = grandparent; \ } else { \ if (node == parent->trans) { \ tree__rotate_##cis(tree, parent); \ node = parent; \ parent = node->parent; \ } \ parent->red = false; \ grandparent->red = true; \ tree__rotate_##trans(tree, grandparent); \ } int tree_add(tree_t* tree, tree_node_t* node, uintptr_t key) { tree_node_t* parent; parent = tree->root; if (parent) { for (;;) { if (key < parent->key) { TREE__INSERT_OR_DESCEND(left) } else if (key > parent->key) { TREE__INSERT_OR_DESCEND(right) } else { return -1; } } } else { tree->root = node; } node->key = key; node->left = node->right = NULL; node->parent = parent; node->red = true; for (; parent && parent->red; parent = node->parent) { if (parent == parent->parent->left) { TREE__REBALANCE_AFTER_INSERT(left, right) } else { TREE__REBALANCE_AFTER_INSERT(right, left) } } tree->root->red = false; return 0; } #define TREE__REBALANCE_AFTER_REMOVE(cis, trans) \ tree_node_t* sibling = parent->trans; \ \ if (sibling->red) { \ sibling->red = false; \ parent->red = true; \ tree__rotate_##cis(tree, parent); \ sibling = parent->trans; \ } \ if ((sibling->left && sibling->left->red) || \ (sibling->right && sibling->right->red)) { \ if (!sibling->trans || !sibling->trans->red) { \ sibling->cis->red = false; \ sibling->red = true; \ tree__rotate_##trans(tree, sibling); \ sibling = parent->trans; \ } \ sibling->red = parent->red; \ parent->red = sibling->trans->red = false; \ tree__rotate_##cis(tree, parent); \ node = tree->root; \ break; \ } \ sibling->red = true; void tree_del(tree_t* tree, tree_node_t* node) { tree_node_t* parent = node->parent; tree_node_t* left = node->left; tree_node_t* right = node->right; tree_node_t* next; bool red; if (!left) { next = right; } else if (!right) { next = left; } else { next = right; while (next->left) next = next->left; } if (parent) { if (parent->left == node) parent->left = next; else parent->right = next; } else { tree->root = next; } if (left && right) { red = next->red; next->red = node->red; next->left = left; left->parent = next; if (next != right) { parent = next->parent; next->parent = node->parent; node = next->right; parent->left = node; next->right = right; right->parent = next; } else { next->parent = parent; parent = next; node = next->right; } } else { red = node->red; node = next; } if (node) node->parent = parent; if (red) return; if (node && node->red) { node->red = false; return; } do { if (node == tree->root) break; if (node == parent->left) { TREE__REBALANCE_AFTER_REMOVE(left, right) } else { TREE__REBALANCE_AFTER_REMOVE(right, left) } node = parent; parent = parent->parent; } while (!node->red); if (node) node->red = false; } tree_node_t* tree_find(const tree_t* tree, uintptr_t key) { tree_node_t* node = tree->root; while (node) { if (key < node->key) node = node->left; else if (key > node->key) node = node->right; else return node; } return NULL; } tree_node_t* tree_root(const tree_t* tree) { return tree->root; } #ifndef SIO_BSP_HANDLE_POLL #define SIO_BSP_HANDLE_POLL 0x4800001D #endif #ifndef SIO_BASE_HANDLE #define SIO_BASE_HANDLE 0x48000022 #endif int ws_global_init(void) { int r; WSADATA wsa_data; r = WSAStartup(MAKEWORD(2, 2), &wsa_data); if (r != 0) return_set_error(-1, (DWORD) r); return 0; } static inline SOCKET ws__ioctl_get_bsp_socket(SOCKET socket, DWORD ioctl) { SOCKET bsp_socket; DWORD bytes; if (WSAIoctl(socket, ioctl, NULL, 0, &bsp_socket, sizeof bsp_socket, &bytes, NULL, NULL) != SOCKET_ERROR) return bsp_socket; else return INVALID_SOCKET; } SOCKET ws_get_base_socket(SOCKET socket) { SOCKET base_socket; DWORD error; for (;;) { base_socket = ws__ioctl_get_bsp_socket(socket, SIO_BASE_HANDLE); if (base_socket != INVALID_SOCKET) return base_socket; error = GetLastError(); if (error == WSAENOTSOCK) return_set_error(INVALID_SOCKET, error); /* Even though Microsoft documentation clearly states that LSPs should * never intercept the `SIO_BASE_HANDLE` ioctl [1], Komodia based LSPs do * so anyway, breaking it, with the apparent intention of preventing LSP * bypass [2]. Fortunately they don't handle `SIO_BSP_HANDLE_POLL`, which * will at least let us obtain the socket associated with the next winsock * protocol chain entry. If this succeeds, loop around and call * `SIO_BASE_HANDLE` again with the returned BSP socket, to make sure that * we unwrap all layers and retrieve the actual base socket. * [1] https://docs.microsoft.com/en-us/windows/win32/winsock/winsock-ioctls * [2] https://www.komodia.com/newwiki/index.php?title=Komodia%27s_Redirector_bug_fixes#Version_2.2.2.6 */ base_socket = ws__ioctl_get_bsp_socket(socket, SIO_BSP_HANDLE_POLL); if (base_socket != INVALID_SOCKET && base_socket != socket) socket = base_socket; else return_set_error(INVALID_SOCKET, error); } }
sophomore_public/libzmq
external/wepoll/wepoll.c
C++
gpl-3.0
69,998
/* * wepoll - epoll for Windows * https://github.com/piscisaureus/wepoll * * Copyright 2012-2020, Bert Belder <bertbelder@gmail.com> * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are * met: * * * Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * * * Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ #ifndef WEPOLL_H_ #define WEPOLL_H_ #ifndef WEPOLL_EXPORT #define WEPOLL_EXPORT #endif #include <stdint.h> enum EPOLL_EVENTS { EPOLLIN = (int) (1U << 0), EPOLLPRI = (int) (1U << 1), EPOLLOUT = (int) (1U << 2), EPOLLERR = (int) (1U << 3), EPOLLHUP = (int) (1U << 4), EPOLLRDNORM = (int) (1U << 6), EPOLLRDBAND = (int) (1U << 7), EPOLLWRNORM = (int) (1U << 8), EPOLLWRBAND = (int) (1U << 9), EPOLLMSG = (int) (1U << 10), /* Never reported. */ EPOLLRDHUP = (int) (1U << 13), EPOLLONESHOT = (int) (1U << 31) }; #define EPOLLIN (1U << 0) #define EPOLLPRI (1U << 1) #define EPOLLOUT (1U << 2) #define EPOLLERR (1U << 3) #define EPOLLHUP (1U << 4) #define EPOLLRDNORM (1U << 6) #define EPOLLRDBAND (1U << 7) #define EPOLLWRNORM (1U << 8) #define EPOLLWRBAND (1U << 9) #define EPOLLMSG (1U << 10) #define EPOLLRDHUP (1U << 13) #define EPOLLONESHOT (1U << 31) #define EPOLL_CTL_ADD 1 #define EPOLL_CTL_MOD 2 #define EPOLL_CTL_DEL 3 typedef void* HANDLE; typedef uintptr_t SOCKET; typedef union epoll_data { void* ptr; int fd; uint32_t u32; uint64_t u64; SOCKET sock; /* Windows specific */ HANDLE hnd; /* Windows specific */ } epoll_data_t; struct epoll_event { uint32_t events; /* Epoll events and flags */ epoll_data_t data; /* User data variable */ }; #ifdef __cplusplus extern "C" { #endif WEPOLL_EXPORT HANDLE epoll_create(int size); WEPOLL_EXPORT HANDLE epoll_create1(int flags); WEPOLL_EXPORT int epoll_close(HANDLE ephnd); WEPOLL_EXPORT int epoll_ctl(HANDLE ephnd, int op, SOCKET sock, struct epoll_event* event); WEPOLL_EXPORT int epoll_wait(HANDLE ephnd, struct epoll_event* events, int maxevents, int timeout); #ifdef __cplusplus } /* extern "C" */ #endif #endif /* WEPOLL_H_ */
sophomore_public/libzmq
external/wepoll/wepoll.h
C++
gpl-3.0
3,471
/* SPDX-License-Identifier: MPL-2.0 */ /* ************************************************************************* NOTE to contributors. This file comprises the principal public contract for ZeroMQ API users. Any change to this file supplied in a stable release SHOULD not break existing applications. In practice this means that the value of constants must not change, and that old values may not be reused for new constants. ************************************************************************* */ #ifndef __ZMQ_H_INCLUDED__ #define __ZMQ_H_INCLUDED__ /* Version macros for compile-time API version detection */ #define ZMQ_VERSION_MAJOR 4 #define ZMQ_VERSION_MINOR 3 #define ZMQ_VERSION_PATCH 6 #define ZMQ_MAKE_VERSION(major, minor, patch) \ ((major) * 10000 + (minor) * 100 + (patch)) #define ZMQ_VERSION \ ZMQ_MAKE_VERSION (ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH) #ifdef __cplusplus extern "C" { #endif #if !defined _WIN32_WCE #include <errno.h> #endif #include <stddef.h> #include <stdio.h> /* Handle DSO symbol visibility */ #if defined ZMQ_NO_EXPORT #define ZMQ_EXPORT #else #if defined _WIN32 #if defined ZMQ_STATIC #define ZMQ_EXPORT #elif defined DLL_EXPORT #define ZMQ_EXPORT __declspec (dllexport) #else #define ZMQ_EXPORT __declspec (dllimport) #endif #else #if defined __SUNPRO_C || defined __SUNPRO_CC #define ZMQ_EXPORT __global #elif (defined __GNUC__ && __GNUC__ >= 4) || defined __INTEL_COMPILER #define ZMQ_EXPORT __attribute__ ((visibility ("default"))) #else #define ZMQ_EXPORT #endif #endif #endif /* Define integer types needed for event interface */ #define ZMQ_DEFINED_STDINT 1 #if defined ZMQ_HAVE_SOLARIS || defined ZMQ_HAVE_OPENVMS #include <inttypes.h> #elif defined _MSC_VER && _MSC_VER < 1600 #ifndef uint64_t typedef unsigned __int64 uint64_t; #endif #ifndef int32_t typedef __int32 int32_t; #endif #ifndef uint32_t typedef unsigned __int32 uint32_t; #endif #ifndef uint16_t typedef unsigned __int16 uint16_t; #endif #ifndef uint8_t typedef unsigned __int8 uint8_t; #endif #else #include <stdint.h> #endif #if !defined _WIN32 // needed for sigset_t definition in zmq_ppoll #include <signal.h> #endif // 32-bit AIX's pollfd struct members are called reqevents and rtnevents so it // defines compatibility macros for them. Need to include that header first to // stop build failures since zmq_pollset_t defines them as events and revents. #ifdef ZMQ_HAVE_AIX #include <poll.h> #endif /******************************************************************************/ /* 0MQ errors. */ /******************************************************************************/ /* A number random enough not to collide with different errno ranges on */ /* different OSes. The assumption is that error_t is at least 32-bit type. */ #define ZMQ_HAUSNUMERO 156384712 /* On Windows platform some of the standard POSIX errnos are not defined. */ #ifndef ENOTSUP #define ENOTSUP (ZMQ_HAUSNUMERO + 1) #endif #ifndef EPROTONOSUPPORT #define EPROTONOSUPPORT (ZMQ_HAUSNUMERO + 2) #endif #ifndef ENOBUFS #define ENOBUFS (ZMQ_HAUSNUMERO + 3) #endif #ifndef ENETDOWN #define ENETDOWN (ZMQ_HAUSNUMERO + 4) #endif #ifndef EADDRINUSE #define EADDRINUSE (ZMQ_HAUSNUMERO + 5) #endif #ifndef EADDRNOTAVAIL #define EADDRNOTAVAIL (ZMQ_HAUSNUMERO + 6) #endif #ifndef ECONNREFUSED #define ECONNREFUSED (ZMQ_HAUSNUMERO + 7) #endif #ifndef EINPROGRESS #define EINPROGRESS (ZMQ_HAUSNUMERO + 8) #endif #ifndef ENOTSOCK #define ENOTSOCK (ZMQ_HAUSNUMERO + 9) #endif #ifndef EMSGSIZE #define EMSGSIZE (ZMQ_HAUSNUMERO + 10) #endif #ifndef EAFNOSUPPORT #define EAFNOSUPPORT (ZMQ_HAUSNUMERO + 11) #endif #ifndef ENETUNREACH #define ENETUNREACH (ZMQ_HAUSNUMERO + 12) #endif #ifndef ECONNABORTED #define ECONNABORTED (ZMQ_HAUSNUMERO + 13) #endif #ifndef ECONNRESET #define ECONNRESET (ZMQ_HAUSNUMERO + 14) #endif #ifndef ENOTCONN #define ENOTCONN (ZMQ_HAUSNUMERO + 15) #endif #ifndef ETIMEDOUT #define ETIMEDOUT (ZMQ_HAUSNUMERO + 16) #endif #ifndef EHOSTUNREACH #define EHOSTUNREACH (ZMQ_HAUSNUMERO + 17) #endif #ifndef ENETRESET #define ENETRESET (ZMQ_HAUSNUMERO + 18) #endif /* Native 0MQ error codes. */ #define EFSM (ZMQ_HAUSNUMERO + 51) #define ENOCOMPATPROTO (ZMQ_HAUSNUMERO + 52) #define ETERM (ZMQ_HAUSNUMERO + 53) #define EMTHREAD (ZMQ_HAUSNUMERO + 54) /* This function retrieves the errno as it is known to 0MQ library. The goal */ /* of this function is to make the code 100% portable, including where 0MQ */ /* compiled with certain CRT library (on Windows) is linked to an */ /* application that uses different CRT library. */ ZMQ_EXPORT int zmq_errno (void); /* Resolves system errors and 0MQ errors to human-readable string. */ ZMQ_EXPORT const char *zmq_strerror (int errnum_); /* Run-time API version detection */ ZMQ_EXPORT void zmq_version (int *major_, int *minor_, int *patch_); /******************************************************************************/ /* 0MQ infrastructure (a.k.a. context) initialisation & termination. */ /******************************************************************************/ /* Context options */ #define ZMQ_IO_THREADS 1 #define ZMQ_MAX_SOCKETS 2 #define ZMQ_SOCKET_LIMIT 3 #define ZMQ_THREAD_PRIORITY 3 #define ZMQ_THREAD_SCHED_POLICY 4 #define ZMQ_MAX_MSGSZ 5 #define ZMQ_MSG_T_SIZE 6 #define ZMQ_THREAD_AFFINITY_CPU_ADD 7 #define ZMQ_THREAD_AFFINITY_CPU_REMOVE 8 #define ZMQ_THREAD_NAME_PREFIX 9 /* Default for new contexts */ #define ZMQ_IO_THREADS_DFLT 1 #define ZMQ_MAX_SOCKETS_DFLT 1023 #define ZMQ_THREAD_PRIORITY_DFLT -1 #define ZMQ_THREAD_SCHED_POLICY_DFLT -1 ZMQ_EXPORT void *zmq_ctx_new (void); ZMQ_EXPORT int zmq_ctx_term (void *context_); ZMQ_EXPORT int zmq_ctx_shutdown (void *context_); ZMQ_EXPORT int zmq_ctx_set (void *context_, int option_, int optval_); ZMQ_EXPORT int zmq_ctx_get (void *context_, int option_); /* Old (legacy) API */ ZMQ_EXPORT void *zmq_init (int io_threads_); ZMQ_EXPORT int zmq_term (void *context_); ZMQ_EXPORT int zmq_ctx_destroy (void *context_); /******************************************************************************/ /* 0MQ message definition. */ /******************************************************************************/ /* Some architectures, like sparc64 and some variants of aarch64, enforce pointer * alignment and raise sigbus on violations. Make sure applications allocate * zmq_msg_t on addresses aligned on a pointer-size boundary to avoid this issue. */ typedef struct zmq_msg_t { #if defined(_MSC_VER) && (defined(_M_X64) || defined(_M_ARM64)) __declspec (align (8)) unsigned char _[64]; #elif defined(_MSC_VER) \ && (defined(_M_IX86) || defined(_M_ARM_ARMV7VE) || defined(_M_ARM)) __declspec (align (4)) unsigned char _[64]; #elif defined(__GNUC__) || defined(__INTEL_COMPILER) \ || (defined(__SUNPRO_C) && __SUNPRO_C >= 0x590) \ || (defined(__SUNPRO_CC) && __SUNPRO_CC >= 0x590) unsigned char _[64] __attribute__ ((aligned (sizeof (void *)))); #else unsigned char _[64]; #endif } zmq_msg_t; typedef void (zmq_free_fn) (void *data_, void *hint_); ZMQ_EXPORT int zmq_msg_init (zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_init_size (zmq_msg_t *msg_, size_t size_); ZMQ_EXPORT int zmq_msg_init_data ( zmq_msg_t *msg_, void *data_, size_t size_, zmq_free_fn *ffn_, void *hint_); ZMQ_EXPORT int zmq_msg_send (zmq_msg_t *msg_, void *s_, int flags_); ZMQ_EXPORT int zmq_msg_recv (zmq_msg_t *msg_, void *s_, int flags_); ZMQ_EXPORT int zmq_msg_close (zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_move (zmq_msg_t *dest_, zmq_msg_t *src_); ZMQ_EXPORT int zmq_msg_copy (zmq_msg_t *dest_, zmq_msg_t *src_); ZMQ_EXPORT void *zmq_msg_data (zmq_msg_t *msg_); ZMQ_EXPORT size_t zmq_msg_size (const zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_more (const zmq_msg_t *msg_); ZMQ_EXPORT int zmq_msg_get (const zmq_msg_t *msg_, int property_); ZMQ_EXPORT int zmq_msg_set (zmq_msg_t *msg_, int property_, int optval_); ZMQ_EXPORT const char *zmq_msg_gets (const zmq_msg_t *msg_, const char *property_); /******************************************************************************/ /* 0MQ socket definition. */ /******************************************************************************/ /* Socket types. */ #define ZMQ_PAIR 0 #define ZMQ_PUB 1 #define ZMQ_SUB 2 #define ZMQ_REQ 3 #define ZMQ_REP 4 #define ZMQ_DEALER 5 #define ZMQ_ROUTER 6 #define ZMQ_PULL 7 #define ZMQ_PUSH 8 #define ZMQ_XPUB 9 #define ZMQ_XSUB 10 #define ZMQ_STREAM 11 /* Deprecated aliases */ #define ZMQ_XREQ ZMQ_DEALER #define ZMQ_XREP ZMQ_ROUTER /* Socket options. */ #define ZMQ_AFFINITY 4 #define ZMQ_ROUTING_ID 5 #define ZMQ_SUBSCRIBE 6 #define ZMQ_UNSUBSCRIBE 7 #define ZMQ_RATE 8 #define ZMQ_RECOVERY_IVL 9 #define ZMQ_SNDBUF 11 #define ZMQ_RCVBUF 12 #define ZMQ_RCVMORE 13 #define ZMQ_FD 14 #define ZMQ_EVENTS 15 #define ZMQ_TYPE 16 #define ZMQ_LINGER 17 #define ZMQ_RECONNECT_IVL 18 #define ZMQ_BACKLOG 19 #define ZMQ_RECONNECT_IVL_MAX 21 #define ZMQ_MAXMSGSIZE 22 #define ZMQ_SNDHWM 23 #define ZMQ_RCVHWM 24 #define ZMQ_MULTICAST_HOPS 25 #define ZMQ_RCVTIMEO 27 #define ZMQ_SNDTIMEO 28 #define ZMQ_LAST_ENDPOINT 32 #define ZMQ_ROUTER_MANDATORY 33 #define ZMQ_TCP_KEEPALIVE 34 #define ZMQ_TCP_KEEPALIVE_CNT 35 #define ZMQ_TCP_KEEPALIVE_IDLE 36 #define ZMQ_TCP_KEEPALIVE_INTVL 37 #define ZMQ_IMMEDIATE 39 #define ZMQ_XPUB_VERBOSE 40 #define ZMQ_ROUTER_RAW 41 #define ZMQ_IPV6 42 #define ZMQ_MECHANISM 43 #define ZMQ_PLAIN_SERVER 44 #define ZMQ_PLAIN_USERNAME 45 #define ZMQ_PLAIN_PASSWORD 46 #define ZMQ_CURVE_SERVER 47 #define ZMQ_CURVE_PUBLICKEY 48 #define ZMQ_CURVE_SECRETKEY 49 #define ZMQ_CURVE_SERVERKEY 50 #define ZMQ_PROBE_ROUTER 51 #define ZMQ_REQ_CORRELATE 52 #define ZMQ_REQ_RELAXED 53 #define ZMQ_CONFLATE 54 #define ZMQ_ZAP_DOMAIN 55 #define ZMQ_ROUTER_HANDOVER 56 #define ZMQ_TOS 57 #define ZMQ_CONNECT_ROUTING_ID 61 #define ZMQ_GSSAPI_SERVER 62 #define ZMQ_GSSAPI_PRINCIPAL 63 #define ZMQ_GSSAPI_SERVICE_PRINCIPAL 64 #define ZMQ_GSSAPI_PLAINTEXT 65 #define ZMQ_HANDSHAKE_IVL 66 #define ZMQ_SOCKS_PROXY 68 #define ZMQ_XPUB_NODROP 69 #define ZMQ_BLOCKY 70 #define ZMQ_XPUB_MANUAL 71 #define ZMQ_XPUB_WELCOME_MSG 72 #define ZMQ_STREAM_NOTIFY 73 #define ZMQ_INVERT_MATCHING 74 #define ZMQ_HEARTBEAT_IVL 75 #define ZMQ_HEARTBEAT_TTL 76 #define ZMQ_HEARTBEAT_TIMEOUT 77 #define ZMQ_XPUB_VERBOSER 78 #define ZMQ_CONNECT_TIMEOUT 79 #define ZMQ_TCP_MAXRT 80 #define ZMQ_THREAD_SAFE 81 #define ZMQ_MULTICAST_MAXTPDU 84 #define ZMQ_VMCI_BUFFER_SIZE 85 #define ZMQ_VMCI_BUFFER_MIN_SIZE 86 #define ZMQ_VMCI_BUFFER_MAX_SIZE 87 #define ZMQ_VMCI_CONNECT_TIMEOUT 88 #define ZMQ_USE_FD 89 #define ZMQ_GSSAPI_PRINCIPAL_NAMETYPE 90 #define ZMQ_GSSAPI_SERVICE_PRINCIPAL_NAMETYPE 91 #define ZMQ_BINDTODEVICE 92 /* Message options */ #define ZMQ_MORE 1 #define ZMQ_SHARED 3 /* Send/recv options. */ #define ZMQ_DONTWAIT 1 #define ZMQ_SNDMORE 2 /* Security mechanisms */ #define ZMQ_NULL 0 #define ZMQ_PLAIN 1 #define ZMQ_CURVE 2 #define ZMQ_GSSAPI 3 /* RADIO-DISH protocol */ #define ZMQ_GROUP_MAX_LENGTH 255 /* Deprecated options and aliases */ #define ZMQ_IDENTITY ZMQ_ROUTING_ID #define ZMQ_CONNECT_RID ZMQ_CONNECT_ROUTING_ID #define ZMQ_TCP_ACCEPT_FILTER 38 #define ZMQ_IPC_FILTER_PID 58 #define ZMQ_IPC_FILTER_UID 59 #define ZMQ_IPC_FILTER_GID 60 #define ZMQ_IPV4ONLY 31 #define ZMQ_DELAY_ATTACH_ON_CONNECT ZMQ_IMMEDIATE #define ZMQ_NOBLOCK ZMQ_DONTWAIT #define ZMQ_FAIL_UNROUTABLE ZMQ_ROUTER_MANDATORY #define ZMQ_ROUTER_BEHAVIOR ZMQ_ROUTER_MANDATORY /* Deprecated Message options */ #define ZMQ_SRCFD 2 /******************************************************************************/ /* GSSAPI definitions */ /******************************************************************************/ /* GSSAPI principal name types */ #define ZMQ_GSSAPI_NT_HOSTBASED 0 #define ZMQ_GSSAPI_NT_USER_NAME 1 #define ZMQ_GSSAPI_NT_KRB5_PRINCIPAL 2 /******************************************************************************/ /* 0MQ socket events and monitoring */ /******************************************************************************/ /* Socket transport events (TCP, IPC and TIPC only) */ #define ZMQ_EVENT_CONNECTED 0x0001 #define ZMQ_EVENT_CONNECT_DELAYED 0x0002 #define ZMQ_EVENT_CONNECT_RETRIED 0x0004 #define ZMQ_EVENT_LISTENING 0x0008 #define ZMQ_EVENT_BIND_FAILED 0x0010 #define ZMQ_EVENT_ACCEPTED 0x0020 #define ZMQ_EVENT_ACCEPT_FAILED 0x0040 #define ZMQ_EVENT_CLOSED 0x0080 #define ZMQ_EVENT_CLOSE_FAILED 0x0100 #define ZMQ_EVENT_DISCONNECTED 0x0200 #define ZMQ_EVENT_MONITOR_STOPPED 0x0400 #define ZMQ_EVENT_ALL 0xFFFF /* Unspecified system errors during handshake. Event value is an errno. */ #define ZMQ_EVENT_HANDSHAKE_FAILED_NO_DETAIL 0x0800 /* Handshake complete successfully with successful authentication (if * * enabled). Event value is unused. */ #define ZMQ_EVENT_HANDSHAKE_SUCCEEDED 0x1000 /* Protocol errors between ZMTP peers or between server and ZAP handler. * * Event value is one of ZMQ_PROTOCOL_ERROR_* */ #define ZMQ_EVENT_HANDSHAKE_FAILED_PROTOCOL 0x2000 /* Failed authentication requests. Event value is the numeric ZAP status * * code, i.e. 300, 400 or 500. */ #define ZMQ_EVENT_HANDSHAKE_FAILED_AUTH 0x4000 #define ZMQ_PROTOCOL_ERROR_ZMTP_UNSPECIFIED 0x10000000 #define ZMQ_PROTOCOL_ERROR_ZMTP_UNEXPECTED_COMMAND 0x10000001 #define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_SEQUENCE 0x10000002 #define ZMQ_PROTOCOL_ERROR_ZMTP_KEY_EXCHANGE 0x10000003 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_UNSPECIFIED 0x10000011 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_MESSAGE 0x10000012 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_HELLO 0x10000013 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_INITIATE 0x10000014 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_ERROR 0x10000015 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_READY 0x10000016 #define ZMQ_PROTOCOL_ERROR_ZMTP_MALFORMED_COMMAND_WELCOME 0x10000017 #define ZMQ_PROTOCOL_ERROR_ZMTP_INVALID_METADATA 0x10000018 // the following two may be due to erroneous configuration of a peer #define ZMQ_PROTOCOL_ERROR_ZMTP_CRYPTOGRAPHIC 0x11000001 #define ZMQ_PROTOCOL_ERROR_ZMTP_MECHANISM_MISMATCH 0x11000002 #define ZMQ_PROTOCOL_ERROR_ZAP_UNSPECIFIED 0x20000000 #define ZMQ_PROTOCOL_ERROR_ZAP_MALFORMED_REPLY 0x20000001 #define ZMQ_PROTOCOL_ERROR_ZAP_BAD_REQUEST_ID 0x20000002 #define ZMQ_PROTOCOL_ERROR_ZAP_BAD_VERSION 0x20000003 #define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_STATUS_CODE 0x20000004 #define ZMQ_PROTOCOL_ERROR_ZAP_INVALID_METADATA 0x20000005 #define ZMQ_PROTOCOL_ERROR_WS_UNSPECIFIED 0x30000000 ZMQ_EXPORT void *zmq_socket (void *, int type_); ZMQ_EXPORT int zmq_close (void *s_); ZMQ_EXPORT int zmq_setsockopt (void *s_, int option_, const void *optval_, size_t optvallen_); ZMQ_EXPORT int zmq_getsockopt (void *s_, int option_, void *optval_, size_t *optvallen_); ZMQ_EXPORT int zmq_bind (void *s_, const char *addr_); ZMQ_EXPORT int zmq_connect (void *s_, const char *addr_); ZMQ_EXPORT int zmq_unbind (void *s_, const char *addr_); ZMQ_EXPORT int zmq_disconnect (void *s_, const char *addr_); ZMQ_EXPORT int zmq_send (void *s_, const void *buf_, size_t len_, int flags_); ZMQ_EXPORT int zmq_send_const (void *s_, const void *buf_, size_t len_, int flags_); ZMQ_EXPORT int zmq_recv (void *s_, void *buf_, size_t len_, int flags_); ZMQ_EXPORT int zmq_socket_monitor (void *s_, const char *addr_, int events_); /******************************************************************************/ /* Hide socket fd type; this was before zmq_poller_event_t typedef below */ /******************************************************************************/ #if defined _WIN32 // Windows uses a pointer-sized unsigned integer to store the socket fd. #if defined _WIN64 typedef unsigned __int64 zmq_fd_t; #else typedef unsigned int zmq_fd_t; #endif #else typedef int zmq_fd_t; #endif /******************************************************************************/ /* Deprecated I/O multiplexing. Prefer using zmq_poller API */ /******************************************************************************/ #define ZMQ_POLLIN 1 #define ZMQ_POLLOUT 2 #define ZMQ_POLLERR 4 #define ZMQ_POLLPRI 8 typedef struct zmq_pollitem_t { void *socket; zmq_fd_t fd; short events; short revents; } zmq_pollitem_t; #define ZMQ_POLLITEMS_DFLT 16 ZMQ_EXPORT int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_); /******************************************************************************/ /* Message proxying */ /******************************************************************************/ ZMQ_EXPORT int zmq_proxy (void *frontend_, void *backend_, void *capture_); ZMQ_EXPORT int zmq_proxy_steerable (void *frontend_, void *backend_, void *capture_, void *control_); /******************************************************************************/ /* Probe library capabilities */ /******************************************************************************/ #define ZMQ_HAS_CAPABILITIES 1 ZMQ_EXPORT int zmq_has (const char *capability_); /* Deprecated aliases */ #define ZMQ_STREAMER 1 #define ZMQ_FORWARDER 2 #define ZMQ_QUEUE 3 /* Deprecated methods */ ZMQ_EXPORT int zmq_device (int type_, void *frontend_, void *backend_); ZMQ_EXPORT int zmq_sendmsg (void *s_, zmq_msg_t *msg_, int flags_); ZMQ_EXPORT int zmq_recvmsg (void *s_, zmq_msg_t *msg_, int flags_); struct iovec; ZMQ_EXPORT int zmq_sendiov (void *s_, struct iovec *iov_, size_t count_, int flags_); ZMQ_EXPORT int zmq_recviov (void *s_, struct iovec *iov_, size_t *count_, int flags_); /******************************************************************************/ /* Encryption functions */ /******************************************************************************/ /* Encode data with Z85 encoding. Returns encoded data */ ZMQ_EXPORT char * zmq_z85_encode (char *dest_, const uint8_t *data_, size_t size_); /* Decode data with Z85 encoding. Returns decoded data */ ZMQ_EXPORT uint8_t *zmq_z85_decode (uint8_t *dest_, const char *string_); /* Generate z85-encoded public and private keypair with libsodium. */ /* Returns 0 on success. */ ZMQ_EXPORT int zmq_curve_keypair (char *z85_public_key_, char *z85_secret_key_); /* Derive the z85-encoded public key from the z85-encoded secret key. */ /* Returns 0 on success. */ ZMQ_EXPORT int zmq_curve_public (char *z85_public_key_, const char *z85_secret_key_); /******************************************************************************/ /* Atomic utility methods */ /******************************************************************************/ ZMQ_EXPORT void *zmq_atomic_counter_new (void); ZMQ_EXPORT void zmq_atomic_counter_set (void *counter_, int value_); ZMQ_EXPORT int zmq_atomic_counter_inc (void *counter_); ZMQ_EXPORT int zmq_atomic_counter_dec (void *counter_); ZMQ_EXPORT int zmq_atomic_counter_value (void *counter_); ZMQ_EXPORT void zmq_atomic_counter_destroy (void **counter_p_); /******************************************************************************/ /* Scheduling timers */ /******************************************************************************/ #define ZMQ_HAVE_TIMERS typedef void (zmq_timer_fn) (int timer_id, void *arg); ZMQ_EXPORT void *zmq_timers_new (void); ZMQ_EXPORT int zmq_timers_destroy (void **timers_p); ZMQ_EXPORT int zmq_timers_add (void *timers, size_t interval, zmq_timer_fn handler, void *arg); ZMQ_EXPORT int zmq_timers_cancel (void *timers, int timer_id); ZMQ_EXPORT int zmq_timers_set_interval (void *timers, int timer_id, size_t interval); ZMQ_EXPORT int zmq_timers_reset (void *timers, int timer_id); ZMQ_EXPORT long zmq_timers_timeout (void *timers); ZMQ_EXPORT int zmq_timers_execute (void *timers); /******************************************************************************/ /* These functions are not documented by man pages -- use at your own risk. */ /* If you need these to be part of the formal ZMQ API, then (a) write a man */ /* page, and (b) write a test case in tests. */ /******************************************************************************/ /* Helper functions are used by perf tests so that they don't have to care */ /* about minutiae of time-related functions on different OS platforms. */ /* Starts the stopwatch. Returns the handle to the watch. */ ZMQ_EXPORT void *zmq_stopwatch_start (void); /* Returns the number of microseconds elapsed since the stopwatch was */ /* started, but does not stop or deallocate the stopwatch. */ ZMQ_EXPORT unsigned long zmq_stopwatch_intermediate (void *watch_); /* Stops the stopwatch. Returns the number of microseconds elapsed since */ /* the stopwatch was started, and deallocates that watch. */ ZMQ_EXPORT unsigned long zmq_stopwatch_stop (void *watch_); /* Sleeps for specified number of seconds. */ ZMQ_EXPORT void zmq_sleep (int seconds_); typedef void (zmq_thread_fn) (void *); /* Start a thread. Returns a handle to the thread. */ ZMQ_EXPORT void *zmq_threadstart (zmq_thread_fn *func_, void *arg_); /* Wait for thread to complete then free up resources. */ ZMQ_EXPORT void zmq_threadclose (void *thread_); /******************************************************************************/ /* These functions are DRAFT and disabled in stable releases, and subject to */ /* change at ANY time until declared stable. */ /******************************************************************************/ #ifdef ZMQ_BUILD_DRAFT_API /* DRAFT Socket types. */ #define ZMQ_SERVER 12 #define ZMQ_CLIENT 13 #define ZMQ_RADIO 14 #define ZMQ_DISH 15 #define ZMQ_GATHER 16 #define ZMQ_SCATTER 17 #define ZMQ_DGRAM 18 #define ZMQ_PEER 19 #define ZMQ_CHANNEL 20 /* DRAFT Socket options. */ #define ZMQ_ZAP_ENFORCE_DOMAIN 93 #define ZMQ_LOOPBACK_FASTPATH 94 #define ZMQ_METADATA 95 #define ZMQ_MULTICAST_LOOP 96 #define ZMQ_ROUTER_NOTIFY 97 #define ZMQ_XPUB_MANUAL_LAST_VALUE 98 #define ZMQ_SOCKS_USERNAME 99 #define ZMQ_SOCKS_PASSWORD 100 #define ZMQ_IN_BATCH_SIZE 101 #define ZMQ_OUT_BATCH_SIZE 102 #define ZMQ_WSS_KEY_PEM 103 #define ZMQ_WSS_CERT_PEM 104 #define ZMQ_WSS_TRUST_PEM 105 #define ZMQ_WSS_HOSTNAME 106 #define ZMQ_WSS_TRUST_SYSTEM 107 #define ZMQ_ONLY_FIRST_SUBSCRIBE 108 #define ZMQ_RECONNECT_STOP 109 #define ZMQ_HELLO_MSG 110 #define ZMQ_DISCONNECT_MSG 111 #define ZMQ_PRIORITY 112 #define ZMQ_BUSY_POLL 113 #define ZMQ_HICCUP_MSG 114 #define ZMQ_XSUB_VERBOSE_UNSUBSCRIBE 115 #define ZMQ_TOPICS_COUNT 116 #define ZMQ_NORM_MODE 117 #define ZMQ_NORM_UNICAST_NACK 118 #define ZMQ_NORM_BUFFER_SIZE 119 #define ZMQ_NORM_SEGMENT_SIZE 120 #define ZMQ_NORM_BLOCK_SIZE 121 #define ZMQ_NORM_NUM_PARITY 122 #define ZMQ_NORM_NUM_AUTOPARITY 123 #define ZMQ_NORM_PUSH 124 /* DRAFT ZMQ_NORM_MODE options */ #define ZMQ_NORM_FIXED 0 #define ZMQ_NORM_CC 1 #define ZMQ_NORM_CCL 2 #define ZMQ_NORM_CCE 3 #define ZMQ_NORM_CCE_ECNONLY 4 /* DRAFT ZMQ_RECONNECT_STOP options */ #define ZMQ_RECONNECT_STOP_CONN_REFUSED 0x1 #define ZMQ_RECONNECT_STOP_HANDSHAKE_FAILED 0x2 #define ZMQ_RECONNECT_STOP_AFTER_DISCONNECT 0x4 /* DRAFT Context options */ #define ZMQ_ZERO_COPY_RECV 10 /* DRAFT Context methods. */ ZMQ_EXPORT int zmq_ctx_set_ext (void *context_, int option_, const void *optval_, size_t optvallen_); ZMQ_EXPORT int zmq_ctx_get_ext (void *context_, int option_, void *optval_, size_t *optvallen_); /* DRAFT Socket methods. */ ZMQ_EXPORT int zmq_join (void *s, const char *group); ZMQ_EXPORT int zmq_leave (void *s, const char *group); ZMQ_EXPORT uint32_t zmq_connect_peer (void *s_, const char *addr_); /* DRAFT Msg methods. */ ZMQ_EXPORT int zmq_msg_set_routing_id (zmq_msg_t *msg, uint32_t routing_id); ZMQ_EXPORT uint32_t zmq_msg_routing_id (zmq_msg_t *msg); ZMQ_EXPORT int zmq_msg_set_group (zmq_msg_t *msg, const char *group); ZMQ_EXPORT const char *zmq_msg_group (zmq_msg_t *msg); ZMQ_EXPORT int zmq_msg_init_buffer (zmq_msg_t *msg_, const void *buf_, size_t size_); /* DRAFT Msg property names. */ #define ZMQ_MSG_PROPERTY_ROUTING_ID "Routing-Id" #define ZMQ_MSG_PROPERTY_SOCKET_TYPE "Socket-Type" #define ZMQ_MSG_PROPERTY_USER_ID "User-Id" #define ZMQ_MSG_PROPERTY_PEER_ADDRESS "Peer-Address" /* Router notify options */ #define ZMQ_NOTIFY_CONNECT 1 #define ZMQ_NOTIFY_DISCONNECT 2 /******************************************************************************/ /* Poller polling on sockets,fd and thread-safe sockets */ /******************************************************************************/ #define ZMQ_HAVE_POLLER typedef struct zmq_poller_event_t { void *socket; zmq_fd_t fd; void *user_data; short events; } zmq_poller_event_t; ZMQ_EXPORT void *zmq_poller_new (void); ZMQ_EXPORT int zmq_poller_destroy (void **poller_p); ZMQ_EXPORT int zmq_poller_size (void *poller); ZMQ_EXPORT int zmq_poller_add (void *poller, void *socket, void *user_data, short events); ZMQ_EXPORT int zmq_poller_modify (void *poller, void *socket, short events); ZMQ_EXPORT int zmq_poller_remove (void *poller, void *socket); ZMQ_EXPORT int zmq_poller_wait (void *poller, zmq_poller_event_t *event, long timeout); ZMQ_EXPORT int zmq_poller_wait_all (void *poller, zmq_poller_event_t *events, int n_events, long timeout); ZMQ_EXPORT int zmq_poller_fd (void *poller, zmq_fd_t *fd); ZMQ_EXPORT int zmq_poller_add_fd (void *poller, zmq_fd_t fd, void *user_data, short events); ZMQ_EXPORT int zmq_poller_modify_fd (void *poller, zmq_fd_t fd, short events); ZMQ_EXPORT int zmq_poller_remove_fd (void *poller, zmq_fd_t fd); ZMQ_EXPORT int zmq_socket_get_peer_state (void *socket, const void *routing_id, size_t routing_id_size); /* DRAFT Socket monitoring events */ #define ZMQ_EVENT_PIPES_STATS 0x10000 #define ZMQ_CURRENT_EVENT_VERSION 1 #define ZMQ_CURRENT_EVENT_VERSION_DRAFT 2 #define ZMQ_EVENT_ALL_V1 ZMQ_EVENT_ALL #define ZMQ_EVENT_ALL_V2 ZMQ_EVENT_ALL_V1 | ZMQ_EVENT_PIPES_STATS ZMQ_EXPORT int zmq_socket_monitor_versioned ( void *s_, const char *addr_, uint64_t events_, int event_version_, int type_); ZMQ_EXPORT int zmq_socket_monitor_pipes_stats (void *s); #if !defined _WIN32 ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_, int nitems_, long timeout_, const sigset_t *sigmask_); #else // Windows has no sigset_t ZMQ_EXPORT int zmq_ppoll (zmq_pollitem_t *items_, int nitems_, long timeout_, const void *sigmask_); #endif #endif // ZMQ_BUILD_DRAFT_API #undef ZMQ_EXPORT #ifdef __cplusplus } #endif #endif
sophomore_public/libzmq
include/zmq.h
C++
gpl-3.0
29,856
/* SPDX-License-Identifier: MPL-2.0 */ /* This file is deprecated, and all its functionality provided by zmq.h */ /* Note that -Wpedantic compilation requires GCC to avoid using its custom extensions such as #warning, hence the trick below. Also, pragmas for warnings or other messages are not standard, not portable, and not all compilers even have an equivalent concept. So in the worst case, this include file is treated as silently empty. */ #if defined(__clang__) || defined(__GNUC__) || defined(__GNUG__) \ || defined(_MSC_VER) #if defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic push #pragma GCC diagnostic warning "-Wcpp" #pragma GCC diagnostic ignored "-Werror" #pragma GCC diagnostic ignored "-Wall" #endif #pragma message( \ "Warning: zmq_utils.h is deprecated. All its functionality is provided by zmq.h.") #if defined(__GNUC__) || defined(__GNUG__) #pragma GCC diagnostic pop #endif #endif
sophomore_public/libzmq
include/zmq_utils.h
C++
gpl-3.0
1,021
# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_check_compile_flag.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_COMPILE_FLAG(FLAG, [ACTION-SUCCESS], [ACTION-FAILURE], [EXTRA-FLAGS], [INPUT]) # # DESCRIPTION # # Check whether the given FLAG works with the current language's compiler # or gives an error. (Warnings, however, are ignored) # # ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on # success/failure. # # If EXTRA-FLAGS is defined, it is added to the current language's default # flags (e.g. CFLAGS) when the check is done. The check is thus made with # the flags: "CFLAGS EXTRA-FLAGS FLAG". This can for example be used to # force the compiler to issue an error when a bad flag is given. # # INPUT gives an alternative input source to AC_COMPILE_IFELSE. # # NOTE: Implementation based on AX_CFLAGS_GCC_OPTION. Please keep this # macro in sync with AX_CHECK_{PREPROC,LINK}_FLAG. # # LICENSE # # Copyright (c) 2008 Guido U. Draheim <guidod@gmx.de> # Copyright (c) 2011 Maarten Bosmans <mkbosmans@gmail.com> # # This program is free software: you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by the # Free Software Foundation, either version 3 of the License, or (at your # option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General # Public License for more details. # # You should have received a copy of the GNU General Public License along # with this program. If not, see <http://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure # scripts that are the output of Autoconf when processing the Macro. You # need not follow the terms of the GNU General Public License when using # or distributing such scripts, even though portions of the text of the # Macro appear in them. The GNU General Public License (GPL) does govern # all other use of the material that constitutes the Autoconf Macro. # # This special exception to the GPL applies to versions of the Autoconf # Macro released by the Autoconf Archive. When you make and distribute a # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. #serial 4 AC_DEFUN([AX_CHECK_COMPILE_FLAG], [AC_PREREQ(2.64)dnl for _AC_LANG_PREFIX and AS_VAR_IF AS_VAR_PUSHDEF([CACHEVAR],[ax_cv_check_[]_AC_LANG_ABBREV[]flags_$4_$1])dnl AC_CACHE_CHECK([whether _AC_LANG compiler accepts $1], CACHEVAR, [ ax_check_save_flags=$[]_AC_LANG_PREFIX[]FLAGS _AC_LANG_PREFIX[]FLAGS="$[]_AC_LANG_PREFIX[]FLAGS $4 $1" AC_COMPILE_IFELSE([m4_default([$5],[AC_LANG_PROGRAM()])], [AS_VAR_SET(CACHEVAR,[yes])], [AS_VAR_SET(CACHEVAR,[no])]) _AC_LANG_PREFIX[]FLAGS=$ax_check_save_flags]) AS_VAR_IF(CACHEVAR,yes, [m4_default([$2], :)], [m4_default([$3], :)]) AS_VAR_POPDEF([CACHEVAR])dnl ])dnl AX_CHECK_COMPILE_FLAGS
sophomore_public/libzmq
m4/ax_check_compile_flag.m4
m4
gpl-3.0
3,330
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_check_vscript.html # =========================================================================== # # SYNOPSIS # # AX_CHECK_VSCRIPT # # DESCRIPTION # # Check whether the linker supports version scripts. Version scripts are # used when building shared libraries to bind symbols to version nodes # (helping to detect incompatibilities) or to limit the visibility of # non-public symbols. # # Output: # # If version scripts are supported, VSCRIPT_LDFLAGS will contain the # appropriate flag to pass to the linker. On GNU systems this would # typically be "-Wl,--version-script", and on Solaris it would typically # be "-Wl,-M". # # Two Automake conditionals are also set: # # HAVE_VSCRIPT is true if the linker supports version scripts with # entries that use simple wildcards, like "local: *". # # HAVE_VSCRIPT_COMPLEX is true if the linker supports version scripts with # pattern matching wildcards, like "global: Java_*". # # On systems that do not support symbol versioning, such as Mac OS X, both # conditionals will be false. They will also be false if the user passes # "--disable-symvers" on the configure command line. # # Example: # # configure.ac: # # AX_CHECK_VSCRIPT # # Makefile.am: # # if HAVE_VSCRIPT # libfoo_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libfoo.map # endif # # if HAVE_VSCRIPT_COMPLEX # libbar_la_LDFLAGS += $(VSCRIPT_LDFLAGS),@srcdir@/libbar.map # endif # # LICENSE # # Copyright (c) 2014 Kevin Cernekee <cernekee@gmail.com> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 2 # _AX_CHECK_VSCRIPT(flag, global-sym, action-if-link-succeeds, [junk-file=no]) AC_DEFUN([_AX_CHECK_VSCRIPT], [ AC_LANG_PUSH([C]) ax_check_vscript_save_flags="$LDFLAGS" echo "V1 { global: $2; local: *; };" > conftest.map AS_IF([test x$4 = xyes], [ echo "{" >> conftest.map ]) LDFLAGS="$LDFLAGS -Wl,$1,conftest.map" AC_LINK_IFELSE([AC_LANG_PROGRAM([[int show, hide;]], [])], [$3]) LDFLAGS="$ax_check_vscript_save_flags" rm -f conftest.map AC_LANG_POP([C]) ]) dnl _AX_CHECK_VSCRIPT AC_DEFUN([AX_CHECK_VSCRIPT], [ AC_ARG_ENABLE([symvers], AS_HELP_STRING([--disable-symvers], [disable library symbol versioning [default=auto]]), [want_symvers=$enableval], [want_symvers=yes] ) AS_IF([test x$want_symvers = xyes], [ dnl First test --version-script and -M with a simple wildcard. AC_CACHE_CHECK([linker version script flag], ax_cv_check_vscript_flag, [ ax_cv_check_vscript_flag=unsupported _AX_CHECK_VSCRIPT([--version-script], [show], [ ax_cv_check_vscript_flag=--version-script ]) AS_IF([test x$ax_cv_check_vscript_flag = xunsupported], [ _AX_CHECK_VSCRIPT([-M], [show], [ax_cv_check_vscript_flag=-M]) ]) dnl The linker may interpret -M (no argument) as "produce a load map." dnl If "-M conftest.map" doesn't fail when conftest.map contains dnl obvious syntax errors, assume this is the case. AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [ _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [show], [ax_cv_check_vscript_flag=unsupported], [yes]) ]) ]) dnl If the simple wildcard worked, retest with a complex wildcard. AS_IF([test x$ax_cv_check_vscript_flag != xunsupported], [ ax_check_vscript_flag=$ax_cv_check_vscript_flag AC_CACHE_CHECK([if version scripts can use complex wildcards], ax_cv_check_vscript_complex_wildcards, [ ax_cv_check_vscript_complex_wildcards=no _AX_CHECK_VSCRIPT([$ax_cv_check_vscript_flag], [sh*], [ ax_cv_check_vscript_complex_wildcards=yes]) ]) ax_check_vscript_complex_wildcards="$ax_cv_check_vscript_complex_wildcards" ], [ ax_check_vscript_flag= ax_check_vscript_complex_wildcards=no ]) ], [ AC_MSG_CHECKING([linker version script flag]) AC_MSG_RESULT([disabled]) ax_check_vscript_flag= ax_check_vscript_complex_wildcards=no ]) AS_IF([test x$ax_check_vscript_flag != x], [ VSCRIPT_LDFLAGS="-Wl,$ax_check_vscript_flag" AC_SUBST([VSCRIPT_LDFLAGS]) ]) AM_CONDITIONAL([HAVE_VSCRIPT], [test x$ax_check_vscript_flag != x]) AM_CONDITIONAL([HAVE_VSCRIPT_COMPLEX], [test x$ax_check_vscript_complex_wildcards = xyes]) ]) dnl AX_CHECK_VSCRIPT
sophomore_public/libzmq
m4/ax_check_vscript.m4
m4
gpl-3.0
4,717
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_code_coverage.html # =========================================================================== # # SYNOPSIS # # AX_CODE_COVERAGE() # # DESCRIPTION # # Defines CODE_COVERAGE_CPPFLAGS, CODE_COVERAGE_CFLAGS, # CODE_COVERAGE_CXXFLAGS and CODE_COVERAGE_LIBS which should be included # in the CPPFLAGS, CFLAGS CXXFLAGS and LIBS/LIBADD variables of every # build target (program or library) which should be built with code # coverage support. Also defines CODE_COVERAGE_RULES which should be # substituted in your Makefile; and $enable_code_coverage which can be # used in subsequent configure output. CODE_COVERAGE_ENABLED is defined # and substituted, and corresponds to the value of the # --enable-code-coverage option, which defaults to being disabled. # # Test also for gcov program and create GCOV variable that could be # substituted. # # Note that all optimization flags in CFLAGS must be disabled when code # coverage is enabled. # # Usage example: # # configure.ac: # # AX_CODE_COVERAGE # # Makefile.am: # # @CODE_COVERAGE_RULES@ # my_program_LIBS = ... $(CODE_COVERAGE_LIBS) ... # my_program_CPPFLAGS = ... $(CODE_COVERAGE_CPPFLAGS) ... # my_program_CFLAGS = ... $(CODE_COVERAGE_CFLAGS) ... # my_program_CXXFLAGS = ... $(CODE_COVERAGE_CXXFLAGS) ... # # This results in a "check-code-coverage" rule being added to any # Makefile.am which includes "@CODE_COVERAGE_RULES@" (assuming the module # has been configured with --enable-code-coverage). Running `make # check-code-coverage` in that directory will run the module's test suite # (`make check`) and build a code coverage report detailing the code which # was touched, then print the URI for the report. # # In earlier versions of this macro, CODE_COVERAGE_LDFLAGS was defined # instead of CODE_COVERAGE_LIBS. They are both still defined, but use of # CODE_COVERAGE_LIBS is preferred for clarity; CODE_COVERAGE_LDFLAGS is # deprecated. They have the same value. # # This code was derived from Makefile.decl in GLib, originally licenced # under LGPLv2.1+. # # LICENSE # # Copyright (c) 2012, 2016 Philip Withnall # Copyright (c) 2012 Xan Lopez # Copyright (c) 2012 Christian Persch # Copyright (c) 2012 Paolo Borelli # Copyright (c) 2012 Dan Winship # Copyright (c) 2015 Bastien ROUCARIES # # This library is free software; you can redistribute it and/or modify it # under the terms of the GNU Lesser General Public License as published by # the Free Software Foundation; either version 2.1 of the License, or (at # your option) any later version. # # This library is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser # General Public License for more details. # # You should have received a copy of the GNU Lesser General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. #serial 25 AC_DEFUN([AX_CODE_COVERAGE],[ dnl Check for --enable-code-coverage AC_REQUIRE([AC_PROG_SED]) # allow to override gcov location AC_ARG_WITH([gcov], [AS_HELP_STRING([--with-gcov[=GCOV]], [use given GCOV for coverage (GCOV=gcov).])], [_AX_CODE_COVERAGE_GCOV_PROG_WITH=$with_gcov], [_AX_CODE_COVERAGE_GCOV_PROG_WITH=gcov]) AC_MSG_CHECKING([whether to build with code coverage support]) AC_ARG_ENABLE([code-coverage], AS_HELP_STRING([--enable-code-coverage], [Whether to enable code coverage support]),, enable_code_coverage=no) AM_CONDITIONAL([CODE_COVERAGE_ENABLED], [test x$enable_code_coverage = xyes]) AC_SUBST([CODE_COVERAGE_ENABLED], [$enable_code_coverage]) AC_MSG_RESULT($enable_code_coverage) AS_IF([ test "$enable_code_coverage" = "yes" ], [ # check for gcov AC_CHECK_TOOL([GCOV], [$_AX_CODE_COVERAGE_GCOV_PROG_WITH], [:]) AS_IF([test "X$GCOV" = "X:"], [AC_MSG_ERROR([gcov is needed to do coverage])]) AC_SUBST([GCOV]) dnl Check if gcc is being used AS_IF([ test "$GCC" = "no" ], [ AC_MSG_ERROR([not compiling with gcc, which is required for gcov code coverage]) ]) AC_CHECK_PROG([LCOV], [lcov], [lcov]) AC_CHECK_PROG([GENHTML], [genhtml], [genhtml]) AS_IF([ test -z "$LCOV" ], [ AC_MSG_ERROR([To enable code coverage reporting you must have lcov installed]) ]) AS_IF([ test -z "$GENHTML" ], [ AC_MSG_ERROR([Could not find genhtml from the lcov package]) ]) dnl Build the code coverage flags dnl Define CODE_COVERAGE_LDFLAGS for backwards compatibility CODE_COVERAGE_CPPFLAGS="-DNDEBUG" CODE_COVERAGE_CFLAGS="-O0 -g -fprofile-arcs -fprofile-update=atomic -ftest-coverage" CODE_COVERAGE_CXXFLAGS="-O0 -g -fprofile-arcs -fprofile-update=atomic -ftest-coverage" CODE_COVERAGE_LIBS="-lgcov" CODE_COVERAGE_LDFLAGS="$CODE_COVERAGE_LIBS" AC_SUBST([CODE_COVERAGE_CPPFLAGS]) AC_SUBST([CODE_COVERAGE_CFLAGS]) AC_SUBST([CODE_COVERAGE_CXXFLAGS]) AC_SUBST([CODE_COVERAGE_LIBS]) AC_SUBST([CODE_COVERAGE_LDFLAGS]) [CODE_COVERAGE_RULES_CHECK=' -$(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) -k check $(A''M_V_at)$(MAKE) $(AM_MAKEFLAGS) code-coverage-capture '] [CODE_COVERAGE_RULES_CAPTURE=' $(code_coverage_v_lcov_cap)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --capture --output-file "$(CODE_COVERAGE_OUTPUT_FILE).tmp" --test-name "$(call code_coverage_sanitize,$(PACKAGE_NAME)-$(PACKAGE_VERSION))" --no-checksum --compat-libtool $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_OPTIONS) $(code_coverage_v_lcov_ign)$(LCOV) $(code_coverage_quiet) $(addprefix --directory ,$(CODE_COVERAGE_DIRECTORY)) --ignore-errors unused --remove "$(CODE_COVERAGE_OUTPUT_FILE).tmp" "/tmp/*" $(CODE_COVERAGE_IGNORE_PATTERN) --output-file "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_LCOV_SHOPTS) $(CODE_COVERAGE_LCOV_RMOPTS) -@rm -f $(CODE_COVERAGE_OUTPUT_FILE).tmp $(code_coverage_v_genhtml)LANG=C $(GENHTML) $(code_coverage_quiet) $(addprefix --prefix ,$(CODE_COVERAGE_DIRECTORY)) --output-directory "$(CODE_COVERAGE_OUTPUT_DIRECTORY)" --title "$(PACKAGE_NAME)-$(PACKAGE_VERSION) Code Coverage" --legend --show-details "$(CODE_COVERAGE_OUTPUT_FILE)" $(CODE_COVERAGE_GENHTML_OPTIONS) @echo "file://$(abs_builddir)/$(CODE_COVERAGE_OUTPUT_DIRECTORY)/index.html" '] [CODE_COVERAGE_RULES_CLEAN=' clean: code-coverage-clean distclean: code-coverage-clean code-coverage-clean: -$(LCOV) --directory $(top_builddir) -z -rm -rf $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_FILE).tmp $(CODE_COVERAGE_OUTPUT_DIRECTORY) -find . \( -name "*.gcda" -o -name "*.gcno" -o -name "*.gcov" \) -delete '] ], [ [CODE_COVERAGE_RULES_CHECK=' @echo "Need to reconfigure with --enable-code-coverage" '] CODE_COVERAGE_RULES_CAPTURE="$CODE_COVERAGE_RULES_CHECK" CODE_COVERAGE_RULES_CLEAN='' ]) [CODE_COVERAGE_RULES=' # Code coverage # # Optional: # - CODE_COVERAGE_DIRECTORY: Top-level directory for code coverage reporting. # Multiple directories may be specified, separated by whitespace. # (Default: $(top_builddir)) # - CODE_COVERAGE_OUTPUT_FILE: Filename and path for the .info file generated # by lcov for code coverage. (Default: # $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info) # - CODE_COVERAGE_OUTPUT_DIRECTORY: Directory for generated code coverage # reports to be created. (Default: # $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage) # - CODE_COVERAGE_BRANCH_COVERAGE: Set to 1 to enforce branch coverage, # set to 0 to disable it and leave empty to stay with the default. # (Default: empty) # - CODE_COVERAGE_LCOV_SHOPTS_DEFAULT: Extra options shared between both lcov # instances. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) # - CODE_COVERAGE_LCOV_SHOPTS: Extra options to shared between both lcov # instances. (Default: $CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) # - CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH: --gcov-tool pathtogcov # - CODE_COVERAGE_LCOV_OPTIONS_DEFAULT: Extra options to pass to the # collecting lcov instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) # - CODE_COVERAGE_LCOV_OPTIONS: Extra options to pass to the collecting lcov # instance. (Default: $CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) # - CODE_COVERAGE_LCOV_RMOPTS_DEFAULT: Extra options to pass to the filtering # lcov instance. (Default: empty) # - CODE_COVERAGE_LCOV_RMOPTS: Extra options to pass to the filtering lcov # instance. (Default: $CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) # - CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT: Extra options to pass to the # genhtml instance. (Default: based on $CODE_COVERAGE_BRANCH_COVERAGE) # - CODE_COVERAGE_GENHTML_OPTIONS: Extra options to pass to the genhtml # instance. (Default: $CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) # - CODE_COVERAGE_IGNORE_PATTERN: Extra glob pattern of files to ignore # # The generated report will be titled using the $(PACKAGE_NAME) and # $(PACKAGE_VERSION). In order to add the current git hash to the title, # use the git-version-gen script, available online. # Optional variables CODE_COVERAGE_DIRECTORY ?= $(top_builddir) CODE_COVERAGE_OUTPUT_FILE ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage.info CODE_COVERAGE_OUTPUT_DIRECTORY ?= $(PACKAGE_NAME)-$(PACKAGE_VERSION)-coverage CODE_COVERAGE_BRANCH_COVERAGE ?= CODE_COVERAGE_LCOV_SHOPTS_DEFAULT ?= $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ --rc lcov_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) CODE_COVERAGE_LCOV_SHOPTS ?= $(CODE_COVERAGE_LCOV_SHOPTS_DEFAULT) CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH ?= --gcov-tool "$(GCOV)" CODE_COVERAGE_LCOV_OPTIONS_DEFAULT ?= $(CODE_COVERAGE_LCOV_OPTIONS_GCOVPATH) CODE_COVERAGE_LCOV_OPTIONS ?= $(CODE_COVERAGE_LCOV_OPTIONS_DEFAULT) CODE_COVERAGE_LCOV_RMOPTS_DEFAULT ?= CODE_COVERAGE_LCOV_RMOPTS ?= $(CODE_COVERAGE_LCOV_RMOPTS_DEFAULT) CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT ?=\ $(if $(CODE_COVERAGE_BRANCH_COVERAGE),\ --rc genhtml_branch_coverage=$(CODE_COVERAGE_BRANCH_COVERAGE)) CODE_COVERAGE_GENHTML_OPTIONS ?= $(CODE_COVERAGE_GENHTML_OPTIONS_DEFAULT) CODE_COVERAGE_IGNORE_PATTERN ?= GITIGNOREFILES ?= GITIGNOREFILES += $(CODE_COVERAGE_OUTPUT_FILE) $(CODE_COVERAGE_OUTPUT_DIRECTORY) code_coverage_v_lcov_cap = $(code_coverage_v_lcov_cap_$(V)) code_coverage_v_lcov_cap_ = $(code_coverage_v_lcov_cap_$(AM_DEFAULT_VERBOSITY)) code_coverage_v_lcov_cap_0 = @echo " LCOV --capture"\ $(CODE_COVERAGE_OUTPUT_FILE); code_coverage_v_lcov_ign = $(code_coverage_v_lcov_ign_$(V)) code_coverage_v_lcov_ign_ = $(code_coverage_v_lcov_ign_$(AM_DEFAULT_VERBOSITY)) code_coverage_v_lcov_ign_0 = @echo " LCOV --remove /tmp/*"\ $(CODE_COVERAGE_IGNORE_PATTERN); code_coverage_v_genhtml = $(code_coverage_v_genhtml_$(V)) code_coverage_v_genhtml_ = $(code_coverage_v_genhtml_$(AM_DEFAULT_VERBOSITY)) code_coverage_v_genhtml_0 = @echo " GEN " $(CODE_COVERAGE_OUTPUT_DIRECTORY); code_coverage_quiet = $(code_coverage_quiet_$(V)) code_coverage_quiet_ = $(code_coverage_quiet_$(AM_DEFAULT_VERBOSITY)) code_coverage_quiet_0 = --quiet # sanitizes the test-name: replaces with underscores: dashes and dots code_coverage_sanitize = $(subst -,_,$(subst .,_,$(1))) # Use recursive makes in order to ignore errors during check check-code-coverage:'"$CODE_COVERAGE_RULES_CHECK"' # Capture code coverage data code-coverage-capture: code-coverage-capture-hook'"$CODE_COVERAGE_RULES_CAPTURE"' # Hook rule executed before code-coverage-capture, overridable by the user code-coverage-capture-hook: '"$CODE_COVERAGE_RULES_CLEAN"' A''M_DISTCHECK_CONFIGURE_FLAGS ?= A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-code-coverage .PHONY: check-code-coverage code-coverage-capture code-coverage-capture-hook code-coverage-clean '] AC_SUBST([CODE_COVERAGE_RULES]) m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([CODE_COVERAGE_RULES])]) ])
sophomore_public/libzmq
m4/ax_code_coverage.m4
m4
gpl-3.0
11,907
# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx.html # =========================================================================== # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX(VERSION, [ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the specified # version of the C++ standard. If necessary, add switches to CXX and # CXXCPP to enable support. VERSION may be '11' (for the C++11 standard) # or '14' (for the C++14 standard). # # The second argument, if specified, indicates whether you insist on an # extended mode (e.g. -std=gnu++11) or a strict conformance mode (e.g. # -std=c++11). If neither is specified, you get whatever works, with # preference for an extended mode. # # The third argument, if specified 'mandatory' or if left unspecified, # indicates that baseline support for the specified C++ standard is # required and that the macro should error out if no mode with that # support is found. If specified 'optional', then configuration proceeds # regardless, after defining HAVE_CXX${VERSION} if and only if a # supporting mode is found. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> # Copyright (c) 2012 Zack Weinberg <zackw@panix.com> # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> # Copyright (c) 2015 Paul Norman <penorman@mac.com> # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 4 dnl This macro is based on the code from the AX_CXX_COMPILE_STDCXX_11 macro dnl (serial version number 13). AC_DEFUN([AX_CXX_COMPILE_STDCXX], [dnl m4_if([$1], [11], [], [$1], [14], [], [$1], [17], [m4_fatal([support for C++17 not yet implemented in AX_CXX_COMPILE_STDCXX])], [m4_fatal([invalid first argument `$1' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$2], [], [], [$2], [ext], [], [$2], [noext], [], [m4_fatal([invalid second argument `$2' to AX_CXX_COMPILE_STDCXX])])dnl m4_if([$3], [], [ax_cxx_compile_cxx$1_required=true], [$3], [mandatory], [ax_cxx_compile_cxx$1_required=true], [$3], [optional], [ax_cxx_compile_cxx$1_required=false], [m4_fatal([invalid third argument `$3' to AX_CXX_COMPILE_STDCXX])]) AC_LANG_PUSH([C++])dnl ac_success=no AC_CACHE_CHECK(whether $CXX supports C++$1 features by default, ax_cv_cxx_compile_cxx$1, [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [ax_cv_cxx_compile_cxx$1=yes], [ax_cv_cxx_compile_cxx$1=no])]) if test x$ax_cv_cxx_compile_cxx$1 = xyes; then ac_success=yes fi m4_if([$2], [noext], [], [dnl if test x$ac_success = xno; then for switch in -std=gnu++$1 -std=gnu++0x; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done fi]) m4_if([$2], [ext], [], [dnl if test x$ac_success = xno; then dnl HP's aCC needs +std=c++11 according to: dnl http://h21007.www2.hp.com/portal/download/files/unprot/aCxx/PDF_Release_Notes/769149-001.pdf dnl Cray's crayCC needs "-h std=c++11" for switch in -std=c++$1 -std=c++0x +std=c++$1 "-h std=c++$1"; do cachevar=AS_TR_SH([ax_cv_cxx_compile_cxx$1_$switch]) AC_CACHE_CHECK(whether $CXX supports C++$1 features with $switch, $cachevar, [ac_save_CXX="$CXX" CXX="$CXX $switch" AC_COMPILE_IFELSE([AC_LANG_SOURCE([_AX_CXX_COMPILE_STDCXX_testbody_$1])], [eval $cachevar=yes], [eval $cachevar=no]) CXX="$ac_save_CXX"]) if eval test x\$$cachevar = xyes; then CXX="$CXX $switch" if test -n "$CXXCPP" ; then CXXCPP="$CXXCPP $switch" fi ac_success=yes break fi done fi]) AC_LANG_POP([C++]) if test x$ax_cxx_compile_cxx$1_required = xtrue; then if test x$ac_success = xno; then AC_MSG_ERROR([*** A compiler with support for C++$1 language features is required.]) fi fi if test x$ac_success = xno; then HAVE_CXX$1=0 AC_MSG_NOTICE([No compiler with C++$1 support was found]) else HAVE_CXX$1=1 AC_DEFINE(HAVE_CXX$1,1, [define if the compiler supports basic C++$1 syntax]) fi AC_SUBST(HAVE_CXX$1) ]) dnl Test body for checking C++11 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_11], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 ) dnl Test body for checking C++14 support m4_define([_AX_CXX_COMPILE_STDCXX_testbody_14], _AX_CXX_COMPILE_STDCXX_testbody_new_in_11 _AX_CXX_COMPILE_STDCXX_testbody_new_in_14 ) dnl Tests for new features in C++11 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_11], [[ // If the compiler admits that it is not ready for C++11, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201103L #error "This is not a C++11 compiler" #else namespace cxx11 { namespace test_static_assert { template <typename T> struct check { static_assert(sizeof(int) <= sizeof(T), "not big enough"); }; } namespace test_final_override { struct Base { virtual void f() {} }; struct Derived : public Base { virtual void f() override {} }; } namespace test_double_right_angle_brackets { template < typename T > struct check {}; typedef check<void> single_type; typedef check<check<void>> double_type; typedef check<check<check<void>>> triple_type; typedef check<check<check<check<void>>>> quadruple_type; } namespace test_decltype { int f() { int a = 1; decltype(a) b = 2; return a + b; } } namespace test_type_deduction { template < typename T1, typename T2 > struct is_same { static const bool value = false; }; template < typename T > struct is_same<T, T> { static const bool value = true; }; template < typename T1, typename T2 > auto add(T1 a1, T2 a2) -> decltype(a1 + a2) { return a1 + a2; } int test(const int c, volatile int v) { static_assert(is_same<int, decltype(0)>::value == true, ""); static_assert(is_same<int, decltype(c)>::value == false, ""); static_assert(is_same<int, decltype(v)>::value == false, ""); auto ac = c; auto av = v; auto sumi = ac + av + 'x'; auto sumf = ac + av + 1.0; static_assert(is_same<int, decltype(ac)>::value == true, ""); static_assert(is_same<int, decltype(av)>::value == true, ""); static_assert(is_same<int, decltype(sumi)>::value == true, ""); static_assert(is_same<int, decltype(sumf)>::value == false, ""); static_assert(is_same<int, decltype(add(c, v))>::value == true, ""); return (sumf > 0.0) ? sumi : add(c, v); } } namespace test_noexcept { int f() { return 0; } int g() noexcept { return 0; } static_assert(noexcept(f()) == false, ""); static_assert(noexcept(g()) == true, ""); } namespace test_constexpr { template < typename CharT > unsigned long constexpr strlen_c_r(const CharT *const s, const unsigned long acc) noexcept { return *s ? strlen_c_r(s + 1, acc + 1) : acc; } template < typename CharT > unsigned long constexpr strlen_c(const CharT *const s) noexcept { return strlen_c_r(s, 0UL); } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("1") == 1UL, ""); static_assert(strlen_c("example") == 7UL, ""); static_assert(strlen_c("another\0example") == 7UL, ""); } namespace test_rvalue_references { template < int N > struct answer { static constexpr int value = N; }; answer<1> f(int&) { return answer<1>(); } answer<2> f(const int&) { return answer<2>(); } answer<3> f(int&&) { return answer<3>(); } void test() { int i = 0; const int c = 0; static_assert(decltype(f(i))::value == 1, ""); static_assert(decltype(f(c))::value == 2, ""); static_assert(decltype(f(0))::value == 3, ""); } } namespace test_uniform_initialization { struct test { static const int zero {}; static const int one {1}; }; static_assert(test::zero == 0, ""); static_assert(test::one == 1, ""); } namespace test_lambdas { void test1() { auto lambda1 = [](){}; auto lambda2 = lambda1; lambda1(); lambda2(); } int test2() { auto a = [](int i, int j){ return i + j; }(1, 2); auto b = []() -> int { return '0'; }(); auto c = [=](){ return a + b; }(); auto d = [&](){ return c; }(); auto e = [a, &b](int x) mutable { const auto identity = [](int y){ return y; }; for (auto i = 0; i < a; ++i) a += b--; return x + identity(a + b); }(0); return a + b + c + d + e; } int test3() { const auto nullary = [](){ return 0; }; const auto unary = [](int x){ return x; }; using nullary_t = decltype(nullary); using unary_t = decltype(unary); const auto higher1st = [](nullary_t f){ return f(); }; const auto higher2nd = [unary](nullary_t f1){ return [unary, f1](unary_t f2){ return f2(unary(f1())); }; }; return higher1st(nullary) + higher2nd(nullary)(unary); } } namespace test_variadic_templates { template <int...> struct sum; template <int N0, int... N1toN> struct sum<N0, N1toN...> { static constexpr auto value = N0 + sum<N1toN...>::value; }; template <> struct sum<> { static constexpr auto value = 0; }; static_assert(sum<>::value == 0, ""); static_assert(sum<1>::value == 1, ""); static_assert(sum<23>::value == 23, ""); static_assert(sum<1, 2>::value == 3, ""); static_assert(sum<5, 5, 11>::value == 21, ""); static_assert(sum<2, 3, 5, 7, 11, 13>::value == 41, ""); } // http://stackoverflow.com/questions/13728184/template-aliases-and-sfinae // Clang 3.1 fails with headers of libstd++ 4.8.3 when using std::function // because of this. namespace test_template_alias_sfinae { struct foo {}; template<typename T> using member = typename T::member_type; template<typename T> void func(...) {} template<typename T> void func(member<T>*) {} void test(); void test() { func<foo>(0); } } } // namespace cxx11 #endif // __cplusplus >= 201103L ]]) dnl Tests for new features in C++14 m4_define([_AX_CXX_COMPILE_STDCXX_testbody_new_in_14], [[ // If the compiler admits that it is not ready for C++14, why torture it? // Hopefully, this will speed up the test. #ifndef __cplusplus #error "This is not a C++ compiler" #elif __cplusplus < 201402L #error "This is not a C++14 compiler" #else namespace cxx14 { namespace test_polymorphic_lambdas { int test() { const auto lambda = [](auto&&... args){ const auto istiny = [](auto x){ return (sizeof(x) == 1UL) ? 1 : 0; }; const int aretiny[] = { istiny(args)... }; return aretiny[0]; }; return lambda(1, 1L, 1.0f, '1'); } } namespace test_binary_literals { constexpr auto ivii = 0b0000000000101010; static_assert(ivii == 42, "wrong value"); } namespace test_generalized_constexpr { template < typename CharT > constexpr unsigned long strlen_c(const CharT *const s) noexcept { auto length = 0UL; for (auto p = s; *p; ++p) ++length; return length; } static_assert(strlen_c("") == 0UL, ""); static_assert(strlen_c("x") == 1UL, ""); static_assert(strlen_c("test") == 4UL, ""); static_assert(strlen_c("another\0test") == 7UL, ""); } namespace test_lambda_init_capture { int test() { auto x = 0; const auto lambda1 = [a = x](int b){ return a + b; }; const auto lambda2 = [a = lambda1(x)](){ return a; }; return lambda2(); } } namespace test_digit_seperators { constexpr auto ten_million = 100'000'000; static_assert(ten_million == 100000000, ""); } namespace test_return_type_deduction { auto f(int& x) { return x; } decltype(auto) g(int& x) { return x; } template < typename T1, typename T2 > struct is_same { static constexpr auto value = false; }; template < typename T > struct is_same<T, T> { static constexpr auto value = true; }; int test() { auto x = 0; static_assert(is_same<int, decltype(f(x))>::value, ""); static_assert(is_same<int&, decltype(g(x))>::value, ""); return x; } } } // namespace cxx14 #endif // __cplusplus >= 201402L ]])
sophomore_public/libzmq
m4/ax_cxx_compile_stdcxx.m4
m4
gpl-3.0
13,824
# ============================================================================ # http://www.gnu.org/software/autoconf-archive/ax_cxx_compile_stdcxx_11.html # ============================================================================ # # SYNOPSIS # # AX_CXX_COMPILE_STDCXX_11([ext|noext], [mandatory|optional]) # # DESCRIPTION # # Check for baseline language coverage in the compiler for the C++11 # standard; if necessary, add switches to CXX and CXXCPP to enable # support. # # This macro is a convenience alias for calling the AX_CXX_COMPILE_STDCXX # macro with the version set to C++11. The two optional arguments are # forwarded literally as the second and third argument respectively. # Please see the documentation for the AX_CXX_COMPILE_STDCXX macro for # more information. If you want to use this macro, you also need to # download the ax_cxx_compile_stdcxx.m4 file. # # LICENSE # # Copyright (c) 2008 Benjamin Kosnik <bkoz@redhat.com> # Copyright (c) 2012 Zack Weinberg <zackw@panix.com> # Copyright (c) 2013 Roy Stogner <roystgnr@ices.utexas.edu> # Copyright (c) 2014, 2015 Google Inc.; contributed by Alexey Sokolov <sokolov@google.com> # Copyright (c) 2015 Paul Norman <penorman@mac.com> # Copyright (c) 2015 Moritz Klammler <moritz@klammler.eu> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 16 m4_include([m4/ax_cxx_compile_stdcxx.m4]) AC_DEFUN([AX_CXX_COMPILE_STDCXX_11], [AX_CXX_COMPILE_STDCXX([11], [$1], [$2])])
sophomore_public/libzmq
m4/ax_cxx_compile_stdcxx_11.m4
m4
gpl-3.0
1,673
# =========================================================================== # https://www.gnu.org/software/autoconf-archive/ax_func_posix_memalign.html # =========================================================================== # # SYNOPSIS # # AX_FUNC_POSIX_MEMALIGN # # DESCRIPTION # # Some versions of posix_memalign (notably glibc 2.2.5) incorrectly apply # their power-of-two check to the size argument, not the alignment # argument. AX_FUNC_POSIX_MEMALIGN defines HAVE_POSIX_MEMALIGN if the # power-of-two check is correctly applied to the alignment argument. # # LICENSE # # Copyright (c) 2008 Scott Pakin <pakin@uiuc.edu> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 AC_DEFUN([AX_FUNC_POSIX_MEMALIGN], [AC_CACHE_CHECK([for working posix_memalign], [ax_cv_func_posix_memalign_works], [AC_RUN_IFELSE([AC_LANG_SOURCE([[ #include <stdlib.h> int main () { void *buffer; /* Some versions of glibc incorrectly perform the alignment check on * the size word. */ exit (posix_memalign (&buffer, sizeof(void *), 123) != 0); } ]])], [ax_cv_func_posix_memalign_works=yes], [ax_cv_func_posix_memalign_works=no], [ax_cv_func_posix_memalign_works=no])]) if test "$ax_cv_func_posix_memalign_works" = "yes" ; then AC_DEFINE([HAVE_POSIX_MEMALIGN], [1], [Define to 1 if `posix_memalign' works.]) fi ])
sophomore_public/libzmq
m4/ax_func_posix_memalign.m4
m4
gpl-3.0
1,553
# =========================================================================== # http://www.gnu.org/software/autoconf-archive/ax_valgrind_check.html # =========================================================================== # # SYNOPSIS # # AX_VALGRIND_CHECK() # # DESCRIPTION # # Checks whether Valgrind is present and, if so, allows running `make # check` under a variety of Valgrind tools to check for memory and # threading errors. # # Defines VALGRIND_CHECK_RULES which should be substituted in your # Makefile; and $enable_valgrind which can be used in subsequent configure # output. VALGRIND_ENABLED is defined and substituted, and corresponds to # the value of the --enable-valgrind option, which defaults to being # enabled if Valgrind is installed and disabled otherwise. # # If unit tests are written using a shell script and automake's # LOG_COMPILER system, the $(VALGRIND) variable can be used within the # shell scripts to enable Valgrind, as described here: # # https://www.gnu.org/software/gnulib/manual/html_node/Running-self_002dtests-under-valgrind.html # # Usage example: # # configure.ac: # # AX_VALGRIND_CHECK # # Makefile.am: # # @VALGRIND_CHECK_RULES@ # VALGRIND_SUPPRESSIONS_FILES = my-project.supp # EXTRA_DIST = my-project.supp # # This results in a "check-valgrind" rule being added to any Makefile.am # which includes "@VALGRIND_CHECK_RULES@" (assuming the module has been # configured with --enable-valgrind). Running `make check-valgrind` in # that directory will run the module's test suite (`make check`) once for # each of the available Valgrind tools (out of memcheck, helgrind, drd and # sgcheck), and will output results to test-suite-$toolname.log for each. # The target will succeed if there are zero errors and fail otherwise. # # Alternatively, a "check-valgrind-$TOOL" rule will be added, for $TOOL in # memcheck, helgrind, drd and sgcheck. These are useful because often only # some of those tools can be ran cleanly on a codebase. # # The macro supports running with and without libtool. # # LICENSE # # Copyright (c) 2014, 2015, 2016 Philip Withnall <philip.withnall@collabora.co.uk> # # Copying and distribution of this file, with or without modification, are # permitted in any medium without royalty provided the copyright notice # and this notice are preserved. This file is offered as-is, without any # warranty. #serial 9 AC_DEFUN([AX_VALGRIND_CHECK],[ dnl Check for --enable-valgrind AC_ARG_ENABLE([valgrind], [AS_HELP_STRING([--enable-valgrind], [Whether to enable Valgrind on the unit tests])], [enable_valgrind=$enableval],[enable_valgrind=]) AS_IF([test "$enable_valgrind" != "no"],[ # Check for Valgrind. AC_CHECK_PROG([VALGRIND],[valgrind],[valgrind]) AS_IF([test "$VALGRIND" = ""],[ AS_IF([test "$enable_valgrind" = "yes"],[ AC_MSG_ERROR([Could not find valgrind; either install it or reconfigure with --disable-valgrind]) ],[ enable_valgrind=no ]) ],[ enable_valgrind=yes ]) ]) AM_CONDITIONAL([VALGRIND_ENABLED],[test "$enable_valgrind" = "yes"]) AC_SUBST([VALGRIND_ENABLED],[$enable_valgrind]) # Check for Valgrind tools we care about. m4_define([valgrind_tool_list],[[memcheck], [helgrind], [drd], [exp-sgcheck]]) AS_IF([test "$VALGRIND" != ""],[ m4_foreach([vgtool],[valgrind_tool_list],[ m4_define([vgtooln],AS_TR_SH(vgtool)) m4_define([ax_cv_var],[ax_cv_valgrind_tool_]vgtooln) AC_CACHE_CHECK([for Valgrind tool ]vgtool,ax_cv_var,[ ax_cv_var= AS_IF([`$VALGRIND --tool=vgtool --help >/dev/null 2>&1`],[ ax_cv_var="vgtool" ]) ]) AC_SUBST([VALGRIND_HAVE_TOOL_]vgtooln,[$ax_cv_var]) ]) ]) [VALGRIND_CHECK_RULES=' # Valgrind check # # Optional: # - VALGRIND_SUPPRESSIONS_FILES: Space-separated list of Valgrind suppressions # files to load. (Default: empty) # - VALGRIND_FLAGS: General flags to pass to all Valgrind tools. # (Default: --num-callers=30) # - VALGRIND_$toolname_FLAGS: Flags to pass to Valgrind $toolname (one of: # memcheck, helgrind, drd, sgcheck). (Default: various) # Optional variables VALGRIND_SUPPRESSIONS ?= $(addprefix --suppressions=,$(VALGRIND_SUPPRESSIONS_FILES)) VALGRIND_FLAGS ?= --num-callers=30 VALGRIND_memcheck_FLAGS ?= --leak-check=full --show-reachable=no VALGRIND_helgrind_FLAGS ?= --history-level=approx VALGRIND_drd_FLAGS ?= VALGRIND_sgcheck_FLAGS ?= # Internal use valgrind_tools = memcheck helgrind drd sgcheck valgrind_log_files = $(addprefix test-suite-,$(addsuffix .log,$(valgrind_tools))) valgrind_memcheck_flags = --tool=memcheck $(VALGRIND_memcheck_FLAGS) valgrind_helgrind_flags = --tool=helgrind $(VALGRIND_helgrind_FLAGS) valgrind_drd_flags = --tool=drd $(VALGRIND_drd_FLAGS) valgrind_sgcheck_flags = --tool=exp-sgcheck $(VALGRIND_sgcheck_FLAGS) valgrind_quiet = $(valgrind_quiet_$(V)) valgrind_quiet_ = $(valgrind_quiet_$(AM_DEFAULT_VERBOSITY)) valgrind_quiet_0 = --quiet # Support running with and without libtool. ifneq ($(LIBTOOL),) valgrind_lt = $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=execute else valgrind_lt = endif # Use recursive makes in order to ignore errors during check check-valgrind: ifeq ($(VALGRIND_ENABLED),yes) -$(foreach tool,$(valgrind_tools), \ $(if $(VALGRIND_HAVE_TOOL_$(tool))$(VALGRIND_HAVE_TOOL_exp_$(tool)), \ $(MAKE) $(AM_MAKEFLAGS) -k check-valgrind-tool VALGRIND_TOOL=$(tool); \ ) \ ) else @echo "Need to reconfigure with --enable-valgrind" endif # Valgrind running VALGRIND_TESTS_ENVIRONMENT = \ $(TESTS_ENVIRONMENT) \ env VALGRIND=$(VALGRIND) \ G_SLICE=always-malloc,debug-blocks \ G_DEBUG=fatal-warnings,fatal-criticals,gc-friendly VALGRIND_LOG_COMPILER = \ $(valgrind_lt) \ $(VALGRIND) $(VALGRIND_SUPPRESSIONS) --error-exitcode=1 $(VALGRIND_FLAGS) check-valgrind-tool: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_$(VALGRIND_TOOL)_flags)" \ TEST_SUITE_LOG=test-suite-$(VALGRIND_TOOL).log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-memcheck: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_memcheck_flags)" \ TEST_SUITE_LOG=test-suite-memcheck.log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-helgrind: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_helgrind_flags)" \ TEST_SUITE_LOG=test-suite-helgrind.log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-drd: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_drd_flags)" \ TEST_SUITE_LOG=test-suite-drd.log else @echo "Need to reconfigure with --enable-valgrind" endif check-valgrind-sgcheck: ifeq ($(VALGRIND_ENABLED),yes) $(MAKE) check-TESTS \ TESTS_ENVIRONMENT="$(VALGRIND_TESTS_ENVIRONMENT)" \ LOG_COMPILER="$(VALGRIND_LOG_COMPILER)" \ LOG_FLAGS="$(valgrind_sgcheck_flags)" \ TEST_SUITE_LOG=test-suite-sgcheck.log else @echo "Need to reconfigure with --enable-valgrind" endif A''M_DISTCHECK_CONFIGURE_FLAGS ?= A''M_DISTCHECK_CONFIGURE_FLAGS += --disable-valgrind MOSTLYCLEANFILES ?= MOSTLYCLEANFILES += $(valgrind_log_files) .PHONY: check-valgrind check-valgrind-tool '] AC_SUBST([VALGRIND_CHECK_RULES]) m4_ifdef([_AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE([VALGRIND_CHECK_RULES])]) ])
sophomore_public/libzmq
m4/ax_valgrind_check.m4
m4
gpl-3.0
7,777
This directory is for packaging tools. Please do not hardcode version numbers into your scripts; you can get them at runtime by calling version.sh, or at configure time if you use autoconf.
sophomore_public/libzmq
packaging/README
none
gpl-3.0
191
zeromq (4.3.6-0.1) UNRELEASED; urgency=low * Initial packaging. -- libzmq Developers <zeromq-dev@lists.zeromq.org> Wed, 31 Dec 2014 00:00:00 +0000
sophomore_public/libzmq
packaging/debian/changelog
none
gpl-3.0
153
9
sophomore_public/libzmq
packaging/debian/compat
none
gpl-3.0
2
Source: zeromq Section: libs Priority: optional Maintainer: libzmq Developers <zeromq-dev@lists.zeromq.org> Build-Depends: debhelper (>= 9), dh-autoreconf, libkrb5-dev, libnorm-dev, libpgm-dev, libsodium-dev, libunwind-dev | libunwind8-dev | libunwind7-dev, libnss3-dev, libgnutls28-dev | libgnutls-dev, libbsd-dev, pkg-config, asciidoctor, Standards-Version: 3.9.8 Homepage: http://www.zeromq.org/ Package: libzmq5 Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Pre-Depends: ${misc:Pre-Depends} Multi-Arch: same Description: lightweight messaging kernel (shared library) ØMQ is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products. . ØMQ sockets provide an abstraction of asynchronous message queues, multiple messaging patterns, message filtering (subscriptions), seamless access to multiple transport protocols and more. . This package contains the libzmq shared library. Package: libzmq3-dev Architecture: any Section: libdevel Depends: libzmq5 (= ${binary:Version}), ${misc:Depends}, libkrb5-dev, libnorm-dev, libpgm-dev, libsodium-dev, libunwind-dev | libunwind8-dev | libunwind7-dev, libnss3-dev, libgnutls28-dev | libgnutls-dev, libbsd-dev, Conflicts: libzmq-dev, libzmq5-dev Replaces: libzmq5-dev Provides: libzmq5-dev Multi-Arch: same Description: lightweight messaging kernel (development files) ØMQ is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products. . ØMQ sockets provide an abstraction of asynchronous message queues, multiple messaging patterns, message filtering (subscriptions), seamless access to multiple transport protocols and more. . This package contains the ZeroMQ development libraries and header files. Package: libzmq5-dbg Architecture: any Priority: extra Section: debug Depends: libzmq5 (= ${binary:Version}), ${misc:Depends} Multi-Arch: same Description: lightweight messaging kernel (debugging symbols) ØMQ is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products. . ØMQ sockets provide an abstraction of asynchronous message queues, multiple messaging patterns, message filtering (subscriptions), seamless access to multiple transport protocols and more. . This package contains the debugging symbols for the ZeroMQ library.
sophomore_public/libzmq
packaging/debian/control
none
gpl-3.0
2,480
Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ Upstream-Name: ZeroMQ Source: http://zeromq.org Files: * Copyright: 2009-2011, 250bpm s.r.o 2007-2013, iMatix Corporation 2010-2011, Miru Limited 2011, VMware, Inc 2007-2023, Other contributors as noted in the AUTHORS file License: MPL-2.0 Files: external/unity/* Copyright: 2007-2014 Mike Karlesky 2007-2014 Mark VanderVoord 2007-2014 Greg Williams License: MIT 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. Files: debian/* Copyright: 2014- , Laszlo Boszormenyi (GCS) <gcs@debian.org> 2012-2014, Alessandro Ghedini <ghedo@debian.org> 2010-2012, Martin Lucina <martin@lucina.net> 2009-2010, Adrian von Bidder <cmot@debian.org> 2009-2010, Peter Busser <peter@mirabilix.nl> 2012, Alessandro Ghedini <ghedo@debian.org> License: LGPL-2.0+ License: LGPL-2.0+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. . This package is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. . You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. . On Debian systems, the complete text of the GNU Lesser General Public License can be found in "/usr/share/common-licenses/LGPL-2". License: MPL-2.0 On Debian systems the full text of the MPL-2.0 can be found in /usr/share/common-licenses/MPL-2.0.
sophomore_public/libzmq
packaging/debian/copyright
none
gpl-3.0
2,757
usr/include/* usr/lib/*/libzmq.a usr/lib/*/libzmq.so usr/lib/*/pkgconfig/libzmq.pc
sophomore_public/libzmq
packaging/debian/libzmq3-dev.install
install
gpl-3.0
83
debian/tmp/usr/share/man/man3/* debian/tmp/usr/share/man/man7/*
sophomore_public/libzmq
packaging/debian/libzmq3-dev.manpages
manpages
gpl-3.0
64
AUTHORS NEWS
sophomore_public/libzmq
packaging/debian/libzmq5.docs
docs
gpl-3.0
13
usr/lib/*/libzmq.so.*
sophomore_public/libzmq
packaging/debian/libzmq5.install
install
gpl-3.0
22
#!/usr/bin/make -f # -*- makefile -*- # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 export DEB_BUILD_MAINT_OPTIONS=hardening=+all export TEST_VERBOSE=1 ifeq ($(DEB_BUILD_ARCH_OS), kfreebsd) DO_TEST = no endif DRAFTS=no # OBS build: add # Macros: # %_with_drafts 1 # at the BOTTOM of the OBS prjconf OBS_BUILD_CFG=/.build/build.dist ifeq ("$(wildcard $(OBS_BUILD_CFG))","") BUILDCONFIG=$(shell ls -1 /usr/src/packages/SOURCES/_buildconfig* | head -n 1) endif ifneq ("$(wildcard $(OBS_BUILD_CFG))","") ifneq ("$(shell grep drafts $(OBS_BUILD_CFG))","") DRAFTS=yes endif endif # User build: DEB_BUILD_OPTIONS=drafts dpkg-buildpackage ifneq (,$(findstring drafts,$(DEB_BUILD_OPTIONS))) DRAFTS=yes endif # Workaround for automake < 1.14 bug $(shell dpkg --compare-versions `dpkg-query -W -f='$${Version}\n' automake` lt 1:1.14 && mkdir -p config) override_dh_clean: dh_clean find $(CURDIR) -type s -exec rm {} \; rm -f $(CURDIR)/doc/*.xml $(CURDIR)/doc/*.3 $(CURDIR)/doc/*.7 rm -f config.log override_dh_auto_configure: dh_auto_configure -- --with-pgm --with-libsodium --enable-drafts=$(DRAFTS) --with-libgssapi_krb5=yes --with-norm=yes --with-nss=yes --with-tls=yes override_dh_auto_test: ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) ifneq ($(DO_TEST), no) dh_auto_test -- VERBOSE=1 else -dh_auto_test -- VERBOSE=1 endif endif override_dh_auto_install: dh_auto_install ifneq ("$(wildcard debian/zmq.hpp)","") cp $(CURDIR)/debian/zmq.hpp $(CURDIR)/debian/tmp/usr/include/ endif override_dh_strip: dh_strip --dbg-package=libzmq5-dbg %: dh $@ --with=autoreconf --parallel .PHONY: override_dh_auto_configure override_dh_strip
sophomore_public/libzmq
packaging/debian/rules
none
gpl-3.0
1,668
3.0 (quilt)
sophomore_public/libzmq
packaging/debian/source/format
none
gpl-3.0
12
Format: 3.0 (quilt) Source: zeromq Binary: libzmq5, libzmq3-dev, libzmq5-dbg Architecture: any Version: 4.3.6-0.1 Maintainer: libzmq Developers <zeromq-dev@lists.zeromq.org> Homepage: http://www.zeromq.org/ Standards-Version: 3.9.8 Build-Depends: debhelper (>= 9), dh-autoreconf, libkrb5-dev, libpgm-dev, libnorm-dev, libsodium-dev, libunwind-dev | libunwind8-dev | libunwind7-dev, libnss3-dev, libgnutls28-dev | libgnutls-dev, libbsd-dev, pkg-config, asciidoctor Package-List: libzmq3-dev deb libdevel optional arch=any libzmq5 deb libs optional arch=any libzmq5-dbg deb debug extra arch=any Files: e7adf4b7dbae09b28cfd10d26cd67fac 794853 zeromq.orig.tar.gz
sophomore_public/libzmq
packaging/debian/zeromq.dsc
dsc
gpl-3.0
663
@ECHO OFF ECHO Started nuget packaging build. ECHO. REM http://www.nuget.org/packages/gsl gsl -q -script:package.gsl package.config ECHO. REM http://nuget.codeplex.com/releases nuget pack package.nuspec -verbosity detailed ECHO. ECHO NOTE: Ignore warnings not applicable to native code: "Issue: Assembly outside lib folder." ECHO. ECHO Completed nuget packaging build. The package is in the following folder: CD PAUSE
sophomore_public/libzmq
packaging/nuget/package.bat
Batchfile
gpl-3.0
417
<?xml version="1.0" encoding="utf-8"?> <!-- These values are populated into the package.gsl templates by package.bat. --> <!-- The target attribute controls path and file name only, id controls package naming. --> <package id="libzmq-vc142" target="libzmq" version = "4.2.3.0" pathversion="4_2_3_0" platformtoolset="v142"> <!--<dependency id="libsodium_vc120" version="1.0.12.0" />--> </package>
sophomore_public/libzmq
packaging/nuget/package.config
INI
gpl-3.0
397
.# Generate NuGet nuspec file (for subsequent packing). .# .# This is a code generator built using the iMatix GSL code generation .# language. See https://github.com/zeromq/gsl for details. This script .# is licensed under MIT/X11. .# .echo "Generating package.nuspec from template." .output "package.nuspec" <?xml version="1.0" encoding="utf-8"?> <!-- ################################################################# # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ################################################################# --> <package xmlns="http://schemas.microsoft.com/packaging/2013/01/nuspec.xsd"> <metadata minClientVersion="2.5"> <id>$(package.id)</id> <version>$(package.version)</version> <title>$(package.id)</title> <authors>libzmq contributors</authors> <owners>Eric Voskuil</owners> <licenseUrl>https://raw.github.com/zeromq/libzmq/master/LICENSE</licenseUrl> <projectUrl>https://github.com/zeromq/libzmq</projectUrl> <iconUrl>https://avatars1.githubusercontent.com/u/109777?s=32</iconUrl> <requireLicenseAcceptance>true</requireLicenseAcceptance> <developmentDependency>false</developmentDependency> <description>The 0MQ lightweight messaging kernel is a library which extends the standard socket interfaces with features traditionally provided by specialised messaging middleware products. 0MQ sockets provide an abstraction of asynchronous message queues, multiple messaging patterns, message filtering (subscriptions), seamless access to multiple transport protocols and more.</description> <summary>The 0MQ lightweight messaging kernel, packaged for specific Visual Studio compiler.</summary> <releaseNotes>https://raw.github.com/zeromq/libzmq/master/NEWS</releaseNotes> <copyright>MPL-2.0</copyright> <tags>native, libzmq, zmq, 0MQ, messaging, sockets, C++</tags> <dependencies> .for dependency <dependency id="$(id)" version="$(version)" /> .endfor </dependencies> </metadata> <files> <!-- include --> <file src="..\\..\\include\\*.h" target="build\\native\\include" /> <file src="..\\..\\builds\\msvc\\platform.hpp" target="build\\native\\include" /> <!-- targets --> <file src="package.targets" target="build\\native\\$(package.id).targets" /> <file src="package.xml" target="build\\native\\package.xml" /> <!-- docs --> <!-- Documents (.*) --> <!--<file src="..\\..\\docs\\*" target="build\\native\\docs" />--> <!-- libraries --> <!-- x86 Dynamic libraries (.dll) --> <file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).dll" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).dll" /> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).dll" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).dll" /> <!-- x86 Debugging symbols (.pdb) --> <!--<file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).pdb" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).pdb" />--> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).pdb" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).pdb" /> <!-- x86 Import libraries (.imp.lib) --> <file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).imp.lib" /> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).imp.lib" /> <!-- x86 Export libraries (.exp) --> <file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).exp" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).exp" /> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).exp" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).exp" /> <!-- x86 Static libraries (.lib) --> <file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\static\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-s-$(package.pathversion).lib" /> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\static\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-sgd-$(package.pathversion).lib" /> <!-- x86 Static link time code generation libraries (.ltcg.lib) --> <file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\ltcg\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-s-$(package.pathversion).ltcg.lib" /> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\ltcg\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x86-$(package.platformtoolset)-mt-sgd-$(package.pathversion).ltcg.lib" /> <!-- x64 Dynamic libraries (.dll) --> <file src="..\\..\\bin\\x64\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).dll" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).dll" /> <file src="..\\..\\bin\\x64\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).dll" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).dll" /> <!-- x64 Debugging symbols (.pdb) --> <!--<file src="..\\..\\bin\\x64\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).pdb" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).pdb" />--> <file src="..\\..\\bin\\x64\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).pdb" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).pdb" /> <!-- x64 Import libraries (.imp.lib) --> <file src="..\\..\\bin\\x64\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).imp.lib" /> <file src="..\\..\\bin\\x64\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).imp.lib" /> <!-- x64 Export libraries (.exp) --> <file src="..\\..\\bin\\x64\\Release\\$(package.platformtoolset)\\dynamic\\$(package.target).exp" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).exp" /> <file src="..\\..\\bin\\x64\\Debug\\$(package.platformtoolset)\\dynamic\\$(package.target).exp" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).exp" /> <!-- x64 Static libraries (.lib) --> <file src="..\\..\\bin\\x64\\Release\\$(package.platformtoolset)\\static\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-s-$(package.pathversion).lib" /> <file src="..\\..\\bin\\x64\\Debug\\$(package.platformtoolset)\\static\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-sgd-$(package.pathversion).lib" /> <!-- x64 Static link time code generation libraries (.ltcg.lib) --> <file src="..\\..\\bin\\Win32\\Release\\$(package.platformtoolset)\\ltcg\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-s-$(package.pathversion).ltcg.lib" /> <file src="..\\..\\bin\\Win32\\Debug\\$(package.platformtoolset)\\ltcg\\$(package.target).lib" target="build\\native\\bin\\$(package.target)-x64-$(package.platformtoolset)-mt-sgd-$(package.pathversion).ltcg.lib" /> </files> <!-- ################################################################# # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ################################################################# --> </package> .echo "Generating package.targets from template." .output "package.targets" <?xml version="1.0" encoding="utf-8"?> <!-- ################################################################# # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ################################################################# --> <Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <!-- user interface --> <ItemGroup> <PropertyPageSchema Include="$\(MSBuildThisFileDirectory)package.xml" /> </ItemGroup> <!-- general --> <ItemDefinitionGroup> <ClCompile> <AdditionalIncludeDirectories>$\(MSBuildThisFileDirectory)include\\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> </ClCompile> <Link> <AdditionalLibraryDirectories>$\(MSBuildThisFileDirectory)bin\\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Linkage-$(package.target))' == 'static' Or '$\(Linkage-$(package.target))' == 'ltcg'"> <ClCompile> <PreprocessorDefinitions>ZMQ_STATIC;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> </ItemDefinitionGroup> <!-- static libraries --> <ItemDefinitionGroup Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'static' And $\(Configuration.IndexOf('Release')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x86-$(package.platformtoolset)-mt-s-$(package.pathversion).lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'static' And $\(Configuration.IndexOf('Debug')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x86-$(package.platformtoolset)-mt-sgd-$(package.pathversion).lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'static' And $\(Configuration.IndexOf('Release')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x64-$(package.platformtoolset)-mt-s-$(package.pathversion).lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'static' And $\(Configuration.IndexOf('Debug')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x64-$(package.platformtoolset)-mt-sgd-$(package.pathversion).lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <!-- static ltcg libraries --> <ItemDefinitionGroup Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'ltcg' And $\(Configuration.IndexOf('Release')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x86-$(package.platformtoolset)-mt-s-$(package.pathversion).ltcg.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'ltcg' And $\(Configuration.IndexOf('Debug')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x86-$(package.platformtoolset)-mt-sgd-$(package.pathversion).ltcg.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'ltcg' And $\(Configuration.IndexOf('Release')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x64-$(package.platformtoolset)-mt-s-$(package.pathversion).ltcg.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'ltcg' And $\(Configuration.IndexOf('Debug')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x64-$(package.platformtoolset)-mt-sgd-$(package.pathversion).ltcg.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <!-- dynamic import libraries --> <ItemDefinitionGroup Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Release')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).imp.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Debug')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).imp.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Release')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).imp.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Debug')) != -1"> <Link> <AdditionalDependencies>$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).imp.lib;%(AdditionalDependencies)</AdditionalDependencies> </Link> </ItemDefinitionGroup> <!-- dynamic libraries with debug symbols --> <Target Name="$(package.target)_AfterBuild" AfterTargets="AfterBuild" /> <Target Name="$(package.target)_AfterBuild_Win32_$(package.platformtoolset)_Dynamic_Release" Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Release')) != -1" AfterTargets="$(package.target)_AfterBuild"> <Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).dll" DestinationFiles="$\(TargetDir)$(package.target).dll" SkipUnchangedFiles="true" /> <!--<Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x86-$(package.platformtoolset)-mt-$(package.pathversion).pdb" DestinationFiles="$\(TargetDir)$(package.target).pdb" SkipUnchangedFiles="true" />--> </Target> <Target Name="$(package.target)_AfterBuild_Win32_$(package.platformtoolset)_Dynamic_Debug" Condition="'$\(Platform)' == 'Win32' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Debug')) != -1" AfterTargets="$(package.target)_AfterBuild"> <Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).dll" DestinationFiles="$\(TargetDir)$(package.target).dll" SkipUnchangedFiles="true" /> <Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x86-$(package.platformtoolset)-mt-gd-$(package.pathversion).pdb" DestinationFiles="$\(TargetDir)$(package.target).pdb" SkipUnchangedFiles="true" /> </Target> <Target Name="$(package.target)_AfterBuild_x64_$(package.platformtoolset)_Dynamic_Release" Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Release')) != -1" AfterTargets="$(package.target)_AfterBuild"> <Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).dll" DestinationFiles="$\(TargetDir)$(package.target).dll" SkipUnchangedFiles="true" /> <!--<Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x64-$(package.platformtoolset)-mt-$(package.pathversion).pdb" DestinationFiles="$\(TargetDir)$(package.target).pdb" SkipUnchangedFiles="true" />--> </Target> <Target Name="$(package.target)_AfterBuild_x64_$(package.platformtoolset)_Dynamic_Debug" Condition="'$\(Platform)' == 'x64' And ('$\(PlatformToolset)' == '$(package.platformtoolset)' Or '$\(PlatformToolset)' == 'CTP_Nov2013') And '$\(Linkage-$(package.target))' == 'dynamic' And $\(Configuration.IndexOf('Debug')) != -1" AfterTargets="$(package.target)_AfterBuild"> <Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).dll" DestinationFiles="$\(TargetDir)$(package.target).dll" SkipUnchangedFiles="true" /> <Copy SourceFiles="$\(MSBuildThisFileDirectory)bin\\$(package.target)-x64-$(package.platformtoolset)-mt-gd-$(package.pathversion).pdb" DestinationFiles="$\(TargetDir)$(package.target).pdb" SkipUnchangedFiles="true" /> </Target> <!-- ################################################################# # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ################################################################# --> </Project> .echo "Generating package.xml (ui extension) from template." .output "package.xml" <?xml version="1.0" encoding="utf-8"?> <!-- ################################################################# # GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # ################################################################# --> <ProjectSchemaDefinitions xmlns="clr-namespace:Microsoft.Build.Framework.XamlTypes;assembly=Microsoft.Build.Framework"> <Rule Name="Linkage-$(package.target)-uiextension" PageTemplate="tool" DisplayName="NuGet Dependencies" SwitchPrefix="/" Order="1"> <Rule.Categories> <Category Name="$(package.target)" DisplayName="$(package.target)" /> </Rule.Categories> <Rule.DataSource> <DataSource Persistence="ProjectFile" ItemType="" /> </Rule.DataSource> <EnumProperty Name="Linkage-$(package.target)" DisplayName="Linkage" Description="How NuGet $(package.target) will be linked into the output of this project" Category="$(package.target)"> <EnumValue Name="" DisplayName="Not linked" /> <EnumValue Name="dynamic" DisplayName="Dynamic (DLL)" /> <EnumValue Name="static" DisplayName="Static (LIB)" /> <EnumValue Name="ltcg" DisplayName="Static using link time compile generation (LTCG)" /> </EnumProperty> </Rule> </ProjectSchemaDefinitions>
sophomore_public/libzmq
packaging/nuget/package.gsl
gsl
gpl-3.0
20,848