# HG changeset patch # User nick # Date 1005492019 0 # Node ID b7d3b450f8fd584c1e9e87b18379aec416370790 # Parent 1b6c207c04102b8c83dc292cbfcd2921f7a8511f using volatile modifier diff -r 1b6c207c0410 -r b7d3b450f8fd my_profile.c --- a/my_profile.c Sun Nov 11 14:42:10 2001 +0000 +++ b/my_profile.c Sun Nov 11 15:20:19 2001 +0000 @@ -5,9 +5,8 @@ * * You can redistribute this file under terms and conditions * of GNU General Public licence v2. - * This file is partly based on vbetest.c from lrmi distributive. */ #include "my_profile.h" -unsigned long long int my_profile_start,my_profile_end,my_profile_total=0ULL; +volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; diff -r 1b6c207c0410 -r b7d3b450f8fd my_profile.h --- a/my_profile.h Sun Nov 11 14:42:10 2001 +0000 +++ b/my_profile.h Sun Nov 11 15:20:19 2001 +0000 @@ -5,12 +5,11 @@ * * You can redistribute this file under terms and conditions * of GNU General Public licence v2. - * This file is partly based on vbetest.c from lrmi distributive. */ #ifndef MY_PROFILE_INC #define MY_PROFILE_INC -extern unsigned long long int my_profile_start,my_profile_end,my_profile_total; +extern volatile unsigned long long int my_profile_start,my_profile_end,my_profile_total; #if defined ( ENABLE_PROFILE ) && defined ( ARCH_X86 ) static inline unsigned long long int read_tsc( void ) @@ -20,10 +19,11 @@ return retval; } -#define PROFILE_START() (my_profile_start=read_tsc()) -#define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=my_profile_end - my_profile_start; printf(your_message" current=%llu total=%llu\n\t",my_profile_end-my_profile_start,my_profile_total); } +#define PROFILE_RESET() (my_profile_total=0ULL) +#define PROFILE_START() { static int inited=0; if(!inited) { inited=1; my_profile_total=0ULL; } my_profile_start=read_tsc(); } +#define PROFILE_END(your_message) { my_profile_end=read_tsc(); my_profile_total+=(my_profile_end-my_profile_start); printf(your_message" current=%llu total=%llu\n\t",(my_profile_end-my_profile_start),my_profile_total); } #else -#define PROFILE_INIT() +#define PROFILE_RESET() #define PROFILE_START() #define PROFILE_END(your_message) #endif