diff options
author | Arnd Bergmann <arnd@arndb.de> | 2009-05-13 18:56:25 -0400 |
---|---|---|
committer | Arnd Bergmann <arnd@klappe2.(none)> | 2009-06-11 15:02:14 -0400 |
commit | c31ae4bb4a9fa4606a74c0a4fb61b74f804e861e (patch) | |
tree | 7694b1a05bc1ac660ac26eb9997200556ccd3933 /arch | |
parent | 63b852a6b67d0820d388b0ecd0da83ccb4048b8d (diff) |
asm-generic: introduce asm/bitsperlong.h
This provides a reliable way for asm-generic/types.h and other
files to find out if it is running on a 32 or 64 bit platform.
We cannot use CONFIG_64BIT for this in headers that are included
from user space because CONFIG symbols are not available there.
We also cannot do it inside of asm/types.h because some headers
need the word size but cannot include types.h.
The solution is to introduce a new header <asm/bitsperlong.h>
that defines both __BITS_PER_LONG for user space and
BITS_PER_LONG for usage in the kernel. The asm-generic
version falls back to 32 bit unless the architecture overrides
it, which I did for all 64 bit platforms.
Signed-off-by: Remis Lima Baima <remis.developer@googlemail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'arch')
28 files changed, 107 insertions, 46 deletions
diff --git a/arch/alpha/include/asm/bitsperlong.h b/arch/alpha/include/asm/bitsperlong.h new file mode 100644 index 000000000000..ad57f7868203 --- /dev/null +++ b/arch/alpha/include/asm/bitsperlong.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __ASM_ALPHA_BITSPERLONG_H | ||
2 | #define __ASM_ALPHA_BITSPERLONG_H | ||
3 | |||
4 | #define __BITS_PER_LONG 64 | ||
5 | |||
6 | #include <asm-generic/bitsperlong.h> | ||
7 | |||
8 | #endif /* __ASM_ALPHA_BITSPERLONG_H */ | ||
diff --git a/arch/alpha/include/asm/types.h b/arch/alpha/include/asm/types.h index f072f344497e..bd621ecd1eb3 100644 --- a/arch/alpha/include/asm/types.h +++ b/arch/alpha/include/asm/types.h | |||
@@ -25,9 +25,6 @@ typedef unsigned int umode_t; | |||
25 | * These aren't exported outside the kernel to avoid name space clashes | 25 | * These aren't exported outside the kernel to avoid name space clashes |
26 | */ | 26 | */ |
27 | #ifdef __KERNEL__ | 27 | #ifdef __KERNEL__ |
28 | |||
29 | #define BITS_PER_LONG 64 | ||
30 | |||
31 | #ifndef __ASSEMBLY__ | 28 | #ifndef __ASSEMBLY__ |
32 | 29 | ||
33 | typedef u64 dma_addr_t; | 30 | typedef u64 dma_addr_t; |
diff --git a/arch/arm/include/asm/bitsperlong.h b/arch/arm/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/arm/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/avr32/include/asm/bitsperlong.h b/arch/avr32/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/avr32/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/blackfin/include/asm/bitsperlong.h b/arch/blackfin/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/blackfin/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/cris/include/asm/bitsperlong.h b/arch/cris/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/cris/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/frv/include/asm/bitsperlong.h b/arch/frv/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/frv/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/h8300/include/asm/bitsperlong.h b/arch/h8300/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/h8300/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/ia64/include/asm/bitsperlong.h b/arch/ia64/include/asm/bitsperlong.h new file mode 100644 index 000000000000..ec4db3c970b7 --- /dev/null +++ b/arch/ia64/include/asm/bitsperlong.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __ASM_IA64_BITSPERLONG_H | ||
2 | #define __ASM_IA64_BITSPERLONG_H | ||
3 | |||
4 | #define __BITS_PER_LONG 64 | ||
5 | |||
6 | #include <asm-generic/bitsperlong.h> | ||
7 | |||
8 | #endif /* __ASM_IA64_BITSPERLONG_H */ | ||
diff --git a/arch/ia64/include/asm/types.h b/arch/ia64/include/asm/types.h index e36b3716e718..fbf1ed3b44ce 100644 --- a/arch/ia64/include/asm/types.h +++ b/arch/ia64/include/asm/types.h | |||
@@ -19,10 +19,6 @@ | |||
19 | # define __IA64_UL(x) (x) | 19 | # define __IA64_UL(x) (x) |
20 | # define __IA64_UL_CONST(x) x | 20 | # define __IA64_UL_CONST(x) x |
21 | 21 | ||
22 | # ifdef __KERNEL__ | ||
23 | # define BITS_PER_LONG 64 | ||
24 | # endif | ||
25 | |||
26 | #else | 22 | #else |
27 | # define __IA64_UL(x) ((unsigned long)(x)) | 23 | # define __IA64_UL(x) ((unsigned long)(x)) |
28 | # define __IA64_UL_CONST(x) x##UL | 24 | # define __IA64_UL_CONST(x) x##UL |
@@ -34,10 +30,7 @@ typedef unsigned int umode_t; | |||
34 | */ | 30 | */ |
35 | # ifdef __KERNEL__ | 31 | # ifdef __KERNEL__ |
36 | 32 | ||
37 | #define BITS_PER_LONG 64 | ||
38 | |||
39 | /* DMA addresses are 64-bits wide, in general. */ | 33 | /* DMA addresses are 64-bits wide, in general. */ |
40 | |||
41 | typedef u64 dma_addr_t; | 34 | typedef u64 dma_addr_t; |
42 | 35 | ||
43 | # endif /* __KERNEL__ */ | 36 | # endif /* __KERNEL__ */ |
diff --git a/arch/m32r/include/asm/bitsperlong.h b/arch/m32r/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/m32r/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/m68k/include/asm/bitsperlong.h b/arch/m68k/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/m68k/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/microblaze/include/asm/bitsperlong.h b/arch/microblaze/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/microblaze/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/mips/include/asm/bitsperlong.h b/arch/mips/include/asm/bitsperlong.h new file mode 100644 index 000000000000..3e4c10a8e787 --- /dev/null +++ b/arch/mips/include/asm/bitsperlong.h | |||
@@ -0,0 +1,8 @@ | |||
1 | #ifndef __ASM_MIPS_BITSPERLONG_H | ||
2 | #define __ASM_MIPS_BITSPERLONG_H | ||
3 | |||
4 | #define __BITS_PER_LONG _MIPS_SZLONG | ||
5 | |||
6 | #include <asm-generic/bitsperlong.h> | ||
7 | |||
8 | #endif /* __ASM_MIPS_BITSPERLONG_H */ | ||
diff --git a/arch/mips/include/asm/types.h b/arch/mips/include/asm/types.h index 7956e69a3bd5..544a2854598f 100644 --- a/arch/mips/include/asm/types.h +++ b/arch/mips/include/asm/types.h | |||
@@ -31,9 +31,6 @@ typedef unsigned short umode_t; | |||
31 | * These aren't exported outside the kernel to avoid name space clashes | 31 | * These aren't exported outside the kernel to avoid name space clashes |
32 | */ | 32 | */ |
33 | #ifdef __KERNEL__ | 33 | #ifdef __KERNEL__ |
34 | |||
35 | #define BITS_PER_LONG _MIPS_SZLONG | ||
36 | |||
37 | #ifndef __ASSEMBLY__ | 34 | #ifndef __ASSEMBLY__ |
38 | 35 | ||
39 | #if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \ | 36 | #if (defined(CONFIG_HIGHMEM) && defined(CONFIG_64BIT_PHYS_ADDR)) \ |
diff --git a/arch/mn10300/include/asm/bitsperlong.h b/arch/mn10300/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/mn10300/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/parisc/include/asm/bitsperlong.h b/arch/parisc/include/asm/bitsperlong.h new file mode 100644 index 000000000000..75196b415d3f --- /dev/null +++ b/arch/parisc/include/asm/bitsperlong.h | |||
@@ -0,0 +1,20 @@ | |||
1 | #ifndef __ASM_PARISC_BITSPERLONG_H | ||
2 | #define __ASM_PARISC_BITSPERLONG_H | ||
3 | |||
4 | /* | ||
5 | * using CONFIG_* outside of __KERNEL__ is wrong, | ||
6 | * __LP64__ was also removed from headers, so what | ||
7 | * is the right approach on parisc? | ||
8 | * -arnd | ||
9 | */ | ||
10 | #if (defined(__KERNEL__) && defined(CONFIG_64BIT)) || defined (__LP64__) | ||
11 | #define __BITS_PER_LONG 64 | ||
12 | #define SHIFT_PER_LONG 6 | ||
13 | #else | ||
14 | #define __BITS_PER_LONG 32 | ||
15 | #define SHIFT_PER_LONG 5 | ||
16 | #endif | ||
17 | |||
18 | #include <asm-generic/bitsperlong.h> | ||
19 | |||
20 | #endif /* __ASM_PARISC_BITSPERLONG_H */ | ||
diff --git a/arch/parisc/include/asm/types.h b/arch/parisc/include/asm/types.h index 7f5a39bfb4ce..20135cc80039 100644 --- a/arch/parisc/include/asm/types.h +++ b/arch/parisc/include/asm/types.h | |||
@@ -14,14 +14,6 @@ typedef unsigned short umode_t; | |||
14 | */ | 14 | */ |
15 | #ifdef __KERNEL__ | 15 | #ifdef __KERNEL__ |
16 | 16 | ||
17 | #ifdef CONFIG_64BIT | ||
18 | #define BITS_PER_LONG 64 | ||
19 | #define SHIFT_PER_LONG 6 | ||
20 | #else | ||
21 | #define BITS_PER_LONG 32 | ||
22 | #define SHIFT_PER_LONG 5 | ||
23 | #endif | ||
24 | |||
25 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
26 | 18 | ||
27 | /* Dma addresses are 32-bits wide. */ | 19 | /* Dma addresses are 32-bits wide. */ |
diff --git a/arch/powerpc/include/asm/bitsperlong.h b/arch/powerpc/include/asm/bitsperlong.h new file mode 100644 index 000000000000..5f1659032c40 --- /dev/null +++ b/arch/powerpc/include/asm/bitsperlong.h | |||
@@ -0,0 +1,12 @@ | |||
1 | #ifndef __ASM_POWERPC_BITSPERLONG_H | ||
2 | #define __ASM_POWERPC_BITSPERLONG_H | ||
3 | |||
4 | #if defined(__powerpc64__) | ||
5 | # define __BITS_PER_LONG 64 | ||
6 | #else | ||
7 | # define __BITS_PER_LONG 32 | ||
8 | #endif | ||
9 | |||
10 | #include <asm-generic/bitsperlong.h> | ||
11 | |||
12 | #endif /* __ASM_POWERPC_BITSPERLONG_H */ | ||
diff --git a/arch/powerpc/include/asm/types.h b/arch/powerpc/include/asm/types.h index 7ce27a52bb34..a5aea0ca34e9 100644 --- a/arch/powerpc/include/asm/types.h +++ b/arch/powerpc/include/asm/types.h | |||
@@ -40,15 +40,6 @@ typedef struct { | |||
40 | #endif /* __ASSEMBLY__ */ | 40 | #endif /* __ASSEMBLY__ */ |
41 | 41 | ||
42 | #ifdef __KERNEL__ | 42 | #ifdef __KERNEL__ |
43 | /* | ||
44 | * These aren't exported outside the kernel to avoid name space clashes | ||
45 | */ | ||
46 | #ifdef __powerpc64__ | ||
47 | #define BITS_PER_LONG 64 | ||
48 | #else | ||
49 | #define BITS_PER_LONG 32 | ||
50 | #endif | ||
51 | |||
52 | #ifndef __ASSEMBLY__ | 43 | #ifndef __ASSEMBLY__ |
53 | 44 | ||
54 | typedef __vector128 vector128; | 45 | typedef __vector128 vector128; |
diff --git a/arch/s390/include/asm/bitsperlong.h b/arch/s390/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6b235aea9c66 --- /dev/null +++ b/arch/s390/include/asm/bitsperlong.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_S390_BITSPERLONG_H | ||
2 | #define __ASM_S390_BITSPERLONG_H | ||
3 | |||
4 | #ifndef __s390x__ | ||
5 | #define __BITS_PER_LONG 32 | ||
6 | #else | ||
7 | #define __BITS_PER_LONG 64 | ||
8 | #endif | ||
9 | |||
10 | #include <asm-generic/bitsperlong.h> | ||
11 | |||
12 | #endif /* __ASM_S390_BITSPERLONG_H */ | ||
13 | |||
diff --git a/arch/s390/include/asm/types.h b/arch/s390/include/asm/types.h index 3dc3fc228812..04d6b95a89c6 100644 --- a/arch/s390/include/asm/types.h +++ b/arch/s390/include/asm/types.h | |||
@@ -28,12 +28,6 @@ typedef __signed__ long saddr_t; | |||
28 | */ | 28 | */ |
29 | #ifdef __KERNEL__ | 29 | #ifdef __KERNEL__ |
30 | 30 | ||
31 | #ifndef __s390x__ | ||
32 | #define BITS_PER_LONG 32 | ||
33 | #else | ||
34 | #define BITS_PER_LONG 64 | ||
35 | #endif | ||
36 | |||
37 | #ifndef __ASSEMBLY__ | 31 | #ifndef __ASSEMBLY__ |
38 | 32 | ||
39 | typedef u64 dma64_addr_t; | 33 | typedef u64 dma64_addr_t; |
diff --git a/arch/sh/include/asm/bitsperlong.h b/arch/sh/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/sh/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||
diff --git a/arch/sparc/include/asm/bitsperlong.h b/arch/sparc/include/asm/bitsperlong.h new file mode 100644 index 000000000000..40dcaa3aaa56 --- /dev/null +++ b/arch/sparc/include/asm/bitsperlong.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_ALPHA_BITSPERLONG_H | ||
2 | #define __ASM_ALPHA_BITSPERLONG_H | ||
3 | |||
4 | #if defined(__sparc__) && defined(__arch64__) | ||
5 | #define __BITS_PER_LONG 64 | ||
6 | #else | ||
7 | #define __BITS_PER_LONG 32 | ||
8 | #endif | ||
9 | |||
10 | #include <asm-generic/bitsperlong.h> | ||
11 | |||
12 | #endif /* __ASM_ALPHA_BITSPERLONG_H */ | ||
13 | |||
diff --git a/arch/sparc/include/asm/types.h b/arch/sparc/include/asm/types.h index 2237118825d0..de671d73baed 100644 --- a/arch/sparc/include/asm/types.h +++ b/arch/sparc/include/asm/types.h | |||
@@ -21,8 +21,6 @@ typedef unsigned short umode_t; | |||
21 | 21 | ||
22 | #ifdef __KERNEL__ | 22 | #ifdef __KERNEL__ |
23 | 23 | ||
24 | #define BITS_PER_LONG 64 | ||
25 | |||
26 | #ifndef __ASSEMBLY__ | 24 | #ifndef __ASSEMBLY__ |
27 | 25 | ||
28 | /* Dma addresses come in generic and 64-bit flavours. */ | 26 | /* Dma addresses come in generic and 64-bit flavours. */ |
@@ -46,8 +44,6 @@ typedef unsigned short umode_t; | |||
46 | 44 | ||
47 | #ifdef __KERNEL__ | 45 | #ifdef __KERNEL__ |
48 | 46 | ||
49 | #define BITS_PER_LONG 32 | ||
50 | |||
51 | #ifndef __ASSEMBLY__ | 47 | #ifndef __ASSEMBLY__ |
52 | 48 | ||
53 | typedef u32 dma_addr_t; | 49 | typedef u32 dma_addr_t; |
diff --git a/arch/x86/include/asm/bitsperlong.h b/arch/x86/include/asm/bitsperlong.h new file mode 100644 index 000000000000..b0ae1c4dc791 --- /dev/null +++ b/arch/x86/include/asm/bitsperlong.h | |||
@@ -0,0 +1,13 @@ | |||
1 | #ifndef __ASM_X86_BITSPERLONG_H | ||
2 | #define __ASM_X86_BITSPERLONG_H | ||
3 | |||
4 | #ifdef __x86_64__ | ||
5 | # define __BITS_PER_LONG 64 | ||
6 | #else | ||
7 | # define __BITS_PER_LONG 32 | ||
8 | #endif | ||
9 | |||
10 | #include <asm-generic/bitsperlong.h> | ||
11 | |||
12 | #endif /* __ASM_X86_BITSPERLONG_H */ | ||
13 | |||
diff --git a/arch/x86/include/asm/types.h b/arch/x86/include/asm/types.h index e6f736320077..09b97745772f 100644 --- a/arch/x86/include/asm/types.h +++ b/arch/x86/include/asm/types.h | |||
@@ -14,12 +14,6 @@ typedef unsigned short umode_t; | |||
14 | */ | 14 | */ |
15 | #ifdef __KERNEL__ | 15 | #ifdef __KERNEL__ |
16 | 16 | ||
17 | #ifdef CONFIG_X86_32 | ||
18 | # define BITS_PER_LONG 32 | ||
19 | #else | ||
20 | # define BITS_PER_LONG 64 | ||
21 | #endif | ||
22 | |||
23 | #ifndef __ASSEMBLY__ | 17 | #ifndef __ASSEMBLY__ |
24 | 18 | ||
25 | typedef u64 dma64_addr_t; | 19 | typedef u64 dma64_addr_t; |
diff --git a/arch/xtensa/include/asm/bitsperlong.h b/arch/xtensa/include/asm/bitsperlong.h new file mode 100644 index 000000000000..6dc0bb0c13b2 --- /dev/null +++ b/arch/xtensa/include/asm/bitsperlong.h | |||
@@ -0,0 +1 @@ | |||
#include <asm-generic/bitsperlong.h> | |||