From d6aebe108ad2bd54789b3a8f6ecc7e6a33c44333 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20P=C3=A9gouri=C3=A9-Gonnard?= Date: Thu, 27 Mar 2014 21:15:40 +0100 Subject: [PATCH] Add 'volatile' to hardclock()'s asm Prevents calls from being optimised away in timing_self_test(). (Should no be a problem for calls from other files.) --- library/timing.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/library/timing.c b/library/timing.c index c8fa653ceb..9a6129bf80 100644 --- a/library/timing.c +++ b/library/timing.c @@ -83,7 +83,7 @@ unsigned long hardclock( void ) unsigned long hardclock( void ) { unsigned long lo, hi; - asm( "rdtsc" : "=a" (lo), "=d" (hi) ); + asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) ); return( lo ); } #endif @@ -96,7 +96,7 @@ unsigned long hardclock( void ) unsigned long hardclock( void ) { unsigned long lo, hi; - asm( "rdtsc" : "=a" (lo), "=d" (hi) ); + asm volatile( "rdtsc" : "=a" (lo), "=d" (hi) ); return( lo | (hi << 32) ); } #endif @@ -112,9 +112,9 @@ unsigned long hardclock( void ) do { - asm( "mftbu %0" : "=r" (tbu0) ); - asm( "mftb %0" : "=r" (tbl ) ); - asm( "mftbu %0" : "=r" (tbu1) ); + asm volatile( "mftbu %0" : "=r" (tbu0) ); + asm volatile( "mftb %0" : "=r" (tbl ) ); + asm volatile( "mftbu %0" : "=r" (tbu1) ); } while( tbu0 != tbu1 ); @@ -133,7 +133,7 @@ unsigned long hardclock( void ) unsigned long hardclock( void ) { unsigned long tick; - asm( "rdpr %%tick, %0;" : "=&r" (tick) ); + asm volatile( "rdpr %%tick, %0;" : "=&r" (tick) ); return( tick ); } #endif @@ -147,8 +147,8 @@ unsigned long hardclock( void ) unsigned long hardclock( void ) { unsigned long tick; - asm( ".byte 0x83, 0x41, 0x00, 0x00" ); - asm( "mov %%g1, %0" : "=r" (tick) ); + asm volatile( ".byte 0x83, 0x41, 0x00, 0x00" ); + asm volatile( "mov %%g1, %0" : "=r" (tick) ); return( tick ); } #endif @@ -161,7 +161,7 @@ unsigned long hardclock( void ) unsigned long hardclock( void ) { unsigned long cc; - asm( "rpcc %0" : "=r" (cc) ); + asm volatile( "rpcc %0" : "=r" (cc) ); return( cc & 0xFFFFFFFF ); } #endif @@ -174,7 +174,7 @@ unsigned long hardclock( void ) unsigned long hardclock( void ) { unsigned long itc; - asm( "mov %0 = ar.itc" : "=r" (itc) ); + asm volatile( "mov %0 = ar.itc" : "=r" (itc) ); return( itc ); } #endif