Messages in this thread | | | Date | Thu, 5 Nov 2009 17:38:42 +1100 | From | Stephen Rothwell <> | Subject | Re: [PATCH] BUILD_BUG_ON: make it handle more cases |
| |
Hi Rusty,
On Thu, 5 Nov 2009 16:58:36 +1030 Rusty Russell <rusty@rustcorp.com.au> wrote: > > Huh? virtio_has_feature does: > > if (__builtin_constant_p(fbit)) > BUILD_BUG_ON(fbit >= 32); > else > BUG_ON(fbit >= 32);
In Linus' tree (and linux-next) it looks like this:
static inline bool virtio_has_feature(const struct virtio_device *vdev, unsigned int fbit) { /* Did you forget to fix assumptions on max features? */ MAYBE_BUILD_BUG_ON(fbit >= 32);
if (fbit < VIRTIO_TRANSPORT_F_START) virtio_check_driver_offered_feature(vdev, fbit);
return test_bit(fbit, vdev->features); }
> So, if it's not a constant, gcc should throw away that first branch. If it > is, it should optimize it away (and no, these are not real bugs AFAICT).
Your version above may well fix the problem. Alternatively marking it __always_inline way work as well.
> I did a 4.3.3 allmodconfig with this patch on 64-bit a few days back and all > was fine. Will try 4.4.0 now.
4.4 is more problematic.
-- Cheers, Stephen Rothwell sfr@canb.auug.org.au http://www.canb.auug.org.au/~sfr/ [unhandled content-type:application/pgp-signature] | |