Skip to content

Commit

Permalink
Merge pull request #27 from crozone/msc-sse-detection
Browse files Browse the repository at this point in the history
Added SSE version check for MSC
  • Loading branch information
crozone authored Sep 25, 2018
2 parents c712f90 + 0b5a9c3 commit 856f80f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
11 changes: 9 additions & 2 deletions spectre.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,20 @@
#pragma optimize("gt",on)
#else
#include <x86intrin.h> /* 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
Expand Down

0 comments on commit 856f80f

Please sign in to comment.