]> git.ipfire.org Git - thirdparty/strongswan.git/commitdiff
Disable crypto benchmarking if CLOCK_THREAD_CPUTIME_ID is not available.
authorTobias Brunner <tobias@strongswan.org>
Mon, 30 Jan 2012 10:04:55 +0000 (11:04 +0100)
committerTobias Brunner <tobias@strongswan.org>
Mon, 30 Jan 2012 10:04:55 +0000 (11:04 +0100)
src/libstrongswan/crypto/crypto_tester.c

index 4635dccea467a734b136059b5911b4b3b5d21c96..8b1daa885f8703c7e594438b59c8fcbe0112e8a4 100644 (file)
@@ -102,6 +102,8 @@ static const char* get_name(void *sym)
        return "unknown";
 }
 
+#ifdef CLOCK_THREAD_CPUTIME_ID
+
 /**
  * Start a benchmark timer
  */
@@ -122,6 +124,14 @@ static u_int end_timing(struct timespec *start)
                        (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
  */