sandbox: remove CONFIG_SANDBOX_BITS_PER_LONG and GENMASK hack
Subsystems (2)
PATCH 1/2 sandbox: remove CONFIG_SANDBOX_BITS_PER_LONG and GENMASK hack
Commit e519c616061d ("bitops: Fix GENMASK definition for Sandbox") is wrong.
BITS_PER_LONG must match to sizeof(long) of the compiler. If not, we are already totally screwed up.
It is weird to patch GENMASK() only.
---
arch/sandbox/Kconfig | 5 ----- arch/sandbox/include/asm/io.h | 4 ---- arch/sandbox/include/asm/posix_types.h | 2 +- arch/sandbox/include/asm/types.h | 2 +- include/linux/bitops.h | 5 ----- 5 files changed, 2 insertions(+), 16 deletions(-)
arch/sandbox/Kconfig +0 -5
@@ -41,9 +41,4 @@ config HOST_64BIT endchoice -config SANDBOX_BITS_PER_LONG - int - default 32 if HOST_32BIT - default 64 if HOST_64BIT - endmenu
arch/sandbox/include/asm/io.h +0 -4
@@ -42,15 +42,11 @@ phys_addr_t map_to_sysmem(const void *ptr);#define readb (addr) ((void)addr, 0)#define readw (addr) ((void)addr, 0)#define readl (addr) ((void)addr, 0) -#ifdef CONFIG_SANDBOX64 #define readq (addr) ((void)addr, 0) -#endif #define writeb (v, addr) ((void)addr)#define writew (v, addr) ((void)addr)#define writel (v, addr) ((void)addr) -#ifdef CONFIG_SANDBOX64 #define writeq (v, addr) ((void)addr) -#endif /* * Clear and set bits in one shot. These macros can be used to clear and
arch/sandbox/include/asm/posix_types.h +1 -1
@@ -28,7 +28,7 @@ typedef int __kernel_pid_t;typedef unsigned short __kernel_ipc_pid_t ;typedef unsigned short __kernel_uid_t ;typedef unsigned short __kernel_gid_t ; -#if CONFIG_SANDBOX_BITS_PER_LONG ==32 +#ifdef CONFIG_HOST_32BIT typedef unsigned int __kernel_size_t ;typedef int __kernel_ssize_t ;typedef int __kernel_ptrdiff_t ;
arch/sandbox/include/asm/types.h +1 -1
@@ -18,7 +18,7 @@ typedef unsigned short umode_t;/* * Number of bits in a C 'long' on this architecture. */ -#ifdef CONFIG_PHYS_64BIT +#ifdef CONFIG_HOST_64BIT #define BITS_PER_LONG 64#else /* CONFIG_PHYS_64BIT */ #define BITS_PER_LONG 32
include/linux/bitops.h +0 -5
@@ -21,13 +21,8 @@* position @h. For example * GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. */ -#ifdef CONFIG_SANDBOX -#define GENMASK (h, l) \ - (((~0UL) << (l)) & (~0UL >> (CONFIG_SANDBOX_BITS_PER_LONG - 1 - (h)))) -#else #define GENMASK (h, l) \ (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) -#endif #define GENMASK_ULL (h, l) \ (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h))))
Signature · 1 line
2.17.1
PATCH 2/2 linux/bitops.h: split BITS, GENMASK macros out into <linux/bits.h>
Based on Linux commit 8bd9cb51daac ("locking/atomics, asm-generic:
Move some macros from <linux/bitops.h> to a new <linux/bits.h> file").
We cannot sync <linux/bits.h>. Unfortunately, BITS_PER_LONG is defined differently from Linux.
---
include/linux/bitops.h | 25 +++---------------------- include/linux/bits.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 include/linux/bits.h
include/linux/bitops.h +3 -22
@@ -2,30 +2,11 @@#define _LINUX_BITOPS_H#include <asm/types.h> -#include <asm-generic/bitsperlong.h> +#include <linux/bits.h> #include <linux/compiler.h> -#ifdef __KERNEL__ -#define BIT (nr) (1UL << (nr)) -#define BIT_ULL (nr) (1ULL << (nr)) -#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) -#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) -#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) -#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG) -#define BITS_PER_BYTE 8 -#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_BYTE * sizeof(long)) -#endif - -/* -* Create a contiguous bitmask starting@bit position @l and ending at -* position @h. For example -* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. -*/ -#define GENMASK (h, l) \ - (((~0UL) << (l)) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) - -#define GENMASK_ULL (h, l) \ - (((~0ULL) << (l)) & (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) +#define BITS_PER_TYPE (type) (sizeof(type) * BITS_PER_BYTE) +#define BITS_TO_LONGS (nr) DIV_ROUND_UP(nr, BITS_PER_TYPE(long))/* * ffs: find first bit set. This is defined the same way as
include/linux/bits.h new file +35 -0
@@ -0,0 +1,35 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef __LINUX_BITS_H +#define __LINUX_BITS_H + +/* +* FIXME: +* Linux defines BITS_PER_LONG in <asm/bitsperlong.h>, which is a wrapper +* of <asm-generic/bitsperlong.h> +* U-Boot does not have <asm/bitsperlong.h>, and defines BITS_PER_LONG +* in <asm/types.h> +*/ +#include <asm/types.h> +//#include <asm/bitsperlong.h> + +#define BIT (nr) (1UL << (nr)) +#define BIT_ULL (nr) (1ULL << (nr)) +#define BIT_MASK (nr) (1UL << ((nr) % BITS_PER_LONG)) +#define BIT_WORD (nr) ((nr) / BITS_PER_LONG) +#define BIT_ULL_MASK (nr) (1ULL << ((nr) % BITS_PER_LONG_LONG)) +#define BIT_ULL_WORD (nr) ((nr) / BITS_PER_LONG_LONG) +#define BITS_PER_BYTE 8 + +/* +* Create a contiguous bitmask starting@bit position @l and ending at +* position @h. For example +* GENMASK_ULL(39, 21) gives us the 64bit vector 0x000000ffffe00000. +*/ +#define GENMASK (h, l) \ + (((~0UL) - (1UL << (l)) + 1) & (~0UL >> (BITS_PER_LONG - 1 - (h)))) + +#define GENMASK_ULL (h, l) \ + (((~0ULL) - (1ULL << (l)) + 1) & \ + (~0ULL >> (BITS_PER_LONG_LONG - 1 - (h)))) + +#endif /* __LINUX_BITS_H */
Signature · 1 line
2.17.1
PATCH 2/2 linux/bitops.h: split BITS, GENMASK macros out into <linux/bits.h>
Quoted 6 lines · Masahiro Yamada
Based on Linux commit
8bd9cb51daac("locking/atomics, asm-generic:
Move some macros from <linux/bitops.h> to a new <linux/bits.h> file").We cannot sync <
linux/bits.h>. Unfortunately,BITS_PER_LONGis defined differently from Linux.
Quoted 7 lines
Signed-off-by Masahiro Yamada <[email protected]>---
include/linux/bitops.h | 25 +++---------------------- include/linux/bits.h | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 22 deletions(-) create mode 100644 include/linux/bits.h
This breaks at least db-88f6720 and am65x_evm_a53 over boards that need to change their #includes apparently. Please re-work to cover that, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 819 bytes Desc: not available URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190717/a798948a/attachment.sig>