Re: [PATCH 2/3] autoconf: prefer an unrolled loop for trivial AC_CHECK_HEADERS

Eric Blake <[email protected]>
Newsgroups gmane.comp.sysutils.autoconf.patches
Organization Red Hat, Inc.
Message-ID <[email protected]>
On 10/31/2016 06:39 AM, Paolo Bonzini wrote:
> An unrolled loop avoids the cost of spawning sed in AS_TR_SH and
> AS_TR_CPP.  Prefer it if there is nothing in the second and third
> argument of AC_CHECK_HEADERS and the first argument is a literal.
> Modify AC_CHECK_HEADERS_ONCE to avoid the variable indirection too.
> 
> * lib/autoconf/headers.m4 (AC_CHECK_HEADERS): Unroll loop if safe.
> (_AC_CHECK_HEADERS): Move basic implementation here.
> (_AC_CHECK_HEADER_ONCE): Expand AC_CHECK_HEADERS here...
> (_AC_HEADERS_EXPANSION): ... and not here, so remove.
> (AC_CHECK_INCLUDES_DEFAULT): Remove unnecessary arguments after the first.
> 
> Signed-off-by: Paolo Bonzini <[email protected]>
> ---
>  lib/autoconf/headers.m4 | 30 +++++++++++++-----------------
>  1 file changed, 13 insertions(+), 17 deletions(-)
> 
> diff --git a/lib/autoconf/headers.m4 b/lib/autoconf/headers.m4
> index 72262c1..e855025 100644
> --- a/lib/autoconf/headers.m4
> +++ b/lib/autoconf/headers.m4
> @@ -182,22 +182,25 @@ m4_define([AH_CHECK_HEADERS],
>  # header.  Either ACTION may include `break' to stop the search.
>  AC_DEFUN([AC_CHECK_HEADERS],
>  [m4_map_args_w([$1], [_AH_CHECK_HEADER(], [)])]dnl
> -[AS_FOR([AC_header], [ac_header], [$1],
> -[AC_CHECK_HEADER(AC_header,
> -		 [AC_DEFINE_UNQUOTED(AS_TR_CPP([HAVE_]AC_header)) $2],
> -		 [$3], [$4])dnl])
> +[m4_if([$2$3]AS_LITERAL_IF([$1], [yes], [no]), []yes,

Again, why []yes instead of [yes]?

>  
>  ## --------------------- ##
> @@ -261,8 +258,7 @@ ac_includes_default="\
>  #endif"
>  ])]dnl
>  [_AC_CHECK_HEADERS_ONCE(
> -  [sys/types.h sys/stat.h strings.h inttypes.h stdint.h unistd.h],
> -  [], [], [$ac_includes_default])]dnl
> +  [sys/types.h sys/stat.h strings.h inttypes.h stdint.h unistd.h])]dnl

This one, I'm worried about.  $ac_includes_default is a shell variable
not documented in the manual (so we can probably get away with changing
it), but doesn't it exist so that projects can redefine the core set of
default headers to check by default, whereas you are now losing that
flexibility?

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc (application/pgp-signature, 604 B)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Public key at http://people.redhat.com/eblake/eblake.gpg
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBCAAGBQJYF2PyAAoJEKeha0olJ0NqR8IH/09ZdzZ3L/fNwKWoL3JLEi5R
fEJ9G3g7b8Npfd2L04pnhVpP3NV3dY+oXQ+eIrDJFquLWFaq3HcXTxFSw2TADNi2
1PhhZR5m9I98WifxU/rx3fNJQn9yBW6zMr+zLvqoxmZSDEjD3eJvQFovQPFsV1Hd
DuYyLEzI2Ho+8EJaOG/X4x//qgpEkFInnJIO7HE599ZNknGVJkPibaJYxHo1SWi7
iI8hhxcbrk98LpCuw7pGGvUa86Rj5idrCOUOLq+rAboga2WWHKf9gdLlJuuEQ3JR
X0zA2DWbZPoYxju/M5uvw8prBd5lE0fnteEd0+pT4etaiCkTA/rwkyudVo80okw=
=BI7t
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.