[Mesa-dev] [PATCH 05/18] mesa: android has no log2f nor ffs

Jose Fonseca jfonseca at vmware.com
Thu Aug 18 00:25:24 PDT 2011


----- Original Message -----
> On Wed, Aug 17, 2011 at 11:33 PM, Ian Romanick <idr at freedesktop.org>
> wrote:
> > -----BEGIN PGP SIGNED MESSAGE-----
> > Hash: SHA1
> >
> > On 08/16/2011 11:28 PM, Chia-I Wu wrote:
> >> Define log2f(v) to be log(v) / M_LN2 and ffs to __builtin_ffs.
> >> ---
> >>  src/mesa/main/imports.h |    8 +++++++-
> >>  1 files changed, 7 insertions(+), 1 deletions(-)
> >>
> >> diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h
> >> index 3fa1db0..e404975 100644
> >> --- a/src/mesa/main/imports.h
> >> +++ b/src/mesa/main/imports.h
> >> @@ -134,7 +134,13 @@ typedef union { GLfloat f; GLint i; }
> >> fi_type;
> >>  #define exp2f(f) ((float) exp2(f))
> >>  #define floorf(f) ((float) floor(f))
> >>  #define logf(f) ((float) log(f))
> >> +
> >> +#ifdef ANDROID
> >> +#define log2f(f) ((float) (log(f) / M_LN2))

Wouldn't (logf(f) * (float)(1.0 / M_LN2)) be more efficient (floating point only, no division) and equally precise?

> >> +#else
> >>  #define log2f(f) ((float) log2(f))
> >> +#endif
> >> +
> >
> > This should use a HAVE_LOG2 and / or HAVE_LO2F feature macros
> > instead.
> Do you suggest we check for log2 in configure.ac and define
> HAVE_LOG2?
>  Looking at the code block and that follows, it looks like we are
> doing platform or compiler workarounds (so that it works for
> non-autoconf users?).

I suppose we could have HAVE_LOG2 etc macros and define/undefine them inside #ifdef ANDRIOD/_WIN32/etc ... #endif, but I'n not sure it would simplify the code greatly for this particular case.

configure.ac's defines would not automatically work for andriod/scons -- all the detection logic would have to be duplicated there too.

Jose


More information about the mesa-dev mailing list