Skip to content

Commit

Permalink
Disable FMA3 when compiling with VS2013 (#2308)
Browse files Browse the repository at this point in the history
* Disable FMA3 when compiling with VS2013

* Add Win64 job to AppVeyor CI
  • Loading branch information
am11 authored and xzyfer committed Jan 30, 2017
1 parent 1849092 commit 27437bc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
8 changes: 6 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ environment:
matrix:
- Compiler: msvc
Config: Release
Platform: Win32
- Compiler: msvc
Config: Debug
Platform: Win32
- Compiler: msvc
Config: Release
Platform: Win64
- Compiler: mingw
Build: static
- Compiler: mingw
Expand Down Expand Up @@ -38,7 +43,7 @@ build_script:
if ($env:Compiler -eq "mingw") {
mingw32-make -j4 sassc
} else {
msbuild /m:4 /p:Configuration=$env:Config sassc\win\sassc.sln
msbuild /m:4 /p:"Configuration=$env:Config;Platform=$env:Platform" sassc\win\sassc.sln
}
# print the branding art
Expand Down Expand Up @@ -84,4 +89,3 @@ test_script:
} else {
echo "Success!"
}
11 changes: 11 additions & 0 deletions src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,22 @@

#include <cmath>
#include <stdint.h>
#if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64)
#include <mutex>
#endif

namespace Sass {

double round(double val, size_t precision)
{
// Disable FMA3-optimized implementation when compiling with VS2013 for x64 targets
// See https://github.com/sass/node-sass/issues/1854 for details
// FIXME: Remove this workaround when we switch to VS2015+
#if defined(_MSC_VER) && _MSC_VER >= 1800 && _MSC_VER < 1900 && defined(_M_X64)
static std::once_flag flag;
std::call_once(flag, []() { _set_FMA3_enable(0); });
#endif

// https://github.com/sass/sass/commit/4e3e1d5684cc29073a507578fc977434ff488c93
if (fmod(val, 1) - 0.5 > - std::pow(0.1, precision + 1)) return std::ceil(val);
else if (fmod(val, 1) - 0.5 > std::pow(0.1, precision)) return std::floor(val);
Expand Down

0 comments on commit 27437bc

Please sign in to comment.