autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/3] Modernize AC_INCLUDES_DEFAULT and friends.


From: Eric Blake
Subject: Re: [PATCH 2/3] Modernize AC_INCLUDES_DEFAULT and friends.
Date: Wed, 11 Sep 2013 21:09:37 -0600
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130805 Thunderbird/17.0.8

On 05/30/2013 03:19 PM, Zack Weinberg wrote:
>  * lib/autoconf/headers.m4 (_AC_INCLUDES_DEFAULT_REQUIREMENTS):
>    Include stddef.h, stdlib.h, and string.h unconditionally.
>    Don't include memory.h at all.
>    Don't use AC_HEADER_STDC.
>    Don't check for stddef.h, stdlib.h, string.h, or memory.h.
>    For compatibility, unconditionally define STDC_HEADERS,
>    HAVE_STDLIB_H, and HAVE_STRING_H.
>    (AN_HEADER list): Remove C89 headers, and memory.h from list.
>    (AC_HEADER_STDC): AU_DEFUN as an explicit invocation of
>    _AC_INCLUDES_DEFAULT_REQUIREMENTS.

This still feels fishy; but if the next patch cleans it up, I'm okay.

>    (AC_HEADER_TIME): AU_DEFUN, and define TIME_WITH_SYS_TIME unconditionally
>    as long as sys/time.h is present.
>    (AC_USG, AC_MEMORY_H): Assume existence of string.h.
>  * lib/autoconf/functions.m4 (_AC_FUNC_MALLOC_IF, _AC_FUNC_REALLOC_IF):
>    Don't use AC_HEADER_STDC. Assume stdlib.h exists.
>    (AC_FUNC_MKTIME): Don't use AC_HEADER_TIME.
>    (AC_FUNC_ALLOCA): Assume stdlib.h exists.
>    (_AC_LIBOBJ_FNMATCH): Assume wchar.h and wctype.h exist.
>    (_AC_LIBOBJ_GETLOADAVG): Assume locale.h exists.
>    (AC_FUNC_MMAP): Assume stdlib.h exists.
>  * tests/tools.at: Use AC_WORDS_BIGENDIAN instead of AC_STDC_HEADERS in
>    autoupdate test.
> 
>  * NEWS, doc/autoconf.texi: Document changes. Remove obsolete advice.
> 
> Signed-off-by: Zack Weinberg <address@hidden>
> ---

Thanks again for cleaning this up.  Between this and the proposal for
--rundir, I need to cut a release soon :)

> +come first in your @var{includes}.  For example, @file{net/if.h} may
> +require @file{sys/types.h}, @file{sys/socket.h}, or both, and
> address@hidden handles @file{sys/types.h} but not
> address@hidden/socket.h}, so you should check for it like this:
> +
> address@hidden
> +AC_CHECK_HEADERS([sys/socket.h])
> +AC_CHECK_HEADERS([net/if.h], [], [],
> +[AC_INCLUDES_DEFAULT
> +#ifdef HAVE_SYS_SOCKET_H
> +# include <sys/socket.h>
> +#endif
> +])

Thank you - this is definitely useful.

> +++ b/lib/autoconf/functions.m4

> @@ -1013,8 +1003,7 @@ test $ac_cv_func_memcmp_working = no && 
> AC_LIBOBJ([memcmp])
>  # --------------
>  AN_FUNCTION([mktime], [AC_FUNC_MKTIME])
>  AC_DEFUN([AC_FUNC_MKTIME],
> -[AC_REQUIRE([AC_HEADER_TIME])dnl
> -AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)
> +[AC_CHECK_HEADERS_ONCE(sys/time.h unistd.h)

As long as you're touching this, add proper quoting to the lines you touch:

AC_CHECK_HEADERS_ONCE([sys/time.h unistd.h])

> +dnl For backward compatibility, provide unconditional AC_DEFINEs of
> +dnl HAVE_STDLIB_H, HAVE_STRING_H, and STDC_HEADERS.
> +AC_DEFINE(HAVE_STDLIB_H, 1,

Again, new code should be a model of proper quoting:

AC_DEFINE([HAVE_STDLIB_H], [1],

> +  [Always define to 1, for backward compatibility.
> +   You can assume <stdlib.h> exists.])
> +AC_DEFINE(HAVE_STRING_H, 1,
> +  [Always define to 1, for backward compatibility.
> +   You can assume <string.h> exists.])
> +AC_DEFINE(STDC_HEADERS, 1,
> +  [Always define to 1, for backward compatibility.
> +   You can assume the C90 standard headers exist.])

and so on

> @@ -601,62 +594,17 @@ fi
>  ])# AC_HEADER_STDBOOL
>  
>  
> -# AC_HEADER_STDC
> +# AU::AC_HEADER_STDC
>  # --------------

The divider is now too short.

> +AU_DEFUN([AC_HEADER_STDC],
> +[
> +# Autoupdate added the following line to ensure that your configure
> +# script's behavior did not change.  It is probably safe to remove.
> +_AC_INCLUDES_DEFAULT_REQUIREMENTS
> +],

I'd still prefer we create and expose a public macro for this purpose,
rather than updating to an _AC_ macro.

>  
> -# AC_HEADER_TIME
> +# AU::AC_HEADER_TIME
>  # --------------

Another too-short divider.

>  
>  # AU::AC_USG
>  # ----------
> -# Define `USG' if string functions are in strings.h.
> +# Define `USG' if string functions are *not* in strings.h.

Have we seriously been documenting it incorrectly for this long?

Looking nice!

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]