Skip to content

Conversation

etienne-lms
Copy link
Contributor

This is an RFC.
The 1st commit of the series already is under review in #97487.

Following #97487, this RFC proposes to implement sys_io_test_bit(), sys_io_test_and_set_bit() and sys_io_test_and_clear_bit() helper functions that were implemented only on 32bit X86 and ARC V2 architectures. The proposed implementation ensures these function return a essentially boolean value that can be used in boolean operations.

I would propose to deprecate the former implementation. Overkilling?

This P-R adds tests for these functions and moves all use of the former helper function to use the sys_io_test*() variant instead (aside the tests samples that still test the former functions to ensure non-regression of their support).

Correct the documentation of sys_test_bit() and its derivative helper
functions (listed below) since these return a bit mask value instead of
an essentially boolean value as previosuly described.

In tree implementation do conform with that: the result of these
functions are always implicitly tested against being 0 or a non-zero
value.

Helper functions which documentation is modified are sys_test_bit(),
sys_test_and_set_bit(), sys_test_and_clear_bit(), sys_bitfield_test_bit(),
sys_bitfield_test_and_set_bit() and sys_bitfield_test_and_clear_bit().

Signed-off-by: Etienne Carriere <[email protected]>
Implement sys_io_test_bit(), sus_io_test_and_set_bit() and
sys_io_test_and_clear_bit() helper function for IO bit test operation
that are expected to return an essentially boolean value. These
function are expected to be used instead of sys_test_bit(),
sys_test_and_set_bit() and sys_test_and_clear_bit() that return a
bit mask result instead of a 0 or 1 result.

The functions are not implemented got 32bit X86 and for ARC v2
architectures that already implement then, respectively in
include/zephyr/arch/x86/ia32/sys_io.h and
include/zephyr/arch/arc/v2/sys_io.h.

Signed-off-by: Etienne Carriere <[email protected]>
Change test of sys_test_bit(), sys_bitfield_test_bit() and their
derivative helper functions return value since these return a bit
mask result, not an essentially boolean value

By the way, simplify indentation in the bitfield tests from
test/kernel/common.

Signed-off-by: Etienne Carriere <[email protected]>
Add tests for sys_io_test_bit(), sys_io_test_and_set_bit() and
sys_io_test_and_clear_bit() that are now implemented for all
architectures.

Add a few inline comments to clarify which bit field helper function
are tested as it may be confusing since they have quite alike labels.

Signed-off-by: Etienne Carriere <[email protected]>
Change sys_test_bit(), sys_test_and_set_bit() and sys_test_and_clear_bit()
documentation to mark them deprecated as one should rather use the
sys_io_test()/sys_io_test_and_set_bit()/sys_test_and_clear_bit()
variant that return an essentially boolean value and can therefore be
used in boolean operations

Signed-off-by: Etienne Carriere <[email protected]>
Replace use of deprecated helper functions sys_test_bit(),
sys_test_and_set_bit() and sys_test_and_clear_bit() with use of
sys_io_test_bit(), sys_io_test_and_set_bit() and
sys_io_test_and_clear_bit() that produce
essentially boolean values safe to use in boolean operations.

Signed-off-by: Etienne Carriere <[email protected]>
Test sys_bitfield_test_bit() return value against 0 (being equal to
or different from) since the function returns a bit mask and not an
essentially boolean value.

Signed-off-by: Etienne Carriere <[email protected]>
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants