Attached are 4 patches. They are also available on github as a pull
request to zeromq2-1.

The first fixes builds on AIX 6.1 for me.

The next 3 are a progression of fixes to get HP-UX builds working with
libdcekt for UUID generation (See
https://zeromq.jira.com/browse/LIBZMQ-226).  The old behavior used
openssl's RAND_bytes() call, but for this to work properly on HP-UX, you
need to either have openssl's prngd running, or have krng (kernel random
number generator) installed.  The old behavior can still be selected by
using the new '--without-dce' flag to configure.

I did not regenerate the automake/autoconf files for the patches.  My
version of automake is newer than the one used for 2.1.0, so I wasn't
sure if you'd want all the new stuff that showed up with that.

Regards,
-- 
AJ Lewis
Software Engineer
Quantum Corporation

Work:    651 688-4346

----------------------------------------------------------------------
The information contained in this transmission may be confidential. Any 
disclosure, copying, or further distribution of confidential information is not 
permitted unless such privilege is explicitly granted in writing by Quantum. 
Quantum reserves the right to have electronic communications, including email 
and attachments, sent across its networks filtered through anti virus and spam 
software programs and retain such messages in order to comply with applicable 
data security and retention requirements. Quantum is not responsible for the 
proper and complete transmission of the substance of this communication or for 
any delay in its receipt.
>From f32cf6d4991bf7a334fa8350157d51fb5469ed50 Mon Sep 17 00:00:00 2001
From: AJ Lewis <[email protected]>
Date: Thu, 27 Oct 2011 08:42:11 -0500
Subject: [PATCH 01/13] Get zeromq compiling on AIX 6.1

Includes platform.hpp in device.cpp and then adds the same check for
platforms found in zmq.cpp to include poll.h.  Without this, device.cpp
fails to compile with:
  device.cpp: In function 'int zmq::device(zmq::socket_base_t*, zmq::socket_base_t*)':
  device.cpp:46: error: 'struct zmq_pollitem_t' has no member named 'reqevents'
  device.cpp:47: error: 'struct zmq_pollitem_t' has no member named 'rtnevents'
  device.cpp:50: error: 'struct zmq_pollitem_t' has no member named 'reqevents'
  device.cpp:51: error: 'struct zmq_pollitem_t' has no member named 'rtnevents'
  device.cpp:67: error: 'struct zmq_pollitem_t' has no member named 'rtnevents'
  device.cpp:92: error: 'struct zmq_pollitem_t' has no member named 'rtnevents'
  gmake[1]: *** [libzmq_la-device.lo] Error 1

Signed-off-by: AJ Lewis <[email protected]>
---
 src/device.cpp |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)

diff --git a/src/device.cpp b/src/device.cpp
index 351283a..4d86e91 100644
--- a/src/device.cpp
+++ b/src/device.cpp
@@ -20,6 +20,20 @@
 
 #include <stddef.h>
 
+#include "platform.hpp"
+
+//  On AIX, poll.h has to be included before zmq.h to get consistent
+//  definition of pollfd structure (AIX uses 'reqevents' and 'retnevents'
+//  instead of 'events' and 'revents' and defines macros to map from POSIX-y
+//  names to AIX-specific names).
+#if defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_FREEBSD ||\
+    defined ZMQ_HAVE_OPENBSD || defined ZMQ_HAVE_SOLARIS ||\
+    defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_QNXNTO ||\
+    defined ZMQ_HAVE_HPUX || defined ZMQ_HAVE_AIX ||\
+    defined ZMQ_HAVE_NETBSD
+#include <poll.h>
+#endif
+
 #include "../include/zmq.h"
 
 #include "device.hpp"
-- 
1.7.7

>From 857c7f91d1e3c5c82408b9d932e117145678b814 Mon Sep 17 00:00:00 2001
From: AJ Lewis <[email protected]>
Date: Thu, 3 Nov 2011 11:37:41 -0500
Subject: [PATCH 1/3] Use DCE library on HP-UX to handle UUID generation

This is the initial dumb implementation - it just replaces RAND_bytes
in the final uuid case rather than handling uuid_create() as done in
the BSD case.

It passes the self tests, but it's probably not the correct way to do
it.

You can also use the openssl method my using the '--without-dce' flag
to configure.

