From 37973b87055c0a7a79e1d1eab36c26f8202e09da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Thu, 30 Oct 2014 12:56:47 +0000 Subject: [PATCH] Use CLOCK_MONOTONIC instead of the non-standard CLOCK_MONOTONIC_PRECISE. Use librt if required for clock_gettime(2). --- t/Makefile.am | 3 ++- t/t_md2.c | 4 ++-- t/t_md4.c | 4 ++-- t/t_md5.c | 4 ++-- t/t_sha1.c | 4 ++-- t/t_sha224.c | 4 ++-- t/t_sha256.c | 4 ++-- t/t_sha384.c | 4 ++-- t/t_sha512.c | 4 ++-- 9 files changed, 18 insertions(+), 17 deletions(-) diff --git a/t/Makefile.am b/t/Makefile.am index 3efeb2d..40199af 100644 --- a/t/Makefile.am +++ b/t/Makefile.am @@ -8,7 +8,8 @@ check_LTLIBRARIES = libt.la libt_la_SOURCES = t_main.c t_file.c t_util.c t_const.c t_malloc.c # Link in the test driver and the full cryb library -LDADD = $(builddir)/libt.la \ +LDADD = ${RT_LIBS} \ + $(builddir)/libt.la \ $(top_builddir)/lib/core/libcryb-core.la \ $(top_builddir)/lib/enc/libcryb-enc.la \ $(top_builddir)/lib/digest/libcryb-digest.la \ diff --git a/t/t_md2.c b/t/t_md2.c index a5fbb06..566c74c 100644 --- a/t/t_md2.c +++ b/t/t_md2.c @@ -179,10 +179,10 @@ t_md2_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_md2_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_md4.c b/t/t_md4.c index 37de91d..d9206d3 100644 --- a/t/t_md4.c +++ b/t/t_md4.c @@ -195,10 +195,10 @@ t_md4_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_md4_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_md5.c b/t/t_md5.c index b12c1a0..d26b0fe 100644 --- a/t/t_md5.c +++ b/t/t_md5.c @@ -195,10 +195,10 @@ t_md5_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_md5_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_sha1.c b/t/t_sha1.c index 0f36222..94ea5ce 100644 --- a/t/t_sha1.c +++ b/t/t_sha1.c @@ -191,10 +191,10 @@ t_sha1_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha1_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_sha224.c b/t/t_sha224.c index 455f87b..64f93a1 100644 --- a/t/t_sha224.c +++ b/t/t_sha224.c @@ -200,10 +200,10 @@ t_sha224_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha224_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_sha256.c b/t/t_sha256.c index 17115d9..b096a24 100644 --- a/t/t_sha256.c +++ b/t/t_sha256.c @@ -196,10 +196,10 @@ t_sha256_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha256_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_sha384.c b/t/t_sha384.c index c530c69..72ae807 100644 --- a/t/t_sha384.c +++ b/t/t_sha384.c @@ -212,10 +212,10 @@ t_sha384_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha384_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec; diff --git a/t/t_sha512.c b/t/t_sha512.c index 460daef..61620ca 100644 --- a/t/t_sha512.c +++ b/t/t_sha512.c @@ -222,10 +222,10 @@ t_sha512_perf(char **desc, void *arg) if ((msg = calloc(1, msglen)) == NULL) err(1, "calloc()"); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &ts); + clock_gettime(CLOCK_MONOTONIC, &ts); for (int i = 0; i < T_PERF_ITERATIONS; ++i) t_sha512_complete(msg, msglen, digest); - clock_gettime(CLOCK_MONOTONIC_PRECISE, &te); + clock_gettime(CLOCK_MONOTONIC, &te); free(msg); ns = te.tv_sec * 1000000000LU + te.tv_nsec; ns -= ts.tv_sec * 1000000000LU + ts.tv_nsec;