From: Anshuman Khandual <anshuman.khandual@arm.com>
To: linux-kernel@vger.kernel.org
Cc: anshuman.khandual@arm.com,
Andrew Morton <akpm@linux-foundation.org>,
Yury Norov <yury.norov@gmail.com>,
Rasmus Villemoes <linux@rasmusvillemoes.dk>,
Arnd Bergmann <arnd@arndb.de>,
linux-arch@vger.kernel.org
Subject: [PATCH 1/2] uapi: Define GENMASK_U128
Date: Wed, 24 Jul 2024 16:01:41 +0530 [thread overview]
Message-ID: <20240724103142.165693-2-anshuman.khandual@arm.com> (raw)
In-Reply-To: <20240724103142.165693-1-anshuman.khandual@arm.com>
This adds GENMASK_U128() and __GENMASK_U128() macros using __BITS_PER_U128
and __int128 data types. These macros will be used in providing support for
generating 128 bit masks.
Cc: Yury Norov <yury.norov@gmail.com>
Cc: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Cc: Arnd Bergmann <arnd@arndb.de>>
Cc: linux-kernel@vger.kernel.org
Cc: linux-arch@vger.kernel.org
Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
---
include/linux/bits.h | 2 ++
include/uapi/asm-generic/bitsperlong.h | 4 ++++
include/uapi/linux/bits.h | 4 ++++
include/uapi/linux/const.h | 3 +++
4 files changed, 13 insertions(+)
diff --git a/include/linux/bits.h b/include/linux/bits.h
index 0eb24d21aac2..0a174cce09d2 100644
--- a/include/linux/bits.h
+++ b/include/linux/bits.h
@@ -35,5 +35,7 @@
(GENMASK_INPUT_CHECK(h, l) + __GENMASK(h, l))
#define GENMASK_ULL(h, l) \
(GENMASK_INPUT_CHECK(h, l) + __GENMASK_ULL(h, l))
+#define GENMASK_U128(h, l) \
+ (GENMASK_INPUT_CHECK(h, l) + __GENMASK_U128(h, l))
#endif /* __LINUX_BITS_H */
diff --git a/include/uapi/asm-generic/bitsperlong.h b/include/uapi/asm-generic/bitsperlong.h
index fadb3f857f28..a2c425455b2f 100644
--- a/include/uapi/asm-generic/bitsperlong.h
+++ b/include/uapi/asm-generic/bitsperlong.h
@@ -28,4 +28,8 @@
#define __BITS_PER_LONG_LONG 64
#endif
+#ifndef __BITS_PER_U128
+#define __BITS_PER_U128 128
+#endif
+
#endif /* _UAPI__ASM_GENERIC_BITS_PER_LONG */
diff --git a/include/uapi/linux/bits.h b/include/uapi/linux/bits.h
index 3c2a101986a3..780cf99b8e6e 100644
--- a/include/uapi/linux/bits.h
+++ b/include/uapi/linux/bits.h
@@ -12,4 +12,8 @@
(((~_ULL(0)) - (_ULL(1) << (l)) + 1) & \
(~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
+#define __GENMASK_U128(h, l) \
+ (((~_U128(0)) - (_U128(1) << (l)) + 1) & \
+ (~_U128(0) >> (__BITS_PER_U128 - 1 - (h))))
+
#endif /* _UAPI_LINUX_BITS_H */
diff --git a/include/uapi/linux/const.h b/include/uapi/linux/const.h
index a429381e7ca5..e7d9189e6630 100644
--- a/include/uapi/linux/const.h
+++ b/include/uapi/linux/const.h
@@ -16,14 +16,17 @@
#ifdef __ASSEMBLY__
#define _AC(X,Y) X
#define _AT(T,X) X
+#define _AC128(X) X
#else
#define __AC(X,Y) (X##Y)
#define _AC(X,Y) __AC(X,Y)
#define _AT(T,X) ((T)(X))
+#define _AC128(X) ((unsigned __int128)(X))
#endif
#define _UL(x) (_AC(x, UL))
#define _ULL(x) (_AC(x, ULL))
+#define _U128(x) (_AC128(x))
#define _BITUL(x) (_UL(1) << (x))
#define _BITULL(x) (_ULL(1) << (x))
--
2.30.2
next prev parent reply other threads:[~2024-07-24 10:31 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-24 10:31 [PATCH 0/2] uapi: Add support for GENMASK_U128() Anshuman Khandual
2024-07-24 10:31 ` Anshuman Khandual [this message]
2024-07-24 11:03 ` [PATCH 1/2] uapi: Define GENMASK_U128 Arnd Bergmann
2024-07-24 11:59 ` Anshuman Khandual
2024-07-24 12:37 ` Arnd Bergmann
2024-07-24 10:31 ` [PATCH 2/2] lib/test_bits.c: Add tests for GENMASK_U128() Anshuman Khandual
2024-07-24 10:45 ` Arnd Bergmann
2024-07-24 12:00 ` Anshuman Khandual
2024-07-25 1:04 ` kernel test robot
2024-07-25 4:19 ` Anshuman Khandual
2024-07-24 10:33 ` [PATCH 0/2] uapi: Add support " Ard Biesheuvel
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240724103142.165693-2-anshuman.khandual@arm.com \
--to=anshuman.khandual@arm.com \
--cc=akpm@linux-foundation.org \
--cc=arnd@arndb.de \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=yury.norov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox