Skip to content

Commit

Permalink
parisc: Don't use BITS_PER_LONG in userspace-exported swab.h header
Browse files Browse the repository at this point in the history
commit 2ad5d52 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>
  • Loading branch information
Helge Deller authored and Greg Kroah-Hartman committed Feb 1, 2017
1 parent acb63c8 commit bde741e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 7 additions & 1 deletion arch/parisc/include/asm/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#endif

#include <linux/compiler.h>
#include <asm/types.h> /* for BITS_PER_LONG/SHIFT_PER_LONG */
#include <asm/types.h>
#include <asm/byteorder.h>
#include <asm/barrier.h>
#include <linux/atomic.h>
Expand All @@ -17,6 +17,12 @@
* to include/asm-i386/bitops.h or kerneldoc
*/

#if __BITS_PER_LONG == 64
#define SHIFT_PER_LONG 6
#else
#define SHIFT_PER_LONG 5
#endif

#define CHOP_SHIFTCOUNT(x) (((unsigned long) (x)) & (BITS_PER_LONG - 1))


Expand Down
2 changes: 0 additions & 2 deletions arch/parisc/include/uapi/asm/bitsperlong.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@

#if defined(__LP64__)
#define __BITS_PER_LONG 64
#define SHIFT_PER_LONG 6
#else
#define __BITS_PER_LONG 32
#define SHIFT_PER_LONG 5
#endif

#include <asm-generic/bitsperlong.h>
Expand Down
5 changes: 3 additions & 2 deletions arch/parisc/include/uapi/asm/swab.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#ifndef _PARISC_SWAB_H
#define _PARISC_SWAB_H

#include <asm/bitsperlong.h>
#include <linux/types.h>
#include <linux/compiler.h>

Expand Down Expand Up @@ -38,7 +39,7 @@ static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
}
#define __arch_swab32 __arch_swab32

#if BITS_PER_LONG > 32
#if __BITS_PER_LONG > 32
/*
** From "PA-RISC 2.0 Architecture", HP Professional Books.
** See Appendix I page 8 , "Endian Byte Swapping".
Expand All @@ -61,6 +62,6 @@ static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
return x;
}
#define __arch_swab64 __arch_swab64
#endif /* BITS_PER_LONG > 32 */
#endif /* __BITS_PER_LONG > 32 */

#endif /* _PARISC_SWAB_H */

0 comments on commit bde741e

Please sign in to comment.