Commit 949d1578 authored by Pieter Hintjens's avatar Pieter Hintjens

Merge pull request #492 from arsenm/master

Make CMake build usable for other systems
parents c7009d27 6ce46441
This diff is collapsed.
#ifndef __ZMQ_PLATFORM_HPP_INCLUDED__
#define __ZMQ_PLATFORM_HPP_INCLUDED__
#cmakedefine ZMQ_FORCE_SELECT
#cmakedefine ZMQ_FORCE_POLL
#cmakedefine ZMQ_FORCE_EPOLL
#cmakedefine ZMQ_FORCE_DEVPOLL
#cmakedefine ZMQ_FORCE_KQUEUE
#cmakedefine ZMQ_FORCE_SELECT
#cmakedefine ZMQ_FORCE_POLL
#cmakedefine ZMQ_FORCE_MUTEXES
#cmakedefine HAVE_CLOCK_GETTIME
#cmakedefine HAVE_GETHRTIME
#cmakedefine ZMQ_HAVE_UIO
#cmakedefine ZMQ_HAVE_EVENTFD
#cmakedefine ZMQ_HAVE_IFADDRS
#cmakedefine ZMQ_HAVE_SOCK_CLOEXEC
#cmakedefine ZMQ_HAVE_SO_KEEPALIVE
#cmakedefine ZMQ_HAVE_TCP_KEEPCNT
#cmakedefine ZMQ_HAVE_TCP_KEEPIDLE
#cmakedefine ZMQ_HAVE_TCP_KEEPINTVL
#cmakedefine ZMQ_HAVE_TCP_KEEPALIVE
#cmakedefine ZMQ_HAVE_OPENPGM
#cmakedefine ZMQ_MAKE_VALGRIND_HAPPY
#ifdef _AIX
#define ZMQ_HAVE_AIX
#endif
#if defined ANDROID
#define ZMQ_HAVE_ANDROID
#endif
#if defined __CYGWIN__
#define ZMQ_HAVE_CYGWIN
#endif
#if defined __MINGW32__
#define ZMQ_HAVE_MINGW32
#endif
#if defined(__FreeBSD__) || defined(__DragonFly__) || defined(__FreeBSD_kernel__)
#define ZMQ_HAVE_FREEBSD
#endif
#if defined __hpux
#define ZMQ_HAVE_HPUX
#endif
#if defined __linux__
#define ZMQ_HAVE_LINUX
#endif
#if defined __NetBSD__
#define ZMQ_HAVE_NETBSD
#endif
#if defined __OpenBSD__
#define ZMQ_HAVE_OPENBSD
#endif
#if defined __VMS
#define ZMQ_HAVE_OPENVMS
#endif
#if defined __APPLE__
#define ZMQ_HAVE_OSX
#endif
#if defined __QNXNTO__
#define ZMQ_HAVE_QNXNTO
#endif
#if defined(sun) || defined(__sun)
#define ZMQ_HAVE_SOLARIS
#endif
#if defined(WIN32) || defined(_WIN32)
#define ZMQ_HAVE_WINDOWS
#endif
#endif
# - Find Asciidoc
# this module looks for asciidoc and a2x
#
# ASCIIDOC_EXECUTABLE - the full path to asciidoc
# ASCIIDOC_FOUND - If false, don't attempt to use asciidoc.
# A2X_EXECUTABLE - the full path to a2x
# A2X_FOUND - If false, don't attempt to use a2x.
find_program(ASCIIDOC_EXECUTABLE asciidoc asciidoc.py
PATHS "$ENV{ASCIIDOC_ROOT}"
"$ENV{PROGRAMW6432}/asciidoc"
"$ENV{PROGRAMFILES}/asciidoc"
"$ENV{PROGRAMFILES(X86)}/asciidoc")
find_program(A2X_EXECUTABLE a2x
PATHS "$ENV{ASCIIDOC_ROOT}"
"$ENV{PROGRAMW6432}/asciidoc"
"$ENV{PROGRAMFILES}/asciidoc"
"$ENV{PROGRAMFILES(X86)}/asciidoc")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_ARGS(AsciiDoc REQUIRED_VARS ASCIIDOC_EXECUTABLE)
mark_as_advanced(ASCIIDOC_EXECUTABLE A2X_EXECUTABLE)
\ No newline at end of file
MESSAGE(STATUS "Detecting ZMQ")
SET(TRY_RUN_DIR ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/zmq_run.dir)
file(READ "${PROJECT_SOURCE_DIR}/include/zmq.h" _ZMQ_H_CONTENTS)
string(REGEX REPLACE ".*#define ZMQ_VERSION_MAJOR ([0-9]+).*" "\\1" ZMQ_VERSION_MAJOR "${_ZMQ_H_CONTENTS}")
string(REGEX REPLACE ".*#define ZMQ_VERSION_MINOR ([0-9]+).*" "\\1" ZMQ_VERSION_MINOR "${_ZMQ_H_CONTENTS}")
string(REGEX REPLACE ".*#define ZMQ_VERSION_PATCH ([0-9]+).*" "\\1" ZMQ_VERSION_PATCH "${_ZMQ_H_CONTENTS}")
set(ZMQ_VERSION "${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}")
TRY_RUN(RUN_RESULT COMPILE_RESULT
${TRY_RUN_DIR}
${CMAKE_SOURCE_DIR}/cmake/Modules/zmq_version.cpp
CMAKE_FLAGS
"-DINCLUDE_DIRECTORIES:STRING=${CMAKE_SOURCE_DIR}/include"
COMPILE_OUTPUT_VARIABLE COMPILE_OUTPUT
RUN_OUTPUT_VARIABLE RUN_OUTPUT)
message(STATUS "Detected ZMQ Version - ${ZMQ_VERSION}")
IF(COMPILE_RESULT)
IF(RUN_RESULT MATCHES "FAILED_TO_RUN")
MESSAGE(STATUS "Detecting ZMQ - failed")
ELSE()
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\1" ZMQ_VERSION_MAJOR "${RUN_OUTPUT}")
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\2" ZMQ_VERSION_MINOR "${RUN_OUTPUT}")
STRING(REGEX REPLACE "([0-9]+)\\.([0-9]+)\\.([0-9]+).*" "\\3" ZMQ_VERSION_PATCH "${RUN_OUTPUT}")
MESSAGE(STATUS "Detecting ZMQ - ${ZMQ_VERSION_MAJOR}.${ZMQ_VERSION_MINOR}.${ZMQ_VERSION_PATCH}")
ENDIF()
ELSE()
MESSAGE(STATUS "Check for ZMQ version - not found")
MESSAGE(STATUS "Detecting ZMQ - failed")
ENDIF()
if(MSVC_VERSION MATCHES "1700")
set(_zmq_COMPILER "-v110")
elseif(MSVC10)
set(_zmq_COMPILER "-v100")
elseif(MSVC90)
set(_zmq_COMPILER "-v90")
else()
set(_zmq_COMPILER "")
endif()
if(MSVC_VERSION MATCHES "1700")
set(_zmq_COMPILER "-v110")
elseif(MSVC10)
set(_zmq_COMPILER "-v100")
elseif(MSVC90)
set(_zmq_COMPILER "-v90")
else()
set(_zmq_COMPILER "")
endif()
macro(zmq_check_sock_cloexec)
message(STATUS "Checking whether SOCK_CLOEXEC is supported")
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char *argv [])
{
int s = socket(PF_INET, SOCK_STREAM | SOCK_CLOEXEC, 0);
return(s == -1);
}
"
ZMQ_HAVE_SOCK_CLOEXEC)
endmacro()
# TCP keep-alives Checks.
macro(zmq_check_so_keepalive)
message(STATUS "Checking whether SO_KEEPALIVE is supported")
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
int main(int argc, char *argv [])
{
int s, rc, opt = 1;
return(
((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) ||
((rc = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,(char*) &opt, sizeof(int))) == -1)
);
}
"
ZMQ_HAVE_SO_KEEPALIVE)
endmacro()
macro(zmq_check_tcp_keepcnt)
message(STATUS "Checking whether TCP_KEEPCNT is supported")
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int main(int argc, char *argv [])
{
int s, rc, opt = 1;
return(
((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) ||
((rc = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,(char*) &opt, sizeof(int))) == -1) ||
((rc = setsockopt(s, IPPROTO_TCP, TCP_KEEPCNT,(char*) &opt, sizeof(int))) == -1)
);
}
"
ZMQ_HAVE_TCP_KEEPCNT)
endmacro()
macro(zmq_check_tcp_keepidle)
message(STATUS "Checking whether TCP_KEEPIDLE is supported")
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int main(int argc, char *argv [])
{
int s, rc, opt = 1;
return(
((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) ||
((rc = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,(char*) &opt, sizeof(int))) == -1) ||
((rc = setsockopt(s, IPPROTO_TCP, TCP_KEEPIDLE,(char*) &opt, sizeof(int))) == -1)
);
}
"
ZMQ_HAVE_TCP_KEEPIDLE)
endmacro()
macro(zmq_check_tcp_keepintvl)
message(STATUS "Checking whether TCP_KEEPINTVL is supported")
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int main(int argc, char *argv [])
{
int s, rc, opt = 1;
return(
((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) ||
((rc = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,(char*) &opt, sizeof(int))) == -1) ||
((rc = setsockopt(s, IPPROTO_TCP, TCP_KEEPINTVL,(char*) &opt, sizeof(int))) == -1)
);
}
"
ZMQ_HAVE_TCP_KEEPINTVL)
endmacro()
macro(zmq_check_tcp_keepalive)
message(STATUS "Checking whether TCP_KEEPALIVE is supported")
check_c_source_runs(
"
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <netinet/tcp.h>
int main(int argc, char *argv [])
{
int s, rc, opt = 1;
return(
((s = socket(PF_INET, SOCK_STREAM, 0)) == -1) ||
((rc = setsockopt(s, SOL_SOCKET, SO_KEEPALIVE,(char*) &opt, sizeof(int))) == -1) ||
((rc = setsockopt(s, IPPROTO_TCP, TCP_KEEPALIVE,(char*) &opt, sizeof(int))) == -1)
);
}
"
ZMQ_HAVE_TCP_KEEPALIVE)
endmacro()
/*
Copyright (c) 2007-2012 iMatix Corporation
Copyright (c) 2009-2011 250bpm s.r.o.
Copyright (c) 2007-2011 Other contributors as noted in the AUTHORS file
This file is part of 0MQ.
0MQ 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 3 of the License, or
(at your option) any later version.
0MQ 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 <http://www.gnu.org/licenses/>.
*/
#include "zmq.h"
#include <stdio.h>
int main ()
{
printf ("%d.%d.%d\n", ZMQ_VERSION_MAJOR, ZMQ_VERSION_MINOR, ZMQ_VERSION_PATCH);
return 0;
}
......@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "../src/platform.hpp"
#include "platform.hpp"
#if defined ZMQ_HAVE_WINDOWS
#include <windows.h>
......
......@@ -26,7 +26,7 @@
#include <stdlib.h>
#include <string.h>
#include "../src/platform.hpp"
#include "platform.hpp"
#if defined ZMQ_HAVE_WINDOWS
#include <windows.h>
......
......@@ -163,7 +163,7 @@ namespace zmq
return false;
}
inline bool message_ready_size (size_t msg_sz)
inline bool message_ready_size (size_t /* msg_sz */)
{
zmq_assert (false);
return false;
......
......@@ -30,8 +30,9 @@ namespace zmq
// Interface to be implemented by message decoder.
struct i_decoder
class i_decoder
{
public:
virtual ~i_decoder () {}
virtual void set_msg_sink (i_msg_sink *msg_sink_) = 0;
......
......@@ -29,8 +29,9 @@ namespace zmq
// Interface to be implemented by message sink.
struct i_msg_sink
class i_msg_sink
{
public:
virtual ~i_msg_sink () {}
// Delivers a message. Returns 0 if successful; -1 otherwise.
......
......@@ -29,8 +29,9 @@ namespace zmq
// Interface to be implemented by message source.
struct i_msg_source
class i_msg_source
{
public:
virtual ~i_msg_source () {}
// Fetch a message. Returns 0 if successful; -1 otherwise.
......
......@@ -73,11 +73,11 @@ zmq::fd_t zmq::open_socket (int domain_, int type_, int protocol_)
void zmq::unblock_socket (fd_t s_)
{
#ifdef ZMQ_HAVE_WINDOWS
#if defined ZMQ_HAVE_WINDOWS
u_long nonblock = 1;
int rc = ioctlsocket (s_, FIONBIO, &nonblock);
wsa_assert (rc != SOCKET_ERROR);
#elif ZMQ_HAVE_OPENVMS
#elif defined ZMQ_HAVE_OPENVMS
int nonblock = 1;
int rc = ioctl (s_, FIONBIO, &nonblock);
errno_assert (rc != -1);
......@@ -92,6 +92,8 @@ void zmq::unblock_socket (fd_t s_)
void zmq::enable_ipv4_mapping (fd_t s_)
{
(void) s_;
#ifdef IPV6_V6ONLY
#ifdef ZMQ_HAVE_WINDOWS
DWORD flag = 0;
......@@ -107,3 +109,4 @@ void zmq::enable_ipv4_mapping (fd_t s_)
#endif
#endif
}
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_PREFIX@/lib
includedir=@CMAKE_INSTALL_PREFIX@/include
Name: libzmq
Description: 0MQ c++ library
Version: @ZMQ_VERSION_MAJOR@.@ZMQ_VERSION_MINOR@.@ZMQ_VERSION_PATCH@
Libs: -L${libdir} -lzmq
Cflags: -I@CMAKE_INSTALL_PREFIX@/include
......@@ -124,6 +124,7 @@ void zmq::object_t::process_command (command_t &cmd_)
process_reaped ();
break;
case command_t::done:
default:
zmq_assert (false);
}
......
......@@ -320,20 +320,23 @@ int zmq::options_t::setsockopt (int option_, const void *optval_,
else {
std::string filter_str ((const char*) optval_, optvallen_);
tcp_address_mask_t filter;
int rc = filter.resolve (filter_str.c_str (), ipv4only ? true : false);
tcp_address_mask_t mask;
int rc = mask.resolve (filter_str.c_str (), ipv4only ? true : false);
if (rc != 0) {
errno = EINVAL;
return -1;
}
tcp_accept_filters.push_back(filter);
tcp_accept_filters.push_back(mask);
return 0;
}
}
default:
{
errno = EINVAL;
return -1;
}
}
errno = EINVAL;
return -1;
}
int zmq::options_t::getsockopt (int option_, void *optval_, size_t *optvallen_)
......
......@@ -206,8 +206,8 @@ void zmq::signaler_t::recv ()
// one, return it back to the eventfd object.
if (unlikely (dummy == 2)) {
const uint64_t inc = 1;
ssize_t sz = write (w, &inc, sizeof (inc));
errno_assert (sz == sizeof (inc));
ssize_t sz2 = write (w, &inc, sizeof (inc));
errno_assert (sz2 == sizeof (inc));
return;
}
......@@ -238,8 +238,10 @@ int zmq::signaler_t::make_fdpair (fd_t *r_, fd_t *w_)
return 0;
#elif defined ZMQ_HAVE_WINDOWS
SECURITY_DESCRIPTOR sd = {0};
SECURITY_ATTRIBUTES sa = {0};
SECURITY_DESCRIPTOR sd;
SECURITY_ATTRIBUTES sa;
memset (&sd, 0, sizeof (sd));
memset (&sa, 0, sizeof (sa));
InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION);
SetSecurityDescriptorDacl(&sd, TRUE, 0, FALSE);
......
......@@ -437,14 +437,14 @@ int zmq::socket_base_t::connect (const char *addr_)
// Create a bi-directional pipe to connect the peers.
object_t *parents [2] = {this, peer.socket};
pipe_t *pipes [2] = {NULL, NULL};
pipe_t *new_pipes [2] = {NULL, NULL};
int hwms [2] = {sndhwm, rcvhwm};
bool delays [2] = {options.delay_on_disconnect, options.delay_on_close};
int rc = pipepair (parents, pipes, hwms, delays);
int rc = pipepair (parents, new_pipes, hwms, delays);
errno_assert (rc == 0);
// Attach local end of the pipe to this socket object.
attach_pipe (pipes [0]);
attach_pipe (new_pipes [0]);
// If required, send the identity of the local socket to the peer.
if (peer.options.recv_identity) {
......@@ -453,9 +453,9 @@ int zmq::socket_base_t::connect (const char *addr_)
errno_assert (rc == 0);
memcpy (id.data (), options.identity, options.identity_size);
id.set_flags (msg_t::identity);
bool written = pipes [0]->write (&id);
bool written = new_pipes [0]->write (&id);
zmq_assert (written);
pipes [0]->flush ();
new_pipes [0]->flush ();
}
// If required, send the identity of the peer to the local socket.
......@@ -465,21 +465,21 @@ int zmq::socket_base_t::connect (const char *addr_)
errno_assert (rc == 0);
memcpy (id.data (), peer.options.identity, peer.options.identity_size);
id.set_flags (msg_t::identity);
bool written = pipes [1]->write (&id);
bool written = new_pipes [1]->write (&id);
zmq_assert (written);
pipes [1]->flush ();
new_pipes [1]->flush ();
}
// Attach remote end of the pipe to the peer socket. Note that peer's
// seqnum was incremented in find_endpoint function. We don't need it
// increased here.
send_bind (peer.socket, pipes [1], false);
send_bind (peer.socket, new_pipes [1], false);
// Save last endpoint URI
options.last_endpoint.assign (addr_);
// remember inproc connections for disconnect
inprocs.insert (inprocs_t::value_type (std::string (addr_), pipes[0]));
inprocs.insert (inprocs_t::value_type (std::string (addr_), new_pipes[0]));
return 0;
}
......@@ -540,17 +540,17 @@ int zmq::socket_base_t::connect (const char *addr_)
if (options.delay_attach_on_connect != 1 || icanhasall) {
// Create a bi-directional pipe.
object_t *parents [2] = {this, session};
pipe_t *pipes [2] = {NULL, NULL};
pipe_t *new_pipes [2] = {NULL, NULL};
int hwms [2] = {options.sndhwm, options.rcvhwm};
bool delays [2] = {options.delay_on_disconnect, options.delay_on_close};
rc = pipepair (parents, pipes, hwms, delays);
rc = pipepair (parents, new_pipes, hwms, delays);
errno_assert (rc == 0);
// Attach local end of the pipe to the socket object.
attach_pipe (pipes [0], icanhasall);
attach_pipe (new_pipes [0], icanhasall);
// Attach remote end of the pipe to the session object later on.
session->attach_pipe (pipes [1]);
session->attach_pipe (new_pipes [1]);
}
// Save last endpoint URI
......@@ -664,7 +664,7 @@ int zmq::socket_base_t::send (msg_t *msg_, int flags_)
return -1;
// Compute the time when the timeout should occur.
// If the timeout is infite, don't care.
// If the timeout is infinite, don't care.
int timeout = options.sndtimeo;
uint64_t end = timeout < 0 ? 0 : (clock.now_ms () + timeout);
......@@ -746,7 +746,7 @@ int zmq::socket_base_t::recv (msg_t *msg_, int flags_)
}
// Compute the time when the timeout should occur.
// If the timeout is infite, don't care.
// If the timeout is infinite, don't care.
int timeout = options.rcvtimeo;
uint64_t end = timeout < 0 ? 0 : (clock.now_ms () + timeout);
......
......@@ -94,7 +94,7 @@ namespace zmq
// Size of the greeting message:
// Preamble (10 bytes) + version (1 byte) + socket type (1 byte).
const static size_t greeting_size = 12;
static const size_t greeting_size = 12;
// True iff we are registered with an I/O poller.
bool io_enabled;
......
......@@ -240,7 +240,8 @@ zmq::fd_t zmq::tcp_listener_t::accept ()
// Accept one connection and deal with different failure modes.
zmq_assert (s != retired_fd);
struct sockaddr_storage ss = {};
struct sockaddr_storage ss;
memset (&ss, 0, sizeof (ss));
#ifdef ZMQ_HAVE_HPUX
int ss_len = sizeof (ss);
#else
......
......@@ -56,7 +56,7 @@
// XSI vector I/O
#if ZMQ_HAVE_UIO
#if defined ZMQ_HAVE_UIO
#include <sys/uio.h>
#else
struct iovec {
......@@ -980,7 +980,7 @@ int zmq_proxy (void *frontend_, void *backend_, void *control_)
// The deprecated device functionality
int zmq_device (int type, void *frontend_, void *backend_)
int zmq_device (int /* type */, void *frontend_, void *backend_)
{
return zmq::proxy (
(zmq::socket_base_t*) frontend_,
......@@ -989,7 +989,7 @@ int zmq_device (int type, void *frontend_, void *backend_)
// Callback to free socket event data
void zmq_free_event (void *event_data, void *hint)
void zmq_free_event (void *event_data, void * /* hint */)
{
zmq_event_t *event = (zmq_event_t *) event_data;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment