Hi,

The app_tminterval utility function in apps.c has a first parameter that is
either TM_START or TM_STOP as defined in apps.h. The two files that use this
function disregard those constants and define their own along with their own
wrapper utility wrapper function.

This patch keeps the wrapper functions as they provide a little convenience, but
removes the duplicate constants and fixes calls to use the apps.h constants.

There also appears to be some left over compatibility for platforms without
timens. Since the libressl build system doesn't define TIMES, this code thinks
the feature isn't available doesn't when reporting usage.

Jonas

diff -Nur libressl-2.1.0/apps/speed.c libssl/apps/speed.c
--- libressl-2.1.0/apps/speed.c 2014-10-11 18:58:11.000000000 +0200
+++ libssl/apps/speed.c 2014-10-14 17:45:02.778749560 +0200
@@ -203,9 +203,6 @@
        run = 0;
 }
 
-#define START  0
-#define STOP   1
-
 
 static double
 Time_F(int s)
@@ -481,10 +478,6 @@
        int multi = 0;
        const char *errstr = NULL;
 
-#ifndef TIMES
-       usertime = -1;
-#endif
-
        memset(results, 0, sizeof(results));
        memset(dsa_key, 0, sizeof(dsa_key));
        for (i = 0; i < EC_NUM; i++)
@@ -959,9 +952,7 @@
 
                        BIO_printf(bio_err, "\n");
                        BIO_printf(bio_err, "Available options:\n");
-#if defined(TIMES) || defined(USE_TOD)
                        BIO_printf(bio_err, "-elapsed        measure time in 
real time instead of CPU user time.\n");
-#endif
 #ifndef OPENSSL_NO_ENGINE
                        BIO_printf(bio_err, "-engine e       use engine e, 
possibly a hardware device.\n");
 #endif
@@ -1066,10 +1057,10 @@
        if (doit[D_MDC2]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_MDC2], c[D_MDC2][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_MDC2][j]); count++)
                                EVP_Digest(buf, (unsigned long) lengths[j], 
&(mdc2[0]), NULL, EVP_mdc2(), NULL);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_MDC2, j, count, d);
                }
        }
@@ -1079,10 +1070,10 @@
        if (doit[D_MD4]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_MD4], c[D_MD4][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_MD4][j]); count++)
                                EVP_Digest(&(buf[0]), (unsigned long) 
lengths[j], &(md4[0]), NULL, EVP_md4(), NULL);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_MD4, j, count, d);
                }
        }
@@ -1092,10 +1083,10 @@
        if (doit[D_MD5]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_MD5], c[D_MD5][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_MD5][j]); count++)
                                EVP_Digest(&(buf[0]), (unsigned long) 
lengths[j], &(md5[0]), NULL, EVP_get_digestbyname("md5"), NULL);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_MD5, j, count, d);
                }
        }
@@ -1111,13 +1102,13 @@
 
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_HMAC], c[D_HMAC][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_HMAC][j]); count++) {
                                HMAC_Init_ex(&hctx, NULL, 0, NULL, NULL);
                                HMAC_Update(&hctx, buf, lengths[j]);
                                HMAC_Final(&hctx, &(hmac[0]), NULL);
                        }
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_HMAC, j, count, d);
                }
                HMAC_CTX_cleanup(&hctx);
@@ -1127,10 +1118,10 @@
        if (doit[D_SHA1]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_SHA1], c[D_SHA1][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_SHA1][j]); count++)
                                EVP_Digest(buf, (unsigned long) lengths[j], 
&(sha[0]), NULL, EVP_sha1(), NULL);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_SHA1, j, count, d);
                }
        }
@@ -1138,10 +1129,10 @@
        if (doit[D_SHA256]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_SHA256], c[D_SHA256][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_SHA256][j]); count++)
                                SHA256(buf, lengths[j], sha256);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_SHA256, j, count, d);
                }
        }
@@ -1151,10 +1142,10 @@
        if (doit[D_SHA512]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_SHA512], c[D_SHA512][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_SHA512][j]); count++)
                                SHA512(buf, lengths[j], sha512);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_SHA512, j, count, d);
                }
        }
@@ -1165,10 +1156,10 @@
        if (doit[D_WHIRLPOOL]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_WHIRLPOOL], c[D_WHIRLPOOL][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_WHIRLPOOL][j]); 
count++)
                                WHIRLPOOL(buf, lengths[j], whirlpool);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_WHIRLPOOL, j, count, d);
                }
        }
@@ -1178,10 +1169,10 @@
        if (doit[D_RMD160]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_RMD160], c[D_RMD160][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_RMD160][j]); count++)
                                EVP_Digest(buf, (unsigned long) lengths[j], 
&(rmd160[0]), NULL, EVP_ripemd160(), NULL);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_RMD160, j, count, d);
                }
        }
@@ -1190,11 +1181,11 @@
        if (doit[D_RC4]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_RC4], c[D_RC4][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_RC4][j]); count++)
                                RC4(&rc4_ks, (unsigned int) lengths[j],
                                    buf, buf);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_RC4, j, count, d);
                }
        }
