1

I wrote a linux driver module (which is on x86_64), I just call rdtsc, but compiler printed:

error: implicit declaration of function 'rdtsc'

Which header file should I include?

Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58
superK
  • 3,932
  • 6
  • 30
  • 54
  • `__rdtsc()` from `immintrin.h` will inline to `rdtsc`, so you can use that ([Get CPU cycle count?](https://stackoverflow.com/a/51907627)). Or see the inline asm in mysticial's answer. – Peter Cordes Aug 18 '18 at 16:02

1 Answers1

0

Wrong uses of RDTSC

First I saw that you had used the "time" tag for your question. RDTSC is not a good thing to use for time. See Getting cpu cycles using RDTSC - why does the value of RDTSC always increase?

for an excellent explanation.

Answer

However if you DO want to use RDTSC functions, the are intel x86 architecture specific and its prototypes are found in linux-source/arch/asm/msr.h

Community
  • 1
  • 1
Ahmed Masud
  • 21,655
  • 3
  • 33
  • 58