the other variants. If doing:
#define GENMASK_TYPE(t, h, l) \
((t)(GENMASK_INPUT_CHECK(h, l) +\
(((t)1 << (h) << 1) - ((t)1 << (l)))))
The unit tests pass for everything and you even still get the warning if
h is out of bound.
But then, bloat-o-meter (x86_64, defconfig, GCC 12.4.1) shows a small
increase:
Total: Before=22723482, After=22724586, chg +0.00%
So, probably not worth the change anyway. I am keeping the current version.
Yours sincerely,
Vincent Mailhol
From: Vincent Mailhol
This is a preparation for the upcoming GENMASK_U*() and BIT_U*()
changes. After introducing those new macros, there will be a lot of
scrolling between the #if, #else and #endif.
Add a comment to the #else and #endif preprocessor macros to help keep
track of which context
From: Vincent Mailhol
Add some additional tests in lib/tests/test_bits.c to cover the
expected results of the fixed type BIT_U*() macros.
Signed-off-by: Vincent Mailhol
Reviewed-by: Lucas De Marchi
---
Changelog:
v7 -> v8:
- In commit db6fe4d61ece ("lib: Move KUnit tests in
Marchi
Acked-by: Jani Nikula
Signed-off-by: Vincent Mailhol
---
Changelog:
v6 -> v7:
- Replace BIT_* and GENMASK_* by BIT_U*() and GENMASK_U*() in the
description.
- Add the information in the description that BIT_U*() and
GENMASK_U*() are fixed width.
v5 -> v6:
On 26/03/2025 at 00:23, Yury Norov wrote:
> On Tue, Mar 25, 2025 at 01:23:22AM +0900, Vincent Mailhol wrote:
(...)
> This series doesn't apply on 6.15-rc1 because test_bits.c has moved to
> lib/tests. Can you please rebase your v8 and submit? I see no other
> issues to merge
From: Vincent Mailhol
Add GENMASK_TYPE() which generalizes __GENMASK() to support different
types, and implement fixed-types versions of GENMASK() based on it.
The fixed-type version allows more strict checks to the min/max values
accepted, which is useful for defining registers like implemented
From: Lucas De Marchi
Implement fixed-type BIT_U*() to help drivers add stricter checks,
like it was done for GENMASK_U*().
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Co-developed-by: Vincent Mailhol
Signed-off-by: Vincent Mailhol
---
Changelog:
v7 -> v8:
- s/shift-co
REG_GENMASK*() to fixed-width GENMASK_U*()
test_bits: add tests for GENMASK_U*()
Vincent Mailhol (3):
bits: add comments and newlines to #if, #else and #endif directives
bits: introduce fixed-type GENMASK_U*()
test_bits: add tests for BIT_U*()
drivers/gpu/drm/i915/i915_reg
tests.
Signed-off-by: Lucas De Marchi
Signed-off-by: Vincent Mailhol
---
Changelog:
v7 -> v8:
- In commit db6fe4d61ece ("lib: Move KUnit tests into tests/
subdirectory"), lib/test_bits.c was moved to
lib/tests/test_bits.c. Adjust the patch descrption accordingly
Marchi
Acked-by: Jani Nikula
Signed-off-by: Vincent Mailhol
---
Changelog:
v7 -> v8:
- No changes.
v6 -> v7:
- Replace BIT_* and GENMASK_* by BIT_U*() and GENMASK_U*() in the
description.
- Add the information in the description that BIT_U*() and
GENMASK_U*
On 24/03/2025 at 23:28, Yury Norov wrote:
> On Sat, Mar 22, 2025 at 06:23:11PM +0900, Vincent Mailhol via B4 Relay wrote:
>> Introduce some fixed width variant of the GENMASK() and the BIT()
>> macros in bits.h. Note that the main goal is not to get the correct
>> type, but r
_U128() from
__GENMASK_U128(), but I did not touch the uapi.
After this series, __GENMASK_U128() is not used anymore in the kernel,
but I am not brave enough to remove it myself because there is always a
risk that some userland code somewhere is relying on it…
(...)
Yours sincerely,
Vincent Mailhol
On 24/03/2025 at 22:41, Andy Shevchenko wrote:
> On Sat, Mar 22, 2025 at 06:23:13PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Lucas De Marchi
>>
>> Implement fixed-type BIT_U*() to help drivers add stricter checks,
>> like it was done for GENMASK_U*().
>
On 24/03/2025 at 16:22, Andy Shevchenko wrote:
> On Sat, Mar 22, 2025 at 06:23:12PM +0900, Vincent Mailhol via B4 Relay wrote:
>>
>> Add GENMASK_TYPE() which generalizes __GENMASK() to support different
>> types, and implement fixed-types versions of GENMASK() based on
From: Vincent Mailhol
The newly introduced GENMASK_TYPE() macro can also be used to generate
the pre-existing non-asm GENMASK*() variants.
Apply GENMASK_TYPE() to GENMASK(), GENMASK_ULL() and GENMASK_U128().
Signed-off-by: Vincent Mailhol
---
include/linux/bits.h | 26
From: Vincent Mailhol
The definitions of GENMASK() and GENMASK_ULL() do not depend any more
on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests
so that __GENMASK{,ULL}() are still covered.
Because __GENMASK() and __GENMASK_ULL() do use GENMASK_INPUT_CHECK(),
drop the
From: Vincent Mailhol
In an upcoming change, the non-asm GENMASK*() will all be unified to
depend on GENMASK_TYPE() which indirectly depend on sizeof(), something
not available in asm.
Instead of adding further complexity to GENMASK_TYPE() to make it work
for both asm and non asm, just split
13271328 +1
cfg80211_inform_bss_data51095108 -1
intel_drrs_activate 379 376 -3
Total: Before=22723481, After=22723482, chg +0.00%
(done with GCC 12.4.1 on an x86_64 defconfig)
--
2.43.0
Signed-off-by: Vincent
From: Lucas De Marchi
Implement fixed-type BIT_U*() to help drivers add stricter checks,
like it was done for GENMASK_U*().
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Co-developed-by: Vincent Mailhol
Signed-off-by: Vincent Mailhol
---
Changelog:
v6 -> v7:
v5 -> v6:
.
Signed-off-by: Lucas De Marchi
Signed-off-by: Vincent Mailhol
---
Changelog:
v6 -> v7:
v5 -> v6:
- No changes.
v4 -> v5:
- Revert v4 change. GENMASK_U8()/GENMASK_U16() are now back to
u8/u16.
v3 -> v4:
- Adjust the type of GENMASK_U8()/GENMASK_U16() fr
From: Vincent Mailhol
Add GENMASK_TYPE() which generalizes __GENMASK() to support different
types, and implement fixed-types versions of GENMASK() based on it.
The fixed-type version allows more strict checks to the min/max values
accepted, which is useful for defining registers like implemented
From: Vincent Mailhol
Add some additional tests in lib/test_bits.c to cover the expected
results of the fixed type BIT_U*() macros.
Signed-off-by: Vincent Mailhol
Reviewed-by: Lucas De Marchi
---
Changelog:
v6 -> v7:
- Add Lucas's Reviewed-by tag.
v5 -> v6:
- No cha
30509051403.2748545-1-lucas.demar...@intel.com
---
Lucas De Marchi (3):
bits: introduce fixed-type BIT_U*()
drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()
test_bits: add tests for GENMASK_U*()
Vincent Mailhol (2):
bits: introduce fixed-type GENMASK_U*()
On 19/03/2025 at 01:45, Yury Norov wrote:
> On Sat, Mar 08, 2025 at 01:48:49AM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Yury Norov
(...)
>> +#define GENMASK(h, l) GENMASK_TYPE(unsigned long, h, l)
>> +#define GENMASK_ULL(h, l) GENMASK_TYPE(uns
On 19/03/2025 at 07:32, Jani Nikula wrote:
> On Tue, 18 Mar 2025, Yury Norov wrote:
>> On Sat, Mar 08, 2025 at 01:48:51AM +0900, Vincent Mailhol via B4 Relay wrote:
>>> From: Lucas De Marchi
>>>
>>> Now that include/linux/bits.h implements fixed-width GENMASK
On 19/03/2025 at 01:06, Yury Norov wrote:
> On Sat, Mar 08, 2025 at 06:10:25PM +0900, Vincent Mailhol wrote:
>> On 08/03/2025 at 02:42, Andy Shevchenko wrote:
>>> On Sat, Mar 08, 2025 at 01:48:48AM +0900, Vincent Mailhol via B4 Relay
>>> wrote:
>>>> From: Vi
On 13/03/2025 at 13:16, Lucas De Marchi wrote:
> On Fri, Mar 07, 2025 at 02:10:28AM +0900, Vincent Mailhol wrote:
>> On 06/03/2025 at 23:34, Lucas De Marchi wrote:
>>> On Thu, Mar 06, 2025 at 08:29:52PM +0900, Vincent Mailhol via B4 Relay
>>> wrote:
>>
>&
On 13/03/2025 at 13:13, Lucas De Marchi wrote:
> On Thu, Mar 06, 2025 at 08:29:56PM +0900, Vincent Mailhol via B4 Relay
> wrote:
>> From: Vincent Mailhol
>>
>> The definitions of GENMASK() and GENMASK_ULL() do not depend any more
>> on __GENMASK() and __GENMASK_ULL(
From: Vincent Mailhol
In an upcoming change, GENMASK() and its friends will indirectly
depend on sizeof() which is not available in asm.
Instead of adding further complexity to __GENMASK() to make it work
for both asm and non asm, just split the definition of the two
variants.
Signed-off-by
On 07/03/2025 at 04:23, David Laight wrote:
> On Thu, 06 Mar 2025 20:29:52 +0900
> Vincent Mailhol via B4 Relay
> wrote:
>
>> From: Vincent Mailhol
>>
>> In an upcoming change, GENMASK() and its friends will indirectly
>> depend on sizeof() which is no
On 09/03/2025 at 19:23, David Laight wrote:
> On Sun, 9 Mar 2025 01:58:53 +
> David Laight wrote:
>
>> On Fri, 7 Mar 2025 18:58:08 +0900
>> Vincent Mailhol wrote:
>>
>>> On 07/03/2025 at 04:23, David Laight wrote:
>>>> On Thu, 06 Mar 2025
On 06/03/2025 at 23:34, Lucas De Marchi wrote:
> On Thu, Mar 06, 2025 at 08:29:52PM +0900, Vincent Mailhol via B4 Relay
> wrote:
(...)
> it seems we now have 1 inconsistency that we comment why
> GENMASK_U128() is not available in asm, but we don't comment why
> GENMASK_
sions. If you know
>> anyone relevant in ARM or everywhere else, feel free to loop them.
>
> I see, yep, we still have time for that, let's wait a bit.
Ack. Andy, I already addressed your last comments in my local tree. I
will now wait for others' feedback.
Yours sincerely,
Vincent Mailhol
On 08/03/2025 at 02:54, Andy Shevchenko wrote:
> On Sat, Mar 08, 2025 at 01:48:51AM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Lucas De Marchi
>>
>> Now that include/linux/bits.h implements fixed-width GENMASK_U*(), use
>> them to implement the i915/xe speci
From: Vincent Mailhol
Add some additional tests in lib/test_bits.c to cover the expected
results of the fixed type BIT_U*() macros.
Signed-off-by: Vincent Mailhol
---
Changelog
v4 -> v5:
- BIT_U8()/BIT_U16() are now back to u8/u16.
v3 -> v4:
- New patch.
---
lib/test_
On 08/03/2025 at 02:49, Andy Shevchenko wrote:
> On Fri, Mar 07, 2025 at 07:48:01PM +0200, Andy Shevchenko wrote:
>> On Sat, Mar 08, 2025 at 01:48:50AM +0900, Vincent Mailhol via B4 Relay wrote:
>
> ...
>
>>> /*
>>> * Missing asm support
>>> *
On 08/03/2025 at 02:42, Andy Shevchenko wrote:
> On Sat, Mar 08, 2025 at 01:48:48AM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Vincent Mailhol
>>
>> In an upcoming change, GENMASK() and its friends will indirectly
>> depend on sizeof() which is not availab
From: Vincent Mailhol
In an upcoming change, GENMASK() and its friends will indirectly
depend on sizeof() which is not available in asm.
Instead of adding further complexity to __GENMASK() to make it work
for both asm and non asm, just split the definition of the two
variants.
Signed-off-by
From: Vincent Mailhol
Add some additional tests in lib/test_bits.c to cover the expected
results of the fixed type BIT_U*() macros.
Signed-off-by: Vincent Mailhol
---
Changelog:
v5 -> v6:
- No changes.
v4 -> v5:
- BIT_U8()/BIT_U16() are now back to u8/u16.
v3
From: Lucas De Marchi
Implement fixed-type BIT_U*() to help drivers add stricter checks,
like it was done for GENMASK_U*().
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Co-developed-by: Vincent Mailhol
Signed-off-by: Vincent Mailhol
---
Changelog:
v5 -> v6:
- No chan
Marchi
Acked-by: Jani Nikula
Signed-off-by: Vincent Mailhol
---
Changelog:
v5 -> v6:
- No changes.
v4 -> v5:
- Add braket to macro names in patch description,
e.g. 'REG_GENMASK*' -> 'REG_GENMASK*()'
v3 -> v4:
- Remove the prefixe
On 08/03/2025 at 01:07, Andy Shevchenko wrote:
> On Fri, Mar 07, 2025 at 07:11:42PM +0900, Vincent Mailhol wrote:
>> On 07/03/2025 at 02:55, Andy Shevchenko wrote:
>>> On Fri, Mar 07, 2025 at 01:08:15AM +0900, Vincent Mailhol wrote:
>>>> On 06/03/2025 at 22:11, Andy
.
Signed-off-by: Lucas De Marchi
Signed-off-by: Vincent Mailhol
---
Changelog:
v5 -> v6:
- No changes.
v4 -> v5:
- Revert v4 change. GENMASK_U8()/GENMASK_U16() are now back to
u8/u16.
v3 -> v4:
- Adjust the type of GENMASK_U8()/GENMASK_U16() from
20230509051403.2748545-1-lucas.demar...@intel.com
---
Lucas De Marchi (3):
bits: introduce fixed-type BIT_U*()
drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()
test_bits: add tests for GENMASK_U*()
Vincent Mailhol (3):
bits: split the definition of the asm and
: error: right shift count >= width of type
[-Werror=shift-count-overflow]
51 | type_max(t) >> (BITS_PER_TYPE(t) - 1 - (h)
| ^~
Signed-off-by: Yury Norov
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Co-developed-by: Vincen
From: Vincent Mailhol
The definitions of GENMASK() and GENMASK_ULL() do not depend any more
on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests
so that __GENMASK{,ULL}() is still covered.
It would be good to have a small assembly test case for GENMASK*() in
case somebody
On 07/03/2025 at 22:27, David Laight wrote:
> On Fri, 7 Mar 2025 18:58:08 +0900
> Vincent Mailhol wrote:
>
>> On 07/03/2025 at 04:23, David Laight wrote:
>>> On Thu, 06 Mar 2025 20:29:52 +0900
>>> Vincent Mailhol via B4 Relay
>>> wrote:
>>>
On 07/03/2025 at 02:55, Andy Shevchenko wrote:
> On Fri, Mar 07, 2025 at 01:08:15AM +0900, Vincent Mailhol wrote:
>> On 06/03/2025 at 22:11, Andy Shevchenko wrote:
>>> On Thu, Mar 06, 2025 at 08:29:58PM +0900, Vincent Mailhol via B4 Relay
>>> wrote:
>>>> Fr
On 06/03/2025 à 22:08, Andy Shevchenko wrote:
> On Thu, Mar 06, 2025 at 08:29:53PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Yury Norov
>>
>> Add GENMASK_TYPE() which generalizes __GENMASK() to support different
>> types, and implement fixed-types versio
On 06/03/2025 at 22:02, Andy Shevchenko wrote:
> On Thu, Mar 06, 2025 at 08:29:51PM +0900, Vincent Mailhol via B4 Relay wrote:
>> Introduce some fixed width variant of the GENMASK() and the BIT()
>> macros in bits.h. Note that the main goal is not to get the correct
>> type,
On 06/03/2025 at 22:11, Andy Shevchenko wrote:
> On Thu, Mar 06, 2025 at 08:29:58PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Vincent Mailhol
>>
>> Add some additional tests in lib/test_bits.c to cover the expected
>> results of the fixed type BIT_U*() macro
On 06/03/2025 at 22:05, Andy Shevchenko wrote:
> On Thu, Mar 06, 2025 at 08:29:52PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Vincent Mailhol
>>
>> In an upcoming change, GENMASK() and its friends will indirectly
>> depend on sizeof() which is not availab
*()
drm/i915: Convert REG_GENMASK*() to fixed-width GENMASK_U*()
test_bits: add tests for GENMASK_U*()
Vincent Mailhol (3):
bits: split the definition of the asm and non-asm GENMASK()
test_bits: add tests for __GENMASK() and __GENMASK_ULL()
test_bits: add tests f
.
Signed-off-by: Lucas De Marchi
Signed-off-by: Vincent Mailhol
---
Changelog:
v4 -> v5:
- Revert v4 change. GENMASK_U8()/GENMASK_U16() are now back to
u8/u16.
v3 -> v4:
- Adjust the type of GENMASK_U8()/GENMASK_U16() from u8/u16 to
unsigned int.
- Reord
Marchi
Acked-by: Jani Nikula
Signed-off-by: Vincent Mailhol
---
Changelog:
v4 -> v5:
- Add braket to macro names in patch description,
e.g. 'REG_GENMASK*' -> 'REG_GENMASK*()'
v3 -> v4:
- Remove the prefixes in macro parameters,
e.
: error: right shift count >= width of type
[-Werror=shift-count-overflow]
51 | type_max(t) >> (BITS_PER_TYPE(t) - 1 - (h)
| ^~
Signed-off-by: Yury Norov
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Co-developed-by: Vincen
From: Vincent Mailhol
The definitions of GENMASK() and GENMASK_ULL() do not depend any more
on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests
so that __GENMASK{,ULL}() is still covered.
Signed-off-by: Vincent Mailhol
---
lib/test_bits.c | 18 ++
1 file
From: Lucas De Marchi
Implement fixed-type BIT_U*() to help drivers add stricter checks,
like was done for GENMASK_U*().
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Co-developed-by: Vincent Mailhol
Signed-off-by: Vincent Mailhol
---
Changelog:
v4 -> v5:
- Rename GENMAS
The question raised by Yury on whether or not we should keep
__GENMASK_U128() in the uapi still remains. And in full honesty, I will
not touch that one. This is not in the scope of this series.
Yours sincerely,
Vincent Mailhol
On 06/03/2025 at 18:12, Andy Shevchenko wrote:
> On Wed, Mar 05, 2025 at 09:50:27PM +, David Laight wrote:
>> On Wed, 5 Mar 2025 21:56:22 +0200
>> Andy Shevchenko wrote:
>>> On Thu, Mar 06, 2025 at 02:17:18AM +0900, Vincent Mailhol wrote:
>>>> On 06/03/
On 06/03/2025 at 00:48, Andy Shevchenko wrote:
> On Wed, Mar 05, 2025 at 11:48:10PM +0900, Vincent Mailhol wrote:
>> On 05/03/2025 at 23:33, Andy Shevchenko wrote:
>>> On Wed, Mar 05, 2025 at 10:00:16PM +0900, Vincent Mailhol via B4 Relay
>>> wrote:
>
&
On 06/03/2025 at 00:47, Yury Norov wrote:
> On Wed, Mar 05, 2025 at 10:00:15PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Yury Norov
>>
>> Add __GENMASK_t() which generalizes __GENMASK() to support different
>> types, and implement fixed-types versions of GE
On 05/03/2025 at 23:38, Yury Norov wrote:
> On Wed, Mar 05, 2025 at 04:36:12PM +0200, Andy Shevchenko wrote:
>> On Wed, Mar 05, 2025 at 09:30:20AM -0500, Yury Norov wrote:
>>> On Wed, Mar 05, 2025 at 10:00:13PM +0900, Vincent Mailhol via B4 Relay
>>> wrote:
On 05/03/2025 at 23:33, Andy Shevchenko wrote:
> On Wed, Mar 05, 2025 at 10:00:16PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Lucas De Marchi
>>
>> Implement fixed-type BIT to help drivers add stricter checks, like was
>
> Here and in the Subject I would us
On 05/03/2025 at 23:30, Andy Shevchenko wrote:
> On Wed, Mar 05, 2025 at 10:00:15PM +0900, Vincent Mailhol via B4 Relay wrote:
>> From: Yury Norov
>>
>> Add __GENMASK_t() which generalizes __GENMASK() to support different
>
> Is it with double underscore? I do not see
From: Lucas De Marchi
Implement fixed-type BIT to help drivers add stricter checks, like was
done for GENMASK().
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Signed-off-by: Vincent Mailhol
---
Changelog:
v3 -> v4:
- Use const_true() to simplify BIT_INPUT_CHECK().
- M
45-1-lucas.demar...@intel.com
--
2.43.0
---
Lucas De Marchi (3):
bits: introduce fixed-type BIT
drm/i915: Convert REG_GENMASK* to fixed-width GENMASK_*
test_bits: add tests for fixed-type genmasks
Vincent Mailhol (4):
bits: fix typo 'unsigned __init128' -> &
Acked-by: Jani Nikula
Signed-off-by: Vincent Mailhol
---
Changelog:
v3 -> v4:
- Remove the prefixes in macro parameters,
e.g. 'REG_GENMASK(__high, __low)' -> 'REG_GENMASK(high, low)'
---
drivers/gpu/drm/i915/i915_reg_defs.h | 108 -
From: Vincent Mailhol
The definitions of GENMASK() and GENMASK_ULL() do not depend any more
on __GENMASK() and __GENMASK_ULL(). Duplicate the existing unit tests
so that __GENMASK{,ULL}() is still covered.
Signed-off-by: Vincent Mailhol
---
lib/test_bits.c | 18 ++
1 file
-off-by: Lucas De Marchi
Signed-off-by: Vincent Mailhol
---
Changelog:
v3 -> v4:
- Adjust the type of GENMASK_U8()/GENMASK_U16() from u8/u16 to
unsigned int.
- Reorder the tests to match the order in which the macros are
declared in bits.h.
---
lib/test_bits.c |
/bits.h:41:31: error: left shift count >= width of type
[-Werror=shift-count-overflow]
41 | (((t)~0ULL - ((t)(1) << (l)) + 1) & \
| ^~
Signed-off-by: Yury Norov
Signed-off-by: Lucas De Marchi
Acked-by: Jani Nikula
Signed-of
From: Vincent Mailhol
Add some additional tests in lib/test_bits.c to cover the expected
results of the BIT_U*() macros.
Signed-off-by: Vincent Mailhol
---
lib/test_bits.c | 10 ++
1 file changed, 10 insertions(+)
diff --git a/lib/test_bits.c b/lib/test_bits.c
index
From: Vincent Mailhol
In an upcoming change, GENMASK() and its friends will indirectly
depend on sizeof() which is not available in asm.
Instead of adding further complexity to __GENMASK() to make it work
for both asm and non asm, just split the definition of the two
variants.
Signed-off-by
From: Vincent Mailhol
"int" was misspelled as "init" in GENMASK_U128() comments. Fix the typo.
Signed-off-by: Vincent Mailhol
---
include/linux/bits.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/include/linux/bits.h b/includ
.
With the -next development windows opening very soon, wouldn't it be a
good idea to revive this topic?
Yours sincerely,
Vincent Mailhol
On Fri. 6 Dec. 2024 at 00:52, Vincent Mailhol
wrote:
> On Thu. 5 Dec. 2024 at 03:54, David Laight wrote:
> > From: Vincent Mailhol
> > > Sent: 02 December 2024 17:33
> > >
> > > In __clamp_once(),
> > >
> > > __builtin_choose_expr(__is_cons
tps://godbolt.org/z/xer4aMees
And can we ignore the case (!(var << 2))? This is not a warning
because of the macro, but because of the caller! If I do any of:
if (!(var << 2)) {}
(void)__builtin_constant_p(!(var << 2));
I also got the warning. The point is that the macro should not
generate *new* warnings. If the given argument already raises a
warning, it is the caller's responsibility to fix.
Yours sincerely,
Vincent Mailhol
On Thu. 5 Dec 2024 at 03:48, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 02 December 2024 17:33
> >
> > __builtin_constant_p() is known for not always being able to produce
> > constant expression [1] which led to the introduction of
> > __is_constexpr
On Fri. 6 Dec. 2024 at 15:40, Martin Uecker wrote:
> Am Freitag, dem 06.12.2024 um 02:25 + schrieb David Laight:
> > From: Vincent Mailhol
> > > Sent: 05 December 2024 15:31
> > >
> > > -CC: Martin Uecker
> > > +CC: Martin Uecker
> > >
On Sun. 8 Dec. 2024 at 00:10, Martin Uecker wrote:
> Am Samstag, dem 07.12.2024 um 22:50 +0900 schrieb Vincent Mailhol:
> > On Sat. 7 Dec. 2024 à 22:19, Martin Uecker wrote:
> > >
> ...
>
> >
> > I was invited to WG14 this September. For now, I am only lurking
On Thu. 5 Dec. 2024 at 03:54, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 02 December 2024 17:33
> >
> > In __clamp_once(),
> >
> > __builtin_choose_expr(__is_constexpr((lo) > (hi)), (lo) <= (hi), true)
> >
> > is equivalent to:
&g
On Thu. 5 Dec 2024 at 03:52, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 02 December 2024 17:33
> >
> > __builtin_choose_expr(__is_constexpr((l) > (h)), (l) > (h), 0)
> >
> > is equivalent to:
> >
> > is_const_true((l) > (h)
-CC: Martin Uecker
+CC: Martin Uecker
(seems that Martin changed his address)
On Thu. 5 Dec. 2024 at 03:39, David Laight wrote:
> > Sent: 02 December 2024 17:33
> >
> > From: Vincent Mailhol
> >
> > __is_constexpr(), while being one of the most glorious one li
On Sat. 7 Dec. 2024 at 20:19, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 07 December 2024 07:43
> ...
> > > So maybe the slightly long lines:
> > > #define const_true(x) _Generic(0 ? (void *)((x) + 0 ? 0L : 1L) : (char
> > > *)0, char *: 1
On Sat. 7 Dec. 2024 at 17:39, Martin Uecker wrote:
> Am Freitag, dem 06.12.2024 um 16:26 +0900 schrieb Vincent Mailhol:
> > > On Fri. 6 Dec. 2024 at 15:40, Martin Uecker wrote:
> > > > > Am Freitag, dem 06.12.2024 um 02:25 + schrieb David Laight:
> >
On Sat. 7 Dec. 2024 à 22:19, Martin Uecker wrote:
> Am Samstag, dem 07.12.2024 um 21:45 +0900 schrieb Vincent Mailhol:
> > On Sat. 7 Dec. 2024 at 17:39, Martin Uecker wrote:
> > > Am Freitag, dem 06.12.2024 um 16:26 +0900 schrieb Vincent Mailhol:
>
> ...
>
> >
On Thu. 5 Dec. 2024 at 03:58, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 02 December 2024 17:33
> >
> > From: Vincent Mailhol
> >
> > is_const() is a one to one replacement of __is_constexpr(). Do the
> > replacement so that __is_constexpr(
On Thu. 5 Dec. 2024 at 08:58, Kees Cook wrote:
> On December 3, 2024 3:33:22 AM GMT+10:00, Vincent Mailhol via B4 Relay
> wrote:
> >This series is the spiritual successor of [1] which introduced
> >const_true(). In [1], following a comment from David Laight, Linus
> >c
On Thu. 5 Dec 2024 at 03:30, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 02 December 2024 17:33
> >
> > From: Vincent Mailhol
> >
> > For completion, add statically_false() which is the equivalent of
> > statically_true() except that it will ret
On Thu. 5 Dec 2024 at 04:00, David Laight wrote:
> From: Vincent Mailhol
> > Sent: 02 December 2024 17:34
> >
> > Most of the use of __is_const_expr() in i915_reg_defs.h are just to
> > test whether an expression is known to be true. Because those checks
> > ar
From: Vincent Mailhol
In __clamp_once(),
__builtin_choose_expr(__is_constexpr((lo) > (hi)), (lo) <= (hi), true)
is equivalent to:
!is_const_false((lo) <= (hi))
Apply is_const_false() to simplify __clamp_once().
Signed-off-by: Vincent Mailhol
---
include/linux/minmax.h | 3 +-
From: Vincent Mailhol
is_const() is a one to one replacement of __is_constexpr(). Do the
replacement so that __is_constexpr() can be removed.
Refer to [1] for an explaination of why __builtin_constant_p() can not
be used as a replacement here.
[1] commit 4d45bc82df66 ("coresight: etm4x:
is_const_false() whenever feasible, or by is_const() otherwise.
Patch 10 finally remove __is_constexpr(). RIP!
[1] add const_true() to simplify GENMASK_INPUT_CHECK()
Link:
https://lore.kernel.org/all/20241113172939.747686-4-mailhol.vinc...@wanadoo.fr/
Signed-off-by: Vincent Mailhol
---
Vincent
From: Vincent Mailhol
For completion, add statically_false() which is the equivalent of
statically_true() except that it will return true only if the input is
known to be false at compile time.
The == operator is used instead of the ! negation to prevent a
-Wint-in-bool-context compiler warning
From: Vincent Mailhol
__is_constexpr(), while being one of the most glorious one liner hack
ever witnessed by mankind, is overly complex. Following the adoption
of C11 in the kernel, this macro can be simplified through the use of
a _Generic() selection.
First, split the macro in two
From: Vincent Mailhol
In GENMASK_INPUT_CHECK(),
__builtin_choose_expr(__is_constexpr((l) > (h)), (l) > (h), 0)
is equivalent to:
is_const_true((l) > (h))
Apply is_const_true() to simplify GENMASK_INPUT_CHECK().
Signed-off-by: Vincent Mailhol
---
This change passes the unit t
From: Vincent Mailhol
Most of the use of __is_const_expr() in i915_reg_defs.h are just to
test whether an expression is known to be true. Because those checks
are all done in a BUILD_BUG_ON_ZERO(), replace those with
is_const_true().
Replace the few other occurrences of __is_const_expr() with
From: Vincent Mailhol
__builtin_constant_p() is known for not always being able to produce
constant expression [1] which led to the introduction of
__is_constexpr() [2]. Because of its dependency on
__builtin_constant_p(), statically_true() suffers from the same
issues.
For example:
void foo
From: Vincent Mailhol
is_const() is a one to one replacement of __is_constexpr(). Do the
replacement so that __is_constexpr() can be removed.
Signed-off-by: Vincent Mailhol
---
include/linux/overflow.h | 8
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/include/linux
From: Vincent Mailhol
Now that all the users of __is_constexpr() have been migrated to
is_const() or one of its friends, remove it.
The homage to Martin Uecker's genius hack remains in the documentation
of __is_const_zero().
Signed-off-by: Vincent Mailhol
---
include/linux/compiler.h
1 - 100 of 101 matches
Mail list logo