Re: [PATCH 1/3] autoconf: prefer an unrolled loop for trivial AC_CHECK_FUNCS
Eric Blake <[email protected]>
| Newsgroups | gmane.comp.sysutils.autoconf.patches |
|---|---|
| Organization | Red Hat, Inc. |
| Message-ID | <[email protected]> |
On 10/31/2016 10:33 AM, Paolo Bonzini wrote: > > > On 31/10/2016 16:28, Eric Blake wrote: >> 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_FUNCS and the first argument is a literal. >>> Modify AC_CHECK_FUNCS_ONCE to avoid the variable indirection too. >>> >>> * lib/autoconf/functions.m4 (AC_CHECK_FUNCS): Unroll loop if safe. >>> (_AC_CHECK_FUNCS): Move basic implementation here. >>> (_AC_CHECK_FUNC_ONCE): Expand AC_CHECK_FUNCS here... >>> (_AC_FUNCS_EXPANSION): ... and not here, so remove. >> >>> - [$3])dnl]) >>> +[m4_if([$2$3]AS_LITERAL_IF([$1], [yes], [no]), []yes, >> >> Why []yes instead of the more typical [yes] ? >> >> If the user has (unwisely) defined yes as a macro, your version will >> compare against their expansion, instead of against the intended literal. > > Because I've never understood the rules for m4_if, and thought []yes > matched what you get from m4_if([$2$3]AS_LITERAL_IF([$1], [yes], [no]). If 'yes' and 'no' are not macros, then these are identical: m4_if([$2$3]AS_LITERAL_IF([$1], yes, no), yes, ...) m4_if([$2$3]AS_LITERAL_IF([$1], [yes], [no]), []yes[], ...) m4_if([$2$3]AS_LITERAL_IF([$1], [[yes]], [[no]]), [yes], ...) because of the order in which quotes are stripped through successive levels of m4 processing. But if yes or no could be a macro, then only the latter form is safe against unintended expansions (yes, including the double-quoting within AS_LITERAL_IF, because one layer of quotes gets stripped when collecting the args to AS_LITERAL_IF, and another gets stripped when concatenating to [$2$3] to determine the final string to compare against the literal of the second argument to m4_if). -- 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/ iQEcBAEBCAAGBQJYF3juAAoJEKeha0olJ0NqNEkH/3W1wUBjoVlLayy1D4eMyRTo w/NbpZnW2VUHk5AFWioCJZD9AIRIArHGsw8igyV7Zr4VJCTKv1fgujZFpYobfZIL faqpMVwOMBp45kx3S+aQ908URGGJEXps1NxR3eVTXHeRDflv3VuXKivaqhqVXhDQ +U/yIdfcmTv4t3f38JZhdDFw3RV0MscqRXsVUgRKcZZWgJSj8eFz2ks+CiidJ9eI 92fafs5OKa5+1LdCP2cuOQkD/LCW+MC7KBkYaVZM7Rv6veUsqXcilk+6A93mzKuX 3eSvSoQ4E8u4PtdRHCtSAwVWJ15TmcR2+lgjUBY+ucLIitG6cGF/FNBczE2YOlM= =PrOJ -----END PGP SIGNATURE-----