[Mesa-dev] [PATCH 02/14] util: added ffsll() function
Brian Paul
brianp at vmware.com
Mon Aug 31 07:36:25 PDT 2015
On 08/28/2015 07:36 PM, Jason Ekstrand wrote:
>
> On Aug 28, 2015 2:31 PM, "Brian Paul" <brianp at vmware.com
> <mailto:brianp at vmware.com>> wrote:
> >
> > v2: fix errant _GNU_SOURCE test, per Matt Turner.
> > ---
> > src/gallium/auxiliary/util/u_math.h | 20 ++++++++++++++++++++
> > 1 file changed, 20 insertions(+)
> >
> > diff --git a/src/gallium/auxiliary/util/u_math.h
> b/src/gallium/auxiliary/util/u_math.h
> > index 56bd185..c551974 100644
> > --- a/src/gallium/auxiliary/util/u_math.h
> > +++ b/src/gallium/auxiliary/util/u_math.h
> > @@ -389,6 +389,26 @@ unsigned ffs( unsigned u )
> > #define ffs __builtin_ffs
> > #endif
> >
> > +#ifdef HAVE___BUILTIN_FFSLL
> > +#define ffsll __builtin_ffsll
> > +#else
> > +static inline int
> > +ffsll(long long int val)
> > +{
> > + int bit;
> > +
>
> Might be better to do
>
> if (val & 0xffffffff)
> return ffs(val &0xffffffff);
> else
> return ffs(val >> 32);
>
> That may be a little cheaper. I don't know if its actually better but
> its one less ffs call (which may cross a library boundary)
I like that too, but I just copied the implementation from imports.c
As was suggested, we can look at consolidating this function and a few
others into src/util/ later.
-Brian
> --Jason
>
> > + bit = ffs((unsigned) (val & 0xffffffff));
> > + if (bit != 0)
> > + return bit;
> > +
> > + bit = ffs((unsigned) (val >> 32));
> > + if (bit != 0)
> > + return 32 + bit;
> > +
> > + return 0;
> > +}
> > +#endif
> > +
> > #endif /* FFS_DEFINED */
> >
> > /**
> > --
> > 1.9.1
> >
> > _______________________________________________
> > mesa-dev mailing list
> > mesa-dev at lists.freedesktop.org <mailto:mesa-dev at lists.freedesktop.org>
> > http://lists.freedesktop.org/mailman/listinfo/mesa-dev
> <https://urldefense.proofpoint.com/v2/url?u=http-3A__lists.freedesktop.org_mailman_listinfo_mesa-2Ddev&d=BQMFaQ&c=Sqcl0Ez6M0X8aeM67LKIiDJAXVeAw-YihVMNtXt-uEs&r=T0t4QG7chq2ZwJo6wilkFznRSFy-8uDKartPGbomVj8&m=u0DJgAjhxxl7RyNVZSQ37HS6W5StpIt-qUTJtm0MFVk&s=_xGcOvu0RaFHWkqySgjs5TAsOM1kiitqJg77nThabd0&e=>
>
More information about the mesa-dev
mailing list