Bug 1314762 - move #includes of system-y headers out of anonymous namespace in SSE.cpp; r=erahm
authorNathan Froyd <froydnj@mozilla.com>
Wed, 02 Nov 2016 16:19:35 -0400
changeset 347771 e38f9ff87d2ea70082a30d9c41a226753165226f
parent 347770 579eddccb01aafc9ece22a1b69530a03c8c2a79d
child 347772 93ffc634816940fa697c3af1d037b7bbeff709e9
push id10298
push userraliiev@mozilla.com
push dateMon, 14 Nov 2016 12:33:03 +0000
treeherdermozilla-aurora@7e29173b1641 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1314762
milestone52.0a1
Bug 1314762 - move #includes of system-y headers out of anonymous namespace in SSE.cpp; r=erahm #include'ing system headers inside anonymous namespaces seems to work OK with GCC and MSVC, but it does not work well with clang-cl in some compilation modes. Moving them out of the anonymous namespace makes everybody happy. MozReview-Commit-ID: K8AkYZEznzm
mozglue/build/SSE.cpp
--- a/mozglue/build/SSE.cpp
+++ b/mozglue/build/SSE.cpp
@@ -2,28 +2,33 @@
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 /* compile-time and runtime tests for whether to use SSE instructions */
 
 #include "SSE.h"
 
+#ifdef HAVE_CPUID_H
+// cpuid.h is available on gcc 4.3 and higher on i386 and x86_64
+#include <cpuid.h>
+#elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
+// MSVC 2005 or newer on x86-32 or x86-64
+#include <intrin.h>
+#endif
+
 namespace {
 
 // SSE.h has parallel #ifs which declare MOZILLA_SSE_HAVE_CPUID_DETECTION.
 // We can't declare these functions in the header file, however, because
 // <intrin.h> conflicts with <windows.h> on MSVC 2005, and some files want to
 // include both SSE.h and <windows.h>.
 
 #ifdef HAVE_CPUID_H
 
-// cpuid.h is available on gcc 4.3 and higher on i386 and x86_64
-#include <cpuid.h>
-
 enum CPUIDRegister { eax = 0, ebx = 1, ecx = 2, edx = 3 };
 
 static bool
 has_cpuid_bits(unsigned int level, CPUIDRegister reg, unsigned int bits)
 {
   unsigned int regs[4];
   unsigned int eax, ebx, ecx, edx;
   unsigned max = __get_cpuid_max(0, NULL);
@@ -40,19 +45,16 @@ has_cpuid_bits(unsigned int level, CPUID
 static uint64_t xgetbv(uint32_t xcr) {
     uint32_t eax, edx;
     __asm__ ( ".byte 0x0f, 0x01, 0xd0" : "=a"(eax), "=d"(edx) : "c"(xcr));
     return (uint64_t)(edx) << 32 | eax;
 }
 
 #elif defined(_MSC_VER) && (defined(_M_IX86) || defined(_M_AMD64))
 
-// MSVC 2005 or newer on x86-32 or x86-64
-#include <intrin.h>
-
 enum CPUIDRegister { eax = 0, ebx = 1, ecx = 2, edx = 3 };
 
 static bool
 has_cpuid_bits(unsigned int level, CPUIDRegister reg, unsigned int bits)
 {
   // Check that the level in question is supported.
   int regs[4];
   __cpuid(regs, level & 0x80000000u);