diff options
author | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-04 17:07:27 +0000 |
---|---|---|
committer | vlefevre <vlefevre@280ebfd0-de03-0410-8827-d642c229c3f4> | 2017-05-04 17:07:27 +0000 |
commit | a59c822fd6769cc2008c8090a468a67693836086 (patch) | |
tree | 1db4f29f014df75f784a023137e481f4ff441ee3 /tools/mbench | |
parent | eb860a4021ff2de78daacb191c11ccaefdbb562f (diff) | |
download | mpfr-a59c822fd6769cc2008c8090a468a67693836086.tar.gz |
[tools/mbench/timp.h] Fixed overflows on unsigned arithmetic.
git-svn-id: svn://scm.gforge.inria.fr/svn/mpfr/trunk@11458 280ebfd0-de03-0410-8827-d642c229c3f4
Diffstat (limited to 'tools/mbench')
-rw-r--r-- | tools/mbench/timp.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/mbench/timp.h b/tools/mbench/timp.h index 858f803b4..a9132eff5 100644 --- a/tools/mbench/timp.h +++ b/tools/mbench/timp.h @@ -158,13 +158,13 @@ static unsigned long long int timp_overhead = 0; timp_rdtsc_before(num_cycle); \ CODE; \ timp_rdtsc_after(num_cycle2); \ - num_cycle = num_cycle2 - num_cycle; \ + num_cycle = num_cycle2 < num_cycle ? 0 : num_cycle2 - num_cycle; \ if (num_cycle < min_num_cycle) \ min_num_cycle = num_cycle; \ if (num_cycle2 - start_num_cycle > TIMP_MAX_WAIT_FOR_MEASURE) \ break; \ } \ - min_num_cycle - timp_overhead; }) + min_num_cycle < timp_overhead ? 0 : min_num_cycle - timp_overhead; }) #define TIMP_OVERHEAD() \ (timp_overhead = 0, timp_overhead = TIMP_MEASURE((void) 0) ) |