[Mesa-dev] [PATCH 1/8] configure.ac: Use AX_GCC_BUILTIN to check availability of __builtin_bswap32

Tom Stellard tom at stellard.net
Fri Feb 21 07:10:04 PST 2014


On Thu, Feb 20, 2014 at 09:53:22PM -0800, Matt Turner wrote:
> On Thu, Feb 20, 2014 at 10:21 AM, Tom Stellard <thomas.stellard at amd.com> wrote:
> > ---
> >  configure.ac                        |   6 ++
> >  m4/ax_gcc_builtin.m4                | 168 ++++++++++++++++++++++++++++++++++++
> >  src/gallium/auxiliary/util/u_math.h |   3 +-
> >  3 files changed, 176 insertions(+), 1 deletion(-)
> >  create mode 100644 m4/ax_gcc_builtin.m4
> >
> > diff --git a/configure.ac b/configure.ac
> > index 8390d27..75d345a 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -119,6 +119,12 @@ if test "x$GCC" = xyes -a "x$acv_mesa_CLANG" = xno; then
> >          GEN_ASM_OFFSETS=yes
> >      fi
> >  fi
> > +
> > +dnl Check for compiler builtins
> > +AX_GCC_BUILTIN([__builtin_bswap32])
> > +
> > +AC_SUBST(HAVE___BUILTIN_BSWAP32)
> > +
> >  AM_CONDITIONAL([GEN_ASM_OFFSETS], test "x$GEN_ASM_OFFSETS" = xyes)
> >
> >  dnl Make sure the pkg-config macros are defined
> > diff --git a/src/gallium/auxiliary/util/u_math.h b/src/gallium/auxiliary/util/u_math.h
> > index b5e0663..b0f0e3d 100644
> > --- a/src/gallium/auxiliary/util/u_math.h
> > +++ b/src/gallium/auxiliary/util/u_math.h
> > @@ -731,7 +731,8 @@ util_bitcount(unsigned n)
> >  static INLINE uint32_t
> >  util_bswap32(uint32_t n)
> >  {
> > -#if defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403)
> > +/* We need the gcc version checks for non-autoconf build system */
> > +#if defined(HAVE___BUILTIN_BSWAP32) || (defined(PIPE_CC_GCC) && (PIPE_CC_GCC_VERSION >= 403))
> >     return __builtin_bswap32(n);
> >  #else
> >     return (n >> 24) |
> 
> I don't think this will work. AC_SUBST substitutes into the files
> listed in AC_OUTPUT. I think what you want is to add something to
> DEFINES. But I don't know what the point is of this patch, since the
> existing preprocessor check should be sufficient?

HAVE___BUILTIN_BSWAP32 does show up in DEFINES, but it looks like the m4
macro is doing this.  I just tested without AC_SUBST and it still works.
I can drop the AC_SUBST lines from this and the bswap64 patch.

The reason to add HAVE___BUILTIN_BSWAP32 is because then the builtin can
be used on compilers other than gcc.

-Tom

> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list