mirror of
https://github.com/zeromq/libzmq.git
synced 2025-03-09 15:26:04 +00:00
Fixes warning when compiling with MSVC on Win64
Signed-off-by: Martin Sustrik <sustrik@250bpm.com>
This commit is contained in:
parent
49387874ef
commit
49df2f416c
@ -99,7 +99,7 @@ namespace zmq
|
|||||||
inline void push_back (T *item_)
|
inline void push_back (T *item_)
|
||||||
{
|
{
|
||||||
if (item_)
|
if (item_)
|
||||||
item_->set_array_index (items.size ());
|
item_->set_array_index ((int) items.size ());
|
||||||
items.push_back (item_);
|
items.push_back (item_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +109,7 @@ namespace zmq
|
|||||||
|
|
||||||
inline void erase (size_type index_) {
|
inline void erase (size_type index_) {
|
||||||
if (items.back ())
|
if (items.back ())
|
||||||
items.back ()->set_array_index (index_);
|
items.back ()->set_array_index ((int) index_);
|
||||||
items [index_] = items.back ();
|
items [index_] = items.back ();
|
||||||
items.pop_back ();
|
items.pop_back ();
|
||||||
}
|
}
|
||||||
@ -117,9 +117,9 @@ namespace zmq
|
|||||||
inline void swap (size_type index1_, size_type index2_)
|
inline void swap (size_type index1_, size_type index2_)
|
||||||
{
|
{
|
||||||
if (items [index1_])
|
if (items [index1_])
|
||||||
items [index1_]->set_array_index (index2_);
|
items [index1_]->set_array_index ((int) index2_);
|
||||||
if (items [index2_])
|
if (items [index2_])
|
||||||
items [index2_]->set_array_index (index1_);
|
items [index2_]->set_array_index ((int) index1_);
|
||||||
std::swap (items [index1_], items [index2_]);
|
std::swap (items [index1_], items [index2_]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -69,7 +69,7 @@ void zmq::dist_t::terminate ()
|
|||||||
zmq_assert (!terminating);
|
zmq_assert (!terminating);
|
||||||
terminating = true;
|
terminating = true;
|
||||||
|
|
||||||
sink->register_term_acks (pipes.size ());
|
sink->register_term_acks ((int) pipes.size ());
|
||||||
for (pipes_t::size_type i = 0; i != pipes.size (); i++)
|
for (pipes_t::size_type i = 0; i != pipes.size (); i++)
|
||||||
pipes [i]->terminate ();
|
pipes [i]->terminate ();
|
||||||
}
|
}
|
||||||
|
@ -86,7 +86,7 @@ namespace zmq
|
|||||||
// first-message-offset.
|
// first-message-offset.
|
||||||
if (beginning) {
|
if (beginning) {
|
||||||
if (offset_ && *offset_ == -1)
|
if (offset_ && *offset_ == -1)
|
||||||
*offset_ = pos;
|
*offset_ = (int) pos;
|
||||||
beginning = false;
|
beginning = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -190,7 +190,7 @@ void zmq::win_error (char *buffer_, size_t buffer_size_)
|
|||||||
DWORD errcode = GetLastError ();
|
DWORD errcode = GetLastError ();
|
||||||
DWORD rc = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
|
DWORD rc = FormatMessageA (FORMAT_MESSAGE_FROM_SYSTEM |
|
||||||
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL,
|
FORMAT_MESSAGE_IGNORE_INSERTS, NULL, errcode, MAKELANGID(LANG_NEUTRAL,
|
||||||
SUBLANG_DEFAULT), buffer_, buffer_size_, NULL );
|
SUBLANG_DEFAULT), buffer_, (DWORD) buffer_size_, NULL );
|
||||||
zmq_assert (rc);
|
zmq_assert (rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -81,7 +81,7 @@ void zmq::fq_t::terminate ()
|
|||||||
zmq_assert (!terminating);
|
zmq_assert (!terminating);
|
||||||
terminating = true;
|
terminating = true;
|
||||||
|
|
||||||
sink->register_term_acks (pipes.size ());
|
sink->register_term_acks ((int) pipes.size ());
|
||||||
for (pipes_t::size_type i = 0; i != pipes.size (); i++)
|
for (pipes_t::size_type i = 0; i != pipes.size (); i++)
|
||||||
pipes [i]->terminate ();
|
pipes [i]->terminate ();
|
||||||
}
|
}
|
||||||
@ -100,7 +100,7 @@ int zmq::fq_t::recv (msg_t *msg_, int flags_)
|
|||||||
errno_assert (rc == 0);
|
errno_assert (rc == 0);
|
||||||
|
|
||||||
// Round-robin over the pipes to get the next message.
|
// Round-robin over the pipes to get the next message.
|
||||||
for (int count = active; count != 0; count--) {
|
for (pipes_t::size_type count = active; count != 0; count--) {
|
||||||
|
|
||||||
// Try to fetch new message. If we've already read part of the message
|
// Try to fetch new message. If we've already read part of the message
|
||||||
// subsequent part should be immediately available.
|
// subsequent part should be immediately available.
|
||||||
@ -149,7 +149,7 @@ bool zmq::fq_t::has_in ()
|
|||||||
// queueing algorithm. If there are no messages available current will
|
// queueing algorithm. If there are no messages available current will
|
||||||
// get back to its original value. Otherwise it'll point to the first
|
// get back to its original value. Otherwise it'll point to the first
|
||||||
// pipe holding messages, skipping only pipes with no messages available.
|
// pipe holding messages, skipping only pipes with no messages available.
|
||||||
for (int count = active; count != 0; count--) {
|
for (pipes_t::size_type count = active; count != 0; count--) {
|
||||||
if (pipes [current]->check_read ())
|
if (pipes [current]->check_read ())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
10
src/ip.cpp
10
src/ip.cpp
@ -200,7 +200,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_,
|
|||||||
|
|
||||||
// Initialize temporary output pointers with ip4_addr
|
// Initialize temporary output pointers with ip4_addr
|
||||||
sockaddr *out_addr = (sockaddr *) &ip4_addr;
|
sockaddr *out_addr = (sockaddr *) &ip4_addr;
|
||||||
size_t out_addrlen = sizeof (ip4_addr);
|
socklen_t out_addrlen = (socklen_t) sizeof (ip4_addr);
|
||||||
|
|
||||||
// 0 is not a valid port.
|
// 0 is not a valid port.
|
||||||
if (!ip4_addr.sin_port) {
|
if (!ip4_addr.sin_port) {
|
||||||
@ -211,7 +211,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_,
|
|||||||
// * resolves to INADDR_ANY.
|
// * resolves to INADDR_ANY.
|
||||||
if (iface.compare("*") == 0) {
|
if (iface.compare("*") == 0) {
|
||||||
ip4_addr.sin_addr.s_addr = htonl (INADDR_ANY);
|
ip4_addr.sin_addr.s_addr = htonl (INADDR_ANY);
|
||||||
zmq_assert (out_addrlen <= sizeof (*addr_));
|
zmq_assert (out_addrlen <= (socklen_t) sizeof (*addr_));
|
||||||
memcpy (addr_, out_addr, out_addrlen);
|
memcpy (addr_, out_addr, out_addrlen);
|
||||||
*addr_len_ = out_addrlen;
|
*addr_len_ = out_addrlen;
|
||||||
return 0;
|
return 0;
|
||||||
@ -222,7 +222,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_,
|
|||||||
if (rc != 0 && errno != ENODEV)
|
if (rc != 0 && errno != ENODEV)
|
||||||
return rc;
|
return rc;
|
||||||
if (rc == 0) {
|
if (rc == 0) {
|
||||||
zmq_assert (out_addrlen <= sizeof (*addr_));
|
zmq_assert (out_addrlen <= (socklen_t) sizeof (*addr_));
|
||||||
memcpy (addr_, out_addr, out_addrlen);
|
memcpy (addr_, out_addr, out_addrlen);
|
||||||
*addr_len_ = out_addrlen;
|
*addr_len_ = out_addrlen;
|
||||||
return 0;
|
return 0;
|
||||||
@ -259,7 +259,7 @@ int zmq::resolve_ip_interface (sockaddr_storage* addr_, socklen_t *addr_len_,
|
|||||||
// Use the first result.
|
// Use the first result.
|
||||||
zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_));
|
zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_));
|
||||||
memcpy (addr_, res->ai_addr, res->ai_addrlen);
|
memcpy (addr_, res->ai_addr, res->ai_addrlen);
|
||||||
*addr_len_ = res->ai_addrlen;
|
*addr_len_ = (socklen_t) res->ai_addrlen;
|
||||||
|
|
||||||
// Cleanup getaddrinfo after copying the possibly referenced result.
|
// Cleanup getaddrinfo after copying the possibly referenced result.
|
||||||
if (res)
|
if (res)
|
||||||
@ -308,7 +308,7 @@ int zmq::resolve_ip_hostname (sockaddr_storage *addr_, socklen_t *addr_len_,
|
|||||||
// Copy first result to output addr with hostname and service.
|
// Copy first result to output addr with hostname and service.
|
||||||
zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_));
|
zmq_assert ((size_t) (res->ai_addrlen) <= sizeof (*addr_));
|
||||||
memcpy (addr_, res->ai_addr, res->ai_addrlen);
|
memcpy (addr_, res->ai_addr, res->ai_addrlen);
|
||||||
*addr_len_ = res->ai_addrlen;
|
*addr_len_ = (socklen_t) res->ai_addrlen;
|
||||||
|
|
||||||
freeaddrinfo (res);
|
freeaddrinfo (res);
|
||||||
|
|
||||||
|
@ -58,7 +58,7 @@ void zmq::lb_t::terminate ()
|
|||||||
zmq_assert (!terminating);
|
zmq_assert (!terminating);
|
||||||
terminating = true;
|
terminating = true;
|
||||||
|
|
||||||
sink->register_term_acks (pipes.size ());
|
sink->register_term_acks ((int) pipes.size ());
|
||||||
for (pipes_t::size_type i = 0; i != pipes.size (); i++)
|
for (pipes_t::size_type i = 0; i != pipes.size (); i++)
|
||||||
pipes [i]->terminate ();
|
pipes [i]->terminate ();
|
||||||
}
|
}
|
||||||
|
@ -161,7 +161,7 @@ void zmq::own_t::process_term (int linger_)
|
|||||||
// Send termination request to all owned objects.
|
// Send termination request to all owned objects.
|
||||||
for (owned_t::iterator it = owned.begin (); it != owned.end (); ++it)
|
for (owned_t::iterator it = owned.begin (); it != owned.end (); ++it)
|
||||||
send_term (*it, linger_);
|
send_term (*it, linger_);
|
||||||
register_term_acks (owned.size ());
|
register_term_acks ((int) owned.size ());
|
||||||
owned.clear ();
|
owned.clear ();
|
||||||
|
|
||||||
// Start termination process and check whether by chance we cannot
|
// Start termination process and check whether by chance we cannot
|
||||||
|
@ -159,12 +159,13 @@ void zmq::select_t::loop ()
|
|||||||
// Wait for events.
|
// Wait for events.
|
||||||
struct timeval tv = {(long) (timeout / 1000),
|
struct timeval tv = {(long) (timeout / 1000),
|
||||||
(long) (timeout % 1000 * 1000)};
|
(long) (timeout % 1000 * 1000)};
|
||||||
int rc = select (maxfd + 1, &readfds, &writefds, &exceptfds,
|
|
||||||
timeout ? &tv : NULL);
|
|
||||||
|
|
||||||
#ifdef ZMQ_HAVE_WINDOWS
|
#ifdef ZMQ_HAVE_WINDOWS
|
||||||
|
int rc = select (0, &readfds, &writefds, &exceptfds,
|
||||||
|
timeout ? &tv : NULL);
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
#else
|
#else
|
||||||
|
int rc = select (maxfd + 1, &readfds, &writefds, &exceptfds,
|
||||||
|
timeout ? &tv : NULL);
|
||||||
if (rc == -1 && errno == EINTR)
|
if (rc == -1 && errno == EINTR)
|
||||||
continue;
|
continue;
|
||||||
errno_assert (rc != -1);
|
errno_assert (rc != -1);
|
||||||
|
@ -69,9 +69,9 @@ zmq::fd_t zmq::tcp_socket_t::get_fd ()
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_socket_t::write (const void *data, int size)
|
int zmq::tcp_socket_t::write (const void *data_, size_t size_)
|
||||||
{
|
{
|
||||||
int nbytes = send (s, (char*) data, size, 0);
|
int nbytes = send (s, (char*) data_, (int) size_, 0);
|
||||||
|
|
||||||
// If not a single byte can be written to the socket in non-blocking mode
|
// If not a single byte can be written to the socket in non-blocking mode
|
||||||
// we'll get an error (this may happen during the speculative write).
|
// we'll get an error (this may happen during the speculative write).
|
||||||
@ -93,9 +93,9 @@ int zmq::tcp_socket_t::write (const void *data, int size)
|
|||||||
return (size_t) nbytes;
|
return (size_t) nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_socket_t::read (void *data, int size)
|
int zmq::tcp_socket_t::read (void *data_, size_t size)
|
||||||
{
|
{
|
||||||
int nbytes = recv (s, (char*) data, size, 0);
|
int nbytes = recv (s, (char*) data_, (int) size_, 0);
|
||||||
|
|
||||||
// If not a single byte can be read from the socket in non-blocking mode
|
// If not a single byte can be read from the socket in non-blocking mode
|
||||||
// we'll get an error (this may happen during the speculative read).
|
// we'll get an error (this may happen during the speculative read).
|
||||||
@ -176,9 +176,9 @@ zmq::fd_t zmq::tcp_socket_t::get_fd ()
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_socket_t::write (const void *data, int size)
|
int zmq::tcp_socket_t::write (const void *data_, size_t size_)
|
||||||
{
|
{
|
||||||
ssize_t nbytes = send (s, data, size, 0);
|
ssize_t nbytes = send (s, data_, size_, 0);
|
||||||
|
|
||||||
// Several errors are OK. When speculative write is being done we may not
|
// Several errors are OK. When speculative write is being done we may not
|
||||||
// be able to write a single byte to the socket. Also, SIGSTOP issued
|
// be able to write a single byte to the socket. Also, SIGSTOP issued
|
||||||
@ -195,9 +195,9 @@ int zmq::tcp_socket_t::write (const void *data, int size)
|
|||||||
return (size_t) nbytes;
|
return (size_t) nbytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
int zmq::tcp_socket_t::read (void *data, int size)
|
int zmq::tcp_socket_t::read (void *data_, size_t size_)
|
||||||
{
|
{
|
||||||
ssize_t nbytes = recv (s, data, size, 0);
|
ssize_t nbytes = recv (s, data_, size_, 0);
|
||||||
|
|
||||||
// Several errors are OK. When speculative read is being done we may not
|
// Several errors are OK. When speculative read is being done we may not
|
||||||
// be able to read a single byte to the socket. Also, SIGSTOP issued
|
// be able to read a single byte to the socket. Also, SIGSTOP issued
|
||||||
|
@ -21,6 +21,8 @@
|
|||||||
#ifndef __ZMQ_TCP_SOCKET_HPP_INCLUDED__
|
#ifndef __ZMQ_TCP_SOCKET_HPP_INCLUDED__
|
||||||
#define __ZMQ_TCP_SOCKET_HPP_INCLUDED__
|
#define __ZMQ_TCP_SOCKET_HPP_INCLUDED__
|
||||||
|
|
||||||
|
#include <stddef.h>
|
||||||
|
|
||||||
#include "fd.hpp"
|
#include "fd.hpp"
|
||||||
#include "stdint.hpp"
|
#include "stdint.hpp"
|
||||||
|
|
||||||
@ -49,13 +51,13 @@ namespace zmq
|
|||||||
// Writes data to the socket. Returns the number of bytes actually
|
// Writes data to the socket. Returns the number of bytes actually
|
||||||
// written (even zero is to be considered to be a success). In case
|
// written (even zero is to be considered to be a success). In case
|
||||||
// of error or orderly shutdown by the other peer -1 is returned.
|
// of error or orderly shutdown by the other peer -1 is returned.
|
||||||
int write (const void *data, int size);
|
int write (const void *data_, size_t size_);
|
||||||
|
|
||||||
// Reads data from the socket (up to 'size' bytes). Returns the number
|
// Reads data from the socket (up to 'size' bytes). Returns the number
|
||||||
// of bytes actually read (even zero is to be considered to be
|
// of bytes actually read (even zero is to be considered to be
|
||||||
// a success). In case of error or orderly shutdown by the other
|
// a success). In case of error or orderly shutdown by the other
|
||||||
// peer -1 is returned.
|
// peer -1 is returned.
|
||||||
int read (void *data, int size);
|
int read (void *data_, size_t size_);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
|
@ -83,7 +83,7 @@ void zmq::xrep_t::process_term (int linger_)
|
|||||||
{
|
{
|
||||||
terminating = true;
|
terminating = true;
|
||||||
|
|
||||||
register_term_acks (inpipes.size () + outpipes.size ());
|
register_term_acks ((int) (inpipes.size () + outpipes.size ()));
|
||||||
|
|
||||||
for (inpipes_t::iterator it = inpipes.begin (); it != inpipes.end ();
|
for (inpipes_t::iterator it = inpipes.begin (); it != inpipes.end ();
|
||||||
++it)
|
++it)
|
||||||
@ -257,7 +257,7 @@ int zmq::xrep_t::xrecv (msg_t *msg_, int flags_)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Round-robin over the pipes to get the next message.
|
// Round-robin over the pipes to get the next message.
|
||||||
for (int count = inpipes.size (); count != 0; count--) {
|
for (inpipes_t::size_type count = inpipes.size (); count != 0; count--) {
|
||||||
|
|
||||||
// Try to fetch new message.
|
// Try to fetch new message.
|
||||||
if (inpipes [current_in].active)
|
if (inpipes [current_in].active)
|
||||||
@ -299,7 +299,6 @@ int zmq::xrep_t::rollback (void)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool zmq::xrep_t::xhas_in ()
|
bool zmq::xrep_t::xhas_in ()
|
||||||
{
|
{
|
||||||
// There are subsequent parts of the partly-read message available.
|
// There are subsequent parts of the partly-read message available.
|
||||||
@ -310,7 +309,7 @@ bool zmq::xrep_t::xhas_in ()
|
|||||||
// queueing algorithm. If there are no messages available current will
|
// queueing algorithm. If there are no messages available current will
|
||||||
// get back to its original value. Otherwise it'll point to the first
|
// get back to its original value. Otherwise it'll point to the first
|
||||||
// pipe holding messages, skipping only pipes with no messages available.
|
// pipe holding messages, skipping only pipes with no messages available.
|
||||||
for (int count = inpipes.size (); count != 0; count--) {
|
for (inpipes_t::size_type count = inpipes.size (); count != 0; count--) {
|
||||||
if (inpipes [current_in].active &&
|
if (inpipes [current_in].active &&
|
||||||
inpipes [current_in].reader->check_read ())
|
inpipes [current_in].reader->check_read ())
|
||||||
return true;
|
return true;
|
||||||
|
@ -587,10 +587,11 @@ int zmq_poll (zmq_pollitem_t *items_, int nitems_, long timeout_)
|
|||||||
memcpy (&inset, &pollset_in, sizeof (fd_set));
|
memcpy (&inset, &pollset_in, sizeof (fd_set));
|
||||||
memcpy (&outset, &pollset_out, sizeof (fd_set));
|
memcpy (&outset, &pollset_out, sizeof (fd_set));
|
||||||
memcpy (&errset, &pollset_err, sizeof (fd_set));
|
memcpy (&errset, &pollset_err, sizeof (fd_set));
|
||||||
int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout);
|
|
||||||
#if defined ZMQ_HAVE_WINDOWS
|
#if defined ZMQ_HAVE_WINDOWS
|
||||||
|
int rc = select (0, &inset, &outset, &errset, ptimeout);
|
||||||
wsa_assert (rc != SOCKET_ERROR);
|
wsa_assert (rc != SOCKET_ERROR);
|
||||||
#else
|
#else
|
||||||
|
int rc = select (maxfd + 1, &inset, &outset, &errset, ptimeout);
|
||||||
if (rc == -1 && errno == EINTR)
|
if (rc == -1 && errno == EINTR)
|
||||||
return -1;
|
return -1;
|
||||||
errno_assert (rc >= 0);
|
errno_assert (rc >= 0);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user