From 79ca5d7aad63973c83a4962a66ab07cd623131ea Mon Sep 17 00:00:00 2001 From: niranjan-nilakantan <123265571+niranjan-nilakantan@users.noreply.github.com> Date: Tue, 23 May 2023 09:27:11 -0700 Subject: Add a declaration for __cpuid for the IntelLLVM compiler. Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1452 __cpuid is declared in intrin.h, but is excluded on non-Windows platforms. We add this declaration to compensate. Fixes #1358 PiperOrigin-RevId: 534449804 Change-Id: I91027f79d8d52c4da428d5c3a53e2cec00825c13 --- absl/crc/internal/cpu_detect.cc | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'absl/crc') diff --git a/absl/crc/internal/cpu_detect.cc b/absl/crc/internal/cpu_detect.cc index d61b7018..83838085 100644 --- a/absl/crc/internal/cpu_detect.cc +++ b/absl/crc/internal/cpu_detect.cc @@ -28,15 +28,12 @@ #include #endif -namespace absl { -ABSL_NAMESPACE_BEGIN -namespace crc_internal { - #if defined(__x86_64__) || defined(_M_X64) - -namespace { - -#if !defined(_WIN32) && !defined(_WIN64) +#if ABSL_HAVE_BUILTIN(__cpuid) +// MSVC-equivalent __cpuid intrinsic declaration for clang-like compilers +// for non-Windows build environments. +extern void __cpuid(int[4], int); +#elif !defined(_WIN32) && !defined(_WIN64) // MSVC defines this function for us. // https://learn.microsoft.com/en-us/cpp/intrinsics/cpuid-cpuidex static void __cpuid(int cpu_info[4], int info_type) { @@ -46,6 +43,15 @@ static void __cpuid(int cpu_info[4], int info_type) { : "a"(info_type), "c"(0)); } #endif // !defined(_WIN32) && !defined(_WIN64) +#endif // defined(__x86_64__) || defined(_M_X64) + +namespace absl { +ABSL_NAMESPACE_BEGIN +namespace crc_internal { + +#if defined(__x86_64__) || defined(_M_X64) + +namespace { enum class Vendor { kUnknown, -- cgit v1.2.3