about summary refs log tree commit diff
path: root/lib/util/wordaccess.h
diff options
context:
space:
mode:
Diffstat (limited to 'lib/util/wordaccess.h')
-rw-r--r--lib/util/wordaccess.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/lib/util/wordaccess.h b/lib/util/wordaccess.h
index 28963aee..2eaa2b24 100644
--- a/lib/util/wordaccess.h
+++ b/lib/util/wordaccess.h
@@ -36,28 +36,39 @@
    work with that.
 
    We also assume that a char is 8 bits.
+
+   HAVE_GCC_BITCOUNT and HAVE_GCC_BSWAP are set in pm_config.h
+
+   BITS_PER_LONG is the number of bits in long int.
 */
-#if (!defined(WORDACCESS_GENERIC) \
-     && defined(__GNUC__) && defined(__GLIBC__) \
-     && (__GNUC__ * 100 + __GNUC_MINOR__ >= 304) )
 
-    #if BYTE_ORDER==BIG_ENDIAN    /* defined by GCC */
+#include "pm_config.h"
 
-        #include "wordaccess_gcc3_be.h"
+#if (!defined(WORDACCESS_GENERIC) && HAVE_GCC_BITCOUNT )
 
-    #elif defined(__ia64__) || defined(__amd64__) || defined(__x86_64__)
-         /* all these macros are defined by GCC */
+    #if BYTE_ORDER == BIG_ENDIAN    /* See pm_config.h */
+        /* Sun Sparc 64, etc */ 
+        #include "wordaccess_gcc3_be.h"
 
+    #elif (BITS_PER_LONG == 64)
+        /* AMD Athlon 64, Intel x86_64, Intel Itanium, etc. */
         #include "wordaccess_64_le.h"
 
-    #else
+    #elif (BITS_PER_LONG == 32)
+        /* Intel x86_32 (80386, 80486, Pentium), etc. */
+        #include "wordaccess_generic.h"
 
-        #include "wordaccess_gcc3_le.h"
+    #else
+        /* Extremely rare case.
+           If long is neither 32 nor 64 bits, (say, 128) it comes here.
+        */
+        #define WORDACCESS_GENERIC
+        #include "wordaccess_generic.h"
 
     #endif
 
 #else
-
+    /* Non GCC, GCC prior to v.3.4 or WORDACCESS_GENERIC defined  */
     #include "wordaccess_generic.h"
 
 #endif