i n v a r i a n t

This commit is contained in:
Hane 2023-07-11 22:26:24 +02:00
commit bf2df1ca01

View file

@ -1,3 +1,4 @@
//https://bugs.llvm.org/show_bug.cgi?id=24232
#ifndef DEBUG #ifndef DEBUG
#define DEBUG #define DEBUG
#endif #endif
@ -6,17 +7,29 @@
#include <iostream> #include <iostream>
#include "debug.h" #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 //static inline
uint64_t rdtscp()// uint32_t & aux ) uint64_t rdtscp()// uint32_t & aux )
{ {
uint64_t raxlo,rdxho; 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) : : ); //"rdtscp\n" : "=a" (raxlo), "=d" (rdxho), "=c" (aux) : : );
"rdtsc\n" : "=a" (raxlo), "=d" (rdxho)); "rdtsc\n" : "=a" (raxlo), "=d" (rdxho));
return (rdxho << 32) + raxlo; return (rdxho << 32) + raxlo; //|
} }
int main(int argc, char** argv){ int main(int argc, char** argv){
log_debugcpp(checkInvariantTSC());
uint64_t test = rdtscp(); uint64_t test = rdtscp();
log_debugcpp(test); log_debugcpp(test);
return 0; return 0;