From c3b166a6cf55afaeea5bbc94ebb275b92efbd3d8 Mon Sep 17 00:00:00 2001 From: Henrik Gramner Date: Sat, 4 May 2013 16:21:32 +0200 Subject: [PATCH] checkasm: Use 64-bit cycle counters Prevents overflows that can occur in some cases. --- tools/checkasm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tools/checkasm.c b/tools/checkasm.c index 4aaa4450..ba363ef0 100644 --- a/tools/checkasm.c +++ b/tools/checkasm.c @@ -61,7 +61,7 @@ typedef struct { void *pointer; // just for detecting duplicates uint32_t cpu; - uint32_t cycles; + uint64_t cycles; uint32_t den; } bench_t; @@ -137,12 +137,12 @@ static int cmp_bench( const void *a, const void *b ) static void print_bench(void) { - uint16_t nops[10000] = {0}; + uint16_t nops[10000]; int nfuncs, nop_time=0; for( int i = 0; i < 10000; i++ ) { - int t = read_time(); + uint32_t t = read_time(); nops[i] = read_time() - t; } qsort( nops, 10000, sizeof(uint16_t), cmp_nop ); @@ -241,7 +241,7 @@ void x264_checkasm_stack_clobber( uint64_t clobber, ... ); #define call_bench(func,cpu,...)\ if( do_bench && !strncmp(func_name, bench_pattern, bench_pattern_len) )\ {\ - uint32_t tsum = 0;\ + uint64_t tsum = 0;\ int tcount = 0;\ call_a1(func, __VA_ARGS__);\ for( int ti = 0; ti < (cpu?BENCH_RUNS:BENCH_RUNS/4); ti++ )\ @@ -252,7 +252,7 @@ void x264_checkasm_stack_clobber( uint64_t clobber, ... ); func(__VA_ARGS__);\ func(__VA_ARGS__);\ t = read_time() - t;\ - if( t*tcount <= tsum*4 && ti > 0 )\ + if( (uint64_t)t*tcount <= tsum*4 && ti > 0 )\ {\ tsum += t;\ tcount++;\ -- 2.47.3