aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/linux/bits.h
diff options
context:
space:
mode:
authorPaolo Bonzini <pbonzini@redhat.com>2023-12-12 11:15:28 -0500
committerPaolo Bonzini <pbonzini@redhat.com>2024-02-08 08:41:03 -0500
commit3c7a8e190bc580813ddd9259f62971c8d2a6b5ad (patch)
tree09e2ec9478f5d3fec2fb4af45c1df92f457a72d8 /include/linux/bits.h
parentMerge tag 'v6.8-p3' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 (diff)
downloadwireguard-linux-3c7a8e190bc580813ddd9259f62971c8d2a6b5ad.tar.xz
wireguard-linux-3c7a8e190bc580813ddd9259f62971c8d2a6b5ad.zip
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>
Diffstat (limited to 'include/linux/bits.h')
-rw-r--r--include/linux/bits.h8
1 files changed, 1 insertions, 7 deletions
diff --git a/include/linux/bits.h b/include/linux/bits.h
index 7c0cf5031abe..0eb24d21aac2 100644
--- a/include/linux/bits.h
+++ b/include/linux/bits.h
@@ -4,6 +4,7 @@
#include <linux/const.h>
#include <vdso/bits.h>
+#include <uapi/linux/bits.h>
#include <asm/bitsperlong.h>
#define BIT_MASK(nr) (UL(1) << ((nr) % BITS_PER_LONG))
@@ -30,15 +31,8 @@
#define GENMASK_INPUT_CHECK(h, l) 0
#endif
-#define __GENMASK(h, l) \
- (((~UL(0)) - (UL(1) << (l)) + 1) & \
- (~UL(0) >> (BITS_PER_LONG - 1 - (h))))
#define GENMASK(h, l) \
(GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
-
-#define __GENMASK_ULL(h, l) \
- (((~ULL(0)) - (ULL(1) << (l)) + 1) & \
- (~ULL(0) >> (BITS_PER_LONG_LONG - 1 - (h))))
#define GENMASK_ULL(h, l) \
(GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l))