diff --git a/configure.ac b/configure.ac index b1ec5940..881232d7 100644 --- a/configure.ac +++ b/configure.ac @@ -63,6 +63,36 @@ LIBZMQ_CHECK_ENABLE_DEBUG # Check wheter to enable code coverage LIBZMQ_WITH_GCOV +AC_MSG_CHECKING([if TIPC is available and supports nonblocking connect]) +AC_RUN_IFELSE([AC_LANG_PROGRAM([[ #include + #include + #include + #include + #include + #include + ]],[[ + struct sockaddr_tipc topsrv; + int sd = socket(AF_TIPC, SOCK_SEQPACKET, 0); + if (sd == -EAFNOSUPPORT) { + return 1; + } + memset(&topsrv, 0, sizeof(topsrv)); + topsrv.family = AF_TIPC; + topsrv.addrtype = TIPC_ADDR_NAME; + topsrv.addr.name.name.type = TIPC_TOP_SRV; + topsrv.addr.name.name.instance = TIPC_TOP_SRV; + fcntl(sd, F_SETFL, O_NONBLOCK); + if (connect(sd, (struct sockaddr *)&topsrv, + sizeof(topsrv)) != 0) { + if (errno != EINPROGRESS) + return -1; + }]]) + ], + [libzmq_tipc_support=yes], + [libzmq_tipc_support=no], + [libzmq_tipc_support=no]) +AC_MSG_RESULT([$libzmq_tipc_support]) + # Allow libsodium to be installed in a custom path: AC_ARG_WITH([libsodium], @@ -141,6 +171,9 @@ case "${host_os}" in AC_DEFINE(ZMQ_HAVE_LINUX, 1, [Have Linux OS]) libzmq_on_linux="yes" + if test "x$libzmq_tipc_support" = "xyes"; then + AC_DEFINE(ZMQ_HAVE_TIPC, 1, [Have TIPC support]) + fi case "${host_os}" in *android*) AC_DEFINE(ZMQ_HAVE_ANDROID, 1, [Have Android OS]) @@ -436,6 +469,7 @@ if test "x$libzmq_pedantic" = "xyes"; then fi AC_LANG_POP([C++]) +AM_CONDITIONAL(BUILD_TIPC, test "x$libzmq_tipc_support" = "xyes") AM_CONDITIONAL(BUILD_PGM, test "x$libzmq_pgm_ext" = "xyes") AM_CONDITIONAL(ON_MINGW, test "x$libzmq_on_mingw32" = "xyes") AM_CONDITIONAL(ON_ANDROID, test "x$libzmq_on_android" = "xyes") diff --git a/src/address.cpp b/src/address.cpp index 0bbe7056..5fe6a3eb 100644 --- a/src/address.cpp +++ b/src/address.cpp @@ -52,7 +52,7 @@ zmq::address_t::~address_t () } } #endif -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC else if (protocol == "tipc") { if (resolved.tipc_addr) { delete resolved.tipc_addr; @@ -75,7 +75,7 @@ int zmq::address_t::to_string (std::string &addr_) const return resolved.ipc_addr->to_string(addr_); } #endif -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC else if (protocol == "tipc") { if (resolved.tipc_addr) { return resolved.tipc_addr->to_string(addr_); diff --git a/src/session_base.cpp b/src/session_base.cpp index 0b9974c5..e7c3e819 100644 --- a/src/session_base.cpp +++ b/src/session_base.cpp @@ -501,7 +501,7 @@ void zmq::session_base_t::start_connecting (bool wait_) return; } #endif -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC if (addr->protocol == "tipc") { tipc_connecter_t *connecter = new (std::nothrow) tipc_connecter_t ( io_thread, this, options, addr, wait_); diff --git a/src/socket_base.cpp b/src/socket_base.cpp index 4abdbb7a..b294a27e 100644 --- a/src/socket_base.cpp +++ b/src/socket_base.cpp @@ -210,7 +210,7 @@ int zmq::socket_base_t::check_protocol (const std::string &protocol_) #endif // TIPC transport is only available on Linux. -#if !defined ZMQ_HAVE_LINUX +#if !defined ZMQ_HAVE_TIPC if (protocol_ == "tipc") { errno = EPROTONOSUPPORT; return -1; @@ -409,7 +409,7 @@ int zmq::socket_base_t::bind (const char *addr_) return 0; } #endif -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC if (protocol == "tipc") { tipc_listener_t *listener = new (std::nothrow) tipc_listener_t ( io_thread, this, options); @@ -589,7 +589,7 @@ int zmq::socket_base_t::connect (const char *addr_) return -1; } #endif -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC else if (protocol == "tipc") { paddr->resolved.tipc_addr = new (std::nothrow) tipc_address_t (); diff --git a/src/tipc_address.cpp b/src/tipc_address.cpp index 51770414..0a3808d5 100644 --- a/src/tipc_address.cpp +++ b/src/tipc_address.cpp @@ -19,7 +19,7 @@ #include "tipc_address.hpp" -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC #include "err.hpp" diff --git a/src/tipc_address.hpp b/src/tipc_address.hpp index 402f9a34..a0d64371 100644 --- a/src/tipc_address.hpp +++ b/src/tipc_address.hpp @@ -24,7 +24,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC #include #include diff --git a/src/tipc_connecter.cpp b/src/tipc_connecter.cpp index 6c9c5d9f..e6108650 100644 --- a/src/tipc_connecter.cpp +++ b/src/tipc_connecter.cpp @@ -19,7 +19,7 @@ #include "tipc_connecter.hpp" -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC #include #include diff --git a/src/tipc_connecter.hpp b/src/tipc_connecter.hpp index c2938fe1..d23cc91c 100644 --- a/src/tipc_connecter.hpp +++ b/src/tipc_connecter.hpp @@ -22,7 +22,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC #include "fd.hpp" #include "own.hpp" diff --git a/src/tipc_listener.cpp b/src/tipc_listener.cpp index 1ba993a6..b5956d82 100644 --- a/src/tipc_listener.cpp +++ b/src/tipc_listener.cpp @@ -19,7 +19,7 @@ #include "tipc_listener.hpp" -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC #include diff --git a/src/tipc_listener.hpp b/src/tipc_listener.hpp index 5a10884b..6cd622c3 100644 --- a/src/tipc_listener.hpp +++ b/src/tipc_listener.hpp @@ -22,7 +22,7 @@ #include "platform.hpp" -#if defined ZMQ_HAVE_LINUX +#if defined ZMQ_HAVE_TIPC #include diff --git a/tests/Makefile.am b/tests/Makefile.am index cfc03b5a..f2de7775 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -52,7 +52,7 @@ noinst_PROGRAMS += test_shutdown_stress \ test_fork endif -if ON_LINUX +if BUILD_TIPC noinst_PROGRAMS += test_connect_delay_tipc \ test_pair_tipc \ test_reqrep_device_tipc \ @@ -110,7 +110,7 @@ test_reqrep_ipc_SOURCES = test_reqrep_ipc.cpp testutil.hpp test_timeo_SOURCES = test_timeo.cpp test_fork_SOURCES = test_fork.cpp endif -if ON_LINUX +if BUILD_TIPC test_connect_delay_tipc_SOURCES = test_connect_delay_tipc.cpp test_pair_tipc_SOURCES = test_pair_tipc.cpp test_reqrep_device_tipc_SOURCES = test_reqrep_device_tipc.cpp