diff --git a/README.md b/README.md index 19ae1ac..dc0a48e 100644 --- a/README.md +++ b/README.md @@ -95,9 +95,12 @@ To build the project without all of the above instructions introduced with SSE2, `CFLAGS=-DNOSSE2 make` -This flag is automatically enabled if the `__SSE__` flag is present but `__SSE2__` is absent. +`NOSSE2` is automatically enabled if the `__SSE__` flag is present but `__SSE2__` is absent. This means `NOSSE2` shouldn't need to be manually specified when compiling on Clang or GCC on non-SSE2 processors. +On MSC, `NOSSE2` is automatically enabled if the `_M_IX86_FP` flag is set to `1` (indicating SSE support, but no SSE2 support). +MSC will set this by default for all x86 processors. + #### 'Target specific option mismatch' error Some 32-bit versions of gcc (e.g. the version used in Ubuntu 14.04) may show the following error while compiling the PoC: diff --git a/spectre.c b/spectre.c index 2f1ce8d..f7985a7 100644 --- a/spectre.c +++ b/spectre.c @@ -19,13 +19,20 @@ #pragma optimize("gt",on) #else #include /* for rdtsc, rdtscp, clflush */ +#endif /* ifdef _MSC_VER */ /* Automatically detect if SSE2 is not available when SSE is advertized */ -#if defined(__SSE__) && !defined(__SSE2__) +#ifdef _MSC_VER +/* MSC */ +#if _M_IX86_FP==1 #define NOSSE2 #endif - +#else +/* Not MSC */ +#if defined(__SSE__) && !defined(__SSE2__) +#define NOSSE2 #endif +#endif /* ifdef _MSC_VER */ #ifdef NOSSE2 #define NORDTSCP