[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

inlined rdtsc() function in header file





Greetings!,

  I've been using the inline asm function David posted to the list a few
weeks ago.  It works great and avoids the assembly function call to a
single instruction ( tsc ) I had been using before.

I can't get it to reside in a header file which is included by two source
files that compiled and linked together to produce a single executable.
I get a redefinition error from gcc.  Actually, if I paste the code into
any two files which are linked together later, an error occurs.  Anyone
have any idea how to get the __inline__ function to work in multiple
source files which result in one binary?

Best regards,
Wayne  

/*
.- David Olofson -------------------------------------------.
`--------------------------------------> david@linuxdj.com -'
 __inline__ unsigned long long int rdtsc(void)
{
        unsigned long long int x;
        __asm__ volatile (".byte 0x0f, 0x31" : "=A" (x));
        return x;
}



--<<< We are committed to exceeding requirements >>>----->-+
C.W. Wright,wright@lidar.wff.nasa.gov,      Ph:757-824-1698
http://lidar.wff.nasa.gov                  Fax:603-925-6886      
NASA, Goddard Space Flight Center
Building N-159 Room E117, Code 972,Wallops Flight Facility
Wallops Island, Va. 23337   Telecommute phone: 410-742-7333
-------+-<-------------------------------------------------