Signed-off-by: AJ Lewis <[email protected]>
---
 configure.in |    9 ++++++++-
 src/uuid.cpp |   12 ++++++++++++
 2 files changed, 20 insertions(+), 1 deletions(-)

diff --git a/configure.in b/configure.in
index 1b9e5f4..fbd0876 100644
--- a/configure.in
+++ b/configure.in
@@ -179,7 +179,14 @@ case "${host_os}" in
         CPPFLAGS="-D_POSIX_C_SOURCE=200112L $CPPFLAGS"
         AC_DEFINE(ZMQ_HAVE_HPUX, 1, [Have HPUX OS])
         AC_CHECK_LIB(rt, sem_init)
-        AC_CHECK_LIB(crypto, RAND_bytes)
+        AC_ARG_WITH([dce],
+                    [AS_HELP_STRING([--without-dce],
+                                    [HP-UX only: Do not use DCE library for UUID functions])],,
+                    [],
+                    [with_dce=yes])
+        AS_IF([test "x$with_dce" != xno],
+              [AC_CHECK_LIB(dcekt, uuid_create)],
+              [AC_CHECK_LIB(crypto, RAND_bytes)])
         ;;
     *mingw32*)
         AC_DEFINE(ZMQ_HAVE_WINDOWS, 1, [Have Windows OS])
diff --git a/src/uuid.cpp b/src/uuid.cpp
index d8cc2e8..c3338bc 100644
--- a/src/uuid.cpp
+++ b/src/uuid.cpp
@@ -125,13 +125,25 @@ const char *zmq::uuid_t::to_string ()
 
 #include <stdio.h>
 #include <string.h>
+#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
+#include <dce/uuid.h>
+#else
 #include <openssl/rand.h>
+#endif
 
 zmq::uuid_t::uuid_t ()
 {
     unsigned char rand_buf [16];
+#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
+    ::uuid_t uuid;
+    unsigned32 ret;
+    uuid_create(&uuid, &ret);
+    zmq_assert (ret == uuid_s_ok);
+    memcpy(rand_buf, &uuid, sizeof(uuid));
+#else
     int ret = RAND_bytes (rand_buf, sizeof rand_buf);
     zmq_assert (ret == 1);
+#endif
 
     //  Read in UUID fields.
     memcpy (&time_low, rand_buf, sizeof time_low);
-- 
1.7.7

>From 357a6e9f05110e241a1682f841b886b88e442263 Mon Sep 17 00:00:00 2001
From: AJ Lewis <[email protected]>
Date: Thu, 3 Nov 2011 11:57:52 -0500
Subject: [PATCH 2/3] Implement DCE uuid calls properly

Create HPUX & LIBDCEKT specific sections similar to BSD section.  It's
possible that these could be merged, but I'm not sure if it would be
as readable because there are some type differences that might make
things difficult.

Signed-off-by: AJ Lewis <[email protected]>
---
 src/uuid.cpp |   37 +++++++++++++++++++++++++------------
 src/uuid.hpp |    5 +++++
 2 files changed, 30 insertions(+), 12 deletions(-)

diff --git a/src/uuid.cpp b/src/uuid.cpp
index c3338bc..f61a246 100644
--- a/src/uuid.cpp
+++ b/src/uuid.cpp
@@ -70,6 +70,31 @@ const char *zmq::uuid_t::to_string ()
     return string_buf;
 }
 
+#elif defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
+
+#include <dce/uuid.h>
+
+zmq::uuid_t::uuid_t ()
+{
+    unsigned32 status;
+    uuid_create (&uuid, &status);
+    zmq_assert (status == uuid_s_ok);
+    uuid_to_string (&uuid, &string_buf, &status);
+    zmq_assert (status == uuid_s_ok);
+
+    create_blob ();
+}
+
+zmq::uuid_t::~uuid_t ()
+{
+    free (string_buf);
+}
+
+const char *zmq::uuid_t::to_string ()
+{
+  return (char*) string_buf;
+}
+
 #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
       defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_CYGWIN
 
@@ -125,25 +150,13 @@ const char *zmq::uuid_t::to_string ()
 
 #include <stdio.h>
 #include <string.h>
-#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
-#include <dce/uuid.h>
-#else
 #include <openssl/rand.h>
