spectre-attack
spectre-attack copied to clipboard
how to compile the code in MacOS?
gcc output
spectre.c:83:21: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
time1 = __rdtscp(&junk); /* READ TIMER */
^~~~~
/Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.1.0/include/ia32intrin.h:71:24: note: passing argument to parameter '__A' here
__rdtscp(unsigned int *__A) {
^
spectre.c:85:21: warning: passing 'int *' to parameter of type 'unsigned int *' converts between pointers to integer types with different sign [-Wpointer-sign]
time2 = __rdtscp(&junk) - time1; /* READ TIMER & COMPUTE ELAPSED TIME */
^~~~~
/Library/Developer/CommandLineTools/usr/bin/../lib/clang/8.1.0/include/ia32intrin.h:71:24: note: passing argument to parameter '__A' here
__rdtscp(unsigned int *__A) {
^
ignore warning
./a.out
Try this implementation with pthread.h Should work on macos https://gist.github.com/Eugnis/3ba3f048988e7be76737ab87da64bb26
Compile on MacOS clang -O0 spectre-thread.c -o spectre && ./spectre
I found it to work today on MacOS with no modifications.