[PATCH] Don't compile crc32c-intel on non-x86 platforms

From: Aaron Carroll <aaronc_at_cse.unsw.edu.au>
Date: Fri, 12 Sep 2008 18:38:29 +1000

crc32c_intel() doesn't make sense on platforms without SSE, so alias it
to crc32c() on such machines.

Signed-off-by: Aaron Carroll <aaronc_at_gelato.unsw.edu.au>

---
 arch/arch-x86.h    |    1 +
 arch/arch-x86_64.h |    1 +
 crc/crc32c-intel.c |    6 ++++++
 crc/crc32c.h       |    7 +++++++
 4 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/arch/arch-x86.h b/arch/arch-x86.h
index 97262ff..9631437 100644
--- a/arch/arch-x86.h
+++ b/arch/arch-x86.h
@@ -39,5 +39,6 @@ static inline unsigned long arch_ffz(unsigned long bitmask)
 	return bitmask;
 }
 #define ARCH_HAVE_FFZ
+#define ARCH_HAVE_SSE
 
 #endif
diff --git a/arch/arch-x86_64.h b/arch/arch-x86_64.h
index 216e74e..457714c 100644
--- a/arch/arch-x86_64.h
+++ b/arch/arch-x86_64.h
@@ -39,5 +39,6 @@ static inline unsigned int arch_ffz(unsigned int bitmask)
 	return bitmask;
 }
 #define ARCH_HAVE_FFZ
+#define ARCH_HAVE_SSE
 
 #endif
diff --git a/crc/crc32c-intel.c b/crc/crc32c-intel.c
index c0abe73..cec5ad5 100644
--- a/crc/crc32c-intel.c
+++ b/crc/crc32c-intel.c
@@ -1,4 +1,5 @@
 #include <inttypes.h>
+#include "crc32c.h"
 
 /*
  * Based on a posting to lkml by Austin Zhang <austin.zhang_at_intel.com>
@@ -11,6 +12,8 @@
  * Volume 2A: Instruction Set Reference, A-M
  */
 
+#ifdef ARCH_HAVE_SSE
+
 #if BITS_PER_LONG == 64
 #define REX_PRE "0x48, "
 #define SCALE_F 8
@@ -64,3 +67,6 @@ uint32_t crc32c_intel(unsigned char const *data, unsigned long length)
 
 	return crc;
 }
+
+#endif /* ARCH_HAVE_SSE */
+
diff --git a/crc/crc32c.h b/crc/crc32c.h
index cf17136..0976261 100644
--- a/crc/crc32c.h
+++ b/crc/crc32c.h
@@ -18,7 +18,14 @@
 #ifndef CRC32C_H
 #define CRC32C_H
 
+#include "../arch/arch.h"
+
 extern uint32_t crc32c(unsigned char const *, unsigned long);
+
+#ifdef ARCH_HAVE_SSE
 extern uint32_t crc32c_intel(unsigned char const *, unsigned long);
+#else
+#define crc32c_intel crc32c
+#endif
 
 #endif
-- 
1.5.4.5
Received on Fri Sep 12 2008 - 10:38:29 CEST

This archive was generated by hypermail 2.2.0 : Fri Sep 12 2008 - 11:00:02 CEST