Disable crypto benchmarking if CLOCK_THREAD_CPUTIME_ID is not available.

This commit is contained in:
Tobias Brunner
2012-01-30 11:04:55 +01:00
parent 023800ba62
commit 7171d8765e
+10
View File
@@ -102,6 +102,8 @@ static const char* get_name(void *sym)
return "unknown"; return "unknown";
} }
#ifdef CLOCK_THREAD_CPUTIME_ID
/** /**
* Start a benchmark timer * Start a benchmark timer
*/ */
@@ -122,6 +124,14 @@ static u_int end_timing(struct timespec *start)
(end.tv_sec - start->tv_sec) * 1000; (end.tv_sec - start->tv_sec) * 1000;
} }
#else /* CLOCK_THREAD_CPUTIME_ID */
/* Make benchmarking a no-op if CLOCK_THREAD_CPUTIME_ID is not available */
#define start_timing(start) ((start)->tv_sec = 0, (start)->tv_nsec = 0)
#define end_timing(...) (this->bench_time)
#endif /* CLOCK_THREAD_CPUTIME_ID */
/** /**
* Benchmark a crypter * Benchmark a crypter
*/ */