apps/speed.c: fix typo in last commit.
[openssl.git] / apps / speed.c
index d2e4abf495dda73d564d44a4c283eda29ded0b6c..25fe24aaec7064c34422ddfe0b6973a98824be7d 100644 (file)
 #include <signal.h>
 #endif
 
 #include <signal.h>
 #endif
 
-#ifdef _WIN32
+#if defined(_WIN32) || defined(__CYGWIN__)
 #include <windows.h>
 #include <windows.h>
+# if defined(__CYGWIN__) && !defined(_WIN32)
+  /* <windows.h> should define _WIN32, which normally is mutually
+   * exclusive with __CYGWIN__, but if it didn't... */
+#  define _WIN32
+  /* this is done because Cygwin alarm() fails sometimes. */
+# endif
 #endif
 
 #include <openssl/bn.h>
 #endif
 
 #include <openssl/bn.h>
@@ -274,9 +280,12 @@ static SIGRETTYPE sig_done(int sig)
 
 #if defined(_WIN32)
 
 
 #if defined(_WIN32)
 
-#define SIGALRM
+#if !defined(SIGALRM)
+# define SIGALRM
+#endif
 static unsigned int lapse,schlock;
 static unsigned int lapse,schlock;
-static void alarm(unsigned int secs) { lapse = secs*1000; }
+static void alarm_win32(unsigned int secs) { lapse = secs*1000; }
+#define alarm alarm_win32
 
 static DWORD WINAPI sleepy(VOID *arg)
        {
 
 static DWORD WINAPI sleepy(VOID *arg)
        {
@@ -1246,7 +1255,8 @@ int MAIN(int argc, char **argv)
                count*=2;
                Time_F(START);
                for (it=count; it; it--)
                count*=2;
                Time_F(START);
                for (it=count; it; it--)
-                       DES_ecb_encrypt(buf_as_des_cblock,buf_as_des_cblock,
+                       DES_ecb_encrypt((DES_cblock *)buf,
+                               (DES_cblock *)buf,
                                &sch,DES_ENCRYPT);
                d=Time_F(STOP);
                } while (d <3);
                                &sch,DES_ENCRYPT);
                d=Time_F(STOP);
                } while (d <3);
@@ -2643,7 +2653,11 @@ static int do_multi(int multi)
        fds=malloc(multi*sizeof *fds);
        for(n=0 ; n < multi ; ++n)
                {
        fds=malloc(multi*sizeof *fds);
        for(n=0 ; n < multi ; ++n)
                {
-               pipe(fd);
+               if (pipe(fd) == -1)
+                       {
+                       fprintf(stderr, "pipe failure\n");
+                       exit(1);
+                       }
                fflush(stdout);
                fflush(stderr);
                if(fork())
                fflush(stdout);
                fflush(stderr);
                if(fork())
@@ -2655,7 +2669,11 @@ static int do_multi(int multi)
                        {
                        close(fd[0]);
                        close(1);
                        {
                        close(fd[0]);
                        close(1);
-                       dup(fd[1]);
+                       if (dup(fd[1]) == -1)
+                               {
+                               fprintf(stderr, "dup failed\n");
+                               exit(1);
+                               }
                        close(fd[1]);
                        mr=1;
                        usertime=0;
                        close(fd[1]);
                        mr=1;
                        usertime=0;
@@ -2738,6 +2756,7 @@ static int do_multi(int multi)
                                else
                                        rsa_results[k][1]=d;
                                }
                                else
                                        rsa_results[k][1]=d;
                                }
+#ifndef OPENSSL_NO_DSA
                        else if(!strncmp(buf,"+F3:",4))
                                {
                                int k;
                        else if(!strncmp(buf,"+F3:",4))
                                {
                                int k;
@@ -2759,6 +2778,7 @@ static int do_multi(int multi)
                                else
                                        dsa_results[k][1]=d;
                                }
                                else
                                        dsa_results[k][1]=d;
                                }
+#endif
 #ifndef OPENSSL_NO_ECDSA
                        else if(!strncmp(buf,"+F4:",4))
                                {
 #ifndef OPENSSL_NO_ECDSA
                        else if(!strncmp(buf,"+F4:",4))
                                {