diff --git a/src/main.cpp b/src/main.cpp index da263e1..247db05 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,3 +1,4 @@ +//https://bugs.llvm.org/show_bug.cgi?id=24232 #ifndef DEBUG #define DEBUG #endif @@ -6,17 +7,29 @@ #include #include "debug.h" +bool checkInvariantTSC(){ + uint64_t rdx; + asm volatile (".intel_syntax noprefix\t\n" \ + "mov eax, 0x80000007\t\n" \ + // 80000007H\t\n" + "cpuid\t\n" : "=d" (rdx) ); + bool iTSC = rdx & (1<<8); + //"and edx, 10000000\n") + return iTSC; +} //static inline uint64_t rdtscp()// uint32_t & aux ) { uint64_t raxlo,rdxho; - asm volatile ( "cpuid\n" \ + asm volatile ( ".intel_syntax noprefix\t\n" + "cpuid\n" \ //"rdtscp\n" : "=a" (raxlo), "=d" (rdxho), "=c" (aux) : : ); "rdtsc\n" : "=a" (raxlo), "=d" (rdxho)); - return (rdxho << 32) + raxlo; + return (rdxho << 32) + raxlo; //| } int main(int argc, char** argv){ + log_debugcpp(checkInvariantTSC()); uint64_t test = rdtscp(); log_debugcpp(test); return 0;