Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

uapi: introduce uapi-friendly macros for GENMASK

Move __GENMASK and __GENMASK_ULL from include/ to include/uapi/ so that they can
be used to define masks in userspace API headers. Compared to what is already
in include/linux/bits.h, the definitions need to use the uglified versions of
UL(), ULL(), BITS_PER_LONG and BITS_PER_LONG_LONG (which did not even exist),
but otherwise expand to the same content.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

+20 -7
+1 -7
include/linux/bits.h
··· 4 4 5 5 #include <linux/const.h> 6 6 #include <vdso/bits.h> 7 + #include <uapi/linux/bits.h> 7 8 #include <asm/bitsperlong.h> 8 9 9 10 #define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG)) ··· 31 30 #define GENMASK_INPUT_CHECK(h, l) 0 32 31 #endif 33 32 34 - #define __GENMASK(h, l) \ 35 - (((~UL(0)) - (UL(1) << (l)) + 1) & \ 36 - (~UL(0) >> (BITS_PER_LONG - 1 - (h)))) 37 33 #define GENMASK(h, l) \ 38 34 (GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l)) 39 - 40 - #define __GENMASK_ULL(h, l) \ 41 - (((~ULL(0)) - (ULL(1) << (l)) + 1) & \ 42 - (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h)))) 43 35 #define GENMASK_ULL(h, l) \ 44 36 (GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l)) 45 37
+4
include/uapi/asm-generic/bitsperlong.h
··· 24 24 #endif 25 25 #endif 26 26 27 + #ifndef __BITS_PER_LONG_LONG 28 + #define __BITS_PER_LONG_LONG 64 29 + #endif 30 + 27 31 #endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */
+15
include/uapi/linux/bits.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ 2 + /* bits.h: Macros for dealing with bitmasks. */ 3 + 4 + #ifndef _UAPI_LINUX_BITS_H 5 + #define _UAPI_LINUX_BITS_H 6 + 7 + #define __GENMASK(h, l) \ 8 + (((~_UL(0)) - (_UL(1) << (l)) + 1) & \ 9 + (~_UL(0) >> (__BITS_PER_LONG - 1 - (h)))) 10 + 11 + #define __GENMASK_ULL(h, l) \ 12 + (((~_ULL(0)) - (_ULL(1) << (l)) + 1) & \ 13 + (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h)))) 14 + 15 + #endif /* _UAPI_LINUX_BITS_H */