-#endif
 
 zmq::uuid_t::uuid_t ()
 {
     unsigned char rand_buf [16];
-#if defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
-    ::uuid_t uuid;
-    unsigned32 ret;
-    uuid_create(&uuid, &ret);
-    zmq_assert (ret == uuid_s_ok);
-    memcpy(rand_buf, &uuid, sizeof(uuid));
-#else
     int ret = RAND_bytes (rand_buf, sizeof rand_buf);
     zmq_assert (ret == 1);
-#endif
 
     //  Read in UUID fields.
     memcpy (&time_low, rand_buf, sizeof time_low);
diff --git a/src/uuid.hpp b/src/uuid.hpp
index 5eab6c8..525dbcb 100644
--- a/src/uuid.hpp
+++ b/src/uuid.hpp
@@ -26,6 +26,8 @@
 
 #if defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD
 #include <uuid.h>
+#elif defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
+#include <dce/uuid.h>
 #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
       defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_CYGWIN
 #include <uuid/uuid.h>
@@ -86,6 +88,9 @@ namespace zmq
 #elif defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD
         ::uuid_t uuid;
         char *string_buf;
+#elif defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
+        ::uuid_t uuid;
+        unsigned_char_t *string_buf;
 #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
       defined ZMQ_HAVE_OSX || defined ZMQ_HAVE_CYGWIN ||\
       defined ZMQ_HAVE_OPENVMS
-- 
1.7.7

>From 1afd7a088400b39fd3309ff996ffbf9e567463ff Mon Sep 17 00:00:00 2001
From: AJ Lewis <[email protected]>
Date: Thu, 3 Nov 2011 12:10:35 -0500
Subject: [PATCH 3/3] Combine the existing freebsd/netbsd section with the new
 HP-UX DCE section

Using a couple #ifdefs, we can combine the freebsd/netbsd uuid section with
the HP-UX DEC section in uuid.cpp.

Signed-off-by: AJ Lewis <[email protected]>
---
 src/uuid.cpp |   39 +++++++++++----------------------------
 1 files changed, 11 insertions(+), 28 deletions(-)

diff --git a/src/uuid.cpp b/src/uuid.cpp
index f61a246..35d854f 100644
--- a/src/uuid.cpp
+++ b/src/uuid.cpp
@@ -44,39 +44,22 @@ const char *zmq::uuid_t::to_string ()
     return (char*) string_buf;
 }
 
-#elif defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD
+#elif defined ZMQ_HAVE_FREEBSD || defined ZMQ_HAVE_NETBSD || (defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT)
 
 #include <stdlib.h>
-#include <uuid.h>
-
-zmq::uuid_t::uuid_t ()
-{
-    uint32_t status;
-    uuid_create (&uuid, &status);
-    zmq_assert (status == uuid_s_ok);
-    uuid_to_string (&uuid, &string_buf, &status);
-    zmq_assert (status == uuid_s_ok);
-
-    create_blob ();
-}
-
-zmq::uuid_t::~uuid_t ()
-{
-    free (string_buf);
-}
-
-const char *zmq::uuid_t::to_string ()
-{
-    return string_buf;
-}
-
-#elif defined ZMQ_HAVE_HPUX && defined HAVE_LIBDCEKT
-
-#include <dce/uuid.h>
+#ifdef ZMQ_HAVE_HPUX
+#  include <dce/uuid.h>
+#else
+#  include <uuid.h>
+#endif
 
 zmq::uuid_t::uuid_t ()
 {
+#ifdef ZMQ_HAVE_HPUX
     unsigned32 status;
+#else
+    uint32_t status;
+#endif
     uuid_create (&uuid, &status);
     zmq_assert (status == uuid_s_ok);
     uuid_to_string (&uuid, &string_buf, &status);
@@ -92,7 +75,7 @@ zmq::uuid_t::~uuid_t ()
 
 const char *zmq::uuid_t::to_string ()
 {
-  return (char*) string_buf;
+    return (char*) string_buf;
 }
 
 #elif defined ZMQ_HAVE_LINUX || defined ZMQ_HAVE_SOLARIS ||\
-- 
1.7.7

_______________________________________________
zeromq-dev mailing list
[email protected]
http://lists.zeromq.org/mailman/listinfo/zeromq-dev

Reply via email to