Commit 15a258b0 authored by Benjamin Kramer's avatar Benjamin Kramer Committed by Commit Bot

[assembler] Don't define the reserved name _xgetbv

_xgetbv is reserved for the implementation and shouldn't be used by user
code. Newer GCCs and clang trunk define _xgetbv, leading to a name
collision if xsaveintrin.h gets included transitively.

This unbreaks building v8 with clang trunk and libstdc++ 4.9, which
happens to pull in xsaveintrin.h transitively through <algorithm>. Newer
versions of libstdc++ don't seem to do that anymore which is why this
issue never showed up before.

R=bmeurer@chromium.org

Change-Id: If94efaf4798e5420738064bcbf26880f904c76a9
Reviewed-on: https://chromium-review.googlesource.com/c/1414858Reviewed-by: 's avatarBenedikt Meurer <bmeurer@chromium.org>
Commit-Queue: Benedikt Meurer <bmeurer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#58849}
parent 1a3aab51
......@@ -31,9 +31,10 @@ namespace internal {
namespace {
#if !V8_LIBC_MSVCRT
V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
V8_INLINE uint64_t xgetbv(unsigned int xcr) {
#if V8_LIBC_MSVCRT
return _xgetbv(xcr);
#else
unsigned eax, edx;
// Check xgetbv; this uses a .byte sequence instead of the instruction
// directly because older assemblers do not include support for xgetbv and
......@@ -41,13 +42,9 @@ V8_INLINE uint64_t _xgetbv(unsigned int xcr) {
// used.
__asm__ volatile(".byte 0x0F, 0x01, 0xD0" : "=a"(eax), "=d"(edx) : "c"(xcr));
return static_cast<uint64_t>(eax) | (static_cast<uint64_t>(edx) << 32);
#endif
}
#define _XCR_XFEATURE_ENABLED_MASK 0
#endif // !V8_LIBC_MSVCRT
bool OSHasAVXSupport() {
#if V8_OS_MACOSX
// Mac OS X up to 10.9 has a bug where AVX transitions were indeed being
......@@ -67,7 +64,7 @@ bool OSHasAVXSupport() {
if (kernel_version_major <= 13) return false;
#endif // V8_OS_MACOSX
// Check whether OS claims to support AVX.
uint64_t feature_mask = _xgetbv(_XCR_XFEATURE_ENABLED_MASK);
uint64_t feature_mask = xgetbv(0); // XCR_XFEATURE_ENABLED_MASK
return (feature_mask & 0x6) == 0x6;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment