aboutsummaryrefslogtreecommitdiffstats
path: root/arch/parisc
diff options
context:
space:
mode:
authorHelge Deller <deller@gmx.de>2017-01-28 05:52:02 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2017-02-01 02:33:08 -0500
commit2b95f1210e5010feb767edefcfff53f2c611c1c5 (patch)
tree8e856022023e5ab57d7995781aa3b2fbfabb6939 /arch/parisc
parentca332b96ba623aa3243a79d355684974f88c3f1a (diff)
parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
commit 2ad5d52d42810bed95100a3d912679d8864421ec upstream. In swab.h the "#if BITS_PER_LONG > 32" breaks compiling userspace programs if BITS_PER_LONG is #defined by userspace with the sizeof() compiler builtin. Solve this problem by using __BITS_PER_LONG instead. Since we now #include asm/bitsperlong.h avoid further potential userspace pollution by moving the #define of SHIFT_PER_LONG to bitops.h which is not exported to userspace. This patch unbreaks compiling qemu on hppa/parisc. Signed-off-by: Helge Deller <deller@gmx.de> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'arch/parisc')
-rw-r--r--arch/parisc/include/asm/bitops.h8
-rw-r--r--arch/parisc/include/uapi/asm/bitsperlong.h2
-rw-r--r--arch/parisc/include/uapi/asm/swab.h5
3 files changed, 10 insertions, 5 deletions
diff --git a/arch/parisc/include/asm/bitops.h b/arch/parisc/include/asm/bitops.h
index 3f9406d9b9d6..da87943328a5 100644
--- a/arch/parisc/include/asm/bitops.h
+++ b/arch/parisc/include/asm/bitops.h
@@ -6,7 +6,7 @@
6#endif 6#endif
7 7
8#include <linux/compiler.h> 8#include <linux/compiler.h>
9#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */ 9#include <asm/types.h>
10#include <asm/byteorder.h> 10#include <asm/byteorder.h>
11#include <asm/barrier.h> 11#include <asm/barrier.h>
12#include <linux/atomic.h> 12#include <linux/atomic.h>
@@ -17,6 +17,12 @@
17 * to include/asm-i386/bitops.h or kerneldoc 17 * to include/asm-i386/bitops.h or kerneldoc
18 */ 18 */
19 19
20#if __BITS_PER_LONG == 64
21#define SHIFT_PER_LONG 6
22#else
23#define SHIFT_PER_LONG 5
24#endif
25
20#define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1)) 26#define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
21 27
22 28
diff --git a/arch/parisc/include/uapi/asm/bitsperlong.h b/arch/parisc/include/uapi/asm/bitsperlong.h
index e0a23c7bdd43..07fa7e50bdc0 100644
--- a/arch/parisc/include/uapi/asm/bitsperlong.h
+++ b/arch/parisc/include/uapi/asm/bitsperlong.h
@@ -3,10 +3,8 @@
3 3
4#if defined(__LP64__) 4#if defined(__LP64__)
5#define __BITS_PER_LONG 64 5#define __BITS_PER_LONG 64
6#define SHIFT_PER_LONG 6
7#else 6#else
8#define __BITS_PER_LONG 32 7#define __BITS_PER_LONG 32
9#define SHIFT_PER_LONG 5
10#endif 8#endif
11 9
12#include <asm-generic/bitsperlong.h> 10#include <asm-generic/bitsperlong.h>
diff --git a/arch/parisc/include/uapi/asm/swab.h b/arch/parisc/include/uapi/asm/swab.h
index e78403b129ef..928e1bbac98f 100644
--- a/arch/parisc/include/uapi/asm/swab.h
+++ b/arch/parisc/include/uapi/asm/swab.h
@@ -1,6 +1,7 @@
1#ifndef _PARISC_SWAB_H 1#ifndef _PARISC_SWAB_H
2#define _PARISC_SWAB_H 2#define _PARISC_SWAB_H
3 3
4#include <asm/bitsperlong.h>
4#include <linux/types.h> 5#include <linux/types.h>
5#include <linux/compiler.h> 6#include <linux/compiler.h>
6 7
@@ -38,7 +39,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
38} 39}
39#define __arch_swab32 __arch_swab32 40#define __arch_swab32 __arch_swab32
40 41
41#if BITS_PER_LONG > 32 42#if __BITS_PER_LONG > 32
42/* 43/*
43** From "PA-RISC 2.0 Architecture", HP Professional Books. 44** From "PA-RISC 2.0 Architecture", HP Professional Books.
44** See Appendix I page 8 , "Endian Byte Swapping". 45** See Appendix I page 8 , "Endian Byte Swapping".
@@ -61,6 +62,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
61 return x; 62 return x;
62} 63}
63#define __arch_swab64 __arch_swab64 64#define __arch_swab64 __arch_swab64
64#endif /* BITS_PER_LONG > 32 */ 65#endif /* __BITS_PER_LONG > 32 */
65 66
66#endif /* _PARISC_SWAB_H */ 67#endif /* _PARISC_SWAB_H */