This should do the trink in gcc:
#include <linux/types.h>
inline void read_tsc(u_int64_t *tsc){
__asm__ __volatile__(
"rdtsc\n\t"
: "=A" (*tsc)
);
}
Though my gcc inline asm syntax is a bit rusty.
On Thu, May 24, 2001 at 08:08:11PM +0100, Paul Kelly wrote:
> Anthony Harrington wrote:
>> > Can anyone tell me a system call for measuring time in nano-seconds ?
>>> I don't believe there is one. The overhead of a syscall will affect your
> timing anyway. Your best bet is probably the TSC - a CPU register on
> i586 class CPUs. It's a counter increments every clock cycle, so the
> resolution - and the answer you get from it - depends on the clock speed
> of the CPU. Have a look in the source of UAE for an example of how to
> use it.
>> Not what you'd call portable, but it gets the job done.
>> Paul.
>>> --
> Irish Linux Users' Group: ilug at linux.ie>http://www.linux.ie/mailman/listinfo/ilug for (un)subscription information.
> List maintainer: listmaster at linux.ie
--
Martin
--
Bother! cried Pooh, as he sold Eeyore to the glue factory.
Maintained by the ILUG website team. The aim of Linux.ie is to
support and help commercial and private users of Linux in Ireland. You can
display ILUG news in your own webpages, read backend
information to find out how. Networking services kindly provided by HEAnet, server kindly donated by
Dell. Linux is a trademark of Linus Torvalds,
used with permission. No penguins were harmed in the production or maintenance
of this highly praised website. Looking for the
Indian Linux Users' Group? Try here. If you've read all this and aren't a lawyer: you should be!