On Fri, May 05, 2017 at 10:47:09PM -0400, David Miller wrote:
> From: David Miller <[email protected]>
> Date: Fri, 05 May 2017 16:20:44 -0400 (EDT)
>
> > Anyways, I'll play with this design and see what happens...
> > Feedback is of course welcome.
>
> Here is a prototype that works for me with test_pkt_access.c,
> which otherwise won't load on sparc.
the approach looks good.
> +static u32 calc_align(u32 imm)
> +{
> + u32 align = 1;
> +
> + if (!imm)
> + return 1U << 31;
> +
> + while (!(imm & 1)) {
> + imm >>= 1;
> + align <<= 1;
> + }
> + return align;
> +}
who about
static u32 calc_align(u32 n)
{
if (!n)
return 1U << 31;
return n - ((n - 1) & n);
}
instead?