On Tue, Feb 16, 2021 at 22:56:19 +0100, Roland Illig wrote:
On 16.02.2021 19:46, Roy Marples wrote:
I suggest we change POINTER_ALIGNED_P to accept the alignment value we
want rather than the bitwise test we supply, like so:
#define POINTER_ALIGNED_P(p, a) (((uintptr_t)(p) & ((a) - 1)))
To make sure that this macro doesn't get broken again, I have written
the attached tests. I will commit them after making sure I got the
changes to distrib/sets/lists/tests/mi correct. All the rest I already
tested successfully.
I don't see any proposal to change the meaning of this macro to
actually require the alignment even for arches without strict
alignment. Does the attached test really passes on e.g. x86 where the
macro is always true? E.g. this one:
+ if (POINTER_ALIGNED_P(p + 1, 2))
+ atf_tc_fail("p + 1 must not be aligned to 2");