From 2eee902be331607154646ca88ac34526a65ca374 Mon Sep 17 00:00:00 2001 From: Paul Bakker Date: Sun, 24 Apr 2011 15:28:55 +0000 Subject: [PATCH] - Better timer for Windows platforms - Made alarmed volatile for better Windows compatibility --- include/polarssl/timing.h | 2 +- library/timing.c | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/include/polarssl/timing.h b/include/polarssl/timing.h index 456508d450..355c63c779 100644 --- a/include/polarssl/timing.h +++ b/include/polarssl/timing.h @@ -39,7 +39,7 @@ struct hr_time extern "C" { #endif -extern int alarmed; +extern volatile int alarmed; /** * \brief Return the CPU cycle counter value diff --git a/library/timing.c b/library/timing.c index 109f70f354..94c36d13c8 100644 --- a/library/timing.c +++ b/library/timing.c @@ -136,6 +136,18 @@ unsigned long hardclock( void ) return( itc ); } +#else +#if defined(_MSC_VER) + +unsigned long hardclock( void ) +{ + LARGE_INTEGER offset; + + QueryPerformanceCounter( &offset ); + + return (unsigned long)( offset.QuadPart ); +} + #else static int hardclock_init = 0; @@ -157,6 +169,7 @@ unsigned long hardclock( void ) } #endif /* generic */ +#endif /* WIN32 */ #endif /* IA-64 */ #endif /* Alpha */ #endif /* SPARC8 */ @@ -164,7 +177,7 @@ unsigned long hardclock( void ) #endif /* AMD64 */ #endif /* i586+ */ -int alarmed = 0; +volatile int alarmed = 0; #if defined(_WIN32)