@@ -1203,23 +1194,23 @@
        if (doit[D_CBC_DES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_CBC_DES], c[D_CBC_DES][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_CBC_DES][j]); count++)
                                DES_ncbc_encrypt(buf, buf, lengths[j], &sch,
                                    &DES_iv, DES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_CBC_DES, j, count, d);
                }
        }
        if (doit[D_EDE3_DES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_EDE3_DES], c[D_EDE3_DES][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_EDE3_DES][j]); 
count++)
                                DES_ede3_cbc_encrypt(buf, buf, lengths[j],
                                    &sch, &sch2, &sch3,
                                    &DES_iv, DES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_EDE3_DES, j, count, d);
                }
        }
@@ -1228,72 +1219,72 @@
        if (doit[D_CBC_128_AES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_CBC_128_AES], 
c[D_CBC_128_AES][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_CBC_128_AES][j]); 
count++)
                                AES_cbc_encrypt(buf, buf,
                                    (unsigned long) lengths[j], &aes_ks1,
                                    iv, AES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_CBC_128_AES, j, count, d);
                }
        }
        if (doit[D_CBC_192_AES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_CBC_192_AES], 
c[D_CBC_192_AES][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_CBC_192_AES][j]); 
count++)
                                AES_cbc_encrypt(buf, buf,
                                    (unsigned long) lengths[j], &aes_ks2,
                                    iv, AES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_CBC_192_AES, j, count, d);
                }
        }
        if (doit[D_CBC_256_AES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_CBC_256_AES], 
c[D_CBC_256_AES][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_CBC_256_AES][j]); 
count++)
                                AES_cbc_encrypt(buf, buf,
                                    (unsigned long) lengths[j], &aes_ks3,
                                    iv, AES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_CBC_256_AES, j, count, d);
                }
        }
        if (doit[D_IGE_128_AES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_IGE_128_AES], 
c[D_IGE_128_AES][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_IGE_128_AES][j]); 
count++)
                                AES_ige_encrypt(buf, buf2,
                                    (unsigned long) lengths[j], &aes_ks1,
                                    iv, AES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_IGE_128_AES, j, count, d);
                }
        }
        if (doit[D_IGE_192_AES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_IGE_192_AES], 
c[D_IGE_192_AES][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_IGE_192_AES][j]); 
count++)
                                AES_ige_encrypt(buf, buf2,
                                    (unsigned long) lengths[j], &aes_ks2,
                                    iv, AES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_IGE_192_AES, j, count, d);
                }
        }
        if (doit[D_IGE_256_AES]) {
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_IGE_256_AES], 
c[D_IGE_256_AES][j], lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_IGE_256_AES][j]); 
count++)
                                AES_ige_encrypt(buf, buf2,
                                    (unsigned long) lengths[j], &aes_ks3,
                                    iv, AES_ENCRYPT);
-                       d = Time_F(STOP);
+                       d = Time_F(TM_STOP);
                        print_result(D_IGE_256_AES, j, count, d);
                }
        }
@@ -1303,10 +1294,10 @@
 
                for (j = 0; j < SIZE_NUM; j++) {
                        print_message(names[D_GHASH], c[D_GHASH][j], 
lengths[j]);
-                       Time_F(START);
+                       Time_F(TM_START);
                        for (count = 0, run = 1; COND(c[D_GHASH][j]); count++)
                                CRYPTO_gcm128_aad(ctx, buf, lengths[j]);diff 
-Nur libressl-2.1.0/apps/s_time.c 
diff -Nur libressl-2.1.0/apps/s_time.c libssl/apps/s_time.c
--- libressl-2.1.0/apps/s_time.c        2014-10-11 18:58:11.000000000 +0200
+++ libssl/apps/s_time.c        2014-10-14 17:43:31.406746753 +0200
@@ -297,8 +297,6 @@
 /***********************************************************************
  * TIME - time functions
  */
-#define START  0
-#define STOP   1
 
 static double
 tm_Time_F(int s)
@@ -365,7 +363,7 @@
 
        bytes_read = 0;
        finishtime = (long) time(NULL) + maxTime;
-       tm_Time_F(START);
+       tm_Time_F(TM_START);
        for (;;) {
                if (finishtime < (long) time(NULL))
                        break;
@@ -411,7 +409,7 @@
                SSL_free(scon);
                scon = NULL;
        }
-       totalTime += tm_Time_F(STOP);   /* Add the time for this iteration */
+       totalTime += tm_Time_F(TM_STOP);        /* Add the time for this 
iteration */
 
        i = (int) ((long) time(NULL) - finishtime + maxTime);
        printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes 
read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read);
@@ -457,7 +455,7 @@
 
        printf("starting\n");
        bytes_read = 0;
-       tm_Time_F(START);
+       tm_Time_F(TM_START);
 
        for (;;) {
                if (finishtime < (long) time(NULL))
@@ -501,7 +499,7 @@
                fputc(ver, stdout);
                fflush(stdout);
        }
-       totalTime += tm_Time_F(STOP);   /* Add the time for this iteration */
+       totalTime += tm_Time_F(TM_STOP);        /* Add the time for this 
iteration */
 
 
        printf("\n\n%d connections in %.2fs; %.2f connections/user sec, bytes 
read %ld\n", nConn, totalTime, ((double) nConn / totalTime), bytes_read);

Reply via email to