Netware-specific changes,
[openssl.git] / apps / speed.c
index 1c2b9cded042d695f9762a33e3c10aa103d0d3b2..d15b06e241e739f842a883824a156bb25a54df21 100644 (file)
@@ -88,7 +88,7 @@
 
 #include <stdio.h>
 #include <stdlib.h>
-#include <signal.h>
+
 #include <string.h>
 #include <math.h>
 #include "apps.h"
 #include OPENSSL_UNISTD
 #endif
 
+#ifndef OPENSSL_SYS_NETWARE
+#include <signal.h>
+#endif
+
 #if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(OPENSSL_SYS_MACOSX)
 # define USE_TOD
 #elif !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_VXWORKS) && (!defined(OPENSSL_SYS_VMS) || defined(__DECC))
 # define TIMEB
 #endif
 
+#if defined(OPENSSL_SYS_NETWARE)
+#undef TIMES
+#undef TIMEB
+#include <time.h>
+#endif
+
 #ifndef _IRIX
 # include <time.h>
 #endif
 #include <sys/timeb.h>
 #endif
 
-#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS)
+#if !defined(TIMES) && !defined(TIMEB) && !defined(USE_TOD) && !defined(OPENSSL_SYS_VXWORKS) && !defined(OPENSSL_SYS_NETWARE)
 #error "It seems neither struct tms nor struct timeb is supported in this platform!"
 #endif
 
 #include <openssl/ecdh.h>
 #endif
 
+/*
+ * The following "HZ" timing stuff should be sync'd up with the code in
+ * crypto/tmdiff.[ch]. That appears to try to do the same job, though I think
+ * this code is more up to date than libcrypto's so there may be features to
+ * migrate over first. This is used in two places further down AFAICS. 
+ * The point is that nothing in openssl actually *uses* that tmdiff stuff, so
+ * either speed.c should be using it or it should go because it's obviously not
+ * useful enough. Anyone want to do a janitorial job on this?
+ */
+
 /* The following if from times(3) man page.  It may need to be changed */
 #ifndef HZ
 # if defined(_SC_CLK_TCK) \
      && (!defined(OPENSSL_SYS_VMS) || __CTRL_VER >= 70000000)
-#  define HZ ((double)sysconf(_SC_CLK_TCK))
+#  define HZ sysconf(_SC_CLK_TCK)
 # else
 #  ifndef CLK_TCK
 #   ifndef _BSD_CLK_TCK_ /* FreeBSD hack */
 # endif
 #endif
 
-#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2)
+#if !defined(OPENSSL_SYS_VMS) && !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACINTOSH_CLASSIC) && !defined(OPENSSL_SYS_OS2) && !defined(OPENSSL_SYS_NETWARE)
 # define HAVE_FORK 1
 #endif
 
@@ -288,13 +308,39 @@ static SIGRETTYPE sig_done(int sig)
 #define START  0
 #define STOP   1
 
+#if defined(OPENSSL_SYS_NETWARE)
+
+   /* for NetWare the best we can do is use clock() which returns the
+    * time, in hundredths of a second, since the NLM began executing
+   */
+static double Time_F(int s)
+       {
+       double ret;
+
+   static clock_t tstart,tend;
+
+   if (s == START)
+   {
+      tstart=clock();
+      return(0);
+   }
+   else
+   {
+      tend=clock();
+      ret=(double)((double)(tend)-(double)(tstart));
+      return((ret < 0.001)?0.001:ret);
+   }
+   }
+
+#else
+
 static double Time_F(int s)
        {
        double ret;
 
 #ifdef USE_TOD
        if(usertime)
-           {
+               {
                static struct rusage tstart,tend;
 
                getrusage_used = 1;
@@ -349,7 +395,8 @@ static double Time_F(int s)
                else
                        {
                        times(&tend);
-                       ret=((double)(tend.tms_utime-tstart.tms_utime))/HZ;
+                       ret = HZ;
+                       ret=(double)(tend.tms_utime-tstart.tms_utime) / ret;
                        return((ret < 1e-3)?1e-3:ret);
                        }
                }
@@ -395,6 +442,7 @@ static double Time_F(int s)
 # endif
 #endif
        }
+#endif /* if defined(OPENSSL_SYS_NETWARE) */
 
 
 static const int KDF1_SHA1_len = 20;
@@ -1219,6 +1267,9 @@ int MAIN(int argc, char **argv)
        c[D_CBC_RC5][0]=count;
        c[D_CBC_BF][0]=count;
        c[D_CBC_CAST][0]=count;
+       c[D_CBC_128_AES][0]=count;
+       c[D_CBC_192_AES][0]=count;
+       c[D_CBC_256_AES][0]=count;
 
        for (i=1; i<SIZE_NUM; i++)
                {
@@ -1244,6 +1295,9 @@ int MAIN(int argc, char **argv)
                c[D_CBC_RC5][i]=c[D_CBC_RC5][i-1]*l0/l1;
                c[D_CBC_BF][i]=c[D_CBC_BF][i-1]*l0/l1;
                c[D_CBC_CAST][i]=c[D_CBC_CAST][i-1]*l0/l1;
+               c[D_CBC_128_AES][i]=c[D_CBC_128_AES][i-1]*l0/l1;
+               c[D_CBC_192_AES][i]=c[D_CBC_192_AES][i-1]*l0/l1;
+               c[D_CBC_256_AES][i]=c[D_CBC_256_AES][i-1]*l0/l1;
                }
 #ifndef OPENSSL_NO_RSA
        rsa_c[R_RSA_512][0]=count/2000;
@@ -2083,7 +2137,7 @@ int MAIN(int argc, char **argv)
                                         * otherwise, use result (see section 4.8 of draft-ietf-tls-ecc-03.txt).
                                         */
                                        int field_size, outlen;
-                                       void *(*kdf)(void *in, size_t inlen, void *out, size_t outlen);
+                                       void *(*kdf)(void *in, size_t inlen, void *out, size_t xoutlen);
                                        field_size = EC_GROUP_get_degree(ecdh_a[j]->group);
                                        if (field_size <= 24 * 8)
                                                {
@@ -2191,7 +2245,10 @@ show_res:
 #endif
 #ifdef HZ
 #define as_string(s) (#s)
-               printf("HZ=%g", (double)HZ);
+               {
+               double dbl = HZ;
+               printf("HZ=%g", dbl);
+               }
 # ifdef _SC_CLK_TCK
                printf(" [sysconf value]");
 # endif