Bug 1345331: Include <intrin.h> at top-level before lz4.c can include it in a namespace. r=Waldo
authorDavid Major <dmajor@mozilla.com>
Thu, 09 Mar 2017 15:11:15 +1300
changeset 394810 2cbbb3db5c533605f8d5de1ef48b2dd6cc285dda
parent 394809 db91cf168102b2a59f955f97ef7a1015fdfddb43
child 394811 261a33fad371b26e5343d0b31da2d18df0eff4a0
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersWaldo
bugs1345331
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1345331: Include <intrin.h> at top-level before lz4.c can include it in a namespace. r=Waldo MozReview-Commit-ID: 8CI8JgR3R1L
mfbt/Compression.cpp
--- a/mfbt/Compression.cpp
+++ b/mfbt/Compression.cpp
@@ -7,16 +7,25 @@
 #include "mozilla/Compression.h"
 #include "mozilla/CheckedInt.h"
 
 // Without including <string>, MSVC 2015 complains about e.g. the impossibility
 // to convert `const void* const` to `void*` when calling memchr from
 // corecrt_memory.h.
 #include <string>
 
+// Because we wrap lz4.c in an anonymous namespace, all of its #includes
+// go in the anonymous namespace too. This would create conflicting
+// declarations for intrinsic functions that are internally defined
+// at top-level. Including intrin.h here prevents it from being included
+// later within the anonymous namespace.
+#ifdef _MSC_VER
+#include <intrin.h>
+#endif
+
 using namespace mozilla::Compression;
 
 namespace {
 
 #include "lz4.c"
 
 }/* anonymous namespace */