I am trying to call cpuid before my rdtsc function to prevent out of order. I initially used this rdtsc function to get 2 timestamps and often I get negative numbers, which is undesirable. This is the rdtsc function, how should I implement cpuid? Or is it called int the main function?
inline uint64_t rdtsc() {
unsigned long a, d;
asm volatile ("rdtsc":"=a" (a), "=d" (d));
return a | ((uint16_t)d << 32);
}