Generic Linux architectural discussions
 help / color / mirror / Atom feed
From: "Arnd Bergmann" <arnd@arndb.de>
To: "Anshuman Khandual" <anshuman.khandual@arm.com>,
	linux-kernel@vger.kernel.org
Cc: "Andrew Morton" <akpm@linux-foundation.org>,
	"Yury Norov" <yury.norov@gmail.com>,
	"Rasmus Villemoes" <linux@rasmusvillemoes.dk>,
	Linux-Arch <linux-arch@vger.kernel.org>
Subject: Re: [PATCH 2/2] lib/test_bits.c: Add tests for GENMASK_U128()
Date: Wed, 24 Jul 2024 12:45:55 +0200	[thread overview]
Message-ID: <83972212-c8b6-4888-8574-4eb153008109@app.fastmail.com> (raw)
In-Reply-To: <20240724103142.165693-3-anshuman.khandual@arm.com>

On Wed, Jul 24, 2024, at 12:31, Anshuman Khandual wrote:
> This adds GENMASK_U128() tests although currently only 64 bit wide masks
> are being tested.
>
> Cc: Andrew Morton <akpm@linux-foundation.org>
> Cc: linux-kernel@vger.kernel.org
> Signed-off-by: Anshuman Khandual <anshuman.khandual@arm.com>
> ---
>  lib/test_bits.c | 21 +++++++++++++++++++++
>  1 file changed, 21 insertions(+)
>
> diff --git a/lib/test_bits.c b/lib/test_bits.c
> index 01313980f175..2515ddc34409 100644
> --- a/lib/test_bits.c
> +++ b/lib/test_bits.c
> @@ -39,6 +39,24 @@ static void genmask_ull_test(struct kunit *test)
>  #endif
>  }
> 
> +static void genmask_u128_test(struct kunit *test)
> +{
> +	/* Tests mask generation only when the mask width is within 64 bits */
> +	KUNIT_EXPECT_EQ(test, 0x0000000000ff0000ULL, GENMASK_U128(87, 80) >> 64);
> +	KUNIT_EXPECT_EQ(test, 0x0000000000ffffffULL, GENMASK_U128(87, 64) >> 64);
> +	KUNIT_EXPECT_EQ(test, 0x0000000000000001ULL, GENMASK_U128(0, 0));

This looks like it would need an #ifdef check for either
__SIZEOF_INT128__ or CONFIG_ARCH_SUPPORTS_INT128, otherwise
it will fail to build on all 32-bit architectures and possibly
old compiler versions on some 64-bit ones. I think I checked
in the past which targets support __u128, but I don't remember
the result.

    Arnd

  reply	other threads:[~2024-07-24 10:46 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 ` [PATCH 1/2] uapi: Define GENMASK_U128 Anshuman Khandual
2024-07-24 11:03   ` 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 [this message]
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=83972212-c8b6-4888-8574-4eb153008109@app.fastmail.com \
    --to=arnd@arndb.de \
    --cc=akpm@linux-foundation.org \
    --cc=anshuman.khandual@arm.com \
    --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