Commit 8f86cac2 authored by Martin Sustrik's avatar Martin Sustrik

ZMQII-69: Make 0MQ build on HP-UX

parent fd673ae2
...@@ -211,6 +211,84 @@ zmq::fd_t zmq::fd_signaler_t::get_fd () ...@@ -211,6 +211,84 @@ zmq::fd_t zmq::fd_signaler_t::get_fd ()
return r; return r;
} }
#elif defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX
#include <sys/types.h>
#include <sys/socket.h>
zmq::fd_signaler_t::fd_signaler_t ()
{
int sv [2];
int rc = socketpair (AF_UNIX, SOCK_STREAM, 0, sv);
errno_assert (rc == 0);
w = sv [0];
r = sv [1];
// Set the reader to non-blocking mode.
int flags = fcntl (r, F_GETFL, 0);
if (flags == -1)
flags = 0;
rc = fcntl (r, F_SETFL, flags | O_NONBLOCK);
errno_assert (rc != -1);
}
zmq::fd_signaler_t::~fd_signaler_t ()
{
close (w);
close (r);
}
void zmq::fd_signaler_t::signal (int signal_)
{
zmq_assert (signal_ >= 0 && signal_ < 64);
unsigned char c = (unsigned char) signal_;
ssize_t nbytes = send (w, &c, 1, 0);
errno_assert (nbytes == 1);
}
uint64_t zmq::fd_signaler_t::poll ()
{
// Set the reader to blocking mode.
int flags = fcntl (fd, F_GETFL, 0);
if (flags == -1)
flags = 0;
int rc = fcntl (fd, F_SETFL, flags & ~O_NONBLOCK);
errno_assert (rc != -1);
// Poll for events.
uint64_t signals = check ();
// Set the reader to non-blocking mode.
flags = fcntl (r, F_GETFL, 0);
if (flags == -1)
flags = 0;
rc = fcntl (r, F_SETFL, flags | O_NONBLOCK);
errno_assert (rc != -1);
return signals;
}
uint64_t zmq::fd_signaler_t::check ()
{
unsigned char buffer [64];
ssize_t nbytes = recv (r, buffer, 64, 0);
if (nbytes == -1 && errno == EAGAIN)
return 0;
zmq_assert (nbytes != -1);
uint64_t signals = 0;
for (int pos = 0; pos != nbytes; pos ++) {
zmq_assert (buffer [pos] < 64);
signals |= (uint64_t (1) << (buffer [pos]));
}
return signals;
}
zmq::fd_t zmq::fd_signaler_t::get_fd ()
{
return r;
}
#else #else
#include <sys/types.h> #include <sys/types.h>
......
...@@ -96,8 +96,6 @@ static int resolve_nic_name (in_addr* addr_, char const *interface_) ...@@ -96,8 +96,6 @@ static int resolve_nic_name (in_addr* addr_, char const *interface_)
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <net/if.h> #include <net/if.h>
#include "formatting.hpp"
static int resolve_nic_name (in_addr* addr_, char const *interface_) static int resolve_nic_name (in_addr* addr_, char const *interface_)
{ {
// Create a socket. // Create a socket.
...@@ -107,7 +105,7 @@ static int resolve_nic_name (in_addr* addr_, char const *interface_) ...@@ -107,7 +105,7 @@ static int resolve_nic_name (in_addr* addr_, char const *interface_)
struct ifreq ifr; struct ifreq ifr;
// Copy interface name for ioctl get. // Copy interface name for ioctl get.
zmq_strncpy (ifr.ifr_name, interface_, sizeof (ifr.ifr_name)); strncpy (ifr.ifr_name, interface_, sizeof (ifr.ifr_name));
// Fetch interface address. // Fetch interface address.
int rc = ioctl (sd, SIOCGIFADDR, (caddr_t) &ifr, sizeof (struct ifreq)); int rc = ioctl (sd, SIOCGIFADDR, (caddr_t) &ifr, sizeof (struct ifreq));
......
...@@ -20,8 +20,15 @@ ...@@ -20,8 +20,15 @@
#ifndef __ZMQ_TCP_CONNECTER_HPP_INCLUDED__ #ifndef __ZMQ_TCP_CONNECTER_HPP_INCLUDED__
#define __ZMQ_TCP_CONNECTER_HPP_INCLUDED__ #define __ZMQ_TCP_CONNECTER_HPP_INCLUDED__
#include "platform.hpp"
#include "fd.hpp" #include "fd.hpp"
#include "ip.hpp"
#ifdef ZMQ_HAVE_WINDOWS
#include "windows.hpp"
#else
#include <sys/types.h>
#include <sys/socket.h>
#endif
namespace zmq namespace zmq
{ {
......
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