lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20250305162031.GO3666230@kernel.org>
Date: Wed, 5 Mar 2025 16:20:31 +0000
From: Simon Horman <horms@...nel.org>
To: Kuan-Wei Chiu <visitorckw@...il.com>
Cc: tglx@...utronix.de, mingo@...hat.com, bp@...en8.de,
	dave.hansen@...ux.intel.com, x86@...nel.org, jk@...abs.org,
	joel@....id.au, eajames@...ux.ibm.com, andrzej.hajda@...el.com,
	neil.armstrong@...aro.org, rfoss@...nel.org,
	maarten.lankhorst@...ux.intel.com, mripard@...nel.org,
	tzimmermann@...e.de, airlied@...il.com, simona@...ll.ch,
	dmitry.torokhov@...il.com, mchehab@...nel.org,
	awalls@...metrocast.net, hverkuil@...all.nl,
	miquel.raynal@...tlin.com, richard@....at, vigneshr@...com,
	louis.peens@...igine.com, andrew+netdev@...n.ch,
	davem@...emloft.net, edumazet@...gle.com, pabeni@...hat.com,
	parthiban.veerasooran@...rochip.com, arend.vanspriel@...adcom.com,
	johannes@...solutions.net, gregkh@...uxfoundation.org,
	jirislaby@...nel.org, yury.norov@...il.com,
	akpm@...ux-foundation.org, hpa@...or.com, alistair@...ple.id.au,
	linux@...musvillemoes.dk, Laurent.pinchart@...asonboard.com,
	jonas@...boo.se, jernej.skrabec@...il.com, kuba@...nel.org,
	linux-kernel@...r.kernel.org, linux-fsi@...ts.ozlabs.org,
	dri-devel@...ts.freedesktop.org, linux-input@...r.kernel.org,
	linux-media@...r.kernel.org, linux-mtd@...ts.infradead.org,
	oss-drivers@...igine.com, netdev@...r.kernel.org,
	linux-wireless@...r.kernel.org, brcm80211@...ts.linux.dev,
	brcm80211-dev-list.pdl@...adcom.com, linux-serial@...r.kernel.org,
	bpf@...r.kernel.org, jserv@...s.ncku.edu.tw,
	david.laight.linux@...il.com, andrew.cooper3@...rix.com,
	Yu-Chun Lin <eleanor15x@...il.com>
Subject: Re: [PATCH v2 03/18] bitops: Add parity16(), parity32(), and
 parity64() helpers

On Sat, Mar 01, 2025 at 10:23:54PM +0800, Kuan-Wei Chiu wrote:
> Introduce parity16(), parity32(), and parity64() functions for
> computing parity on 16-bit, 32-bit, and 64-bit integers, respectively.
> These functions use __builtin_parity() or __builtin_parityll() when
> available, ensuring efficient computation. If the input is a
> compile-time constant, they expand using the _parity_const() macro to
> allow constant folding.
> 
> These additions provide parity computation helpers for larger integer
> types, ensuring consistency and performance across different
> bit-widths.
> 
> Co-developed-by: Yu-Chun Lin <eleanor15x@...il.com>
> Signed-off-by: Yu-Chun Lin <eleanor15x@...il.com>
> Signed-off-by: Kuan-Wei Chiu <visitorckw@...il.com>
> ---
>  include/linux/bitops.h | 63 ++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 63 insertions(+)
> 
> diff --git a/include/linux/bitops.h b/include/linux/bitops.h
> index 4c307d9c1545..41e9e7fb894b 100644
> --- a/include/linux/bitops.h
> +++ b/include/linux/bitops.h
> @@ -276,6 +276,69 @@ static inline __attribute_const__ int parity8(u8 val)
>  	return __builtin_constant_p(val) ? _parity_const(val) : _parity8(val);
>  }
>  
> +#ifndef _parity16
> +static inline __attribute_const__ int _parity16(u16 val)
> +{
> +	return __builtin_parity(val);
> +}
> +#endif
> +
> +/**
> + * parity16 - get the parity of an u16 value
> + * @value: the value to be examined

nit: This really ought to be @val to match the function signature.
     Likewise for parity8, parity32, and parity64.

> + *
> + * Determine the parity of the u16 argument.
> + *
> + * Returns:
> + * 0 for even parity, 1 for odd parity
> + */
> +static inline __attribute_const__ int parity16(u16 val)
> +{
> +	return __builtin_constant_p(val) ? _parity_const(val) : _parity16(val);
> +}

...

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