Commit c31ae4bb4a9fa4606a74c0a4fb61b74f804e861e
Committed by
Arnd Bergmann
1 parent
63b852a6b6
Exists in
master
and in
39 other branches
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>
Showing 33 changed files with 145 additions and 46 deletions Side-by-side Diff
- arch/alpha/include/asm/bitsperlong.h
- arch/alpha/include/asm/types.h
- arch/arm/include/asm/bitsperlong.h
- arch/avr32/include/asm/bitsperlong.h
- arch/blackfin/include/asm/bitsperlong.h
- arch/cris/include/asm/bitsperlong.h
- arch/frv/include/asm/bitsperlong.h
- arch/h8300/include/asm/bitsperlong.h
- arch/ia64/include/asm/bitsperlong.h
- arch/ia64/include/asm/types.h
- arch/m32r/include/asm/bitsperlong.h
- arch/m68k/include/asm/bitsperlong.h
- arch/microblaze/include/asm/bitsperlong.h
- arch/mips/include/asm/bitsperlong.h
- arch/mips/include/asm/types.h
- arch/mn10300/include/asm/bitsperlong.h
- arch/parisc/include/asm/bitsperlong.h
- arch/parisc/include/asm/types.h
- arch/powerpc/include/asm/bitsperlong.h
- arch/powerpc/include/asm/types.h
- arch/s390/include/asm/bitsperlong.h
- arch/s390/include/asm/types.h
- arch/sh/include/asm/bitsperlong.h
- arch/sparc/include/asm/bitsperlong.h
- arch/sparc/include/asm/types.h
- arch/x86/include/asm/bitsperlong.h
- arch/x86/include/asm/types.h
- arch/xtensa/include/asm/bitsperlong.h
- include/asm-generic/Kbuild
- include/asm-generic/Kbuild.asm
- include/asm-generic/bitsperlong.h
- include/asm-generic/int-l64.h
- include/asm-generic/int-ll64.h
arch/alpha/include/asm/bitsperlong.h
arch/alpha/include/asm/types.h
arch/arm/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/avr32/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/blackfin/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/cris/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/frv/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/h8300/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/ia64/include/asm/bitsperlong.h
arch/ia64/include/asm/types.h
... | ... | @@ -19,10 +19,6 @@ |
19 | 19 | # define __IA64_UL(x) (x) |
20 | 20 | # define __IA64_UL_CONST(x) x |
21 | 21 | |
22 | -# ifdef __KERNEL__ | |
23 | -# define BITS_PER_LONG 64 | |
24 | -# endif | |
25 | - | |
26 | 22 | #else |
27 | 23 | # define __IA64_UL(x) ((unsigned long)(x)) |
28 | 24 | # define __IA64_UL_CONST(x) x##UL |
29 | 25 | |
... | ... | @@ -34,10 +30,7 @@ |
34 | 30 | */ |
35 | 31 | # ifdef __KERNEL__ |
36 | 32 | |
37 | -#define BITS_PER_LONG 64 | |
38 | - | |
39 | 33 | /* DMA addresses are 64-bits wide, in general. */ |
40 | - | |
41 | 34 | typedef u64 dma_addr_t; |
42 | 35 | |
43 | 36 | # endif /* __KERNEL__ */ |
arch/m32r/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/m68k/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/microblaze/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/mips/include/asm/bitsperlong.h
arch/mips/include/asm/types.h
arch/mn10300/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/parisc/include/asm/bitsperlong.h
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 */ |
arch/parisc/include/asm/types.h
... | ... | @@ -14,14 +14,6 @@ |
14 | 14 | */ |
15 | 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 | 17 | #ifndef __ASSEMBLY__ |
26 | 18 | |
27 | 19 | /* Dma addresses are 32-bits wide. */ |
arch/powerpc/include/asm/bitsperlong.h
arch/powerpc/include/asm/types.h
... | ... | @@ -40,15 +40,6 @@ |
40 | 40 | #endif /* __ASSEMBLY__ */ |
41 | 41 | |
42 | 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 | 43 | #ifndef __ASSEMBLY__ |
53 | 44 | |
54 | 45 | typedef __vector128 vector128; |
arch/s390/include/asm/bitsperlong.h
arch/s390/include/asm/types.h
arch/sh/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
arch/sparc/include/asm/bitsperlong.h
arch/sparc/include/asm/types.h
... | ... | @@ -21,8 +21,6 @@ |
21 | 21 | |
22 | 22 | #ifdef __KERNEL__ |
23 | 23 | |
24 | -#define BITS_PER_LONG 64 | |
25 | - | |
26 | 24 | #ifndef __ASSEMBLY__ |
27 | 25 | |
28 | 26 | /* Dma addresses come in generic and 64-bit flavours. */ |
... | ... | @@ -45,8 +43,6 @@ |
45 | 43 | #endif /* __ASSEMBLY__ */ |
46 | 44 | |
47 | 45 | #ifdef __KERNEL__ |
48 | - | |
49 | -#define BITS_PER_LONG 32 | |
50 | 46 | |
51 | 47 | #ifndef __ASSEMBLY__ |
52 | 48 |
arch/x86/include/asm/bitsperlong.h
arch/x86/include/asm/types.h
arch/xtensa/include/asm/bitsperlong.h
1 | +#include <asm-generic/bitsperlong.h> |
include/asm-generic/Kbuild
include/asm-generic/Kbuild.asm
include/asm-generic/bitsperlong.h
1 | +#ifndef __ASM_GENERIC_BITS_PER_LONG | |
2 | +#define __ASM_GENERIC_BITS_PER_LONG | |
3 | + | |
4 | +/* | |
5 | + * There seems to be no way of detecting this automatically from user | |
6 | + * space, so 64 bit architectures should override this in their | |
7 | + * bitsperlong.h. In particular, an architecture that supports | |
8 | + * both 32 and 64 bit user space must not rely on CONFIG_64BIT | |
9 | + * to decide it, but rather check a compiler provided macro. | |
10 | + */ | |
11 | +#ifndef __BITS_PER_LONG | |
12 | +#define __BITS_PER_LONG 32 | |
13 | +#endif | |
14 | + | |
15 | +#ifdef __KERNEL__ | |
16 | + | |
17 | +#ifdef CONFIG_64BIT | |
18 | +#define BITS_PER_LONG 64 | |
19 | +#else | |
20 | +#define BITS_PER_LONG 32 | |
21 | +#endif /* CONFIG_64BIT */ | |
22 | + | |
23 | +/* | |
24 | + * FIXME: The check currently breaks x86-64 build, so it's | |
25 | + * temporarily disabled. Please fix x86-64 and reenable | |
26 | + */ | |
27 | +#if 0 && BITS_PER_LONG != __BITS_PER_LONG | |
28 | +#error Inconsistent word size. Check asm/bitsperlong.h | |
29 | +#endif | |
30 | + | |
31 | +#endif /* __KERNEL__ */ | |
32 | +#endif /* __ASM_GENERIC_BITS_PER_LONG */ |
include/asm-generic/int-l64.h
include/asm-generic/int-ll64.h