Skip to content

Commit 2ad5d52

Browse files
committed
parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
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 <[email protected]> Cc: <[email protected]>
1 parent 83b5d1e commit 2ad5d52

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

arch/parisc/include/asm/bitops.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#endif
77

88
#include <linux/compiler.h>
9-
#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */
9+
#include <asm/types.h>
1010
#include <asm/byteorder.h>
1111
#include <asm/barrier.h>
1212
#include <linux/atomic.h>
@@ -17,6 +17,12 @@
1717
* to include/asm-i386/bitops.h or kerneldoc
1818
*/
1919

20+
#if __BITS_PER_LONG == 64
21+
#define SHIFT_PER_LONG 6
22+
#else
23+
#define SHIFT_PER_LONG 5
24+
#endif
25+
2026
#define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))
2127

2228

arch/parisc/include/uapi/asm/bitsperlong.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@
33

44
#if defined(__LP64__)
55
#define __BITS_PER_LONG 64
6-
#define SHIFT_PER_LONG 6
76
#else
87
#define __BITS_PER_LONG 32
9-
#define SHIFT_PER_LONG 5
108
#endif
119

1210
#include <asm-generic/bitsperlong.h>

arch/parisc/include/uapi/asm/swab.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#ifndef _PARISC_SWAB_H
22
#define _PARISC_SWAB_H
33

4+
#include <asm/bitsperlong.h>
45
#include <linux/types.h>
56
#include <linux/compiler.h>
67

@@ -38,7 +39,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
3839
}
3940
#define __arch_swab32 __arch_swab32
4041

41-
#if BITS_PER_LONG > 32
42+
#if __BITS_PER_LONG > 32
4243
/*
4344
** From "PA-RISC 2.0 Architecture", HP Professional Books.
4445
** See Appendix I page 8 , "Endian Byte Swapping".
@@ -61,6 +62,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
6162
return x;
6263
}
6364
#define __arch_swab64 __arch_swab64
64-
#endif /* BITS_PER_LONG > 32 */
65+
#endif /* __BITS_PER_LONG > 32 */
6566

6667
#endif /* _PARISC_SWAB_H */

0 commit comments

Comments
 (0)