apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "MATHIHALLI,MADHUSUDAN (HP-Cupertino,ex1)" <madhusudan_mathiha...@hp.com>
Subject [PATCH] APR_HAS_RANDOM
Date Wed, 20 Feb 2002 22:48:05 GMT
HPUX does not have /dev/random, hence I was trying to use the rand()
function.. I was wondering if there was any specific reason not to use it
this way.. If there's no objection, can somebody pl. commit this patch.

Thanks
-Madhu

diff -ru PA/httpd-2.0.32/srclib/apr/configure.in
TEST/httpd-2.0.32/srclib/apr/configure.in
--- PA/httpd-2.0.32/srclib/apr/configure.in     Wed Feb 20 14:23:33 2002
+++ TEST/httpd-2.0.32/srclib/apr/configure.in   Wed Feb 20 11:12:49 2002
@@ -1309,6 +1309,10 @@
             AC_MSG_RESULT([Using OS/2 builtin random])
             rand="1"
             ;;
+        *hp-hpux11*)
+            AC_MSG_RESULT([Using HP-UX builtin random])
+            rand="1"
+            ;;
         *)
             AC_ARG_WITH(egd,
               [  --with-egd=<path>       use egd-compatible socket],

--- PA/httpd-2.0.32/srclib/apr/misc/unix/rand.c Wed Feb 20 14:23:35 2002
+++ TEST/httpd-2.0.32/srclib/apr/misc/unix/rand.c       Wed Feb 20 14:43:22
2002
@@ -104,6 +104,18 @@
     for (idx=0; idx<length; idx++)
        buf[idx] = randbyte();

+#elif defined(HPUX11)
+    unsigned int idx;
+    static int was_init = 0;
+
+    if ( !was_init ) {
+       was_init = 1;
+       srand(apr_time_now());
+    }
+
+    for (idx=0; idx<length; idx++)
+       buf[idx] = rand() % sizeof(char);
+
 #elif defined(HAVE_EGD)
     /* use EGD-compatible socket daemon (such as EGD or PRNGd).
      * message format:

Mime
View raw message