[PATCH] drivescan/misc: arch stuff
authorJens Axboe <axboe@suse.de>
Tue, 8 Nov 2005 19:10:13 +0000 (20:10 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 8 Nov 2005 19:10:13 +0000 (20:10 +0100)
arch-alpha.h
arch-ia64.h
arch-ppc.h
arch-s390.h
arch-x86.h
arch-x86_64.h
arch.h
drivescan.c

index 84eea86f201a6999686515bfb86918e7886ae5ca..49c7b1b2ee906bf2e2fd397b8d7dac72edd4aaed 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ARCH_ALPHA_H
 #define ARCH_ALPHA_H
 
+static int arch = arch_alpha;
+
+#define BITS_PER_LONG  (64)
+
 #ifndef __NR_ioprio_set
 #define __NR_ioprio_set                442
 #define __NR_ioprio_get                443
index af9f649b2d4589d029d8be1d18f4bb5c899ae6ff..ea6d7ddbab468540417a5bcf1ecbb18ca1036585 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ARCH_IA64_H
 #define ARCH_IA64_H
 
+static int arch = arch_ia64;
+
+#define BITS_PER_LONG  (64)
+
 #ifndef __NR_ioprio_set
 #define __NR_ioprio_set                1274
 #define __NR_ioprio_get                1275
index e822027cc25a19fffa5dd7b3795445293bc03c3b..a5c6a595f410facea14e86fe91667006b911e301 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ARCH_PPC_H
 #define ARCH_PPH_H
 
+static int arch = arch_ppc;
+
+#define BITS_PER_LONG  (32)
+
 #ifndef __NR_ioprio_set
 #define __NR_ioprio_set                273
 #define __NR_ioprio_get                274
index 4616ed0053d9802b9029662a2e8b6ed103da44f2..54d935426a203bea60bd436256b0adf785b7a3fd 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ARCH_S390_H
 #define ARCH_S390_H
 
+static int arch = arch_s390;
+
+#define BITS_PER_LONG  (64)
+
 #ifndef __NR_ioprio_set
 #define __NR_ioprio_set                282
 #define __NR_ioprio_get                283
index 39b77cc9ac5f1efc7ecc1f61d6348ffd264be303..483e60ce744e709d7e4e043225195392ab2a2251 100644 (file)
@@ -1,6 +1,9 @@
 #ifndef ARCH_X86_H
 #define ARCH_X86_H
 
+static int arch = arch_i386;
+
+#define BITS_PER_LONG  (32)
 
 #ifndef __NR_ioprio_set
 #define __NR_ioprio_set                289
index aca13850fc92ba8273d4b9e30952dd643b4563f5..2ef5365d507a6d00e81b285938a53ffa27e1df57 100644 (file)
@@ -1,6 +1,10 @@
 #ifndef ARCH_X86_64_h
 #define ARCH_X86_64_h
 
+static int arch = arch_x86_64;
+
+#define BITS_PER_LONG  (64)
+
 #ifndef __NR_ioprio_set
 #define __NR_ioprio_set                251
 #define __NR_ioprio_get                252
diff --git a/arch.h b/arch.h
index 32884161ade25111d2e5774e22f76446246ba736..c6adf410e78290ffdac3edbbbe1cadba539e6ee2 100644 (file)
--- a/arch.h
+++ b/arch.h
@@ -1,6 +1,15 @@
 #ifndef ARCH_H
 #define ARCH_H
 
+enum {
+       arch_x86_64,
+       arch_i386,
+       arch_ppc,
+       arch_ia64,
+       arch_s390,
+       arch_alpha,
+};
+
 #if defined(__i386__)
 #include "arch-x86.h"
 #elif defined(__x86_64__)
index 3d10df74c6fe0890251649c52655b43ef102a458..e4299edf7eaa67ea227876ed7832028199fc7457 100644 (file)
 #include <sys/time.h>
 #include <sys/stat.h>
 
-enum {
-       arch_x86_64,
-       arch_i386,
-       arch_ppc,
-       arch_ia64,
-};
-
-#if defined(__x86_64)
-#define BITS_PER_LONG 64
-static int arch = arch_x86_64;
-inline unsigned long ffz(unsigned long bitmask)
-{
-       __asm__("bsfq %1,%0" :"=r" (bitmask) :"r" (~bitmask));
-       return bitmask;
-}
-#elif defined (__i386__)
-#define BITS_PER_LONG 32
-static int arch = arch_i386;
-inline unsigned long ffz(unsigned long bitmask)
-{
-       __asm__("bsfl %1,%0" :"=r" (bitmask) :"r" (~bitmask));
-       return bitmask;
-}
-#elif defined (__powerpc__)
-#define BITS_PER_LONG 32
-static int arch = arch_ppc;
-inline int __ilog2(unsigned long bitmask)
-{
-       int lz;
-
-       asm ("cntlzw %0,%1" : "=r" (lz) : "r" (bitmask));
-       return 31 - lz;
-}
-
-static inline int ffz(unsigned long bitmask)
-{
-       if ((bitmask = ~bitmask) == 0)
-               return 32;
-       return  __ilog2(bitmask & -bitmask);
-}
-#elif defined(__ia64__)
-#define BITS_PER_LONG 64
-static int arch = arch_ia64;
-#define ia64_popcnt(x)                                                 \
-({                                                                     \
-       unsigned long ia64_intri_res;                                   \
-       asm ("popcnt %0=%1" : "=r" (ia64_intri_res) : "r" (x));         \
-       ia64_intri_res;                                                 \
-})
-inline unsigned long ffz(unsigned long bitmask)
-{
-       return ia64_popcnt(bitmask & (~bitmask - 1));
-}
-#else
-#error "Unsupported architecture"
-#endif
+#include "arch.h"
 
 #if BITS_PER_LONG == 32
 typedef unsigned long long u64;