Last-Update: 2015-01-26
Forwarded: https://code.google.com/p/crcutil/issues/detail?id=6
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
Description: Fix FTBFS by introducing <cpuid.h> which should be universally
             available as part of GCC 4.4 and above. Please review.
~~~~
 libtool: compile:  g++ -DHAVE_CONFIG_H -I. -D_FORTIFY_SOURCE=2 -mcrc32 -msse2 -DCRCUTIL_USE_ASM=0 -DCRCUTIL_USE_MM_CRC32=1 -Wall -msse2 -Icode -g -O2 -fstack-protector-strong -Wformat -Werror=format-security -c code/multiword_128_64_gcc_amd64_sse2.cc -fPIE -o code/multiword_128_64_gcc_amd64_sse2.o >/dev/null 2>&1
 code/crc32c_sse4.cc: In static member function 'static bool crcutil::Crc32cSSE4::IsSSE42Available()':
 code/crc32c_sse4.cc:331:4: error: PIC register clobbered by '%ebx' in 'asm'
    );
     ^
 Makefile:685: recipe for target 'code/crc32c_sse4.lo' failed
~~~~

--- a/code/crc32c_sse4.cc
+++ b/code/crc32c_sse4.cc
@@ -18,8 +18,9 @@
 
 #include "crc32c_sse4.h"
 
 #if HAVE_I386 || HAVE_AMD64
+#include <cpuid.h>
 
 namespace crcutil {
 
 #define UPDATE_STRIPE_CRCS(index, block_size, num_stripes) do { \
@@ -310,8 +311,14 @@
 #if defined(_MSC_VER)
   int cpu_info[4];
   __cpuid(cpu_info, 1);
   return ((cpu_info[3] & (1 << 20)) != 0);
+#else
+  unsigned int eax, ebx, ecx;
+  unsigned int cpuid_edx=0;
+  __get_cpuid(1, &eax, &ebx, &ecx, &cpuid_edx);
+  return ((ecx & (1 << 20)) != 0);
+/*
 #elif defined(__GNUC__) && (HAVE_AMD64 || HAVE_I386)
   // Not using "cpuid.h" intentionally: it is missing from
   // too many installations.
   uint32 eax;
@@ -331,8 +338,9 @@
   );
   return ((ecx & (1 << 20)) != 0);
 #else
   return false;
+*/
 #endif
 }
 
 
