Source-Changes-D archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: POINTER_ALIGNED_P (was: Re: CVS commit: src/sys)
On Wed, Feb 17, 2021 at 17:49:15 -0000, Christos Zoulas wrote:
> In article <YCxJ044lGyfLpKuP%pony.stderr.spb.ru@localhost>,
> Valery Ushakov <uwe%stderr.spb.ru@localhost> wrote:
>
> >But to get back to my main point, PLEASE, can we stop making random
> >aimless changes without prior discussion?
>
> Here's the change I'd like to make:
> - pass the alignment instead of the mask (as Roy asked and to match the
> other macro)
> - use alignof to determine that alignment and CTASSERT what we expect
> - remove unused macros
>
> This incrementally improves things.
[...]
> diff -u -p -u -r1.688 param.h
> --- sys/param.h 15 Feb 2021 19:46:53 -0000 1.688
> +++ sys/param.h 17 Feb 2021 17:45:55 -0000
> @@ -290,7 +290,7 @@
> #ifdef __NO_STRICT_ALIGNMENT
> #define POINTER_ALIGNED_P(p, a) 1
> #else
> -#define POINTER_ALIGNED_P(p, a) (((uintptr_t)(p) & (a)) == 0)
> +#define POINTER_ALIGNED_P(p, a) (((uintptr_t)(p) & ((a) - 1)) == 0)
> #endif
>
> /*
This incrementally improves wrong things b/c you still have the "is
aligned" and "ought to be aligned" conflated in one.
-uwe
Home |
Main Index |
Thread Index |
Old Index